From fb216bec81012c34a2f41f799386f343a40b4754 Mon Sep 17 00:00:00 2001 From: Amelie Delaunay Date: Thu, 16 Mar 2023 15:18:14 +0100 Subject: [PATCH] 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: d75846ed08e6 ("mfd: stmfx: Fix dev_err_probe() call in stmfx_chip_init()") Signed-off-by: Amelie Delaunay Reviewed-on: https://gerrit.st.com/c/mpu/oe/st/linux-stm32/+/295987 ACI: CITOOLS ACI: CIBUILD Reviewed-by: Antonio Maria BORNEO Reviewed-by: Denis HUMEAU --- 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 83b068e7ac1b..30f83efad318 100644 --- a/drivers/mfd/stmfx.c +++ b/drivers/mfd/stmfx.c @@ -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"); }