Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f375a49f authored by Brian Masney's avatar Brian Masney Committed by Jonathan Cameron
Browse files

staging: iio: tsl2583: add error code to sysfs store functions



in_illuminance_input_target_store() and in_illuminance_calibrate_store()
validated the data from userspace, however it would not return an
error code to userspace if an invalid value was passed in. This patch
changes these functions so that they return -EINVAL if invalid data is
passed in.

Signed-off-by: default avatarBrian Masney <masneyb@onstation.org>
Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
parent b2fa81be
Loading
Loading
Loading
Loading
+4 −6
Original line number Diff line number Diff line
@@ -525,10 +525,9 @@ static ssize_t in_illuminance_input_target_store(struct device *dev,
	struct tsl2583_chip *chip = iio_priv(indio_dev);
	int value;

	if (kstrtoint(buf, 0, &value))
	if (kstrtoint(buf, 0, &value) || !value)
		return -EINVAL;

	if (value)
	chip->taos_settings.als_cal_target = value;

	return len;
@@ -541,10 +540,9 @@ static ssize_t in_illuminance_calibrate_store(struct device *dev,
	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
	int value;

	if (kstrtoint(buf, 0, &value))
	if (kstrtoint(buf, 0, &value) || value != 1)
		return -EINVAL;

	if (value == 1)
	taos_als_calibrate(indio_dev);

	return len;