mbox series

[0/9] Improve CS35l41 ALSA SoC audio driver

Message ID 20230902210621.1184693-1-cristian.ciocaltea@collabora.com
Headers show
Series Improve CS35l41 ALSA SoC audio driver | expand

Message

Cristian Ciocaltea Sept. 2, 2023, 9:06 p.m. UTC
This patch series contains several fixes and improvements to 
the CS35l41 audio codec driver.

It has been verified on Valve's Steam Deck.

Cristian Ciocaltea (9):
  ASoC: cs35l41: Handle mdsync_down reg write errors
  ASoC: cs35l41: Handle mdsync_up reg write errors
  ASoC: cs35l41: Initialize completion object before requesting IRQ
  ASoC: cs35l41: Fix broken shared boost activation
  ASoC: cs35l41: Rename pll_lock to pll_lock_done
  ASoC: cs35l41: Make use of dev_err_probe()
  ASoC: cs35l41: Verify PM runtime resume errors in IRQ handler
  ASoC: cs35l41: Use modern pm_ops
  ASoC: cs35l41: Use devm_pm_runtime_enable()

 include/sound/cs35l41.h        |   5 +-
 sound/soc/codecs/cs35l41-i2c.c |  11 ++-
 sound/soc/codecs/cs35l41-lib.c |  83 ++++++++++++++++------
 sound/soc/codecs/cs35l41-spi.c |  11 ++-
 sound/soc/codecs/cs35l41.c     | 121 ++++++++++++++++++++++-----------
 sound/soc/codecs/cs35l41.h     |   4 +-
 6 files changed, 158 insertions(+), 77 deletions(-)

Comments

Charles Keepax Sept. 5, 2023, 9:19 a.m. UTC | #1
On Sun, Sep 03, 2023 at 12:06:13AM +0300, Cristian Ciocaltea wrote:
> The return code of regmap_multi_reg_write() call related to "MDSYNC
> down" sequence is shadowed by the subsequent
> wait_for_completion_timeout() invocation, which is expected to time
> timeout in case the write operation failed.
> 
> Let cs35l41_global_enable() return the correct error code instead of
> -ETIMEDOUT.
> 
> Fixes: f5030564938b ("ALSA: cs35l41: Add shared boost feature")
> Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
> ---
>  sound/soc/codecs/cs35l41-lib.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/sound/soc/codecs/cs35l41-lib.c b/sound/soc/codecs/cs35l41-lib.c
> index 4ec306cd2f47..a018f1d98428 100644
> --- a/sound/soc/codecs/cs35l41-lib.c
> +++ b/sound/soc/codecs/cs35l41-lib.c
> @@ -1243,7 +1243,7 @@ int cs35l41_global_enable(struct device *dev, struct regmap *regmap, enum cs35l4
>  		cs35l41_mdsync_down_seq[2].def = pwr_ctrl1;
>  		ret = regmap_multi_reg_write(regmap, cs35l41_mdsync_down_seq,
>  					     ARRAY_SIZE(cs35l41_mdsync_down_seq));
> -		if (!enable)
> +		if (ret || !enable)
>  			break;

Acked-by: Charles Keepax <ckeepax@opensource.cirrus.com>

Thanks,
Charles
Charles Keepax Sept. 5, 2023, 9:23 a.m. UTC | #2
On Sun, Sep 03, 2023 at 12:06:14AM +0300, Cristian Ciocaltea wrote:
> The return code of regmap_multi_reg_write() call related to "MDSYNC up"
> sequence is shadowed by the subsequent regmap_read_poll_timeout()
> invocation, which will hit a timeout in case the write operation above
> fails.
> 
> Make sure cs35l41_global_enable() returns the correct error code instead
> of -ETIMEDOUT.
> 
> Additionally, to be able to distinguish between the timeouts of
> wait_for_completion_timeout() and regmap_read_poll_timeout(), print an
> error message for the former and return immediately.  This also avoids
> having to wait unnecessarily for the second time.
> 
> Fixes: f8264c759208 ("ALSA: cs35l41: Poll for Power Up/Down rather than waiting a fixed delay")
> Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
> ---

Acked-by: Charles Keepax <ckeepax@opensource.cirrus.com>

Thanks,
Charles
Charles Keepax Sept. 5, 2023, 9:23 a.m. UTC | #3
On Sun, Sep 03, 2023 at 12:06:15AM +0300, Cristian Ciocaltea wrote:
> Technically, an interrupt handler can be called before probe() finishes
> its execution, hence ensure the pll_lock completion object is always
> initialized before being accessed in cs35l41_irq().
> 
> Fixes: f5030564938b ("ALSA: cs35l41: Add shared boost feature")
> Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
> ---

Acked-by: Charles Keepax <ckeepax@opensource.cirrus.com>

Thanks,
Charles
Charles Keepax Sept. 5, 2023, 9:35 a.m. UTC | #4
On Sun, Sep 03, 2023 at 12:06:17AM +0300, Cristian Ciocaltea wrote:
> Use a more intuitive name for 'pll_lock' completion, which helps
> improving code readability a bit.
> 
> Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
> ---

Acked-by: Charles Keepax <ckeepax@opensource.cirrus.com>

Thanks,
Charles
Charles Keepax Sept. 5, 2023, 9:37 a.m. UTC | #5
On Sun, Sep 03, 2023 at 12:06:20AM +0300, Cristian Ciocaltea wrote:
> Make use of the recently introduced EXPORT_GPL_DEV_PM_OPS() macro, to
> conditionally export the runtime/system PM functions.
> 
> Replace the old SET_{RUNTIME,SYSTEM_SLEEP,NOIRQ_SYSTEM_SLEEP}_PM_OPS()
> helpers with their modern alternatives and get rid of the now
> unnecessary '__maybe_unused' annotations on all PM functions.
> 
> Additionally, use the pm_ptr() macro to fix the following errors when
> building with CONFIG_PM disabled:
> 
> ERROR: modpost: "cs35l41_pm_ops" [sound/soc/codecs/snd-soc-cs35l41-spi.ko] undefined!
> ERROR: modpost: "cs35l41_pm_ops" [sound/soc/codecs/snd-soc-cs35l41-i2c.ko] undefined!
> 
> Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
> ---

Acked-by: Charles Keepax <ckeepax@opensource.cirrus.com>

Thanks,
Charles