.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * Linux I2C core OF support code |
---|
3 | 4 | * |
---|
4 | 5 | * Copyright (C) 2008 Jochen Friedrich <jochen@scram.de> |
---|
5 | 6 | * based on a previous patch from Jon Smirl <jonsmirl@gmail.com> |
---|
6 | 7 | * |
---|
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> |
---|
13 | 9 | */ |
---|
14 | 10 | |
---|
15 | 11 | #include <dt-bindings/i2c/i2c.h> |
---|
.. | .. |
---|
19 | 15 | #include <linux/module.h> |
---|
20 | 16 | #include <linux/of.h> |
---|
21 | 17 | #include <linux/of_device.h> |
---|
| 18 | +#include <linux/sysfs.h> |
---|
| 19 | +#include <trace/hooks/i2c.h> |
---|
22 | 20 | |
---|
23 | 21 | #include "i2c-core.h" |
---|
24 | 22 | |
---|
.. | .. |
---|
34 | 32 | dev_err(dev, "of_i2c: modalias failure on %pOF\n", node); |
---|
35 | 33 | return -EINVAL; |
---|
36 | 34 | } |
---|
| 35 | + |
---|
| 36 | + trace_android_vh_of_i2c_get_board_info(node, &(info->dev_name)); |
---|
37 | 37 | |
---|
38 | 38 | ret = of_property_read_u32(node, "reg", &addr); |
---|
39 | 39 | if (ret) { |
---|
.. | .. |
---|
78 | 78 | if (ret) |
---|
79 | 79 | return ERR_PTR(ret); |
---|
80 | 80 | |
---|
81 | | - client = i2c_new_device(adap, &info); |
---|
82 | | - if (!client) { |
---|
| 81 | + client = i2c_new_client_device(adap, &info); |
---|
| 82 | + if (IS_ERR(client)) |
---|
83 | 83 | dev_err(&adap->dev, "of_i2c: Failure registering %pOF\n", node); |
---|
84 | | - return ERR_PTR(-EINVAL); |
---|
85 | | - } |
---|
| 84 | + |
---|
86 | 85 | return client; |
---|
87 | 86 | } |
---|
88 | 87 | |
---|
.. | .. |
---|
117 | 116 | of_node_put(bus); |
---|
118 | 117 | } |
---|
119 | 118 | |
---|
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) |
---|
126 | 120 | { |
---|
127 | 121 | if (dev->of_node == data) |
---|
128 | 122 | return 1; |
---|
.. | .. |
---|
139 | 133 | struct device *dev; |
---|
140 | 134 | struct i2c_client *client; |
---|
141 | 135 | |
---|
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); |
---|
143 | 137 | if (!dev) |
---|
144 | 138 | return NULL; |
---|
145 | 139 | |
---|