summaryrefslogtreecommitdiffstats
path: root/drivers/misc/apds990x.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/misc/apds990x.c')
-rw-r--r--drivers/misc/apds990x.c37
1 files changed, 24 insertions, 13 deletions
diff --git a/drivers/misc/apds990x.c b/drivers/misc/apds990x.c
index 98f9bb26492a..868a30a1b417 100644
--- a/drivers/misc/apds990x.c
+++ b/drivers/misc/apds990x.c
@@ -696,9 +696,11 @@ static ssize_t apds990x_lux_calib_store(struct device *dev,
696{ 696{
697 struct apds990x_chip *chip = dev_get_drvdata(dev); 697 struct apds990x_chip *chip = dev_get_drvdata(dev);
698 unsigned long value; 698 unsigned long value;
699 int ret;
699 700
700 if (strict_strtoul(buf, 0, &value)) 701 ret = kstrtoul(buf, 0, &value);
701 return -EINVAL; 702 if (ret)
703 return ret;
702 704
703 chip->lux_calib = value; 705 chip->lux_calib = value;
704 706
@@ -759,8 +761,9 @@ static ssize_t apds990x_rate_store(struct device *dev,
759 unsigned long value; 761 unsigned long value;
760 int ret; 762 int ret;
761 763
762 if (strict_strtoul(buf, 0, &value)) 764 ret = kstrtoul(buf, 0, &value);
763 return -EINVAL; 765 if (ret)
766 return ret;
764 767
765 mutex_lock(&chip->mutex); 768 mutex_lock(&chip->mutex);
766 ret = apds990x_set_arate(chip, value); 769 ret = apds990x_set_arate(chip, value);
@@ -813,9 +816,11 @@ static ssize_t apds990x_prox_enable_store(struct device *dev,
813{ 816{
814 struct apds990x_chip *chip = dev_get_drvdata(dev); 817 struct apds990x_chip *chip = dev_get_drvdata(dev);
815 unsigned long value; 818 unsigned long value;
819 int ret;
816 820
817 if (strict_strtoul(buf, 0, &value)) 821 ret = kstrtoul(buf, 0, &value);
818 return -EINVAL; 822 if (ret)
823 return ret;
819 824
820 mutex_lock(&chip->mutex); 825 mutex_lock(&chip->mutex);
821 826
@@ -892,11 +897,12 @@ static ssize_t apds990x_lux_thresh_below_show(struct device *dev,
892static ssize_t apds990x_set_lux_thresh(struct apds990x_chip *chip, u32 *target, 897static ssize_t apds990x_set_lux_thresh(struct apds990x_chip *chip, u32 *target,
893 const char *buf) 898 const char *buf)
894{ 899{
895 int ret = 0;
896 unsigned long thresh; 900 unsigned long thresh;
901 int ret;
897 902
898 if (strict_strtoul(buf, 0, &thresh)) 903 ret = kstrtoul(buf, 0, &thresh);
899 return -EINVAL; 904 if (ret)
905 return ret;
900 906
901 if (thresh > APDS_RANGE) 907 if (thresh > APDS_RANGE)
902 return -EINVAL; 908 return -EINVAL;
@@ -957,9 +963,11 @@ static ssize_t apds990x_prox_threshold_store(struct device *dev,
957{ 963{
958 struct apds990x_chip *chip = dev_get_drvdata(dev); 964 struct apds990x_chip *chip = dev_get_drvdata(dev);
959 unsigned long value; 965 unsigned long value;
966 int ret;
960 967
961 if (strict_strtoul(buf, 0, &value)) 968 ret = kstrtoul(buf, 0, &value);
962 return -EINVAL; 969 if (ret)
970 return ret;
963 971
964 if ((value > APDS_RANGE) || (value == 0) || 972 if ((value > APDS_RANGE) || (value == 0) ||
965 (value < APDS_PROX_HYSTERESIS)) 973 (value < APDS_PROX_HYSTERESIS))
@@ -990,9 +998,12 @@ static ssize_t apds990x_power_state_store(struct device *dev,
990{ 998{
991 struct apds990x_chip *chip = dev_get_drvdata(dev); 999 struct apds990x_chip *chip = dev_get_drvdata(dev);
992 unsigned long value; 1000 unsigned long value;
1001 int ret;
1002
1003 ret = kstrtoul(buf, 0, &value);
1004 if (ret)
1005 return ret;
993 1006
994 if (strict_strtoul(buf, 0, &value))
995 return -EINVAL;
996 if (value) { 1007 if (value) {
997 pm_runtime_get_sync(dev); 1008 pm_runtime_get_sync(dev);
998 mutex_lock(&chip->mutex); 1009 mutex_lock(&chip->mutex);