[016/105] staging:iio:light:tsl2x7x: fix the error handling in tsl2x7x_probe()

Message ID 1372445527-24414-17-git-send-email-kamal@canonical.com
State New
Headers show

Commit Message

Kamal Mostafa June 28, 2013, 6:50 p.m. -stable review patch.  If anyone has any objections, please let me know.


From: Wei Yongjun <yongjun_wei@trendmicro.com.cn>

commit 3b813798aa7030f1beef638c75f8b0008f737a82 upstream.

Fix to return -EINVAL in the i2c device found error handling
case instead of 0, as done elsewhere in this function.
And also correct the fail1 and fail2 lable to do the right thing.

Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
 drivers/staging/iio/light/tsl2x7x_core.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)


diff --git a/drivers/staging/iio/light/tsl2x7x_core.c b/drivers/staging/iio/light/tsl2x7x_core.c
index 9e50fbb..395d8f6 100644
--- a/drivers/staging/iio/light/tsl2x7x_core.c
+++ b/drivers/staging/iio/light/tsl2x7x_core.c
@@ -1923,6 +1923,7 @@  static int tsl2x7x_probe(struct i2c_client *clientp,
 				"%s: i2c device found does not match expected id\n",
+		ret = -EINVAL;
 		goto fail1;
@@ -1961,7 +1962,7 @@  static int tsl2x7x_probe(struct i2c_client *clientp,
 		if (ret) {
 				"%s: irq request failed", __func__);
-			goto fail2;
+			goto fail1;
@@ -1974,17 +1975,17 @@  static int tsl2x7x_probe(struct i2c_client *clientp,
 	if (ret) {
 			"%s: iio registration failed\n", __func__);
-		goto fail1;
+		goto fail2;
 	dev_info(&clientp->dev, "%s Light sensor found.\n", id->name);
 	return 0;
 	if (clientp->irq)
 		free_irq(clientp->irq, indio_dev);
 	return ret;