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

From: Maxin B. John
Date: Thu Sep 01 2011 - 17:24:49 EST


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 <maxin.john@xxxxxxxxx>
---
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 */
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/