summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorWolfram Sang <wsa+renesas@sang-engineering.com>2019-11-06 22:21:01 +0100
committerWolfram Sang <wsa@the-dreams.de>2019-12-11 08:39:07 +0100
commit8c9312a925ad859daefd0f443ef3b6dc7157d881 (patch)
treef53aa271f4e1e307b31e081fe994c94a901fae19 /include
parenti2c: fix header file kernel-doc warning (diff)
downloadlinux-8c9312a925ad859daefd0f443ef3b6dc7157d881.tar.xz
linux-8c9312a925ad859daefd0f443ef3b6dc7157d881.zip
i2c: add helper to check if a client has a driver attached
As a preparation for an API conversion, factor out something frequently used in the media subsystem. As an improvement, it bails out on both, NULL and ERRPTR to handle the old and new API. Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
Diffstat (limited to 'include')
-rw-r--r--include/linux/i2c.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index 91954324f985..582ef05ec07e 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -851,6 +851,11 @@ extern void i2c_del_driver(struct i2c_driver *driver);
#define i2c_add_driver(driver) \
i2c_register_driver(THIS_MODULE, driver)
+static inline bool i2c_client_has_driver(struct i2c_client *client)
+{
+ return !IS_ERR_OR_NULL(client) && client->dev.driver;
+}
+
/* call the i2c_client->command() of all attached clients with
* the given arguments */
extern void i2c_clients_command(struct i2c_adapter *adap,