Skip to content

Commit 7c81582

Browse files
ADESTMlag-linaro
authored andcommitted
mfd: stmfx: Nullify stmfx->vdd in case of error
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: d75846e ("mfd: stmfx: Fix dev_err_probe() call in stmfx_chip_init()") Signed-off-by: Amelie Delaunay <amelie.delaunay@foss.st.com> Link: https://lore.kernel.org/r/20230609092804.793100-2-amelie.delaunay@foss.st.com Signed-off-by: Lee Jones <lee@kernel.org>
1 parent f592cf6 commit 7c81582

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

drivers/mfd/stmfx.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -330,9 +330,8 @@ static int stmfx_chip_init(struct i2c_client *client)
330330
stmfx->vdd = devm_regulator_get_optional(&client->dev, "vdd");
331331
ret = PTR_ERR_OR_ZERO(stmfx->vdd);
332332
if (ret) {
333-
if (ret == -ENODEV)
334-
stmfx->vdd = NULL;
335-
else
333+
stmfx->vdd = NULL;
334+
if (ret != -ENODEV)
336335
return dev_err_probe(&client->dev, ret, "Failed to get VDD regulator\n");
337336
}
338337

0 commit comments

Comments
 (0)