linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] ASoC: codecs: wsa883x: Shutdown on error path
@ 2022-11-09 16:37 Krzysztof Kozlowski
  2022-11-09 16:37 ` [PATCH 2/2] ASoC: codecs: wsa883x: Simplify with dev_err_probe Krzysztof Kozlowski
  2022-11-17 11:48 ` [PATCH 1/2] ASoC: codecs: wsa883x: Shutdown on error path Mark Brown
  0 siblings, 2 replies; 3+ messages in thread
From: Krzysztof Kozlowski @ 2022-11-09 16:37 UTC (permalink / raw)
  To: Srinivas Kandagatla, Banajit Goswami, Liam Girdwood, Mark Brown,
	Jaroslav Kysela, Takashi Iwai, alsa-devel, linux-kernel
  Cc: Krzysztof Kozlowski

If probe fails, toggle shutdown via GPIO to save power and reverse
probe actions.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
---
 sound/soc/codecs/wsa883x.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/sound/soc/codecs/wsa883x.c b/sound/soc/codecs/wsa883x.c
index 77a7dd3cf495..4ad8b875eb8f 100644
--- a/sound/soc/codecs/wsa883x.c
+++ b/sound/soc/codecs/wsa883x.c
@@ -1415,6 +1415,7 @@ static int wsa883x_probe(struct sdw_slave *pdev,
 
 	wsa883x->regmap = devm_regmap_init_sdw(pdev, &wsa883x_regmap_config);
 	if (IS_ERR(wsa883x->regmap)) {
+		gpiod_direction_output(wsa883x->sd_n, 1);
 		dev_err(&pdev->dev, "regmap_init failed\n");
 		ret = PTR_ERR(wsa883x->regmap);
 		goto err;
-- 
2.34.1


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

* [PATCH 2/2] ASoC: codecs: wsa883x: Simplify with dev_err_probe
  2022-11-09 16:37 [PATCH 1/2] ASoC: codecs: wsa883x: Shutdown on error path Krzysztof Kozlowski
@ 2022-11-09 16:37 ` Krzysztof Kozlowski
  2022-11-17 11:48 ` [PATCH 1/2] ASoC: codecs: wsa883x: Shutdown on error path Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Krzysztof Kozlowski @ 2022-11-09 16:37 UTC (permalink / raw)
  To: Srinivas Kandagatla, Banajit Goswami, Liam Girdwood, Mark Brown,
	Jaroslav Kysela, Takashi Iwai, alsa-devel, linux-kernel
  Cc: Krzysztof Kozlowski

Code can be a bit simpler with dev_err_probe().

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
---
 sound/soc/codecs/wsa883x.c | 21 +++++++++------------
 1 file changed, 9 insertions(+), 12 deletions(-)

diff --git a/sound/soc/codecs/wsa883x.c b/sound/soc/codecs/wsa883x.c
index 4ad8b875eb8f..85a2d928db13 100644
--- a/sound/soc/codecs/wsa883x.c
+++ b/sound/soc/codecs/wsa883x.c
@@ -1380,22 +1380,19 @@ static int wsa883x_probe(struct sdw_slave *pdev,
 		return -ENOMEM;
 
 	wsa883x->vdd = devm_regulator_get(dev, "vdd");
-	if (IS_ERR(wsa883x->vdd)) {
-		dev_err(dev, "No vdd regulator found\n");
-		return PTR_ERR(wsa883x->vdd);
-	}
+	if (IS_ERR(wsa883x->vdd))
+		return dev_err_probe(dev, PTR_ERR(wsa883x->vdd),
+				     "No vdd regulator found\n");
 
 	ret = regulator_enable(wsa883x->vdd);
-	if (ret) {
-		dev_err(dev, "Failed to enable vdd regulator (%d)\n", ret);
-		return ret;
-	}
+	if (ret)
+		return dev_err_probe(dev, ret, "Failed to enable vdd regulator\n");
 
 	wsa883x->sd_n = devm_gpiod_get_optional(&pdev->dev, "powerdown",
 						GPIOD_FLAGS_BIT_NONEXCLUSIVE | GPIOD_OUT_HIGH);
 	if (IS_ERR(wsa883x->sd_n)) {
-		dev_err(&pdev->dev, "Shutdown Control GPIO not found\n");
-		ret = PTR_ERR(wsa883x->sd_n);
+		ret = dev_err_probe(&pdev->dev, PTR_ERR(wsa883x->sd_n),
+				    "Shutdown Control GPIO not found\n");
 		goto err;
 	}
 
@@ -1416,8 +1413,8 @@ static int wsa883x_probe(struct sdw_slave *pdev,
 	wsa883x->regmap = devm_regmap_init_sdw(pdev, &wsa883x_regmap_config);
 	if (IS_ERR(wsa883x->regmap)) {
 		gpiod_direction_output(wsa883x->sd_n, 1);
-		dev_err(&pdev->dev, "regmap_init failed\n");
-		ret = PTR_ERR(wsa883x->regmap);
+		ret = dev_err_probe(&pdev->dev, PTR_ERR(wsa883x->regmap),
+				    "regmap_init failed\n");
 		goto err;
 	}
 	pm_runtime_set_autosuspend_delay(dev, 3000);
-- 
2.34.1


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

* Re: [PATCH 1/2] ASoC: codecs: wsa883x: Shutdown on error path
  2022-11-09 16:37 [PATCH 1/2] ASoC: codecs: wsa883x: Shutdown on error path Krzysztof Kozlowski
  2022-11-09 16:37 ` [PATCH 2/2] ASoC: codecs: wsa883x: Simplify with dev_err_probe Krzysztof Kozlowski
@ 2022-11-17 11:48 ` Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2022-11-17 11:48 UTC (permalink / raw)
  To: Srinivas Kandagatla, Liam Girdwood, Takashi Iwai, linux-kernel,
	Krzysztof Kozlowski, alsa-devel, Banajit Goswami,
	Jaroslav Kysela

On Wed, 9 Nov 2022 17:37:58 +0100, Krzysztof Kozlowski wrote:
> If probe fails, toggle shutdown via GPIO to save power and reverse
> probe actions.
> 
> 

Applied to

   broonie/sound.git for-next

Thanks!

[1/2] ASoC: codecs: wsa883x: Shutdown on error path
      commit: 8e022387444bc5039a271fbf5a778551c4a1926b
[2/2] ASoC: codecs: wsa883x: Simplify with dev_err_probe
      commit: 6b6ab406cedaf70f58961d4ea82e88e65e721d06

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:[~2022-11-17 11:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-09 16:37 [PATCH 1/2] ASoC: codecs: wsa883x: Shutdown on error path Krzysztof Kozlowski
2022-11-09 16:37 ` [PATCH 2/2] ASoC: codecs: wsa883x: Simplify with dev_err_probe Krzysztof Kozlowski
2022-11-17 11:48 ` [PATCH 1/2] ASoC: codecs: wsa883x: Shutdown on error path Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).