[PATCH 0/8] ASoC: microchip: some cleanups for AT91 sound drivers
Hi,
The following patches do some cleanups for Microchip AT91 sound drivers. Along with it I took the chance and updated MAINTAINERS file.
Thank you, Claudiu Beznea
Claudiu Beznea (8): ASoC: mchp-spdiftx: use FIELD_PREP() where possible ASoC: mchp-spdiftx: use regmap_update_bits() ASoC: mchp-spdiftx: update debug message ASoC: mchp-pdmc: use FIELD_PREP() where possible ASoC: mchp-pdmc: return directly ret ASoC: mchp-pdmc: avoid casting to/from void pointer MAINTAINERS: add myself as maintainer for Microchip AT91 sound drivers MAINTAINERS: update Microchip AT91 sound entries with documentation files
MAINTAINERS | 9 +++++-- sound/soc/atmel/mchp-pdmc.c | 19 ++++++-------- sound/soc/atmel/mchp-spdiftx.c | 45 ++++++++++++---------------------- 3 files changed, 29 insertions(+), 44 deletions(-)
Use directly FIELD_PREP() marco where possible. There is no need for the extra wrappers.
Signed-off-by: Claudiu Beznea claudiu.beznea@microchip.com --- sound/soc/atmel/mchp-spdiftx.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-)
diff --git a/sound/soc/atmel/mchp-spdiftx.c b/sound/soc/atmel/mchp-spdiftx.c index 20d135c718b0..bf4252412f9f 100644 --- a/sound/soc/atmel/mchp-spdiftx.c +++ b/sound/soc/atmel/mchp-spdiftx.c @@ -72,11 +72,9 @@
/* Valid Bits per Sample */ #define SPDIFTX_MR_VBPS_MASK GENMASK(13, 8) -#define SPDIFTX_MR_VBPS(bps) FIELD_PREP(SPDIFTX_MR_VBPS_MASK, bps)
/* Chunk Size */ #define SPDIFTX_MR_CHUNK_MASK GENMASK(19, 16) -#define SPDIFTX_MR_CHUNK(size) FIELD_PREP(SPDIFTX_MR_CHUNK_MASK, size)
/* Validity Bits for Channels 1 and 2 */ #define SPDIFTX_MR_VALID1 BIT(24) @@ -89,7 +87,6 @@
/* Bytes per Sample */ #define SPDIFTX_MR_BPS_MASK GENMASK(29, 28) -#define SPDIFTX_MR_BPS(bytes) FIELD_PREP(SPDIFTX_MR_BPS_MASK, (bytes - 1))
/* * ---- Interrupt Enable/Disable/Mask/Status Register (Write/Read-only) ---- @@ -402,47 +399,47 @@ static int mchp_spdiftx_hw_params(struct snd_pcm_substream *substream, params_channels(params)); return -EINVAL; } - mr |= SPDIFTX_MR_CHUNK(dev->playback.maxburst); + mr |= FIELD_PREP(SPDIFTX_MR_CHUNK_MASK, dev->playback.maxburst);
switch (params_format(params)) { case SNDRV_PCM_FORMAT_S8: - mr |= SPDIFTX_MR_VBPS(8); + mr |= FIELD_PREP(SPDIFTX_MR_VBPS_MASK, 8); break; case SNDRV_PCM_FORMAT_S16_BE: mr |= SPDIFTX_MR_ENDIAN_BIG; fallthrough; case SNDRV_PCM_FORMAT_S16_LE: - mr |= SPDIFTX_MR_VBPS(16); + mr |= FIELD_PREP(SPDIFTX_MR_VBPS_MASK, 16); break; case SNDRV_PCM_FORMAT_S18_3BE: mr |= SPDIFTX_MR_ENDIAN_BIG; fallthrough; case SNDRV_PCM_FORMAT_S18_3LE: - mr |= SPDIFTX_MR_VBPS(18); + mr |= FIELD_PREP(SPDIFTX_MR_VBPS_MASK, 18); break; case SNDRV_PCM_FORMAT_S20_3BE: mr |= SPDIFTX_MR_ENDIAN_BIG; fallthrough; case SNDRV_PCM_FORMAT_S20_3LE: - mr |= SPDIFTX_MR_VBPS(20); + mr |= FIELD_PREP(SPDIFTX_MR_VBPS_MASK, 20); break; case SNDRV_PCM_FORMAT_S24_3BE: mr |= SPDIFTX_MR_ENDIAN_BIG; fallthrough; case SNDRV_PCM_FORMAT_S24_3LE: - mr |= SPDIFTX_MR_VBPS(24); + mr |= FIELD_PREP(SPDIFTX_MR_VBPS_MASK, 24); break; case SNDRV_PCM_FORMAT_S24_BE: mr |= SPDIFTX_MR_ENDIAN_BIG; fallthrough; case SNDRV_PCM_FORMAT_S24_LE: - mr |= SPDIFTX_MR_VBPS(24); + mr |= FIELD_PREP(SPDIFTX_MR_VBPS_MASK, 24); break; case SNDRV_PCM_FORMAT_S32_BE: mr |= SPDIFTX_MR_ENDIAN_BIG; fallthrough; case SNDRV_PCM_FORMAT_S32_LE: - mr |= SPDIFTX_MR_VBPS(32); + mr |= FIELD_PREP(SPDIFTX_MR_VBPS_MASK, 32); break; default: dev_err(dev->dev, "unsupported PCM format: %d\n", @@ -450,7 +447,7 @@ static int mchp_spdiftx_hw_params(struct snd_pcm_substream *substream, return -EINVAL; }
- mr |= SPDIFTX_MR_BPS(bps); + mr |= FIELD_PREP(SPDIFTX_MR_BPS_MASK, bps - 1);
switch (params_rate(params)) { case 22050:
Use regmap_update_bits() instead of regmap_read(), running variable, regmap_write(). There is no need for extra variables and checks around it as regmap_update_bits() already does this. With this code becomes simpler.
Signed-off-by: Claudiu Beznea claudiu.beznea@microchip.com --- sound/soc/atmel/mchp-spdiftx.c | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-)
diff --git a/sound/soc/atmel/mchp-spdiftx.c b/sound/soc/atmel/mchp-spdiftx.c index bf4252412f9f..e7241d819748 100644 --- a/sound/soc/atmel/mchp-spdiftx.c +++ b/sound/soc/atmel/mchp-spdiftx.c @@ -306,15 +306,10 @@ static int mchp_spdiftx_trigger(struct snd_pcm_substream *substream, int cmd, { struct mchp_spdiftx_dev *dev = snd_soc_dai_get_drvdata(dai); struct mchp_spdiftx_mixer_control *ctrl = &dev->control; - u32 mr; - int running; int ret;
/* do not start/stop while channel status or user data is updated */ spin_lock(&ctrl->lock); - regmap_read(dev->regmap, SPDIFTX_MR, &mr); - running = !!(mr & SPDIFTX_MR_TXEN_ENABLE); - switch (cmd) { case SNDRV_PCM_TRIGGER_RESUME: case SNDRV_PCM_TRIGGER_START: @@ -323,10 +318,8 @@ static int mchp_spdiftx_trigger(struct snd_pcm_substream *substream, int cmd, dev->suspend_irq = 0; fallthrough; case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: - if (!running) { - mr &= ~SPDIFTX_MR_TXEN_MASK; - mr |= SPDIFTX_MR_TXEN_ENABLE; - } + ret = regmap_update_bits(dev->regmap, SPDIFTX_MR, SPDIFTX_MR_TXEN_MASK, + SPDIFTX_MR_TXEN_ENABLE); break; case SNDRV_PCM_TRIGGER_SUSPEND: regmap_read(dev->regmap, SPDIFTX_IMR, &dev->suspend_irq); @@ -336,17 +329,12 @@ static int mchp_spdiftx_trigger(struct snd_pcm_substream *substream, int cmd, SPDIFTX_IR_TXUDR | SPDIFTX_IR_TXOVR); fallthrough; case SNDRV_PCM_TRIGGER_PAUSE_PUSH: - if (running) { - mr &= ~SPDIFTX_MR_TXEN_MASK; - mr |= SPDIFTX_MR_TXEN_DISABLE; - } + ret = regmap_update_bits(dev->regmap, SPDIFTX_MR, SPDIFTX_MR_TXEN_MASK, + SPDIFTX_MR_TXEN_DISABLE); break; default: - spin_unlock(&ctrl->lock); - return -EINVAL; + ret = -EINVAL; } - - ret = regmap_write(dev->regmap, SPDIFTX_MR, mr); spin_unlock(&ctrl->lock); if (ret) dev_err(dev->dev, "unable to disable TX: %d\n", ret);
Previous debug message states that there was a failure and tx was not disabled. Which is not true as the TX in this function could also be enabled. Thus improve a bit the debug message by s/disable/start/stop/.
Signed-off-by: Claudiu Beznea claudiu.beznea@microchip.com --- sound/soc/atmel/mchp-spdiftx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sound/soc/atmel/mchp-spdiftx.c b/sound/soc/atmel/mchp-spdiftx.c index e7241d819748..02a2fa7a42dd 100644 --- a/sound/soc/atmel/mchp-spdiftx.c +++ b/sound/soc/atmel/mchp-spdiftx.c @@ -337,7 +337,7 @@ static int mchp_spdiftx_trigger(struct snd_pcm_substream *substream, int cmd, } spin_unlock(&ctrl->lock); if (ret) - dev_err(dev->dev, "unable to disable TX: %d\n", ret); + dev_err(dev->dev, "unable to start/stop TX: %d\n", ret);
return ret; }
Use FIELD_PREP() macro where possible instead of driver local defined macros.
Signed-off-by: Claudiu Beznea claudiu.beznea@microchip.com --- sound/soc/atmel/mchp-pdmc.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/sound/soc/atmel/mchp-pdmc.c b/sound/soc/atmel/mchp-pdmc.c index 1aed3baa9369..6ec5324fd65e 100644 --- a/sound/soc/atmel/mchp-pdmc.c +++ b/sound/soc/atmel/mchp-pdmc.c @@ -8,6 +8,7 @@
#include <dt-bindings/sound/microchip,pdmc.h>
+#include <linux/bitfield.h> #include <linux/clk.h> #include <linux/module.h> #include <linux/of.h> @@ -49,8 +50,6 @@ #define MCHP_PDMC_MR_OSR256 (3 << 16)
#define MCHP_PDMC_MR_SINCORDER_MASK GENMASK(23, 20) -#define MCHP_PDMC_MR_SINCORDER(order) (((order) << 20) & \ - MCHP_PDMC_MR_SINCORDER_MASK)
#define MCHP_PDMC_MR_SINC_OSR_MASK GENMASK(27, 24) #define MCHP_PDMC_MR_SINC_OSR_DIS (0 << 24) @@ -62,8 +61,6 @@ #define MCHP_PDMC_MR_SINC_OSR_256 (6 << 24)
#define MCHP_PDMC_MR_CHUNK_MASK GENMASK(31, 28) -#define MCHP_PDMC_MR_CHUNK(chunk) (((chunk) << 28) & \ - MCHP_PDMC_MR_CHUNK_MASK)
/* * ---- Configuration Register (Read/Write) ---- @@ -617,10 +614,10 @@ static int mchp_pdmc_hw_params(struct snd_pcm_substream *substream,
mr_val |= mchp_pdmc_mr_set_osr(dd->audio_filter_en, osr);
- mr_val |= MCHP_PDMC_MR_SINCORDER(dd->sinc_order); + mr_val |= FIELD_PREP(MCHP_PDMC_MR_SINCORDER_MASK, dd->sinc_order);
dd->addr.maxburst = mchp_pdmc_period_to_maxburst(snd_pcm_lib_period_bytes(substream)); - mr_val |= MCHP_PDMC_MR_CHUNK(dd->addr.maxburst); + mr_val |= FIELD_PREP(MCHP_PDMC_MR_CHUNK_MASK, dd->addr.maxburst); dev_dbg(comp->dev, "maxburst set to %d\n", dd->addr.maxburst);
snd_soc_component_update_bits(comp, MCHP_PDMC_MR,
Return directly ret instead of having different branches for error and OK paths.
Signed-off-by: Claudiu Beznea claudiu.beznea@microchip.com --- sound/soc/atmel/mchp-pdmc.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/sound/soc/atmel/mchp-pdmc.c b/sound/soc/atmel/mchp-pdmc.c index 6ec5324fd65e..853a7adfd654 100644 --- a/sound/soc/atmel/mchp-pdmc.c +++ b/sound/soc/atmel/mchp-pdmc.c @@ -759,12 +759,10 @@ static int mchp_pdmc_pcm_new(struct snd_soc_pcm_runtime *rtd, int ret;
ret = mchp_pdmc_add_chmap_ctls(rtd->pcm, dd); - if (ret < 0) { + if (ret < 0) dev_err(dd->dev, "failed to add channel map controls: %d\n", ret); - return ret; - }
- return 0; + return ret; }
static struct snd_soc_dai_driver mchp_pdmc_dai = {
Do not cast to and from void pointer. There is no need for this.
Signed-off-by: Claudiu Beznea claudiu.beznea@microchip.com --- sound/soc/atmel/mchp-pdmc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/sound/soc/atmel/mchp-pdmc.c b/sound/soc/atmel/mchp-pdmc.c index 853a7adfd654..81bfa98fd516 100644 --- a/sound/soc/atmel/mchp-pdmc.c +++ b/sound/soc/atmel/mchp-pdmc.c @@ -783,7 +783,7 @@ static struct snd_soc_dai_driver mchp_pdmc_dai = { /* PDMC interrupt handler */ static irqreturn_t mchp_pdmc_interrupt(int irq, void *dev_id) { - struct mchp_pdmc *dd = (struct mchp_pdmc *)dev_id; + struct mchp_pdmc *dd = dev_id; u32 isr, msr, pending; irqreturn_t ret = IRQ_NONE;
@@ -1077,7 +1077,7 @@ static int mchp_pdmc_probe(struct platform_device *pdev) }
ret = devm_request_irq(dev, irq, mchp_pdmc_interrupt, 0, - dev_name(&pdev->dev), (void *)dd); + dev_name(&pdev->dev), dd); if (ret < 0) { dev_err(dev, "can't register ISR for IRQ %u (ret=%i)\n", irq, ret);
Codrin is not with Microchip anymore. As I worked lately with Microchip AT91 sound drivers add myself as maintainer for these.
Signed-off-by: Claudiu Beznea claudiu.beznea@microchip.com --- MAINTAINERS | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/MAINTAINERS b/MAINTAINERS index 1e246c16aff6..252cc33f0f5c 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -13666,7 +13666,7 @@ F: Documentation/devicetree/bindings/serial/atmel,at91-usart.yaml F: drivers/spi/spi-at91-usart.c
MICROCHIP AUDIO ASOC DRIVERS -M: Codrin Ciubotariu codrin.ciubotariu@microchip.com +M: Claudiu Beznea claudiu.beznea@microchip.com L: alsa-devel@alsa-project.org (moderated for non-subscribers) S: Supported F: sound/soc/atmel @@ -13833,7 +13833,7 @@ S: Supported F: drivers/spi/spi-atmel.*
MICROCHIP SSC DRIVER -M: Codrin Ciubotariu codrin.ciubotariu@microchip.com +M: Claudiu Beznea claudiu.beznea@microchip.com L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers) S: Supported F: drivers/misc/atmel-ssc.c
On 01/03/2023 at 17:08, Claudiu Beznea wrote:
Codrin is not with Microchip anymore. As I worked lately with Microchip AT91 sound drivers add myself as maintainer for these.
Signed-off-by: Claudiu Beznea claudiu.beznea@microchip.com
Acked-by: Nicolas Ferre nicolas.ferre@microchip.com
Thanks Claudiu for taking this responsibility!
Best regards, Nicolas
MAINTAINERS | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/MAINTAINERS b/MAINTAINERS index 1e246c16aff6..252cc33f0f5c 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -13666,7 +13666,7 @@ F: Documentation/devicetree/bindings/serial/atmel,at91-usart.yaml F: drivers/spi/spi-at91-usart.c
MICROCHIP AUDIO ASOC DRIVERS -M: Codrin Ciubotariu codrin.ciubotariu@microchip.com +M: Claudiu Beznea claudiu.beznea@microchip.com L: alsa-devel@alsa-project.org (moderated for non-subscribers) S: Supported F: sound/soc/atmel @@ -13833,7 +13833,7 @@ S: Supported F: drivers/spi/spi-atmel.*
MICROCHIP SSC DRIVER -M: Codrin Ciubotariu codrin.ciubotariu@microchip.com +M: Claudiu Beznea claudiu.beznea@microchip.com L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers) S: Supported F: drivers/misc/atmel-ssc.c
Add documentation files to Microchip AT91 sound entries.
Signed-off-by: Claudiu Beznea claudiu.beznea@microchip.com --- MAINTAINERS | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/MAINTAINERS b/MAINTAINERS index 252cc33f0f5c..b5a966f84d89 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -13669,6 +13669,10 @@ MICROCHIP AUDIO ASOC DRIVERS M: Claudiu Beznea claudiu.beznea@microchip.com L: alsa-devel@alsa-project.org (moderated for non-subscribers) S: Supported +F: Documentation/devicetree/bindings/sound/atmel* +F: Documentation/devicetree/bindings/sound/axentia,tse850-pcm5142.txt +F: Documentation/devicetree/bindings/sound/microchip,sama7g5-* +F: Documentation/devicetree/bindings/sound/mikroe,mikroe-proto.txt F: sound/soc/atmel
MICROCHIP CSI2DC DRIVER @@ -13836,6 +13840,7 @@ MICROCHIP SSC DRIVER M: Claudiu Beznea claudiu.beznea@microchip.com L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers) S: Supported +F: Documentation/devicetree/bindings/misc/atmel-ssc.txt F: drivers/misc/atmel-ssc.c F: include/linux/atmel-ssc.h
On 01/03/2023 at 17:08, Claudiu Beznea wrote:
Add documentation files to Microchip AT91 sound entries.
Signed-off-by: Claudiu Beznea claudiu.beznea@microchip.com
Acked-by: Nicolas Ferre nicolas.ferre@microchip.com
MAINTAINERS | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/MAINTAINERS b/MAINTAINERS index 252cc33f0f5c..b5a966f84d89 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -13669,6 +13669,10 @@ MICROCHIP AUDIO ASOC DRIVERS M: Claudiu Beznea claudiu.beznea@microchip.com L: alsa-devel@alsa-project.org (moderated for non-subscribers) S: Supported +F: Documentation/devicetree/bindings/sound/atmel* +F: Documentation/devicetree/bindings/sound/axentia,tse850-pcm5142.txt +F: Documentation/devicetree/bindings/sound/microchip,sama7g5-* +F: Documentation/devicetree/bindings/sound/mikroe,mikroe-proto.txt F: sound/soc/atmel
MICROCHIP CSI2DC DRIVER @@ -13836,6 +13840,7 @@ MICROCHIP SSC DRIVER M: Claudiu Beznea claudiu.beznea@microchip.com L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers) S: Supported +F: Documentation/devicetree/bindings/misc/atmel-ssc.txt F: drivers/misc/atmel-ssc.c F: include/linux/atmel-ssc.h
On Wed, 01 Mar 2023 13:37:59 +0200, Claudiu Beznea wrote:
The following patches do some cleanups for Microchip AT91 sound drivers. Along with it I took the chance and updated MAINTAINERS file.
Thank you, Claudiu Beznea
Claudiu Beznea (8): ASoC: mchp-spdiftx: use FIELD_PREP() where possible ASoC: mchp-spdiftx: use regmap_update_bits() ASoC: mchp-spdiftx: update debug message ASoC: mchp-pdmc: use FIELD_PREP() where possible ASoC: mchp-pdmc: return directly ret ASoC: mchp-pdmc: avoid casting to/from void pointer MAINTAINERS: add myself as maintainer for Microchip AT91 sound drivers MAINTAINERS: update Microchip AT91 sound entries with documentation files
[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[1/8] ASoC: mchp-spdiftx: use FIELD_PREP() where possible commit: 28ce5698456ab53540093836c6fee15119cf1821 [2/8] ASoC: mchp-spdiftx: use regmap_update_bits() commit: 0ab4bd5bf277349262065e88eb2feaaabf53584c [3/8] ASoC: mchp-spdiftx: update debug message commit: 2d8dad4dc4d4a12afa3c31e72b60727d4c133b99 [4/8] ASoC: mchp-pdmc: use FIELD_PREP() where possible commit: 129742576dd1b972ea1e671595a085e29012f7f3 [5/8] ASoC: mchp-pdmc: return directly ret commit: 51124a30308e6db8658575e5d9ec1ea3cb3ba3c3 [6/8] ASoC: mchp-pdmc: avoid casting to/from void pointer commit: cb72b29cd5cfac20894a040e411dec70bb75097c [7/8] MAINTAINERS: add myself as maintainer for Microchip AT91 sound drivers commit: 8f943f00d7a844daa9acafd304c2178f30ecc255 [8/8] MAINTAINERS: update Microchip AT91 sound entries with documentation files commit: 15dbfc04e6865bae1aa275216baa1a7eb55cd2cf
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks, Mark
participants (3)
-
Claudiu Beznea
-
Mark Brown
-
Nicolas Ferre