i2c: slave: improve sanity check when registering
authorWolfram Sang <wsa+renesas@sang-engineering.com>
Sat, 25 Jul 2020 19:50:52 +0000 (21:50 +0200)
committerWolfram Sang <wsa@kernel.org>
Tue, 28 Jul 2020 16:37:08 +0000 (18:37 +0200)
Add check for ERR_PTR and simplify code while here.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Reviewed-by: Alain Volmat <alain.volmat@st.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
drivers/i2c/i2c-core-slave.c

index 5427f04..5497513 100644 (file)
@@ -18,10 +18,8 @@ int i2c_slave_register(struct i2c_client *client, i2c_slave_cb_t slave_cb)
 {
        int ret;
 
-       if (!client || !slave_cb) {
-               WARN(1, "insufficient data\n");
+       if (WARN(IS_ERR_OR_NULL(client) || !slave_cb, "insufficient data\n"))
                return -EINVAL;
-       }
 
        if (!(client->flags & I2C_CLIENT_SLAVE))
                dev_warn(&client->dev, "%s: client slave flag not set. You might see address collisions\n",