mirror of
https://github.com/torvalds/linux.git
synced 2026-06-04 20:46:48 +02:00
iio: light: veml6070: add action for i2c_unregister_device
Simplify the code by adding an action to call i2c_unregister_device(), which removes the need for a 'fail' label, gotos to it, and an explicit call in veml6070_remove(). Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com> Link: https://patch.msgid.link/20240929-veml6070-cleanup-v1-1-a9350341a646@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
This commit is contained in:
parent
0f87813bc3
commit
7501bff87c
|
|
@ -135,6 +135,13 @@ static const struct iio_info veml6070_info = {
|
||||||
.read_raw = veml6070_read_raw,
|
.read_raw = veml6070_read_raw,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static void veml6070_i2c_unreg(void *p)
|
||||||
|
{
|
||||||
|
struct veml6070_data *data = p;
|
||||||
|
|
||||||
|
i2c_unregister_device(data->client2);
|
||||||
|
}
|
||||||
|
|
||||||
static int veml6070_probe(struct i2c_client *client)
|
static int veml6070_probe(struct i2c_client *client)
|
||||||
{
|
{
|
||||||
struct veml6070_data *data;
|
struct veml6070_data *data;
|
||||||
|
|
@ -166,17 +173,13 @@ static int veml6070_probe(struct i2c_client *client)
|
||||||
VEML6070_COMMAND_SD;
|
VEML6070_COMMAND_SD;
|
||||||
ret = i2c_smbus_write_byte(data->client1, data->config);
|
ret = i2c_smbus_write_byte(data->client1, data->config);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto fail;
|
return ret;
|
||||||
|
|
||||||
ret = iio_device_register(indio_dev);
|
ret = devm_add_action_or_reset(&client->dev, veml6070_i2c_unreg, data);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto fail;
|
return ret;
|
||||||
|
|
||||||
return ret;
|
return iio_device_register(indio_dev);
|
||||||
|
|
||||||
fail:
|
|
||||||
i2c_unregister_device(data->client2);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void veml6070_remove(struct i2c_client *client)
|
static void veml6070_remove(struct i2c_client *client)
|
||||||
|
|
@ -185,7 +188,6 @@ static void veml6070_remove(struct i2c_client *client)
|
||||||
struct veml6070_data *data = iio_priv(indio_dev);
|
struct veml6070_data *data = iio_priv(indio_dev);
|
||||||
|
|
||||||
iio_device_unregister(indio_dev);
|
iio_device_unregister(indio_dev);
|
||||||
i2c_unregister_device(data->client2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct i2c_device_id veml6070_id[] = {
|
static const struct i2c_device_id veml6070_id[] = {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user