Patchwork [1/2] macintosh: wrong test in fan_{read,write}_reg()

login
register
mail settings
Submitter Andrew Morton
Date Jan. 18, 2011, 9:09 p.m.
Message ID <201101182109.p0IL992W005451@imap1.linux-foundation.org>
Download mbox | patch
Permalink /patch/79360/
State Not Applicable
Headers show

Comments

Andrew Morton - Jan. 18, 2011, 9:09 p.m.
From: roel kluin <roel.kluin@gmail.com>

Fix error test in fan_{read,write}_reg()

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 drivers/macintosh/therm_pm72.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Benjamin Herrenschmidt - Jan. 18, 2011, 9:22 p.m.
On Tue, 2011-01-18 at 13:09 -0800, akpm@linux-foundation.org wrote:
> From: roel kluin <roel.kluin@gmail.com>
> 
> Fix error test in fan_{read,write}_reg()

Thanks, I'll pick that up.

Cheers,
Ben.

> Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
> ---
> 
>  drivers/macintosh/therm_pm72.c |    4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff -puN drivers/macintosh/therm_pm72.c~macintosh-wrong-test-in-fan_readwrite_reg drivers/macintosh/therm_pm72.c
> --- a/drivers/macintosh/therm_pm72.c~macintosh-wrong-test-in-fan_readwrite_reg
> +++ a/drivers/macintosh/therm_pm72.c
> @@ -443,7 +443,7 @@ static int fan_read_reg(int reg, unsigne
>  	tries = 0;
>  	for (;;) {
>  		nr = i2c_master_recv(fcu, buf, nb);
> -		if (nr > 0 || (nr < 0 && nr != ENODEV) || tries >= 100)
> +		if (nr > 0 || (nr < 0 && nr != -ENODEV) || tries >= 100)
>  			break;
>  		msleep(10);
>  		++tries;
> @@ -464,7 +464,7 @@ static int fan_write_reg(int reg, const 
>  	tries = 0;
>  	for (;;) {
>  		nw = i2c_master_send(fcu, buf, nb);
> -		if (nw > 0 || (nw < 0 && nw != EIO) || tries >= 100)
> +		if (nw > 0 || (nw < 0 && nw != -EIO) || tries >= 100)
>  			break;
>  		msleep(10);
>  		++tries;
> _

Patch

diff -puN drivers/macintosh/therm_pm72.c~macintosh-wrong-test-in-fan_readwrite_reg drivers/macintosh/therm_pm72.c
--- a/drivers/macintosh/therm_pm72.c~macintosh-wrong-test-in-fan_readwrite_reg
+++ a/drivers/macintosh/therm_pm72.c
@@ -443,7 +443,7 @@  static int fan_read_reg(int reg, unsigne
 	tries = 0;
 	for (;;) {
 		nr = i2c_master_recv(fcu, buf, nb);
-		if (nr > 0 || (nr < 0 && nr != ENODEV) || tries >= 100)
+		if (nr > 0 || (nr < 0 && nr != -ENODEV) || tries >= 100)
 			break;
 		msleep(10);
 		++tries;
@@ -464,7 +464,7 @@  static int fan_write_reg(int reg, const 
 	tries = 0;
 	for (;;) {
 		nw = i2c_master_send(fcu, buf, nb);
-		if (nw > 0 || (nw < 0 && nw != EIO) || tries >= 100)
+		if (nw > 0 || (nw < 0 && nw != -EIO) || tries >= 100)
 			break;
 		msleep(10);
 		++tries;