Skip to content

Commit 76496e7

Browse files
tengkt06dtor
authored andcommitted
Input: convert obsolete strict_strtox to kstrtox
With commit 67d0a07 we mark strict_strtox as obsolete. Convert all remaining such uses in drivers/input/. Also change long to appropriate types, and return error conditions from kstrtox separately, as Dmitry sugguests. Signed-off-by: JJ Ding <dgdunix@gmail.com> Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
1 parent 7cf801c commit 76496e7

15 files changed

Lines changed: 173 additions & 104 deletions

File tree

‎drivers/input/input-polldev.c‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,12 @@ static ssize_t input_polldev_set_poll(struct device *dev,
8383
{
8484
struct input_polled_dev *polldev = dev_get_drvdata(dev);
8585
struct input_dev *input = polldev->input;
86-
unsigned long interval;
86+
unsigned int interval;
87+
int err;
8788

88-
if (strict_strtoul(buf, 0, &interval))
89-
return -EINVAL;
89+
err = kstrtouint(buf, 0, &interval);
90+
if (err)
91+
return err;
9092

9193
if (interval < polldev->poll_interval_min)
9294
return -EINVAL;

‎drivers/input/keyboard/atkbd.c‎

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1305,15 +1305,19 @@ static ssize_t atkbd_show_extra(struct atkbd *atkbd, char *buf)
13051305
static ssize_t atkbd_set_extra(struct atkbd *atkbd, const char *buf, size_t count)
13061306
{
13071307
struct input_dev *old_dev, *new_dev;
1308-
unsigned long value;
1308+
unsigned int value;
13091309
int err;
13101310
bool old_extra;
13111311
unsigned char old_set;
13121312

13131313
if (!atkbd->write)
13141314
return -EIO;
13151315

1316-
if (strict_strtoul(buf, 10, &value) || value > 1)
1316+
err = kstrtouint(buf, 10, &value);
1317+
if (err)
1318+
return err;
1319+
1320+
if (value > 1)
13171321
return -EINVAL;
13181322

13191323
if (atkbd->extra != value) {
@@ -1389,11 +1393,15 @@ static ssize_t atkbd_show_scroll(struct atkbd *atkbd, char *buf)
13891393
static ssize_t atkbd_set_scroll(struct atkbd *atkbd, const char *buf, size_t count)
13901394
{
13911395
struct input_dev *old_dev, *new_dev;
1392-
unsigned long value;
1396+
unsigned int value;
13931397
int err;
13941398
bool old_scroll;
13951399

1396-
if (strict_strtoul(buf, 10, &value) || value > 1)
1400+
err = kstrtouint(buf, 10, &value);
1401+
if (err)
1402+
return err;
1403+
1404+
if (value > 1)
13971405
return -EINVAL;
13981406

13991407
if (atkbd->scroll != value) {
@@ -1433,15 +1441,19 @@ static ssize_t atkbd_show_set(struct atkbd *atkbd, char *buf)
14331441
static ssize_t atkbd_set_set(struct atkbd *atkbd, const char *buf, size_t count)
14341442
{
14351443
struct input_dev *old_dev, *new_dev;
1436-
unsigned long value;
1444+
unsigned int value;
14371445
int err;
14381446
unsigned char old_set;
14391447
bool old_extra;
14401448

14411449
if (!atkbd->write)
14421450
return -EIO;
14431451

1444-
if (strict_strtoul(buf, 10, &value) || (value != 2 && value != 3))
1452+
err = kstrtouint(buf, 10, &value);
1453+
if (err)
1454+
return err;
1455+
1456+
if (value != 2 && value != 3)
14451457
return -EINVAL;
14461458

14471459
if (atkbd->set != value) {
@@ -1484,14 +1496,18 @@ static ssize_t atkbd_show_softrepeat(struct atkbd *atkbd, char *buf)
14841496
static ssize_t atkbd_set_softrepeat(struct atkbd *atkbd, const char *buf, size_t count)
14851497
{
14861498
struct input_dev *old_dev, *new_dev;
1487-
unsigned long value;
1499+
unsigned int value;
14881500
int err;
14891501
bool old_softrepeat, old_softraw;
14901502

14911503
if (!atkbd->write)
14921504
return -EIO;
14931505

1494-
if (strict_strtoul(buf, 10, &value) || value > 1)
1506+
err = kstrtouint(buf, 10, &value);
1507+
if (err)
1508+
return err;
1509+
1510+
if (value > 1)
14951511
return -EINVAL;
14961512

14971513
if (atkbd->softrepeat != value) {
@@ -1534,11 +1550,15 @@ static ssize_t atkbd_show_softraw(struct atkbd *atkbd, char *buf)
15341550
static ssize_t atkbd_set_softraw(struct atkbd *atkbd, const char *buf, size_t count)
15351551
{
15361552
struct input_dev *old_dev, *new_dev;
1537-
unsigned long value;
1553+
unsigned int value;
15381554
int err;
15391555
bool old_softraw;
15401556

1541-
if (strict_strtoul(buf, 10, &value) || value > 1)
1557+
err = kstrtouint(buf, 10, &value);
1558+
if (err)
1559+
return err;
1560+
1561+
if (value > 1)
15421562
return -EINVAL;
15431563

15441564
if (atkbd->softraw != value) {

‎drivers/input/keyboard/lm8323.c‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -545,13 +545,12 @@ static ssize_t lm8323_pwm_store_time(struct device *dev,
545545
{
546546
struct led_classdev *led_cdev = dev_get_drvdata(dev);
547547
struct lm8323_pwm *pwm = cdev_to_pwm(led_cdev);
548-
int ret;
549-
unsigned long time;
548+
int ret, time;
550549

551-
ret = strict_strtoul(buf, 10, &time);
550+
ret = kstrtoint(buf, 10, &time);
552551
/* Numbers only, please. */
553552
if (ret)
554-
return -EINVAL;
553+
return ret;
555554

556555
pwm->fade_time = time;
557556

@@ -613,9 +612,9 @@ static ssize_t lm8323_set_disable(struct device *dev,
613612
{
614613
struct lm8323_chip *lm = dev_get_drvdata(dev);
615614
int ret;
616-
unsigned long i;
615+
unsigned int i;
617616

618-
ret = strict_strtoul(buf, 10, &i);
617+
ret = kstrtouint(buf, 10, &i);
619618

620619
mutex_lock(&lm->lock);
621620
lm->kp_enabled = !i;

‎drivers/input/misc/adxl34x.c‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -451,10 +451,10 @@ static ssize_t adxl34x_disable_store(struct device *dev,
451451
const char *buf, size_t count)
452452
{
453453
struct adxl34x *ac = dev_get_drvdata(dev);
454-
unsigned long val;
454+
unsigned int val;
455455
int error;
456456

457-
error = strict_strtoul(buf, 10, &val);
457+
error = kstrtouint(buf, 10, &val);
458458
if (error)
459459
return error;
460460

@@ -540,10 +540,10 @@ static ssize_t adxl34x_rate_store(struct device *dev,
540540
const char *buf, size_t count)
541541
{
542542
struct adxl34x *ac = dev_get_drvdata(dev);
543-
unsigned long val;
543+
unsigned char val;
544544
int error;
545545

546-
error = strict_strtoul(buf, 10, &val);
546+
error = kstrtou8(buf, 10, &val);
547547
if (error)
548548
return error;
549549

@@ -575,10 +575,10 @@ static ssize_t adxl34x_autosleep_store(struct device *dev,
575575
const char *buf, size_t count)
576576
{
577577
struct adxl34x *ac = dev_get_drvdata(dev);
578-
unsigned long val;
578+
unsigned int val;
579579
int error;
580580

581-
error = strict_strtoul(buf, 10, &val);
581+
error = kstrtouint(buf, 10, &val);
582582
if (error)
583583
return error;
584584

@@ -622,13 +622,13 @@ static ssize_t adxl34x_write_store(struct device *dev,
622622
const char *buf, size_t count)
623623
{
624624
struct adxl34x *ac = dev_get_drvdata(dev);
625-
unsigned long val;
625+
unsigned int val;
626626
int error;
627627

628628
/*
629629
* This allows basic ADXL register write access for debug purposes.
630630
*/
631-
error = strict_strtoul(buf, 16, &val);
631+
error = kstrtouint(buf, 16, &val);
632632
if (error)
633633
return error;
634634

‎drivers/input/misc/ati_remote2.c‎

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@ static int ati_remote2_set_mask(const char *val,
4141
const struct kernel_param *kp,
4242
unsigned int max)
4343
{
44-
unsigned long mask;
44+
unsigned int mask;
4545
int ret;
4646

4747
if (!val)
4848
return -EINVAL;
4949

50-
ret = strict_strtoul(val, 0, &mask);
50+
ret = kstrtouint(val, 0, &mask);
5151
if (ret)
5252
return ret;
5353

@@ -719,11 +719,12 @@ static ssize_t ati_remote2_store_channel_mask(struct device *dev,
719719
struct usb_device *udev = to_usb_device(dev);
720720
struct usb_interface *intf = usb_ifnum_to_if(udev, 0);
721721
struct ati_remote2 *ar2 = usb_get_intfdata(intf);
722-
unsigned long mask;
722+
unsigned int mask;
723723
int r;
724724

725-
if (strict_strtoul(buf, 0, &mask))
726-
return -EINVAL;
725+
r = kstrtouint(buf, 0, &mask);
726+
if (r)
727+
return r;
727728

728729
if (mask & ~ATI_REMOTE2_MAX_CHANNEL_MASK)
729730
return -EINVAL;
@@ -768,10 +769,12 @@ static ssize_t ati_remote2_store_mode_mask(struct device *dev,
768769
struct usb_device *udev = to_usb_device(dev);
769770
struct usb_interface *intf = usb_ifnum_to_if(udev, 0);
770771
struct ati_remote2 *ar2 = usb_get_intfdata(intf);
771-
unsigned long mask;
772+
unsigned int mask;
773+
int err;
772774

773-
if (strict_strtoul(buf, 0, &mask))
774-
return -EINVAL;
775+
err = kstrtouint(buf, 0, &mask);
776+
if (err)
777+
return err;
775778

776779
if (mask & ~ATI_REMOTE2_MAX_MODE_MASK)
777780
return -EINVAL;

‎drivers/input/mouse/elantech.c‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1031,16 +1031,13 @@ static ssize_t elantech_set_int_attr(struct psmouse *psmouse,
10311031
struct elantech_data *etd = psmouse->private;
10321032
struct elantech_attr_data *attr = data;
10331033
unsigned char *reg = (unsigned char *) etd + attr->field_offset;
1034-
unsigned long value;
1034+
unsigned char value;
10351035
int err;
10361036

1037-
err = strict_strtoul(buf, 16, &value);
1037+
err = kstrtou8(buf, 16, &value);
10381038
if (err)
10391039
return err;
10401040

1041-
if (value > 0xff)
1042-
return -EINVAL;
1043-
10441041
/* Do we need to preserve some bits for version 2 hardware too? */
10451042
if (etd->hw_version == 1) {
10461043
if (attr->reg == 0x10)

‎drivers/input/mouse/hgpk.c‎

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -789,11 +789,14 @@ static ssize_t hgpk_set_powered(struct psmouse *psmouse, void *data,
789789
const char *buf, size_t count)
790790
{
791791
struct hgpk_data *priv = psmouse->private;
792-
unsigned long value;
792+
unsigned int value;
793793
int err;
794794

795-
err = strict_strtoul(buf, 10, &value);
796-
if (err || value > 1)
795+
err = kstrtouint(buf, 10, &value);
796+
if (err)
797+
return err;
798+
799+
if (value > 1)
797800
return -EINVAL;
798801

799802
if (value != priv->powered) {
@@ -881,11 +884,14 @@ static ssize_t hgpk_trigger_recal(struct psmouse *psmouse, void *data,
881884
const char *buf, size_t count)
882885
{
883886
struct hgpk_data *priv = psmouse->private;
884-
unsigned long value;
887+
unsigned int value;
885888
int err;
886889

887-
err = strict_strtoul(buf, 10, &value);
888-
if (err || value != 1)
890+
err = kstrtouint(buf, 10, &value);
891+
if (err)
892+
return err;
893+
894+
if (value != 1)
889895
return -EINVAL;
890896

891897
/*

‎drivers/input/mouse/logips2pp.c‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,14 @@ static ssize_t ps2pp_attr_show_smartscroll(struct psmouse *psmouse,
155155
static ssize_t ps2pp_attr_set_smartscroll(struct psmouse *psmouse, void *data,
156156
const char *buf, size_t count)
157157
{
158-
unsigned long value;
158+
unsigned int value;
159+
int err;
159160

160-
if (strict_strtoul(buf, 10, &value) || value > 1)
161+
err = kstrtouint(buf, 10, &value);
162+
if (err)
163+
return err;
164+
165+
if (value > 1)
161166
return -EINVAL;
162167

163168
ps2pp_set_smartscroll(psmouse, value);

‎drivers/input/mouse/psmouse-base.c‎

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1558,13 +1558,12 @@ static ssize_t psmouse_show_int_attr(struct psmouse *psmouse, void *offset, char
15581558
static ssize_t psmouse_set_int_attr(struct psmouse *psmouse, void *offset, const char *buf, size_t count)
15591559
{
15601560
unsigned int *field = (unsigned int *)((char *)psmouse + (size_t)offset);
1561-
unsigned long value;
1562-
1563-
if (strict_strtoul(buf, 10, &value))
1564-
return -EINVAL;
1561+
unsigned int value;
1562+
int err;
15651563

1566-
if ((unsigned int)value != value)
1567-
return -EINVAL;
1564+
err = kstrtouint(buf, 10, &value);
1565+
if (err)
1566+
return err;
15681567

15691568
*field = value;
15701569

@@ -1671,21 +1670,25 @@ static ssize_t psmouse_attr_set_protocol(struct psmouse *psmouse, void *data, co
16711670

16721671
static ssize_t psmouse_attr_set_rate(struct psmouse *psmouse, void *data, const char *buf, size_t count)
16731672
{
1674-
unsigned long value;
1673+
unsigned int value;
1674+
int err;
16751675

1676-
if (strict_strtoul(buf, 10, &value))
1677-
return -EINVAL;
1676+
err = kstrtouint(buf, 10, &value);
1677+
if (err)
1678+
return err;
16781679

16791680
psmouse->set_rate(psmouse, value);
16801681
return count;
16811682
}
16821683

16831684
static ssize_t psmouse_attr_set_resolution(struct psmouse *psmouse, void *data, const char *buf, size_t count)
16841685
{
1685-
unsigned long value;
1686+
unsigned int value;
1687+
int err;
16861688

1687-
if (strict_strtoul(buf, 10, &value))
1688-
return -EINVAL;
1689+
err = kstrtouint(buf, 10, &value);
1690+
if (err)
1691+
return err;
16891692

16901693
psmouse->set_resolution(psmouse, value);
16911694
return count;

0 commit comments

Comments
 (0)