Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1503802
| From | Brian Masney <masneyb@onstation.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 5/7] iio: light: tsl2583: check return values from taos_chip_{on,off} |
| Date | 2016-10-19 17:00 +0200 |
| Message-ID | <stZSO-2nd-57@gated-at.bofh.it> (permalink) |
| References | <stZSO-2nd-55@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
The return values from taos_chip_on() and taos_chip_off() was not
checked in several places. This patch adds proper error checking to
these function calls.
Signed-off-by: Brian Masney <masneyb@onstation.org>
---
drivers/staging/iio/light/tsl2583.c | 25 ++++++++++++++++++-------
1 file changed, 18 insertions(+), 7 deletions(-)
diff --git a/drivers/staging/iio/light/tsl2583.c b/drivers/staging/iio/light/tsl2583.c
index a60433e..60f0ce9 100644
--- a/drivers/staging/iio/light/tsl2583.c
+++ b/drivers/staging/iio/light/tsl2583.c
@@ -515,15 +515,18 @@ static ssize_t power_state_store(struct device *dev,
const char *buf, size_t len)
{
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
- int value;
+ int value, ret;
if (kstrtoint(buf, 0, &value))
return -EINVAL;
if (!value)
- taos_chip_off(indio_dev);
+ ret = taos_chip_off(indio_dev);
else
- taos_chip_on(indio_dev);
+ ret = taos_chip_on(indio_dev);
+
+ if (ret < 0)
+ return ret;
return len;
}
@@ -775,14 +778,20 @@ static ssize_t illuminance0_lux_table_store(struct device *dev,
goto luxable_store_done;
}
- if (chip->taos_chip_status == TSL258X_CHIP_WORKING)
- taos_chip_off(indio_dev);
+ if (chip->taos_chip_status == TSL258X_CHIP_WORKING) {
+ ret = taos_chip_off(indio_dev);
+ if (ret < 0)
+ return ret;
+ }
/* Zero out the table */
memset(taos_device_lux, 0, sizeof(taos_device_lux));
memcpy(taos_device_lux, &value[1], (value[0] * 4));
- taos_chip_on(indio_dev);
+ ret = taos_chip_on(indio_dev);
+ if (ret < 0)
+ return ret;
+
ret = len;
luxable_store_done:
@@ -914,7 +923,9 @@ static int taos_probe(struct i2c_client *clientp,
taos_defaults(chip);
/* Make sure the chip is on */
- taos_chip_on(indio_dev);
+ ret = taos_chip_on(indio_dev);
+ if (ret < 0)
+ return ret;
dev_info(&clientp->dev, "Light sensor found.\n");
--
2.7.4
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 1/7] iio: light: tsl2583: return proper error code Brian Masney <masneyb@onstation.org> - 2016-10-19 16:50 +0200
[PATCH 3/7] iio: light: tsl2583: use DEVICE_ATTR_{RO, RW, WO} macros Brian Masney <masneyb@onstation.org> - 2016-10-19 16:50 +0200
Re: [PATCH 3/7] iio: light: tsl2583: use DEVICE_ATTR_{RO, RW, WO} macros Peter Meerwald-Stadler <pmeerw@pmeerw.net> - 2016-10-19 18:00 +0200
Re: [PATCH 3/7] iio: light: tsl2583: use DEVICE_ATTR_{RO, RW, WO} macros Jonathan Cameron <jic23@jic23.retrosnub.co.uk> - 2016-10-19 18:40 +0200
[PATCH 2/7] iio: light: tsl2583: change functions to only have a single exit point Brian Masney <masneyb@onstation.org> - 2016-10-19 17:00 +0200
Re: [PATCH 2/7] iio: light: tsl2583: change functions to only have a single exit point Dan Carpenter <dan.carpenter@oracle.com> - 2016-10-19 17:00 +0200
[PATCH 4/7] iio: light: tsl2583: return proper error code in sysfs store functions Brian Masney <masneyb@onstation.org> - 2016-10-19 17:00 +0200
[PATCH 5/7] iio: light: tsl2583: check return values from taos_chip_{on,off} Brian Masney <masneyb@onstation.org> - 2016-10-19 17:00 +0200
Re: [PATCH 1/7] iio: light: tsl2583: return proper error code Jonathan Cameron <jic23@kernel.org> - 2016-10-22 19:20 +0200
csiph-web