[media] em28xx-i2c: rt_mutex_trylock() returns zero on failure
authorDan Carpenter <dan.carpenter@oracle.com>
Mon, 9 May 2016 08:22:55 +0000 (05:22 -0300)
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>
Fri, 10 Jun 2016 11:29:40 +0000 (08:29 -0300)
The code is checking for negative returns but it should be checking for
zero.

Fixes: aab3125c43d8 ('[media] em28xx: add support for registering multiple i2c buses')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
drivers/media/usb/em28xx/em28xx-i2c.c

index a19b5c8b56ff79301d6f24d186ce54639efe6304..1a9e1e556706c46fae02f66be22b7690b0647e8f 100644 (file)
@@ -507,9 +507,8 @@ static int em28xx_i2c_xfer(struct i2c_adapter *i2c_adap,
        if (dev->disconnected)
                return -ENODEV;
 
-       rc = rt_mutex_trylock(&dev->i2c_bus_lock);
-       if (rc < 0)
-               return rc;
+       if (!rt_mutex_trylock(&dev->i2c_bus_lock))
+               return -EAGAIN;
 
        /* Switch I2C bus if needed */
        if (bus != dev->cur_i2c_bus &&