forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-11 04dd17822334871b23ea2862f7798fb0e0007777
kernel/drivers/staging/greybus/i2c.c
....@@ -10,8 +10,8 @@
1010 #include <linux/module.h>
1111 #include <linux/slab.h>
1212 #include <linux/i2c.h>
13
+#include <linux/greybus.h>
1314
14
-#include "greybus.h"
1515 #include "gbphy.h"
1616
1717 struct gb_i2c_device {
....@@ -31,7 +31,14 @@
3131 return gb_i2c_functionality; /* All bits the same for now */
3232 }
3333
34
-static int gb_i2c_functionality_operation(struct gb_i2c_device *gb_i2c_dev)
34
+/*
35
+ * Do initial setup of the i2c device. This includes verifying we
36
+ * can support it (based on the protocol version it advertises).
37
+ * If that's OK, we get and cached its functionality bits.
38
+ *
39
+ * Note: gb_i2c_dev->connection is assumed to have been valid.
40
+ */
41
+static int gb_i2c_device_setup(struct gb_i2c_device *gb_i2c_dev)
3542 {
3643 struct gb_i2c_functionality_response response;
3744 u32 functionality;
....@@ -107,7 +114,7 @@
107114
108115 /* Response consists only of incoming data */
109116 operation = gb_operation_create(connection, GB_I2C_TYPE_TRANSFER,
110
- request_size, data_in_size, GFP_KERNEL);
117
+ request_size, data_in_size, GFP_KERNEL);
111118 if (!operation)
112119 return NULL;
113120
....@@ -137,7 +144,7 @@
137144 }
138145
139146 static void gb_i2c_decode_response(struct i2c_msg *msgs, u32 msg_count,
140
- struct gb_i2c_transfer_response *response)
147
+ struct gb_i2c_transfer_response *response)
141148 {
142149 struct i2c_msg *msg = msgs;
143150 u8 *data;
....@@ -164,7 +171,7 @@
164171 }
165172
166173 static int gb_i2c_transfer_operation(struct gb_i2c_device *gb_i2c_dev,
167
- struct i2c_msg *msgs, u32 msg_count)
174
+ struct i2c_msg *msgs, u32 msg_count)
168175 {
169176 struct gb_connection *connection = gb_i2c_dev->connection;
170177 struct device *dev = &gb_i2c_dev->gbphy_dev->dev;
....@@ -199,7 +206,7 @@
199206 }
200207
201208 static int gb_i2c_master_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs,
202
- int msg_count)
209
+ int msg_count)
203210 {
204211 struct gb_i2c_device *gb_i2c_dev;
205212
....@@ -207,20 +214,6 @@
207214
208215 return gb_i2c_transfer_operation(gb_i2c_dev, msgs, msg_count);
209216 }
210
-
211
-#if 0
212
-/* Later */
213
-static int gb_i2c_smbus_xfer(struct i2c_adapter *adap,
214
- u16 addr, unsigned short flags, char read_write,
215
- u8 command, int size, union i2c_smbus_data *data)
216
-{
217
- struct gb_i2c_device *gb_i2c_dev;
218
-
219
- gb_i2c_dev = i2c_get_adapdata(adap);
220
-
221
- return 0;
222
-}
223
-#endif
224217
225218 static u32 gb_i2c_functionality(struct i2c_adapter *adap)
226219 {
....@@ -231,25 +224,11 @@
231224
232225 static const struct i2c_algorithm gb_i2c_algorithm = {
233226 .master_xfer = gb_i2c_master_xfer,
234
- /* .smbus_xfer = gb_i2c_smbus_xfer, */
235227 .functionality = gb_i2c_functionality,
236228 };
237229
238
-/*
239
- * Do initial setup of the i2c device. This includes verifying we
240
- * can support it (based on the protocol version it advertises).
241
- * If that's OK, we get and cached its functionality bits.
242
- *
243
- * Note: gb_i2c_dev->connection is assumed to have been valid.
244
- */
245
-static int gb_i2c_device_setup(struct gb_i2c_device *gb_i2c_dev)
246
-{
247
- /* Assume the functionality never changes, just get it once */
248
- return gb_i2c_functionality_operation(gb_i2c_dev);
249
-}
250
-
251230 static int gb_i2c_probe(struct gbphy_device *gbphy_dev,
252
- const struct gbphy_device_id *id)
231
+ const struct gbphy_device_id *id)
253232 {
254233 struct gb_connection *connection;
255234 struct gb_i2c_device *gb_i2c_dev;
....@@ -260,9 +239,10 @@
260239 if (!gb_i2c_dev)
261240 return -ENOMEM;
262241
263
- connection = gb_connection_create(gbphy_dev->bundle,
264
- le16_to_cpu(gbphy_dev->cport_desc->id),
265
- NULL);
242
+ connection =
243
+ gb_connection_create(gbphy_dev->bundle,
244
+ le16_to_cpu(gbphy_dev->cport_desc->id),
245
+ NULL);
266246 if (IS_ERR(connection)) {
267247 ret = PTR_ERR(connection);
268248 goto exit_i2cdev_free;
....@@ -286,7 +266,6 @@
286266 adapter->owner = THIS_MODULE;
287267 adapter->class = I2C_CLASS_HWMON | I2C_CLASS_SPD;
288268 adapter->algo = &gb_i2c_algorithm;
289
- /* adapter->algo_data = what? */
290269
291270 adapter->dev.parent = &gbphy_dev->dev;
292271 snprintf(adapter->name, sizeof(adapter->name), "Greybus i2c adapter");