Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

iio: ltr501: Fix proximity threshold boundary check

Currently, proximity sensor boundary check is done
inside the switch block but outside the case
statement.Since this code will never get executed,
moved the check outside the switch case statement.

867 case IIO_PROXIMITY:
868 switch (dir) {
// Following line has been moved outside the switch block.
869 if (val > LTR501_PS_THRESH_MASK)
870 return -EINVAL;
871 case IIO_EV_DIR_RISING:

Signed-off-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>

authored by

Kuppuswamy Sathyanarayanan and committed by
Jonathan Cameron
01e537f7 f2c714a0

+1 -1
+1 -1
drivers/iio/light/ltr501.c
··· 865 865 return -EINVAL; 866 866 } 867 867 case IIO_PROXIMITY: 868 - switch (dir) { 869 868 if (val > LTR501_PS_THRESH_MASK) 870 869 return -EINVAL; 870 + switch (dir) { 871 871 case IIO_EV_DIR_RISING: 872 872 mutex_lock(&data->lock_ps); 873 873 ret = regmap_bulk_write(data->regmap,