* [PATCH 1/2] mfd: wcd934x: Fix an error handling path in wcd934x_slim_probe()
@ 2023-05-20 7:10 Christophe JAILLET
2023-05-20 7:11 ` [PATCH 2/2] mfd: wcd934x: Simplify with dev_err_probe() Christophe JAILLET
2023-05-25 11:19 ` [PATCH 1/2] mfd: wcd934x: Fix an error handling path in wcd934x_slim_probe() Lee Jones
0 siblings, 2 replies; 4+ messages in thread
From: Christophe JAILLET @ 2023-05-20 7:10 UTC (permalink / raw)
To: Lee Jones, Maíra Canal
Cc: linux-kernel, kernel-janitors, Christophe JAILLET, Lee Jones
If devm_gpiod_get_optional() fails, some resources need to be released, as
already done in the .remove() function.
While at it, remove the unneeded error code from a dev_err_probe() call.
It is already added in a human readable way by dev_err_probe() itself.
Fixes: 6a0ee2a61a31 ("mfd: wcd934x: Replace legacy gpio interface for gpiod")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
drivers/mfd/wcd934x.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/mfd/wcd934x.c b/drivers/mfd/wcd934x.c
index 07e884087f2c..281470d6b0b9 100644
--- a/drivers/mfd/wcd934x.c
+++ b/drivers/mfd/wcd934x.c
@@ -258,8 +258,9 @@ static int wcd934x_slim_probe(struct slim_device *sdev)
usleep_range(600, 650);
reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
if (IS_ERR(reset_gpio)) {
- return dev_err_probe(dev, PTR_ERR(reset_gpio),
- "Failed to get reset gpio: err = %ld\n", PTR_ERR(reset_gpio));
+ ret = dev_err_probe(dev, PTR_ERR(reset_gpio),
+ "Failed to get reset gpio\n");
+ goto err_disable_regulators;
}
msleep(20);
gpiod_set_value(reset_gpio, 1);
@@ -269,6 +270,10 @@ static int wcd934x_slim_probe(struct slim_device *sdev)
dev_set_drvdata(dev, ddata);
return 0;
+
+err_disable_regulators:
+ regulator_bulk_disable(WCD934X_MAX_SUPPLY, ddata->supplies);
+ return ret;
}
static void wcd934x_slim_remove(struct slim_device *sdev)
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH 2/2] mfd: wcd934x: Simplify with dev_err_probe()
2023-05-20 7:10 [PATCH 1/2] mfd: wcd934x: Fix an error handling path in wcd934x_slim_probe() Christophe JAILLET
@ 2023-05-20 7:11 ` Christophe JAILLET
2023-05-25 11:20 ` Lee Jones
2023-05-25 11:19 ` [PATCH 1/2] mfd: wcd934x: Fix an error handling path in wcd934x_slim_probe() Lee Jones
1 sibling, 1 reply; 4+ messages in thread
From: Christophe JAILLET @ 2023-05-20 7:11 UTC (permalink / raw)
To: Lee Jones; +Cc: linux-kernel, kernel-janitors, Christophe JAILLET
Use dev_err_probe() to simplify code, save a few LoC and be consistent
with error codes handling in messages.
It also filters -EPROBE_DEFER that can be returned by devm_clk_get().
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
drivers/mfd/wcd934x.c | 19 +++++++------------
1 file changed, 7 insertions(+), 12 deletions(-)
diff --git a/drivers/mfd/wcd934x.c b/drivers/mfd/wcd934x.c
index 281470d6b0b9..6b942d5270c1 100644
--- a/drivers/mfd/wcd934x.c
+++ b/drivers/mfd/wcd934x.c
@@ -227,10 +227,9 @@ static int wcd934x_slim_probe(struct slim_device *sdev)
"Failed to get IRQ\n");
ddata->extclk = devm_clk_get(dev, "extclk");
- if (IS_ERR(ddata->extclk)) {
- dev_err(dev, "Failed to get extclk");
- return PTR_ERR(ddata->extclk);
- }
+ if (IS_ERR(ddata->extclk))
+ return dev_err_probe(dev, PTR_ERR(ddata->extclk),
+ "Failed to get extclk");
ddata->supplies[0].supply = "vdd-buck";
ddata->supplies[1].supply = "vdd-buck-sido";
@@ -239,16 +238,12 @@ static int wcd934x_slim_probe(struct slim_device *sdev)
ddata->supplies[4].supply = "vdd-io";
ret = regulator_bulk_get(dev, WCD934X_MAX_SUPPLY, ddata->supplies);
- if (ret) {
- dev_err(dev, "Failed to get supplies: err = %d\n", ret);
- return ret;
- }
+ if (ret)
+ return dev_err_probe(dev, ret, "Failed to get supplies\n");
ret = regulator_bulk_enable(WCD934X_MAX_SUPPLY, ddata->supplies);
- if (ret) {
- dev_err(dev, "Failed to enable supplies: err = %d\n", ret);
- return ret;
- }
+ if (ret)
+ return dev_err_probe(dev, ret, "Failed to enable supplies\n");
/*
* For WCD934X, it takes about 600us for the Vout_A and
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH 1/2] mfd: wcd934x: Fix an error handling path in wcd934x_slim_probe()
2023-05-20 7:10 [PATCH 1/2] mfd: wcd934x: Fix an error handling path in wcd934x_slim_probe() Christophe JAILLET
2023-05-20 7:11 ` [PATCH 2/2] mfd: wcd934x: Simplify with dev_err_probe() Christophe JAILLET
@ 2023-05-25 11:19 ` Lee Jones
1 sibling, 0 replies; 4+ messages in thread
From: Lee Jones @ 2023-05-25 11:19 UTC (permalink / raw)
To: Christophe JAILLET
Cc: Maíra Canal, linux-kernel, kernel-janitors, Lee Jones
On Sat, 20 May 2023, Christophe JAILLET wrote:
> If devm_gpiod_get_optional() fails, some resources need to be released, as
> already done in the .remove() function.
>
> While at it, remove the unneeded error code from a dev_err_probe() call.
> It is already added in a human readable way by dev_err_probe() itself.
>
> Fixes: 6a0ee2a61a31 ("mfd: wcd934x: Replace legacy gpio interface for gpiod")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
> drivers/mfd/wcd934x.c | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
Applied, thanks
--
Lee Jones [李琼斯]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-05-25 11:20 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-20 7:10 [PATCH 1/2] mfd: wcd934x: Fix an error handling path in wcd934x_slim_probe() Christophe JAILLET
2023-05-20 7:11 ` [PATCH 2/2] mfd: wcd934x: Simplify with dev_err_probe() Christophe JAILLET
2023-05-25 11:20 ` Lee Jones
2023-05-25 11:19 ` [PATCH 1/2] mfd: wcd934x: Fix an error handling path in wcd934x_slim_probe() Lee Jones
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox