Commit 23f1ce3c authored by Chuhong Yuan's avatar Chuhong Yuan Committed by Jonathan Cameron

iio: humidity: 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: default avatarChuhong Yuan <hslester96@gmail.com>
Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent 857ba268
...@@ -240,32 +240,15 @@ static int am2315_probe(struct i2c_client *client, ...@@ -240,32 +240,15 @@ static int am2315_probe(struct i2c_client *client,
indio_dev->channels = am2315_channels; indio_dev->channels = am2315_channels;
indio_dev->num_channels = ARRAY_SIZE(am2315_channels); indio_dev->num_channels = ARRAY_SIZE(am2315_channels);
ret = iio_triggered_buffer_setup(indio_dev, iio_pollfunc_store_time, ret = devm_iio_triggered_buffer_setup(&client->dev,
indio_dev, iio_pollfunc_store_time,
am2315_trigger_handler, NULL); am2315_trigger_handler, NULL);
if (ret < 0) { if (ret < 0) {
dev_err(&client->dev, "iio triggered buffer setup failed\n"); dev_err(&client->dev, "iio triggered buffer setup failed\n");
return ret; return ret;
} }
ret = iio_device_register(indio_dev); return devm_iio_device_register(&client->dev, indio_dev);
if (ret < 0)
goto err_buffer_cleanup;
return 0;
err_buffer_cleanup:
iio_triggered_buffer_cleanup(indio_dev);
return ret;
}
static int am2315_remove(struct i2c_client *client)
{
struct iio_dev *indio_dev = i2c_get_clientdata(client);
iio_device_unregister(indio_dev);
iio_triggered_buffer_cleanup(indio_dev);
return 0;
} }
static const struct i2c_device_id am2315_i2c_id[] = { static const struct i2c_device_id am2315_i2c_id[] = {
...@@ -287,7 +270,6 @@ static struct i2c_driver am2315_driver = { ...@@ -287,7 +270,6 @@ static struct i2c_driver am2315_driver = {
.acpi_match_table = ACPI_PTR(am2315_acpi_id), .acpi_match_table = ACPI_PTR(am2315_acpi_id),
}, },
.probe = am2315_probe, .probe = am2315_probe,
.remove = am2315_remove,
.id_table = am2315_i2c_id, .id_table = am2315_i2c_id,
}; };
......
...@@ -385,28 +385,16 @@ static int hdc100x_probe(struct i2c_client *client, ...@@ -385,28 +385,16 @@ static int hdc100x_probe(struct i2c_client *client,
hdc100x_set_it_time(data, 1, hdc100x_int_time[1][0]); hdc100x_set_it_time(data, 1, hdc100x_int_time[1][0]);
hdc100x_update_config(data, HDC100X_REG_CONFIG_ACQ_MODE, 0); hdc100x_update_config(data, HDC100X_REG_CONFIG_ACQ_MODE, 0);
ret = iio_triggered_buffer_setup(indio_dev, NULL, ret = devm_iio_triggered_buffer_setup(&client->dev,
indio_dev, NULL,
hdc100x_trigger_handler, hdc100x_trigger_handler,
&hdc_buffer_setup_ops); &hdc_buffer_setup_ops);
if (ret < 0) { if (ret < 0) {
dev_err(&client->dev, "iio triggered buffer setup failed\n"); dev_err(&client->dev, "iio triggered buffer setup failed\n");
return ret; return ret;
} }
ret = iio_device_register(indio_dev);
if (ret < 0)
iio_triggered_buffer_cleanup(indio_dev);
return ret; return devm_iio_device_register(&client->dev, indio_dev);
}
static int hdc100x_remove(struct i2c_client *client)
{
struct iio_dev *indio_dev = i2c_get_clientdata(client);
iio_device_unregister(indio_dev);
iio_triggered_buffer_cleanup(indio_dev);
return 0;
} }
static const struct i2c_device_id hdc100x_id[] = { static const struct i2c_device_id hdc100x_id[] = {
...@@ -436,7 +424,6 @@ static struct i2c_driver hdc100x_driver = { ...@@ -436,7 +424,6 @@ static struct i2c_driver hdc100x_driver = {
.of_match_table = of_match_ptr(hdc100x_dt_ids), .of_match_table = of_match_ptr(hdc100x_dt_ids),
}, },
.probe = hdc100x_probe, .probe = hdc100x_probe,
.remove = hdc100x_remove,
.id_table = hdc100x_id, .id_table = hdc100x_id,
}; };
module_i2c_driver(hdc100x_driver); module_i2c_driver(hdc100x_driver);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment