diff options
Diffstat (limited to 'include/linux/i2c.h')
-rw-r--r-- | include/linux/i2c.h | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/include/linux/i2c.h b/include/linux/i2c.h index 38dd4025aa4e..4bae0b72ed3c 100644 --- a/include/linux/i2c.h +++ b/include/linux/i2c.h | |||
@@ -37,6 +37,7 @@ | |||
37 | #include <linux/of.h> /* for struct device_node */ | 37 | #include <linux/of.h> /* for struct device_node */ |
38 | 38 | ||
39 | extern struct bus_type i2c_bus_type; | 39 | extern struct bus_type i2c_bus_type; |
40 | extern struct device_type i2c_adapter_type; | ||
40 | 41 | ||
41 | /* --- General options ------------------------------------------------ */ | 42 | /* --- General options ------------------------------------------------ */ |
42 | 43 | ||
@@ -284,12 +285,18 @@ i2c_new_device(struct i2c_adapter *adap, struct i2c_board_info const *info); | |||
284 | 285 | ||
285 | /* If you don't know the exact address of an I2C device, use this variant | 286 | /* If you don't know the exact address of an I2C device, use this variant |
286 | * instead, which can probe for device presence in a list of possible | 287 | * instead, which can probe for device presence in a list of possible |
287 | * addresses. | 288 | * addresses. The "probe" callback function is optional. If it is provided, |
289 | * it must return 1 on successful probe, 0 otherwise. If it is not provided, | ||
290 | * a default probing method is used. | ||
288 | */ | 291 | */ |
289 | extern struct i2c_client * | 292 | extern struct i2c_client * |
290 | i2c_new_probed_device(struct i2c_adapter *adap, | 293 | i2c_new_probed_device(struct i2c_adapter *adap, |
291 | struct i2c_board_info *info, | 294 | struct i2c_board_info *info, |
292 | unsigned short const *addr_list); | 295 | unsigned short const *addr_list, |
296 | int (*probe)(struct i2c_adapter *, unsigned short addr)); | ||
297 | |||
298 | /* Common custom probe functions */ | ||
299 | extern int i2c_probe_func_quick_read(struct i2c_adapter *, unsigned short addr); | ||
293 | 300 | ||
294 | /* For devices that use several addresses, use i2c_new_dummy() to make | 301 | /* For devices that use several addresses, use i2c_new_dummy() to make |
295 | * client handles for the extra addresses. | 302 | * client handles for the extra addresses. |
@@ -362,6 +369,7 @@ struct i2c_adapter { | |||
362 | char name[48]; | 369 | char name[48]; |
363 | struct completion dev_released; | 370 | struct completion dev_released; |
364 | 371 | ||
372 | struct mutex userspace_clients_lock; | ||
365 | struct list_head userspace_clients; | 373 | struct list_head userspace_clients; |
366 | }; | 374 | }; |
367 | #define to_i2c_adapter(d) container_of(d, struct i2c_adapter, dev) | 375 | #define to_i2c_adapter(d) container_of(d, struct i2c_adapter, dev) |
@@ -376,23 +384,16 @@ static inline void i2c_set_adapdata(struct i2c_adapter *dev, void *data) | |||
376 | dev_set_drvdata(&dev->dev, data); | 384 | dev_set_drvdata(&dev->dev, data); |
377 | } | 385 | } |
378 | 386 | ||
379 | /** | 387 | static inline int i2c_parent_is_i2c_adapter(const struct i2c_adapter *adapter) |
380 | * i2c_lock_adapter - Prevent access to an I2C bus segment | ||
381 | * @adapter: Target I2C bus segment | ||
382 | */ | ||
383 | static inline void i2c_lock_adapter(struct i2c_adapter *adapter) | ||
384 | { | 388 | { |
385 | rt_mutex_lock(&adapter->bus_lock); | 389 | return adapter->dev.parent != NULL |
390 | && adapter->dev.parent->bus == &i2c_bus_type | ||
391 | && adapter->dev.parent->type == &i2c_adapter_type; | ||
386 | } | 392 | } |
387 | 393 | ||
388 | /** | 394 | /* Adapter locking functions, exported for shared pin cases */ |
389 | * i2c_unlock_adapter - Reauthorize access to an I2C bus segment | 395 | void i2c_lock_adapter(struct i2c_adapter *); |
390 | * @adapter: Target I2C bus segment | 396 | void i2c_unlock_adapter(struct i2c_adapter *); |
391 | */ | ||
392 | static inline void i2c_unlock_adapter(struct i2c_adapter *adapter) | ||
393 | { | ||
394 | rt_mutex_unlock(&adapter->bus_lock); | ||
395 | } | ||
396 | 397 | ||
397 | /*flags for the client struct: */ | 398 | /*flags for the client struct: */ |
398 | #define I2C_CLIENT_PEC 0x04 /* Use Packet Error Checking */ | 399 | #define I2C_CLIENT_PEC 0x04 /* Use Packet Error Checking */ |