Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1503796
| From | Brian Masney <masneyb@onstation.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 4/7] iio: light: tsl2583: return proper error code in sysfs store functions |
| Date | 2016-10-19 17:00 +0200 |
| Message-ID | <su0vx-2D0-77@gated-at.bofh.it> (permalink) |
| References | <stZSO-2nd-55@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
illuminance0_calibbias_store(), illuminance0_input_target_store(), and illuminance0_calibrate_store() did not return an error code when an invalid value was passed in. The input was checked to see if the input was valid, however the caller would not be notified that an invalid value was passed in. This patch changes these three functions to return -EINVAL when invalid input is passed in. Signed-off-by: Brian Masney <masneyb@onstation.org> --- drivers/staging/iio/light/tsl2583.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/drivers/staging/iio/light/tsl2583.c b/drivers/staging/iio/light/tsl2583.c index bbb8fc3..a60433e 100644 --- a/drivers/staging/iio/light/tsl2583.c +++ b/drivers/staging/iio/light/tsl2583.c @@ -657,9 +657,10 @@ static ssize_t illuminance0_calibbias_store(struct device *dev, if (kstrtoint(buf, 0, &value)) return -EINVAL; + else if (!value) + return -EINVAL; - if (value) - chip->taos_settings.als_gain_trim = value; + chip->taos_settings.als_gain_trim = value; return len; } @@ -684,9 +685,10 @@ static ssize_t illuminance0_input_target_store(struct device *dev, if (kstrtoint(buf, 0, &value)) return -EINVAL; + else if (!value) + return -EINVAL; - if (value) - chip->taos_settings.als_cal_target = value; + chip->taos_settings.als_cal_target = value; return len; } @@ -713,9 +715,10 @@ static ssize_t illuminance0_calibrate_store(struct device *dev, if (kstrtoint(buf, 0, &value)) return -EINVAL; + else if (value != 1) + return -EINVAL; - if (value == 1) - taos_als_calibrate(indio_dev); + taos_als_calibrate(indio_dev); return len; } -- 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