diff options
author | Wolfram Sang <wsa+renesas@sang-engineering.com> | 2020-07-25 22:50:52 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2020-08-11 16:32:33 +0300 |
commit | c79c21c791fa073b05f0e6fc14539a6701bcc39f (patch) | |
tree | 850007167916f54a769c1ec5835d71bfe7806e15 | |
parent | 1e64cb7dabcc7340ab04d0258ea61b72babfe79c (diff) | |
download | linux-c79c21c791fa073b05f0e6fc14539a6701bcc39f.tar.xz |
i2c: slave: improve sanity check when registering
[ Upstream commit 1b1be3bf27b62f5abcf85c6f3214bdb9c7526685 ]
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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r-- | drivers/i2c/i2c-core-slave.c | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/drivers/i2c/i2c-core-slave.c b/drivers/i2c/i2c-core-slave.c index 47a9f70a24a9..88959c8580ce 100644 --- a/drivers/i2c/i2c-core-slave.c +++ b/drivers/i2c/i2c-core-slave.c @@ -22,10 +22,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", |