diff options
| author | Wolfram Sang <[email protected]> | 2023-01-17 09:50:02 +0100 |
|---|---|---|
| committer | Wolfram Sang <[email protected]> | 2023-01-17 09:50:02 +0100 |
| commit | 681eb1674697c7e730cd523f2a5c637b7796df0c (patch) | |
| tree | bb4086a833fe037b631b3fa64c9651ed503a61fa /include/linux | |
| parent | 597688792c4d9939e1900f5840ca18804e9d4290 (diff) | |
| parent | 373c612d72461ddaea223592df31e62c934aae61 (diff) | |
Merge branch 'i2c/fwnode-api' into i2c/for-mergewindow
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/i2c.h | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/include/linux/i2c.h b/include/linux/i2c.h index d84e0e99f084..500404d85141 100644 --- a/include/linux/i2c.h +++ b/include/linux/i2c.h @@ -965,15 +965,33 @@ int i2c_handle_smbus_host_notify(struct i2c_adapter *adap, unsigned short addr); #endif /* I2C */ +/* must call put_device() when done with returned i2c_client device */ +struct i2c_client *i2c_find_device_by_fwnode(struct fwnode_handle *fwnode); + +/* must call put_device() when done with returned i2c_adapter device */ +struct i2c_adapter *i2c_find_adapter_by_fwnode(struct fwnode_handle *fwnode); + +/* must call i2c_put_adapter() when done with returned i2c_adapter device */ +struct i2c_adapter *i2c_get_adapter_by_fwnode(struct fwnode_handle *fwnode); + #if IS_ENABLED(CONFIG_OF) /* must call put_device() when done with returned i2c_client device */ -struct i2c_client *of_find_i2c_device_by_node(struct device_node *node); +static inline struct i2c_client *of_find_i2c_device_by_node(struct device_node *node) +{ + return i2c_find_device_by_fwnode(of_fwnode_handle(node)); +} /* must call put_device() when done with returned i2c_adapter device */ -struct i2c_adapter *of_find_i2c_adapter_by_node(struct device_node *node); +static inline struct i2c_adapter *of_find_i2c_adapter_by_node(struct device_node *node) +{ + return i2c_find_adapter_by_fwnode(of_fwnode_handle(node)); +} /* must call i2c_put_adapter() when done with returned i2c_adapter device */ -struct i2c_adapter *of_get_i2c_adapter_by_node(struct device_node *node); +static inline struct i2c_adapter *of_get_i2c_adapter_by_node(struct device_node *node) +{ + return i2c_get_adapter_by_fwnode(of_fwnode_handle(node)); +} const struct of_device_id *i2c_of_match_device(const struct of_device_id *matches, |