Messages in this thread Patch in this message | | | From | Jiasheng Jiang <> | Subject | [PATCH] drivers/misc/lis3lv02d/lis3lv02d_i2c.c: Check for error return from regulator_bulk_enable in lis3lv02d_i2c_probe | Date | Thu, 6 Jan 2022 15:13:16 +0800 |
| |
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() and return error if fails.
Fixes: ec400c9fab99 ("lis3lv02d: make regulator API usage unconditional") Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn> --- drivers/misc/lis3lv02d/lis3lv02d_i2c.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/drivers/misc/lis3lv02d/lis3lv02d_i2c.c b/drivers/misc/lis3lv02d/lis3lv02d_i2c.c index 4001e3c0a167..4fe5ff8cacb8 100644 --- a/drivers/misc/lis3lv02d/lis3lv02d_i2c.c +++ b/drivers/misc/lis3lv02d/lis3lv02d_i2c.c @@ -105,7 +105,7 @@ MODULE_DEVICE_TABLE(of, lis3lv02d_i2c_dt_ids); static int lis3lv02d_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id) { - int ret = 0; + int ret = 0, err; struct lis3lv02d_platform_data *pdata = client->dev.platform_data; #ifdef CONFIG_OF @@ -160,11 +160,19 @@ static int lis3lv02d_i2c_probe(struct i2c_client *client, i2c_set_clientdata(client, &lis3_dev); /* Provide power over the init call */ - lis3_reg_ctrl(&lis3_dev, LIS3_REG_ON); + err = lis3_reg_ctrl(&lis3_dev, LIS3_REG_ON); + if (err) { + ret = err; + goto fail2; + } ret = lis3lv02d_init_device(&lis3_dev); - lis3_reg_ctrl(&lis3_dev, LIS3_REG_OFF); + err = lis3_reg_ctrl(&lis3_dev, LIS3_REG_OFF); + if (err) { + ret = err; + goto fail2; + } if (ret) goto fail2; -- 2.25.1
| |