Message ID | 20230725121507.515435-1-yangyingliang@huawei.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [-next] media: i2c: ds90ub960: fix return value check in ub960_rxport_add_serializer() | expand |
On Tue, Jul 25, 2023 at 08:15:07PM +0800, Yang Yingliang wrote: > i2c_new_client_device() never returns NULL pointer, it will return > ERR_PTR() when it fails, so replace the check with IS_ERR() and > use PTR_ERR() as return code. Isn't the same fix to one that was in the mailing lists a few days ago? Anyway, FWIW, Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
On 2023/7/25 21:30, Andy Shevchenko wrote: > On Tue, Jul 25, 2023 at 08:15:07PM +0800, Yang Yingliang wrote: >> i2c_new_client_device() never returns NULL pointer, it will return >> ERR_PTR() when it fails, so replace the check with IS_ERR() and >> use PTR_ERR() as return code. > Isn't the same fix to one that was in the mailing lists a few days ago? Yes, it's same. This patch can be dropped. Thanks, Yang > Anyway, FWIW, > Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> >
diff --git a/drivers/media/i2c/ds90ub960.c b/drivers/media/i2c/ds90ub960.c index e101bcf2356a..92aa004a3674 100644 --- a/drivers/media/i2c/ds90ub960.c +++ b/drivers/media/i2c/ds90ub960.c @@ -1662,10 +1662,10 @@ static int ub960_rxport_add_serializer(struct ub960_data *priv, u8 nport) ser_info.addr = rxport->ser.alias; rxport->ser.client = i2c_new_client_device(priv->client->adapter, &ser_info); - if (!rxport->ser.client) { + if (IS_ERR(rxport->ser.client)) { dev_err(dev, "rx%u: cannot add %s i2c device", nport, ser_info.type); - return -EIO; + return PTR_ERR(rxport->ser.client); } dev_dbg(dev, "rx%u: remote serializer at alias 0x%02x (%u-%04x)\n",
i2c_new_client_device() never returns NULL pointer, it will return ERR_PTR() when it fails, so replace the check with IS_ERR() and use PTR_ERR() as return code. Fixes: afe267f2d368 ("media: i2c: add DS90UB960 driver") Signed-off-by: Yang Yingliang <yangyingliang@huawei.com> --- drivers/media/i2c/ds90ub960.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)