linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch] [media] em28xx-i2c: rt_mutex_trylock() returns zero on failure
@ 2016-03-11  8:13 Dan Carpenter
  2016-05-07 13:01 ` Mauro Carvalho Chehab
  0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2016-03-11  8:13 UTC (permalink / raw)
  To: Mauro Carvalho Chehab; +Cc: linux-media, linux-kernel, kernel-janitors

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 &&

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [patch] [media] em28xx-i2c: rt_mutex_trylock() returns zero on failure
  2016-03-11  8:13 [patch] [media] em28xx-i2c: rt_mutex_trylock() returns zero on failure Dan Carpenter
@ 2016-05-07 13:01 ` Mauro Carvalho Chehab
  2016-05-09  8:22   ` [patch v2][media] " Dan Carpenter
  0 siblings, 1 reply; 3+ messages in thread
From: Mauro Carvalho Chehab @ 2016-05-07 13:01 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: linux-media, linux-kernel, kernel-janitors

Em Fri, 11 Mar 2016 11:13:01 +0300
Dan Carpenter <dan.carpenter@oracle.com> escreveu:

> 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?

I guess -EAGAIN would be better.

Regards,
Mauro

> 
> 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 &&
> --
> To unsubscribe from this list: send the line "unsubscribe linux-media" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


-- 
Thanks,
Mauro

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [patch v2][media] em28xx-i2c: rt_mutex_trylock() returns zero on failure
  2016-05-07 13:01 ` Mauro Carvalho Chehab
@ 2016-05-09  8:22   ` Dan Carpenter
  0 siblings, 0 replies; 3+ messages in thread
From: Dan Carpenter @ 2016-05-09  8:22 UTC (permalink / raw)
  To: Mauro Carvalho Chehab; +Cc: linux-media, linux-kernel, kernel-janitors

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>
---
Use different error code.

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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-05-09  8:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-11  8:13 [patch] [media] em28xx-i2c: rt_mutex_trylock() returns zero on failure Dan Carpenter
2016-05-07 13:01 ` Mauro Carvalho Chehab
2016-05-09  8:22   ` [patch v2][media] " Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).