2022-01-06 06:57:22

by Jiasheng Jiang

[permalink] [raw]
Subject: [PATCH] drivers/misc/lis3lv02d/lis3lv02d_i2c.c: Check for error return from regulator_bulk_enable in lis3_i2c_init

Because of the possible failure of the consumer, the
regulator_bulk_enable() may return error.
Therefore, it should be better to check the return value of the
lis3_reg_ctrl().
There are two callers, and I submit two patches to fix separately.
This patch is about lis3_i2c_init().

Fixes: ec400c9fab99 ("lis3lv02d: make regulator API usage unconditional")
Signed-off-by: Jiasheng Jiang <[email protected]>
---
drivers/misc/lis3lv02d/lis3lv02d_i2c.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/misc/lis3lv02d/lis3lv02d_i2c.c b/drivers/misc/lis3lv02d/lis3lv02d_i2c.c
index 52555d2e824b..4001e3c0a167 100644
--- a/drivers/misc/lis3lv02d/lis3lv02d_i2c.c
+++ b/drivers/misc/lis3lv02d/lis3lv02d_i2c.c
@@ -69,7 +69,9 @@ static int lis3_i2c_init(struct lis3lv02d *lis3)
u8 reg;
int ret;

- lis3_reg_ctrl(lis3, LIS3_REG_ON);
+ ret = lis3_reg_ctrl(lis3, LIS3_REG_ON);
+ if (ret)
+ return ret;

lis3->read(lis3, WHO_AM_I, &reg);
if (reg != lis3->whoami)
--
2.25.1