hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/drivers/i2c/i2c-core-of.c
....@@ -1,15 +1,11 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Linux I2C core OF support code
34 *
45 * Copyright (C) 2008 Jochen Friedrich <jochen@scram.de>
56 * based on a previous patch from Jon Smirl <jonsmirl@gmail.com>
67 *
7
- * Copyright (C) 2013, 2018 Wolfram Sang <wsa@the-dreams.de>
8
- *
9
- * This program is free software; you can redistribute it and/or modify it
10
- * under the terms of the GNU General Public License as published by the Free
11
- * Software Foundation; either version 2 of the License, or (at your option)
12
- * any later version.
8
+ * Copyright (C) 2013, 2018 Wolfram Sang <wsa@kernel.org>
139 */
1410
1511 #include <dt-bindings/i2c/i2c.h>
....@@ -19,6 +15,8 @@
1915 #include <linux/module.h>
2016 #include <linux/of.h>
2117 #include <linux/of_device.h>
18
+#include <linux/sysfs.h>
19
+#include <trace/hooks/i2c.h>
2220
2321 #include "i2c-core.h"
2422
....@@ -34,6 +32,8 @@
3432 dev_err(dev, "of_i2c: modalias failure on %pOF\n", node);
3533 return -EINVAL;
3634 }
35
+
36
+ trace_android_vh_of_i2c_get_board_info(node, &(info->dev_name));
3737
3838 ret = of_property_read_u32(node, "reg", &addr);
3939 if (ret) {
....@@ -78,11 +78,10 @@
7878 if (ret)
7979 return ERR_PTR(ret);
8080
81
- client = i2c_new_device(adap, &info);
82
- if (!client) {
81
+ client = i2c_new_client_device(adap, &info);
82
+ if (IS_ERR(client))
8383 dev_err(&adap->dev, "of_i2c: Failure registering %pOF\n", node);
84
- return ERR_PTR(-EINVAL);
85
- }
84
+
8685 return client;
8786 }
8887
....@@ -117,12 +116,7 @@
117116 of_node_put(bus);
118117 }
119118
120
-static int of_dev_node_match(struct device *dev, void *data)
121
-{
122
- return dev->of_node == data;
123
-}
124
-
125
-static int of_dev_or_parent_node_match(struct device *dev, void *data)
119
+static int of_dev_or_parent_node_match(struct device *dev, const void *data)
126120 {
127121 if (dev->of_node == data)
128122 return 1;
....@@ -139,7 +133,7 @@
139133 struct device *dev;
140134 struct i2c_client *client;
141135
142
- dev = bus_find_device(&i2c_bus_type, NULL, node, of_dev_node_match);
136
+ dev = bus_find_device_by_of_node(&i2c_bus_type, node);
143137 if (!dev)
144138 return NULL;
145139