.. | .. |
---|
10 | 10 | #include <linux/module.h> |
---|
11 | 11 | #include <linux/slab.h> |
---|
12 | 12 | #include <linux/i2c.h> |
---|
| 13 | +#include <linux/greybus.h> |
---|
13 | 14 | |
---|
14 | | -#include "greybus.h" |
---|
15 | 15 | #include "gbphy.h" |
---|
16 | 16 | |
---|
17 | 17 | struct gb_i2c_device { |
---|
.. | .. |
---|
31 | 31 | return gb_i2c_functionality; /* All bits the same for now */ |
---|
32 | 32 | } |
---|
33 | 33 | |
---|
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) |
---|
35 | 42 | { |
---|
36 | 43 | struct gb_i2c_functionality_response response; |
---|
37 | 44 | u32 functionality; |
---|
.. | .. |
---|
107 | 114 | |
---|
108 | 115 | /* Response consists only of incoming data */ |
---|
109 | 116 | 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); |
---|
111 | 118 | if (!operation) |
---|
112 | 119 | return NULL; |
---|
113 | 120 | |
---|
.. | .. |
---|
137 | 144 | } |
---|
138 | 145 | |
---|
139 | 146 | 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) |
---|
141 | 148 | { |
---|
142 | 149 | struct i2c_msg *msg = msgs; |
---|
143 | 150 | u8 *data; |
---|
.. | .. |
---|
164 | 171 | } |
---|
165 | 172 | |
---|
166 | 173 | 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) |
---|
168 | 175 | { |
---|
169 | 176 | struct gb_connection *connection = gb_i2c_dev->connection; |
---|
170 | 177 | struct device *dev = &gb_i2c_dev->gbphy_dev->dev; |
---|
.. | .. |
---|
199 | 206 | } |
---|
200 | 207 | |
---|
201 | 208 | static int gb_i2c_master_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, |
---|
202 | | - int msg_count) |
---|
| 209 | + int msg_count) |
---|
203 | 210 | { |
---|
204 | 211 | struct gb_i2c_device *gb_i2c_dev; |
---|
205 | 212 | |
---|
.. | .. |
---|
207 | 214 | |
---|
208 | 215 | return gb_i2c_transfer_operation(gb_i2c_dev, msgs, msg_count); |
---|
209 | 216 | } |
---|
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 |
---|
224 | 217 | |
---|
225 | 218 | static u32 gb_i2c_functionality(struct i2c_adapter *adap) |
---|
226 | 219 | { |
---|
.. | .. |
---|
231 | 224 | |
---|
232 | 225 | static const struct i2c_algorithm gb_i2c_algorithm = { |
---|
233 | 226 | .master_xfer = gb_i2c_master_xfer, |
---|
234 | | - /* .smbus_xfer = gb_i2c_smbus_xfer, */ |
---|
235 | 227 | .functionality = gb_i2c_functionality, |
---|
236 | 228 | }; |
---|
237 | 229 | |
---|
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 | | - |
---|
251 | 230 | static int gb_i2c_probe(struct gbphy_device *gbphy_dev, |
---|
252 | | - const struct gbphy_device_id *id) |
---|
| 231 | + const struct gbphy_device_id *id) |
---|
253 | 232 | { |
---|
254 | 233 | struct gb_connection *connection; |
---|
255 | 234 | struct gb_i2c_device *gb_i2c_dev; |
---|
.. | .. |
---|
260 | 239 | if (!gb_i2c_dev) |
---|
261 | 240 | return -ENOMEM; |
---|
262 | 241 | |
---|
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); |
---|
266 | 246 | if (IS_ERR(connection)) { |
---|
267 | 247 | ret = PTR_ERR(connection); |
---|
268 | 248 | goto exit_i2cdev_free; |
---|
.. | .. |
---|
286 | 266 | adapter->owner = THIS_MODULE; |
---|
287 | 267 | adapter->class = I2C_CLASS_HWMON | I2C_CLASS_SPD; |
---|
288 | 268 | adapter->algo = &gb_i2c_algorithm; |
---|
289 | | - /* adapter->algo_data = what? */ |
---|
290 | 269 | |
---|
291 | 270 | adapter->dev.parent = &gbphy_dev->dev; |
---|
292 | 271 | snprintf(adapter->name, sizeof(adapter->name), "Greybus i2c adapter"); |
---|