Thread (2 messages) 2 messages, 2 authors, 2011-09-01
STALE5383d

[PATCH] staging: iio: light: Fix compiler warning in tsl2563.c

From: Maxin B. John <hidden>
Date: 2011-09-01 21:24:44
Also in: lkml
Subsystem: iio subsystem and drivers, staging - industrial io, staging subsystem, the rest · Maintainers: Jonathan Cameron, Greg Kroah-Hartman, Linus Torvalds

  CC [M]  drivers/staging/iio/light/tsl2563.o
drivers/staging/iio/light/tsl2563.c: In function 'tsl2563_probe':
drivers/staging/iio/light/tsl2563.c:736: warning: 'id' may be used 
uninitialized in this function

Also fixes the tsl2563_read_id().

Signed-off-by: Maxin B. John <redacted>
---
diff --git a/drivers/staging/iio/light/tsl2563.c b/drivers/staging/iio/light/tsl2563.c
index f25243b..f8f787d 100644
--- a/drivers/staging/iio/light/tsl2563.c
+++ b/drivers/staging/iio/light/tsl2563.c
@@ -225,9 +225,9 @@ static int tsl2563_read_id(struct tsl2563_chip *chip, u8 *id)
 
 	ret = i2c_smbus_read_byte_data(client, TSL2563_CMD | TSL2563_REG_ID);
 	if (ret < 0)
-		return ret;
+		return -EIO;
 
-	return 0;
+	return ret;
 }
 
 /*
@@ -697,7 +697,7 @@ static int __devinit tsl2563_probe(struct i2c_client *client,
 	struct tsl2563_platform_data *pdata = client->dev.platform_data;
 	int err = 0;
 	int ret;
-	u8 id;
+	u8 id = 0;
 
 	indio_dev = iio_allocate_device(sizeof(*chip));
 	if (!indio_dev)
@@ -709,15 +709,17 @@ static int __devinit tsl2563_probe(struct i2c_client *client,
 	chip->client = client;
 
 	err = tsl2563_detect(chip);
-	if (err) {
+	if (err < 0) {
 		dev_err(&client->dev, "device not found, error %d\n", -err);
 		goto fail1;
 	}
 
 	err = tsl2563_read_id(chip, &id);
-	if (err)
+	if (err < 0) {
+		dev_err(&client->dev, "id reading failed, error %d\n", -err);
 		goto fail1;
-
+	}
+	id = err;
 	mutex_init(&chip->lock);
 
 	/* Default values used until userspace says otherwise */
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help