.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /** |
---|
2 | 3 | * Aosong AM2315 relative humidity and temperature |
---|
3 | 4 | * |
---|
4 | 5 | * Copyright (c) 2016, Intel Corporation. |
---|
5 | | - * |
---|
6 | | - * This file is subject to the terms and conditions of version 2 of |
---|
7 | | - * the GNU General Public License. See the file COPYING in the main |
---|
8 | | - * directory of this archive for more details. |
---|
9 | 6 | * |
---|
10 | 7 | * 7-bit I2C address: 0x5C. |
---|
11 | 8 | */ |
---|
.. | .. |
---|
240 | 237 | i2c_set_clientdata(client, indio_dev); |
---|
241 | 238 | mutex_init(&data->lock); |
---|
242 | 239 | |
---|
243 | | - indio_dev->dev.parent = &client->dev; |
---|
244 | 240 | indio_dev->info = &am2315_info; |
---|
245 | 241 | indio_dev->name = AM2315_DRIVER_NAME; |
---|
246 | 242 | indio_dev->modes = INDIO_DIRECT_MODE; |
---|
247 | 243 | indio_dev->channels = am2315_channels; |
---|
248 | 244 | indio_dev->num_channels = ARRAY_SIZE(am2315_channels); |
---|
249 | 245 | |
---|
250 | | - ret = iio_triggered_buffer_setup(indio_dev, iio_pollfunc_store_time, |
---|
| 246 | + ret = devm_iio_triggered_buffer_setup(&client->dev, |
---|
| 247 | + indio_dev, iio_pollfunc_store_time, |
---|
251 | 248 | am2315_trigger_handler, NULL); |
---|
252 | 249 | if (ret < 0) { |
---|
253 | 250 | dev_err(&client->dev, "iio triggered buffer setup failed\n"); |
---|
254 | 251 | return ret; |
---|
255 | 252 | } |
---|
256 | 253 | |
---|
257 | | - ret = iio_device_register(indio_dev); |
---|
258 | | - if (ret < 0) |
---|
259 | | - goto err_buffer_cleanup; |
---|
260 | | - |
---|
261 | | - return 0; |
---|
262 | | - |
---|
263 | | -err_buffer_cleanup: |
---|
264 | | - iio_triggered_buffer_cleanup(indio_dev); |
---|
265 | | - return ret; |
---|
266 | | -} |
---|
267 | | - |
---|
268 | | -static int am2315_remove(struct i2c_client *client) |
---|
269 | | -{ |
---|
270 | | - struct iio_dev *indio_dev = i2c_get_clientdata(client); |
---|
271 | | - |
---|
272 | | - iio_device_unregister(indio_dev); |
---|
273 | | - iio_triggered_buffer_cleanup(indio_dev); |
---|
274 | | - |
---|
275 | | - return 0; |
---|
| 254 | + return devm_iio_device_register(&client->dev, indio_dev); |
---|
276 | 255 | } |
---|
277 | 256 | |
---|
278 | 257 | static const struct i2c_device_id am2315_i2c_id[] = { |
---|
.. | .. |
---|
294 | 273 | .acpi_match_table = ACPI_PTR(am2315_acpi_id), |
---|
295 | 274 | }, |
---|
296 | 275 | .probe = am2315_probe, |
---|
297 | | - .remove = am2315_remove, |
---|
298 | 276 | .id_table = am2315_i2c_id, |
---|
299 | 277 | }; |
---|
300 | 278 | |
---|