Skip to content

Commit f7b4127

Browse files
Jingoo Hangregkh
authored andcommitted
misc: replace strict_strtoul() with kstrtoul()
The usage of strict_strtoul() is not preferred, because strict_strtoul() is obsolete. Thus, kstrtoul() should be used. Signed-off-by: Jingoo Han <jg1.han@samsung.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 4cd5773 commit f7b4127

14 files changed

Lines changed: 154 additions & 83 deletions

‎drivers/misc/ad525x_dpot.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ static ssize_t sysfs_set_reg(struct device *dev,
470470
!test_bit(DPOT_RDAC_MASK & reg, data->otp_en_mask))
471471
return -EPERM;
472472

473-
err = strict_strtoul(buf, 10, &value);
473+
err = kstrtoul(buf, 10, &value);
474474
if (err)
475475
return err;
476476

‎drivers/misc/apds9802als.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,9 @@ static ssize_t als_sensing_range_store(struct device *dev,
126126
int ret_val;
127127
unsigned long val;
128128

129-
if (strict_strtoul(buf, 10, &val))
130-
return -EINVAL;
129+
ret_val = kstrtoul(buf, 10, &val);
130+
if (ret_val)
131+
return ret_val;
131132

132133
if (val < 4096)
133134
val = 1;

‎drivers/misc/apds990x.c‎

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -696,9 +696,11 @@ static ssize_t apds990x_lux_calib_store(struct device *dev,
696696
{
697697
struct apds990x_chip *chip = dev_get_drvdata(dev);
698698
unsigned long value;
699+
int ret;
699700

700-
if (strict_strtoul(buf, 0, &value))
701-
return -EINVAL;
701+
ret = kstrtoul(buf, 0, &value);
702+
if (ret)
703+
return ret;
702704

703705
chip->lux_calib = value;
704706

@@ -759,8 +761,9 @@ static ssize_t apds990x_rate_store(struct device *dev,
759761
unsigned long value;
760762
int ret;
761763

762-
if (strict_strtoul(buf, 0, &value))
763-
return -EINVAL;
764+
ret = kstrtoul(buf, 0, &value);
765+
if (ret)
766+
return ret;
764767

765768
mutex_lock(&chip->mutex);
766769
ret = apds990x_set_arate(chip, value);
@@ -813,9 +816,11 @@ static ssize_t apds990x_prox_enable_store(struct device *dev,
813816
{
814817
struct apds990x_chip *chip = dev_get_drvdata(dev);
815818
unsigned long value;
819+
int ret;
816820

817-
if (strict_strtoul(buf, 0, &value))
818-
return -EINVAL;
821+
ret = kstrtoul(buf, 0, &value);
822+
if (ret)
823+
return ret;
819824

820825
mutex_lock(&chip->mutex);
821826

@@ -892,11 +897,12 @@ static ssize_t apds990x_lux_thresh_below_show(struct device *dev,
892897
static ssize_t apds990x_set_lux_thresh(struct apds990x_chip *chip, u32 *target,
893898
const char *buf)
894899
{
895-
int ret = 0;
896900
unsigned long thresh;
901+
int ret;
897902

898-
if (strict_strtoul(buf, 0, &thresh))
899-
return -EINVAL;
903+
ret = kstrtoul(buf, 0, &thresh);
904+
if (ret)
905+
return ret;
900906

901907
if (thresh > APDS_RANGE)
902908
return -EINVAL;
@@ -957,9 +963,11 @@ static ssize_t apds990x_prox_threshold_store(struct device *dev,
957963
{
958964
struct apds990x_chip *chip = dev_get_drvdata(dev);
959965
unsigned long value;
966+
int ret;
960967

961-
if (strict_strtoul(buf, 0, &value))
962-
return -EINVAL;
968+
ret = kstrtoul(buf, 0, &value);
969+
if (ret)
970+
return ret;
963971

964972
if ((value > APDS_RANGE) || (value == 0) ||
965973
(value < APDS_PROX_HYSTERESIS))
@@ -990,9 +998,12 @@ static ssize_t apds990x_power_state_store(struct device *dev,
990998
{
991999
struct apds990x_chip *chip = dev_get_drvdata(dev);
9921000
unsigned long value;
1001+
int ret;
1002+
1003+
ret = kstrtoul(buf, 0, &value);
1004+
if (ret)
1005+
return ret;
9931006

994-
if (strict_strtoul(buf, 0, &value))
995-
return -EINVAL;
9961007
if (value) {
9971008
pm_runtime_get_sync(dev);
9981009
mutex_lock(&chip->mutex);

‎drivers/misc/bh1770glc.c‎

Lines changed: 38 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -651,8 +651,9 @@ static ssize_t bh1770_power_state_store(struct device *dev,
651651
unsigned long value;
652652
ssize_t ret;
653653

654-
if (strict_strtoul(buf, 0, &value))
655-
return -EINVAL;
654+
ret = kstrtoul(buf, 0, &value);
655+
if (ret)
656+
return ret;
656657

657658
mutex_lock(&chip->mutex);
658659
if (value) {
@@ -726,9 +727,11 @@ static ssize_t bh1770_prox_enable_store(struct device *dev,
726727
{
727728
struct bh1770_chip *chip = dev_get_drvdata(dev);
728729
unsigned long value;
730+
int ret;
729731

730-
if (strict_strtoul(buf, 0, &value))
731-
return -EINVAL;
732+
ret = kstrtoul(buf, 0, &value);
733+
if (ret)
734+
return ret;
732735

733736
mutex_lock(&chip->mutex);
734737
/* Assume no proximity. Sensor will tell real state soon */
@@ -824,9 +827,11 @@ static ssize_t bh1770_set_prox_rate_above(struct device *dev,
824827
{
825828
struct bh1770_chip *chip = dev_get_drvdata(dev);
826829
unsigned long value;
830+
int ret;
827831

828-
if (strict_strtoul(buf, 0, &value))
829-
return -EINVAL;
832+
ret = kstrtoul(buf, 0, &value);
833+
if (ret)
834+
return ret;
830835

831836
mutex_lock(&chip->mutex);
832837
chip->prox_rate_threshold = bh1770_prox_rate_validate(value);
@@ -840,9 +845,11 @@ static ssize_t bh1770_set_prox_rate_below(struct device *dev,
840845
{
841846
struct bh1770_chip *chip = dev_get_drvdata(dev);
842847
unsigned long value;
848+
int ret;
843849

844-
if (strict_strtoul(buf, 0, &value))
845-
return -EINVAL;
850+
ret = kstrtoul(buf, 0, &value);
851+
if (ret)
852+
return ret;
846853

847854
mutex_lock(&chip->mutex);
848855
chip->prox_rate = bh1770_prox_rate_validate(value);
@@ -865,8 +872,10 @@ static ssize_t bh1770_set_prox_thres(struct device *dev,
865872
unsigned long value;
866873
int ret;
867874

868-
if (strict_strtoul(buf, 0, &value))
869-
return -EINVAL;
875+
ret = kstrtoul(buf, 0, &value);
876+
if (ret)
877+
return ret;
878+
870879
if (value > BH1770_PROX_RANGE)
871880
return -EINVAL;
872881

@@ -893,9 +902,11 @@ static ssize_t bh1770_prox_persistence_store(struct device *dev,
893902
{
894903
struct bh1770_chip *chip = dev_get_drvdata(dev);
895904
unsigned long value;
905+
int ret;
896906

897-
if (strict_strtoul(buf, 0, &value))
898-
return -EINVAL;
907+
ret = kstrtoul(buf, 0, &value);
908+
if (ret)
909+
return ret;
899910

900911
if (value > BH1770_PROX_MAX_PERSISTENCE)
901912
return -EINVAL;
@@ -918,9 +929,11 @@ static ssize_t bh1770_prox_abs_thres_store(struct device *dev,
918929
{
919930
struct bh1770_chip *chip = dev_get_drvdata(dev);
920931
unsigned long value;
932+
int ret;
921933

922-
if (strict_strtoul(buf, 0, &value))
923-
return -EINVAL;
934+
ret = kstrtoul(buf, 0, &value);
935+
if (ret)
936+
return ret;
924937

925938
if (value > BH1770_PROX_RANGE)
926939
return -EINVAL;
@@ -963,9 +976,11 @@ static ssize_t bh1770_lux_calib_store(struct device *dev,
963976
unsigned long value;
964977
u32 old_calib;
965978
u32 new_corr;
979+
int ret;
966980

967-
if (strict_strtoul(buf, 0, &value))
968-
return -EINVAL;
981+
ret = kstrtoul(buf, 0, &value);
982+
if (ret)
983+
return ret;
969984

970985
mutex_lock(&chip->mutex);
971986
old_calib = chip->lux_calib;
@@ -1012,8 +1027,9 @@ static ssize_t bh1770_set_lux_rate(struct device *dev,
10121027
unsigned long rate_hz;
10131028
int ret, i;
10141029

1015-
if (strict_strtoul(buf, 0, &rate_hz))
1016-
return -EINVAL;
1030+
ret = kstrtoul(buf, 0, &rate_hz);
1031+
if (ret)
1032+
return ret;
10171033

10181034
for (i = 0; i < ARRAY_SIZE(lux_rates_hz) - 1; i++)
10191035
if (rate_hz >= lux_rates_hz[i])
@@ -1047,11 +1063,12 @@ static ssize_t bh1770_get_lux_thresh_below(struct device *dev,
10471063
static ssize_t bh1770_set_lux_thresh(struct bh1770_chip *chip, u16 *target,
10481064
const char *buf)
10491065
{
1050-
int ret = 0;
10511066
unsigned long thresh;
1067+
int ret;
10521068

1053-
if (strict_strtoul(buf, 0, &thresh))
1054-
return -EINVAL;
1069+
ret = kstrtoul(buf, 0, &thresh);
1070+
if (ret)
1071+
return ret;
10551072

10561073
if (thresh > BH1770_LUX_RANGE)
10571074
return -EINVAL;

‎drivers/misc/bh1780gli.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ static ssize_t bh1780_store_power_state(struct device *dev,
107107
unsigned long val;
108108
int error;
109109

110-
error = strict_strtoul(buf, 0, &val);
110+
error = kstrtoul(buf, 0, &val);
111111
if (error)
112112
return error;
113113

‎drivers/misc/carma/carma-fpga-program.c‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -830,8 +830,9 @@ static ssize_t penable_store(struct device *dev, struct device_attribute *attr,
830830
unsigned long val;
831831
int ret;
832832

833-
if (strict_strtoul(buf, 0, &val))
834-
return -EINVAL;
833+
ret = kstrtoul(buf, 0, &val);
834+
if (ret)
835+
return ret;
835836

836837
if (val) {
837838
ret = fpga_enable_power_supplies(priv);
@@ -859,8 +860,9 @@ static ssize_t program_store(struct device *dev, struct device_attribute *attr,
859860
unsigned long val;
860861
int ret;
861862

862-
if (strict_strtoul(buf, 0, &val))
863-
return -EINVAL;
863+
ret = kstrtoul(buf, 0, &val);
864+
if (ret)
865+
return ret;
864866

865867
/* We can't have an image writer and be programming simultaneously */
866868
if (mutex_lock_interruptible(&priv->lock))

‎drivers/misc/carma/carma-fpga.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,10 +1002,10 @@ static ssize_t data_en_set(struct device *dev, struct device_attribute *attr,
10021002
unsigned long enable;
10031003
int ret;
10041004

1005-
ret = strict_strtoul(buf, 0, &enable);
1005+
ret = kstrtoul(buf, 0, &enable);
10061006
if (ret) {
10071007
dev_err(priv->dev, "unable to parse enable input\n");
1008-
return -EINVAL;
1008+
return ret;
10091009
}
10101010

10111011
/* protect against concurrent enable/disable */

‎drivers/misc/hmc6352.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,9 @@ static int compass_store(struct device *dev, const char *buf, size_t count,
4646
int ret;
4747
unsigned long val;
4848

49-
if (strict_strtoul(buf, 10, &val))
50-
return -EINVAL;
49+
ret = kstrtoul(buf, 10, &val);
50+
if (ret)
51+
return ret;
5152
if (val >= strlen(map))
5253
return -EINVAL;
5354
mutex_lock(&compass_mutex);

‎drivers/misc/isl29003.c‎

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,11 @@ static ssize_t isl29003_store_range(struct device *dev,
208208
unsigned long val;
209209
int ret;
210210

211-
if ((strict_strtoul(buf, 10, &val) < 0) || (val > 3))
211+
ret = kstrtoul(buf, 10, &val);
212+
if (ret)
213+
return ret;
214+
215+
if (val > 3)
212216
return -EINVAL;
213217

214218
ret = isl29003_set_range(client, val);
@@ -239,7 +243,11 @@ static ssize_t isl29003_store_resolution(struct device *dev,
239243
unsigned long val;
240244
int ret;
241245

242-
if ((strict_strtoul(buf, 10, &val) < 0) || (val > 3))
246+
ret = kstrtoul(buf, 10, &val);
247+
if (ret)
248+
return ret;
249+
250+
if (val > 3)
243251
return -EINVAL;
244252

245253
ret = isl29003_set_resolution(client, val);
@@ -267,7 +275,11 @@ static ssize_t isl29003_store_mode(struct device *dev,
267275
unsigned long val;
268276
int ret;
269277

270-
if ((strict_strtoul(buf, 10, &val) < 0) || (val > 2))
278+
ret = kstrtoul(buf, 10, &val);
279+
if (ret)
280+
return ret;
281+
282+
if (val > 2)
271283
return -EINVAL;
272284

273285
ret = isl29003_set_mode(client, val);
@@ -298,7 +310,11 @@ static ssize_t isl29003_store_power_state(struct device *dev,
298310
unsigned long val;
299311
int ret;
300312

301-
if ((strict_strtoul(buf, 10, &val) < 0) || (val > 1))
313+
ret = kstrtoul(buf, 10, &val);
314+
if (ret)
315+
return ret;
316+
317+
if (val > 1)
302318
return -EINVAL;
303319

304320
ret = isl29003_set_power_state(client, val);

‎drivers/misc/isl29020.c‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,10 @@ static ssize_t als_sensing_range_store(struct device *dev,
9090
int ret_val;
9191
unsigned long val;
9292

93-
if (strict_strtoul(buf, 10, &val))
94-
return -EINVAL;
93+
ret_val = kstrtoul(buf, 10, &val);
94+
if (ret_val)
95+
return ret_val;
96+
9597
if (val < 1 || val > 64000)
9698
return -EINVAL;
9799

0 commit comments

Comments
 (0)