diff mbox series

[01/17] i2c: add helper to check if a client has a driver attached

Message ID 20191106212120.27983-2-wsa+renesas@sang-engineering.com
State Accepted
Headers show
Series media: use new API for creating client devices | expand

Commit Message

Wolfram Sang Nov. 6, 2019, 9:21 p.m. UTC
Factoring out something used in the media subsystem. As an improvement,
it bails out on both, NULL and ERRPTR.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
 include/linux/i2c.h | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Wolfram Sang Dec. 11, 2019, 7:59 a.m. UTC | #1
On Wed, Nov 06, 2019 at 10:21:01PM +0100, Wolfram Sang wrote:
> Factoring out something used in the media subsystem. As an improvement,
> it bails out on both, NULL and ERRPTR.
> 
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>

I picked it up myself now, so we can start using it right away.

Applied to for-current, thanks!
diff mbox series

Patch

diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index aaf57d9b41db..93b315c9a062 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -850,6 +850,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;
+}
+
 extern struct i2c_client *i2c_use_client(struct i2c_client *client);
 extern void i2c_release_client(struct i2c_client *client);