iio: light: si1145: Use device-managed APIs
Use device-managed APIs to simplify the code. The remove functions are redundant now and can be deleted. Signed-off-by: Chuhong Yuan <hslester96@gmail.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
This commit is contained in:
parent
eb1d8ebf2d
commit
d3017f5fbb
|
@ -1261,7 +1261,7 @@ static int si1145_probe_trigger(struct iio_dev *indio_dev)
|
|||
return ret;
|
||||
}
|
||||
|
||||
ret = iio_trigger_register(trig);
|
||||
ret = devm_iio_trigger_register(&client->dev, trig);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
|
@ -1271,16 +1271,6 @@ static int si1145_probe_trigger(struct iio_dev *indio_dev)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void si1145_remove_trigger(struct iio_dev *indio_dev)
|
||||
{
|
||||
struct si1145_data *data = iio_priv(indio_dev);
|
||||
|
||||
if (data->trig) {
|
||||
iio_trigger_unregister(data->trig);
|
||||
data->trig = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static int si1145_probe(struct i2c_client *client,
|
||||
const struct i2c_device_id *id)
|
||||
{
|
||||
|
@ -1332,7 +1322,8 @@ static int si1145_probe(struct i2c_client *client,
|
|||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
ret = iio_triggered_buffer_setup(indio_dev, NULL,
|
||||
ret = devm_iio_triggered_buffer_setup(&client->dev,
|
||||
indio_dev, NULL,
|
||||
si1145_trigger_handler, &si1145_buffer_setup_ops);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
@ -1340,23 +1331,12 @@ static int si1145_probe(struct i2c_client *client,
|
|||
if (client->irq) {
|
||||
ret = si1145_probe_trigger(indio_dev);
|
||||
if (ret < 0)
|
||||
goto error_free_buffer;
|
||||
return ret;
|
||||
} else {
|
||||
dev_info(&client->dev, "no irq, using polling\n");
|
||||
}
|
||||
|
||||
ret = iio_device_register(indio_dev);
|
||||
if (ret < 0)
|
||||
goto error_free_trigger;
|
||||
|
||||
return 0;
|
||||
|
||||
error_free_trigger:
|
||||
si1145_remove_trigger(indio_dev);
|
||||
error_free_buffer:
|
||||
iio_triggered_buffer_cleanup(indio_dev);
|
||||
|
||||
return ret;
|
||||
return devm_iio_device_register(&client->dev, indio_dev);
|
||||
}
|
||||
|
||||
static const struct i2c_device_id si1145_ids[] = {
|
||||
|
@ -1371,23 +1351,11 @@ static const struct i2c_device_id si1145_ids[] = {
|
|||
};
|
||||
MODULE_DEVICE_TABLE(i2c, si1145_ids);
|
||||
|
||||
static int si1145_remove(struct i2c_client *client)
|
||||
{
|
||||
struct iio_dev *indio_dev = i2c_get_clientdata(client);
|
||||
|
||||
iio_device_unregister(indio_dev);
|
||||
si1145_remove_trigger(indio_dev);
|
||||
iio_triggered_buffer_cleanup(indio_dev);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct i2c_driver si1145_driver = {
|
||||
.driver = {
|
||||
.name = "si1145",
|
||||
},
|
||||
.probe = si1145_probe,
|
||||
.remove = si1145_remove,
|
||||
.id_table = si1145_ids,
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue