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.

Change-Id: Idf38c25903907a25079425fb9aadb024e0e8f3b5
Fixes: d75846ed08 ("mfd: stmfx: Fix dev_err_probe() call in stmfx_chip_init()")
Signed-off-by: Amelie Delaunay <amelie.delaunay@foss.st.com>
Reviewed-on: https://gerrit.st.com/c/mpu/oe/st/linux-stm32/+/295987
ACI: CITOOLS <MDG-smet-aci-reviews@list.st.com>
ACI: CIBUILD <MDG-smet-aci-builds@list.st.com>
Reviewed-by: Antonio Maria BORNEO <antonio.borneo@st.com>
Reviewed-by: Denis HUMEAU <denis.humeau@st.com>
This commit is contained in:
Amelie Delaunay
2023-03-16 15:18:14 +01:00
committed by Eric Fourmont
parent 2a415dccb4
commit fb216bec81

View File

@ -328,9 +328,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");
}