forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/drivers/iio/humidity/am2315.c
....@@ -1,11 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /**
23 * Aosong AM2315 relative humidity and temperature
34 *
45 * 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.
96 *
107 * 7-bit I2C address: 0x5C.
118 */
....@@ -240,39 +237,21 @@
240237 i2c_set_clientdata(client, indio_dev);
241238 mutex_init(&data->lock);
242239
243
- indio_dev->dev.parent = &client->dev;
244240 indio_dev->info = &am2315_info;
245241 indio_dev->name = AM2315_DRIVER_NAME;
246242 indio_dev->modes = INDIO_DIRECT_MODE;
247243 indio_dev->channels = am2315_channels;
248244 indio_dev->num_channels = ARRAY_SIZE(am2315_channels);
249245
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,
251248 am2315_trigger_handler, NULL);
252249 if (ret < 0) {
253250 dev_err(&client->dev, "iio triggered buffer setup failed\n");
254251 return ret;
255252 }
256253
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);
276255 }
277256
278257 static const struct i2c_device_id am2315_i2c_id[] = {
....@@ -294,7 +273,6 @@
294273 .acpi_match_table = ACPI_PTR(am2315_acpi_id),
295274 },
296275 .probe = am2315_probe,
297
- .remove = am2315_remove,
298276 .id_table = am2315_i2c_id,
299277 };
300278