In error path, disable vdd regulator if it exists, but don't overload ret.
Because if regulator_disable() is successful, stmfx_chip_init will exit
successfully while chip init failed.
Fixes: 06252ade9156 ("mfd: Add ST Multi-Function eXpander (STMFX) core driver")
Signed-off-by: Amelie Delaunay <[email protected]>
---
drivers/mfd/stmfx.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/mfd/stmfx.c b/drivers/mfd/stmfx.c
index f30c7c304147..54cc902cb578 100644
--- a/drivers/mfd/stmfx.c
+++ b/drivers/mfd/stmfx.c
@@ -387,7 +387,7 @@ static int stmfx_chip_init(struct i2c_client *client)
err:
if (stmfx->vdd)
- return regulator_disable(stmfx->vdd);
+ regulator_disable(stmfx->vdd);
return ret;
}
--
2.25.1
Nullify stmfx->vdd in case devm_regulator_get_optional() returns an error.
And simplify code by returning an error only if return code is not -ENODEV,
which means there is no vdd regulator and it is not an issue.
Fixes: d75846ed08e6 ("mfd: stmfx: Fix dev_err_probe() call in stmfx_chip_init()")
Signed-off-by: Amelie Delaunay <[email protected]>
---
drivers/mfd/stmfx.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/mfd/stmfx.c b/drivers/mfd/stmfx.c
index 54cc902cb578..c02cbd9c2f5d 100644
--- a/drivers/mfd/stmfx.c
+++ b/drivers/mfd/stmfx.c
@@ -330,9 +330,8 @@ static int stmfx_chip_init(struct i2c_client *client)
stmfx->vdd = devm_regulator_get_optional(&client->dev, "vdd");
ret = PTR_ERR_OR_ZERO(stmfx->vdd);
if (ret) {
- if (ret == -ENODEV)
- stmfx->vdd = NULL;
- else
+ stmfx->vdd = NULL;
+ if (ret != -ENODEV)
return dev_err_probe(&client->dev, ret, "Failed to get VDD regulator\n");
}
--
2.25.1
On Fri, 09 Jun 2023, Amelie Delaunay wrote:
> In error path, disable vdd regulator if it exists, but don't overload ret.
> Because if regulator_disable() is successful, stmfx_chip_init will exit
> successfully while chip init failed.
>
> Fixes: 06252ade9156 ("mfd: Add ST Multi-Function eXpander (STMFX) core driver")
> Signed-off-by: Amelie Delaunay <[email protected]>
> ---
> drivers/mfd/stmfx.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
Applied, thanks
--
Lee Jones [李琼斯]
On Fri, 09 Jun 2023, Amelie Delaunay wrote:
> Nullify stmfx->vdd in case devm_regulator_get_optional() returns an error.
> And simplify code by returning an error only if return code is not -ENODEV,
> which means there is no vdd regulator and it is not an issue.
>
> Fixes: d75846ed08e6 ("mfd: stmfx: Fix dev_err_probe() call in stmfx_chip_init()")
> Signed-off-by: Amelie Delaunay <[email protected]>
> ---
> drivers/mfd/stmfx.c | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
Applied, thanks
--
Lee Jones [李琼斯]