forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/drivers/iio/humidity/hdc100x.c
....@@ -6,15 +6,16 @@
66 * Author: Matt Ranostay <matt.ranostay@konsulko.com>
77 *
88 * Datasheets:
9
- * http://www.ti.com/product/HDC1000/datasheet
10
- * http://www.ti.com/product/HDC1008/datasheet
11
- * http://www.ti.com/product/HDC1010/datasheet
12
- * http://www.ti.com/product/HDC1050/datasheet
13
- * http://www.ti.com/product/HDC1080/datasheet
9
+ * https://www.ti.com/product/HDC1000/datasheet
10
+ * https://www.ti.com/product/HDC1008/datasheet
11
+ * https://www.ti.com/product/HDC1010/datasheet
12
+ * https://www.ti.com/product/HDC1050/datasheet
13
+ * https://www.ti.com/product/HDC1080/datasheet
1414 */
1515
1616 #include <linux/delay.h>
1717 #include <linux/module.h>
18
+#include <linux/mod_devicetable.h>
1819 #include <linux/init.h>
1920 #include <linux/i2c.h>
2021
....@@ -290,21 +291,14 @@
290291 ret = hdc100x_update_config(data, HDC100X_REG_CONFIG_ACQ_MODE,
291292 HDC100X_REG_CONFIG_ACQ_MODE);
292293 mutex_unlock(&data->lock);
293
- if (ret)
294
- return ret;
295294
296
- return iio_triggered_buffer_postenable(indio_dev);
295
+ return ret;
297296 }
298297
299298 static int hdc100x_buffer_predisable(struct iio_dev *indio_dev)
300299 {
301300 struct hdc100x_data *data = iio_priv(indio_dev);
302301 int ret;
303
-
304
- /* First detach poll func, then reset ACQ mode. OK to disable buffer */
305
- ret = iio_triggered_buffer_predisable(indio_dev);
306
- if (ret)
307
- return ret;
308302
309303 mutex_lock(&data->lock);
310304 ret = hdc100x_update_config(data, HDC100X_REG_CONFIG_ACQ_MODE, 0);
....@@ -377,7 +371,6 @@
377371 data->client = client;
378372 mutex_init(&data->lock);
379373
380
- indio_dev->dev.parent = &client->dev;
381374 indio_dev->name = dev_name(&client->dev);
382375 indio_dev->modes = INDIO_DIRECT_MODE;
383376 indio_dev->info = &hdc100x_info;
....@@ -391,28 +384,16 @@
391384 hdc100x_set_it_time(data, 1, hdc100x_int_time[1][0]);
392385 hdc100x_update_config(data, HDC100X_REG_CONFIG_ACQ_MODE, 0);
393386
394
- ret = iio_triggered_buffer_setup(indio_dev, NULL,
387
+ ret = devm_iio_triggered_buffer_setup(&client->dev,
388
+ indio_dev, NULL,
395389 hdc100x_trigger_handler,
396390 &hdc_buffer_setup_ops);
397391 if (ret < 0) {
398392 dev_err(&client->dev, "iio triggered buffer setup failed\n");
399393 return ret;
400394 }
401
- ret = iio_device_register(indio_dev);
402
- if (ret < 0)
403
- iio_triggered_buffer_cleanup(indio_dev);
404395
405
- return ret;
406
-}
407
-
408
-static int hdc100x_remove(struct i2c_client *client)
409
-{
410
- struct iio_dev *indio_dev = i2c_get_clientdata(client);
411
-
412
- iio_device_unregister(indio_dev);
413
- iio_triggered_buffer_cleanup(indio_dev);
414
-
415
- return 0;
396
+ return devm_iio_device_register(&client->dev, indio_dev);
416397 }
417398
418399 static const struct i2c_device_id hdc100x_id[] = {
....@@ -439,10 +420,9 @@
439420 static struct i2c_driver hdc100x_driver = {
440421 .driver = {
441422 .name = "hdc100x",
442
- .of_match_table = of_match_ptr(hdc100x_dt_ids),
423
+ .of_match_table = hdc100x_dt_ids,
443424 },
444425 .probe = hdc100x_probe,
445
- .remove = hdc100x_remove,
446426 .id_table = hdc100x_id,
447427 };
448428 module_i2c_driver(hdc100x_driver);