Skip to content

Commit

Permalink
[media] em28xx-i2c: rt_mutex_trylock() returns zero on failure
Browse files Browse the repository at this point in the history
The code is checking for negative returns but it should be checking for
zero.

Fixes: aab3125 ('[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>
  • Loading branch information
Dan Carpenter authored and Mauro Carvalho Chehab committed Jun 10, 2016
1 parent 917d11a commit e44c153
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions drivers/media/usb/em28xx/em28xx-i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 &&
Expand Down

0 comments on commit e44c153

Please sign in to comment.