public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ASoC: cs42l51: Fix some error handling paths in cs42l51_probe()
@ 2024-10-26 20:46 Christophe JAILLET
  2024-10-28 10:38 ` Charles Keepax
  2024-10-28 17:18 ` Mark Brown
  0 siblings, 2 replies; 3+ messages in thread
From: Christophe JAILLET @ 2024-10-26 20:46 UTC (permalink / raw)
  To: David Rhodes, Richard Fitzgerald, Liam Girdwood, Mark Brown,
	Jaroslav Kysela, Takashi Iwai, Olivier Moysan
  Cc: linux-kernel, kernel-janitors, Christophe JAILLET, linux-sound,
	patches

If devm_gpiod_get_optional() fails, we need to disable previously enabled
regulators, as done in the other error handling path of the function.

Also, gpiod_set_value_cansleep(, 1) needs to be called to undo a
potential gpiod_set_value_cansleep(, 0).
If the "reset" gpio is not defined, this additional call is just a no-op.

This behavior is the same as the one already in the .remove() function.

Fixes: 11b9cd748e31 ("ASoC: cs42l51: add reset management")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
Compile tested only
---
 sound/soc/codecs/cs42l51.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/sound/soc/codecs/cs42l51.c b/sound/soc/codecs/cs42l51.c
index e4827b8c2bde..6e51954bdb1e 100644
--- a/sound/soc/codecs/cs42l51.c
+++ b/sound/soc/codecs/cs42l51.c
@@ -747,8 +747,10 @@ int cs42l51_probe(struct device *dev, struct regmap *regmap)
 
 	cs42l51->reset_gpio = devm_gpiod_get_optional(dev, "reset",
 						      GPIOD_OUT_LOW);
-	if (IS_ERR(cs42l51->reset_gpio))
-		return PTR_ERR(cs42l51->reset_gpio);
+	if (IS_ERR(cs42l51->reset_gpio)) {
+		ret = PTR_ERR(cs42l51->reset_gpio);
+		goto error;
+	}
 
 	if (cs42l51->reset_gpio) {
 		dev_dbg(dev, "Release reset gpio\n");
@@ -780,6 +782,7 @@ int cs42l51_probe(struct device *dev, struct regmap *regmap)
 	return 0;
 
 error:
+	gpiod_set_value_cansleep(cs42l51->reset_gpio, 1);
 	regulator_bulk_disable(ARRAY_SIZE(cs42l51->supplies),
 			       cs42l51->supplies);
 	return ret;
-- 
2.47.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] ASoC: cs42l51: Fix some error handling paths in cs42l51_probe()
  2024-10-26 20:46 [PATCH] ASoC: cs42l51: Fix some error handling paths in cs42l51_probe() Christophe JAILLET
@ 2024-10-28 10:38 ` Charles Keepax
  2024-10-28 17:18 ` Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Charles Keepax @ 2024-10-28 10:38 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: David Rhodes, Richard Fitzgerald, Liam Girdwood, Mark Brown,
	Jaroslav Kysela, Takashi Iwai, Olivier Moysan, linux-kernel,
	kernel-janitors, linux-sound, patches

On Sat, Oct 26, 2024 at 10:46:34PM +0200, Christophe JAILLET wrote:
> If devm_gpiod_get_optional() fails, we need to disable previously enabled
> regulators, as done in the other error handling path of the function.
> 
> Also, gpiod_set_value_cansleep(, 1) needs to be called to undo a
> potential gpiod_set_value_cansleep(, 0).
> If the "reset" gpio is not defined, this additional call is just a no-op.
> 
> This behavior is the same as the one already in the .remove() function.
> 
> Fixes: 11b9cd748e31 ("ASoC: cs42l51: add reset management")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---

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

Thanks,
Charles

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] ASoC: cs42l51: Fix some error handling paths in cs42l51_probe()
  2024-10-26 20:46 [PATCH] ASoC: cs42l51: Fix some error handling paths in cs42l51_probe() Christophe JAILLET
  2024-10-28 10:38 ` Charles Keepax
@ 2024-10-28 17:18 ` Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2024-10-28 17:18 UTC (permalink / raw)
  To: David Rhodes, Richard Fitzgerald, Liam Girdwood, Jaroslav Kysela,
	Takashi Iwai, Olivier Moysan, Christophe JAILLET
  Cc: linux-kernel, kernel-janitors, linux-sound, patches

On Sat, 26 Oct 2024 22:46:34 +0200, Christophe JAILLET wrote:
> If devm_gpiod_get_optional() fails, we need to disable previously enabled
> regulators, as done in the other error handling path of the function.
> 
> Also, gpiod_set_value_cansleep(, 1) needs to be called to undo a
> potential gpiod_set_value_cansleep(, 0).
> If the "reset" gpio is not defined, this additional call is just a no-op.
> 
> [...]

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/1] ASoC: cs42l51: Fix some error handling paths in cs42l51_probe()
      commit: d221b844ee79823ffc29b7badc4010bdb0960224

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-10-28 17:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-26 20:46 [PATCH] ASoC: cs42l51: Fix some error handling paths in cs42l51_probe() Christophe JAILLET
2024-10-28 10:38 ` Charles Keepax
2024-10-28 17:18 ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox