forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-13 9d77db3c730780c8ef5ccd4b66403ff5675cfe4e
kernel/drivers/iio/adc/mcp3422.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * mcp3422.c - driver for the Microchip mcp3421/2/3/4/5/6/7/8 chip family
34 *
....@@ -5,24 +6,20 @@
56 * Author: Angelo Compagnucci <angelo.compagnucci@gmail.com>
67 *
78 * Datasheet: http://ww1.microchip.com/downloads/en/devicedoc/22088b.pdf
8
- * http://ww1.microchip.com/downloads/en/DeviceDoc/22226a.pdf
9
- * http://ww1.microchip.com/downloads/en/DeviceDoc/22072b.pdf
9
+ * https://ww1.microchip.com/downloads/en/DeviceDoc/22226a.pdf
10
+ * https://ww1.microchip.com/downloads/en/DeviceDoc/22072b.pdf
1011 *
1112 * This driver exports the value of analog input voltage to sysfs, the
1213 * voltage unit is nV.
13
- *
14
- * This program is free software; you can redistribute it and/or modify
15
- * it under the terms of the GNU General Public License as published by
16
- * the Free Software Foundation; either version 2 of the License, or
17
- * (at your option) any later version.
1814 */
1915
2016 #include <linux/err.h>
2117 #include <linux/i2c.h>
2218 #include <linux/module.h>
19
+#include <linux/mod_devicetable.h>
2320 #include <linux/delay.h>
2421 #include <linux/sysfs.h>
25
-#include <linux/of.h>
22
+#include <asm/unaligned.h>
2623
2724 #include <linux/iio/iio.h>
2825 #include <linux/iio/sysfs.h>
....@@ -117,11 +114,11 @@
117114
118115 if (sample_rate == MCP3422_SRATE_3) {
119116 ret = i2c_master_recv(adc->i2c, buf, 4);
120
- temp = buf[0] << 16 | buf[1] << 8 | buf[2];
117
+ temp = get_unaligned_be24(&buf[0]);
121118 *config = buf[3];
122119 } else {
123120 ret = i2c_master_recv(adc->i2c, buf, 3);
124
- temp = buf[0] << 8 | buf[1];
121
+ temp = get_unaligned_be16(&buf[0]);
125122 *config = buf[2];
126123 }
127124
....@@ -354,8 +351,6 @@
354351
355352 mutex_init(&adc->lock);
356353
357
- indio_dev->dev.parent = &client->dev;
358
- indio_dev->dev.of_node = client->dev.of_node;
359354 indio_dev->name = dev_name(&client->dev);
360355 indio_dev->modes = INDIO_DIRECT_MODE;
361356 indio_dev->info = &mcp3422_info;
....@@ -411,18 +406,16 @@
411406 };
412407 MODULE_DEVICE_TABLE(i2c, mcp3422_id);
413408
414
-#ifdef CONFIG_OF
415409 static const struct of_device_id mcp3422_of_match[] = {
416410 { .compatible = "mcp3422" },
417411 { }
418412 };
419413 MODULE_DEVICE_TABLE(of, mcp3422_of_match);
420
-#endif
421414
422415 static struct i2c_driver mcp3422_driver = {
423416 .driver = {
424417 .name = "mcp3422",
425
- .of_match_table = of_match_ptr(mcp3422_of_match),
418
+ .of_match_table = mcp3422_of_match,
426419 },
427420 .probe = mcp3422_probe,
428421 .id_table = mcp3422_id,