[ This patch was sent some time ago to Harald but I forgot to CC: the
list. ]

The chgstate_names[] array is indexed by power of two and not
by bit number. Unfortunately, show_chgstate() is using bit numbers. This
results in wrong output when looking at the chgstate sysfs file.


Signed-off-by: Arnaud Patard <[EMAIL PROTECTED]>
---
---
 drivers/i2c/chips/pcf50606.c |   10 	6 +	4 -	0 !
 1 file changed, 6 insertions(+), 4 deletions(-)

Index: linux-2.6.22/drivers/i2c/chips/pcf50606.c
===================================================================
--- linux-2.6.22.orig/drivers/i2c/chips/pcf50606.c	2008-01-13 23:26:48.000000000 +0100
+++ linux-2.6.22/drivers/i2c/chips/pcf50606.c	2008-01-13 23:28:03.000000000 +0100
@@ -1040,11 +1040,13 @@ static ssize_t show_chgstate(struct devi
 	struct i2c_client *client = to_i2c_client(dev);
 	struct pcf50606_data *pcf = i2c_get_clientdata(client);
 	char *b = buf;
-	int i;
+	int i, flag;
 
-	for (i = 0; i < 32; i++)
-		if (pcf->flags & (1 << i) && i < ARRAY_SIZE(chgstate_names))
-			b += sprintf(b, "%s ", chgstate_names[i]);
+	for (i = 0; i < 32; i++) {
+		flag = 1 << i;
+		if (pcf->flags & flag && flag <= PCF50606_F_CHG_READY)
+			b += sprintf(b, "%s ", chgstate_names[flag]);
+	}
 
 	if (b > buf)
 		b += sprintf(b, "\n");

Reply via email to