Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1355680 > unrolled thread

[patch] [media] em28xx-i2c: rt_mutex_trylock() returns zero on failure

Started byDan Carpenter <dan.carpenter@oracle.com>
First post2016-03-11 09:20 +0100
Last post2016-03-11 09:20 +0100
Articles 1 — 1 participant

Back to article view | Back to linux.kernel


Contents

  [patch] [media] em28xx-i2c: rt_mutex_trylock() returns zero on  failure Dan Carpenter <dan.carpenter@oracle.com> - 2016-03-11 09:20 +0100

#1355680 — [patch] [media] em28xx-i2c: rt_mutex_trylock() returns zero on failure

FromDan Carpenter <dan.carpenter@oracle.com>
Date2016-03-11 09:20 +0100
Subject[patch] [media] em28xx-i2c: rt_mutex_trylock() returns zero on failure
Message-ID<rbqsF-3iZ-3@gated-at.bofh.it>
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>
---
Is -EBUSY correct?  -EAGAIN?

diff --git a/drivers/media/usb/em28xx/em28xx-i2c.c b/drivers/media/usb/em28xx/em28xx-i2c.c
index a19b5c8..f80dd3a 100644
--- a/drivers/media/usb/em28xx/em28xx-i2c.c
+++ b/drivers/media/usb/em28xx/em28xx-i2c.c
@@ -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 -EBUSY;
 
 	/* Switch I2C bus if needed */
 	if (bus != dev->cur_i2c_bus &&

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web