[PATCH 4/7] iio: light: tsl2583: return proper error code in sysfs store functions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxx>
---
 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

--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux