1
0
Fork 0

LF-99 hwmon: mag3110: correct processing order after probe error

Disable regulator first after an error occurs when probe. Remove the
directly return code when probe error occurs.

Acked-by: Fugang Duan <fugang.duan@nxp.com>
Signed-off-by: Clark Wang <xiaoning.wang@nxp.com>
5.4-rM2-2.2.x-imx-squashed
Clark Wang 2019-11-24 16:37:05 +08:00 committed by Dong Aisheng
parent 347a845787
commit d2615a1773
1 changed files with 17 additions and 11 deletions

View File

@ -450,21 +450,27 @@ static int mag3110_probe(struct i2c_client *client,
if (!i2c_check_functionality(adapter,
I2C_FUNC_SMBUS_BYTE |
I2C_FUNC_SMBUS_BYTE_DATA |
I2C_FUNC_SMBUS_I2C_BLOCK))
return -EIO;
I2C_FUNC_SMBUS_I2C_BLOCK)) {
ret = -EIO;
goto error_disable_reg;
}
dev_info(&client->dev, "check mag3110 chip ID\n");
ret = mag3110_read_reg(client, MAG3110_WHO_AM_I);
if (MAG3110_ID != ret) {
dev_err(&client->dev,
"read chip ID 0x%x is not equal to 0x%x!\n", ret,
MAG3110_ID);
return -EINVAL;
ret = -EINVAL;
goto error_disable_reg;
}
data = kzalloc(sizeof(struct mag3110_data), GFP_KERNEL);
if (!data)
return -ENOMEM;
if (!data) {
ret = -ENOMEM;
goto error_disable_reg;
}
data->client = client;
i2c_set_clientdata(client, data);
/* Init queue */
@ -544,15 +550,15 @@ error_rm_poll_dev:
error_free_poll_dev:
input_free_polled_device(data->poll_dev);
error_rm_hwmon_dev:
if (!IS_ERR(vdd))
regulator_disable(vdd);
if (!IS_ERR(vdd_io))
regulator_disable(vdd_io);
hwmon_device_unregister(data->hwmon_dev);
kfree(data);
mag3110_pdata = NULL;
error_disable_reg:
if (!IS_ERR(vdd))
regulator_disable(vdd);
if (!IS_ERR(vdd_io))
regulator_disable(vdd_io);
return ret;
}