diff options
author | JJ Ding <dgdunix@gmail.com> | 2011-11-09 13:20:14 -0500 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2011-11-10 00:23:26 -0500 |
commit | 76496e7a02e99d42844f4fffa145b81e513e7acd (patch) | |
tree | 33812cc8a9b250a95cf90c237c46ec6fc6fcf2ff /drivers/input/mouse | |
parent | 7cf801cfc0774b777aa6861cf4a43a90b112b1ed (diff) |
Input: convert obsolete strict_strtox to kstrtox
With commit 67d0a0754455f89ef3946946159d8ec9e45ce33a 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>
Diffstat (limited to 'drivers/input/mouse')
-rw-r--r-- | drivers/input/mouse/elantech.c | 7 | ||||
-rw-r--r-- | drivers/input/mouse/hgpk.c | 18 | ||||
-rw-r--r-- | drivers/input/mouse/logips2pp.c | 9 | ||||
-rw-r--r-- | drivers/input/mouse/psmouse-base.c | 27 | ||||
-rw-r--r-- | drivers/input/mouse/sentelic.c | 43 | ||||
-rw-r--r-- | drivers/input/mouse/trackpoint.c | 17 |
6 files changed, 80 insertions, 41 deletions
diff --git a/drivers/input/mouse/elantech.c b/drivers/input/mouse/elantech.c index 09b93b11a274..b562392d0cd8 100644 --- a/drivers/input/mouse/elantech.c +++ b/drivers/input/mouse/elantech.c | |||
@@ -1031,16 +1031,13 @@ static ssize_t elantech_set_int_attr(struct psmouse *psmouse, | |||
1031 | struct elantech_data *etd = psmouse->private; | 1031 | struct elantech_data *etd = psmouse->private; |
1032 | struct elantech_attr_data *attr = data; | 1032 | struct elantech_attr_data *attr = data; |
1033 | unsigned char *reg = (unsigned char *) etd + attr->field_offset; | 1033 | unsigned char *reg = (unsigned char *) etd + attr->field_offset; |
1034 | unsigned long value; | 1034 | unsigned char value; |
1035 | int err; | 1035 | int err; |
1036 | 1036 | ||
1037 | err = strict_strtoul(buf, 16, &value); | 1037 | err = kstrtou8(buf, 16, &value); |
1038 | if (err) | 1038 | if (err) |
1039 | return err; | 1039 | return err; |
1040 | 1040 | ||
1041 | if (value > 0xff) | ||
1042 | return -EINVAL; | ||
1043 | |||
1044 | /* Do we need to preserve some bits for version 2 hardware too? */ | 1041 | /* Do we need to preserve some bits for version 2 hardware too? */ |
1045 | if (etd->hw_version == 1) { | 1042 | if (etd->hw_version == 1) { |
1046 | if (attr->reg == 0x10) | 1043 | if (attr->reg == 0x10) |
diff --git a/drivers/input/mouse/hgpk.c b/drivers/input/mouse/hgpk.c index 0470dd46b566..1c5d521de600 100644 --- a/drivers/input/mouse/hgpk.c +++ b/drivers/input/mouse/hgpk.c | |||
@@ -789,11 +789,14 @@ static ssize_t hgpk_set_powered(struct psmouse *psmouse, void *data, | |||
789 | const char *buf, size_t count) | 789 | const char *buf, size_t count) |
790 | { | 790 | { |
791 | struct hgpk_data *priv = psmouse->private; | 791 | struct hgpk_data *priv = psmouse->private; |
792 | unsigned long value; | 792 | unsigned int value; |
793 | int err; | 793 | int err; |
794 | 794 | ||
795 | err = strict_strtoul(buf, 10, &value); | 795 | err = kstrtouint(buf, 10, &value); |
796 | if (err || value > 1) | 796 | if (err) |
797 | return err; | ||
798 | |||
799 | if (value > 1) | ||
797 | return -EINVAL; | 800 | return -EINVAL; |
798 | 801 | ||
799 | if (value != priv->powered) { | 802 | if (value != priv->powered) { |
@@ -881,11 +884,14 @@ static ssize_t hgpk_trigger_recal(struct psmouse *psmouse, void *data, | |||
881 | const char *buf, size_t count) | 884 | const char *buf, size_t count) |
882 | { | 885 | { |
883 | struct hgpk_data *priv = psmouse->private; | 886 | struct hgpk_data *priv = psmouse->private; |
884 | unsigned long value; | 887 | unsigned int value; |
885 | int err; | 888 | int err; |
886 | 889 | ||
887 | err = strict_strtoul(buf, 10, &value); | 890 | err = kstrtouint(buf, 10, &value); |
888 | if (err || value != 1) | 891 | if (err) |
892 | return err; | ||
893 | |||
894 | if (value != 1) | ||
889 | return -EINVAL; | 895 | return -EINVAL; |
890 | 896 | ||
891 | /* | 897 | /* |
diff --git a/drivers/input/mouse/logips2pp.c b/drivers/input/mouse/logips2pp.c index faac2c3bef74..84de2fc6acc1 100644 --- a/drivers/input/mouse/logips2pp.c +++ b/drivers/input/mouse/logips2pp.c | |||
@@ -155,9 +155,14 @@ static ssize_t ps2pp_attr_show_smartscroll(struct psmouse *psmouse, | |||
155 | static ssize_t ps2pp_attr_set_smartscroll(struct psmouse *psmouse, void *data, | 155 | static ssize_t ps2pp_attr_set_smartscroll(struct psmouse *psmouse, void *data, |
156 | const char *buf, size_t count) | 156 | const char *buf, size_t count) |
157 | { | 157 | { |
158 | unsigned long value; | 158 | unsigned int value; |
159 | int err; | ||
159 | 160 | ||
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) | ||
161 | return -EINVAL; | 166 | return -EINVAL; |
162 | 167 | ||
163 | ps2pp_set_smartscroll(psmouse, value); | 168 | ps2pp_set_smartscroll(psmouse, value); |
diff --git a/drivers/input/mouse/psmouse-base.c b/drivers/input/mouse/psmouse-base.c index 9f352fbd7b4f..a6973e575aa9 100644 --- a/drivers/input/mouse/psmouse-base.c +++ b/drivers/input/mouse/psmouse-base.c | |||
@@ -1558,13 +1558,12 @@ static ssize_t psmouse_show_int_attr(struct psmouse *psmouse, void *offset, char | |||
1558 | static ssize_t psmouse_set_int_attr(struct psmouse *psmouse, void *offset, const char *buf, size_t count) | 1558 | static ssize_t psmouse_set_int_attr(struct psmouse *psmouse, void *offset, const char *buf, size_t count) |
1559 | { | 1559 | { |
1560 | unsigned int *field = (unsigned int *)((char *)psmouse + (size_t)offset); | 1560 | unsigned int *field = (unsigned int *)((char *)psmouse + (size_t)offset); |
1561 | unsigned long value; | 1561 | unsigned int value; |
1562 | 1562 | int err; | |
1563 | if (strict_strtoul(buf, 10, &value)) | ||
1564 | return -EINVAL; | ||
1565 | 1563 | ||
1566 | if ((unsigned int)value != value) | 1564 | err = kstrtouint(buf, 10, &value); |
1567 | return -EINVAL; | 1565 | if (err) |
1566 | return err; | ||
1568 | 1567 | ||
1569 | *field = value; | 1568 | *field = value; |
1570 | 1569 | ||
@@ -1671,10 +1670,12 @@ static ssize_t psmouse_attr_set_protocol(struct psmouse *psmouse, void *data, co | |||
1671 | 1670 | ||
1672 | static ssize_t psmouse_attr_set_rate(struct psmouse *psmouse, void *data, const char *buf, size_t count) | 1671 | static ssize_t psmouse_attr_set_rate(struct psmouse *psmouse, void *data, const char *buf, size_t count) |
1673 | { | 1672 | { |
1674 | unsigned long value; | 1673 | unsigned int value; |
1674 | int err; | ||
1675 | 1675 | ||
1676 | if (strict_strtoul(buf, 10, &value)) | 1676 | err = kstrtouint(buf, 10, &value); |
1677 | return -EINVAL; | 1677 | if (err) |
1678 | return err; | ||
1678 | 1679 | ||
1679 | psmouse->set_rate(psmouse, value); | 1680 | psmouse->set_rate(psmouse, value); |
1680 | return count; | 1681 | return count; |
@@ -1682,10 +1683,12 @@ static ssize_t psmouse_attr_set_rate(struct psmouse *psmouse, void *data, const | |||
1682 | 1683 | ||
1683 | static ssize_t psmouse_attr_set_resolution(struct psmouse *psmouse, void *data, const char *buf, size_t count) | 1684 | static ssize_t psmouse_attr_set_resolution(struct psmouse *psmouse, void *data, const char *buf, size_t count) |
1684 | { | 1685 | { |
1685 | unsigned long value; | 1686 | unsigned int value; |
1687 | int err; | ||
1686 | 1688 | ||
1687 | if (strict_strtoul(buf, 10, &value)) | 1689 | err = kstrtouint(buf, 10, &value); |
1688 | return -EINVAL; | 1690 | if (err) |
1691 | return err; | ||
1689 | 1692 | ||
1690 | psmouse->set_resolution(psmouse, value); | 1693 | psmouse->set_resolution(psmouse, value); |
1691 | return count; | 1694 | return count; |
diff --git a/drivers/input/mouse/sentelic.c b/drivers/input/mouse/sentelic.c index c5b12d2e955a..5babc47b39aa 100644 --- a/drivers/input/mouse/sentelic.c +++ b/drivers/input/mouse/sentelic.c | |||
@@ -408,7 +408,7 @@ static int fsp_onpad_hscr(struct psmouse *psmouse, bool enable) | |||
408 | static ssize_t fsp_attr_set_setreg(struct psmouse *psmouse, void *data, | 408 | static ssize_t fsp_attr_set_setreg(struct psmouse *psmouse, void *data, |
409 | const char *buf, size_t count) | 409 | const char *buf, size_t count) |
410 | { | 410 | { |
411 | unsigned long reg, val; | 411 | int reg, val; |
412 | char *rest; | 412 | char *rest; |
413 | ssize_t retval; | 413 | ssize_t retval; |
414 | 414 | ||
@@ -416,7 +416,11 @@ static ssize_t fsp_attr_set_setreg(struct psmouse *psmouse, void *data, | |||
416 | if (rest == buf || *rest != ' ' || reg > 0xff) | 416 | if (rest == buf || *rest != ' ' || reg > 0xff) |
417 | return -EINVAL; | 417 | return -EINVAL; |
418 | 418 | ||
419 | if (strict_strtoul(rest + 1, 16, &val) || val > 0xff) | 419 | retval = kstrtoint(rest + 1, 16, &val); |
420 | if (retval) | ||
421 | return retval; | ||
422 | |||
423 | if (val > 0xff) | ||
420 | return -EINVAL; | 424 | return -EINVAL; |
421 | 425 | ||
422 | if (fsp_reg_write_enable(psmouse, true)) | 426 | if (fsp_reg_write_enable(psmouse, true)) |
@@ -448,10 +452,13 @@ static ssize_t fsp_attr_set_getreg(struct psmouse *psmouse, void *data, | |||
448 | const char *buf, size_t count) | 452 | const char *buf, size_t count) |
449 | { | 453 | { |
450 | struct fsp_data *pad = psmouse->private; | 454 | struct fsp_data *pad = psmouse->private; |
451 | unsigned long reg; | 455 | int reg, val, err; |
452 | int val; | 456 | |
457 | err = kstrtoint(buf, 16, ®); | ||
458 | if (err) | ||
459 | return err; | ||
453 | 460 | ||
454 | if (strict_strtoul(buf, 16, ®) || reg > 0xff) | 461 | if (reg > 0xff) |
455 | return -EINVAL; | 462 | return -EINVAL; |
456 | 463 | ||
457 | if (fsp_reg_read(psmouse, reg, &val)) | 464 | if (fsp_reg_read(psmouse, reg, &val)) |
@@ -480,9 +487,13 @@ static ssize_t fsp_attr_show_pagereg(struct psmouse *psmouse, | |||
480 | static ssize_t fsp_attr_set_pagereg(struct psmouse *psmouse, void *data, | 487 | static ssize_t fsp_attr_set_pagereg(struct psmouse *psmouse, void *data, |
481 | const char *buf, size_t count) | 488 | const char *buf, size_t count) |
482 | { | 489 | { |
483 | unsigned long val; | 490 | int val, err; |
484 | 491 | ||
485 | if (strict_strtoul(buf, 16, &val) || val > 0xff) | 492 | err = kstrtoint(buf, 16, &val); |
493 | if (err) | ||
494 | return err; | ||
495 | |||
496 | if (val > 0xff) | ||
486 | return -EINVAL; | 497 | return -EINVAL; |
487 | 498 | ||
488 | if (fsp_page_reg_write(psmouse, val)) | 499 | if (fsp_page_reg_write(psmouse, val)) |
@@ -505,9 +516,14 @@ static ssize_t fsp_attr_show_vscroll(struct psmouse *psmouse, | |||
505 | static ssize_t fsp_attr_set_vscroll(struct psmouse *psmouse, void *data, | 516 | static ssize_t fsp_attr_set_vscroll(struct psmouse *psmouse, void *data, |
506 | const char *buf, size_t count) | 517 | const char *buf, size_t count) |
507 | { | 518 | { |
508 | unsigned long val; | 519 | unsigned int val; |
520 | int err; | ||
521 | |||
522 | err = kstrtouint(buf, 10, &val); | ||
523 | if (err) | ||
524 | return err; | ||
509 | 525 | ||
510 | if (strict_strtoul(buf, 10, &val) || val > 1) | 526 | if (val > 1) |
511 | return -EINVAL; | 527 | return -EINVAL; |
512 | 528 | ||
513 | fsp_onpad_vscr(psmouse, val); | 529 | fsp_onpad_vscr(psmouse, val); |
@@ -529,9 +545,14 @@ static ssize_t fsp_attr_show_hscroll(struct psmouse *psmouse, | |||
529 | static ssize_t fsp_attr_set_hscroll(struct psmouse *psmouse, void *data, | 545 | static ssize_t fsp_attr_set_hscroll(struct psmouse *psmouse, void *data, |
530 | const char *buf, size_t count) | 546 | const char *buf, size_t count) |
531 | { | 547 | { |
532 | unsigned long val; | 548 | unsigned int val; |
549 | int err; | ||
550 | |||
551 | err = kstrtouint(buf, 10, &val); | ||
552 | if (err) | ||
553 | return err; | ||
533 | 554 | ||
534 | if (strict_strtoul(buf, 10, &val) || val > 1) | 555 | if (val > 1) |
535 | return -EINVAL; | 556 | return -EINVAL; |
536 | 557 | ||
537 | fsp_onpad_hscr(psmouse, val); | 558 | fsp_onpad_hscr(psmouse, val); |
diff --git a/drivers/input/mouse/trackpoint.c b/drivers/input/mouse/trackpoint.c index 54b2fa892e19..22b218018137 100644 --- a/drivers/input/mouse/trackpoint.c +++ b/drivers/input/mouse/trackpoint.c | |||
@@ -89,10 +89,12 @@ static ssize_t trackpoint_set_int_attr(struct psmouse *psmouse, void *data, | |||
89 | struct trackpoint_data *tp = psmouse->private; | 89 | struct trackpoint_data *tp = psmouse->private; |
90 | struct trackpoint_attr_data *attr = data; | 90 | struct trackpoint_attr_data *attr = data; |
91 | unsigned char *field = (unsigned char *)((char *)tp + attr->field_offset); | 91 | unsigned char *field = (unsigned char *)((char *)tp + attr->field_offset); |
92 | unsigned long value; | 92 | unsigned char value; |
93 | int err; | ||
93 | 94 | ||
94 | if (strict_strtoul(buf, 10, &value) || value > 255) | 95 | err = kstrtou8(buf, 10, &value); |
95 | return -EINVAL; | 96 | if (err) |
97 | return err; | ||
96 | 98 | ||
97 | *field = value; | 99 | *field = value; |
98 | trackpoint_write(&psmouse->ps2dev, attr->command, value); | 100 | trackpoint_write(&psmouse->ps2dev, attr->command, value); |
@@ -115,9 +117,14 @@ static ssize_t trackpoint_set_bit_attr(struct psmouse *psmouse, void *data, | |||
115 | struct trackpoint_data *tp = psmouse->private; | 117 | struct trackpoint_data *tp = psmouse->private; |
116 | struct trackpoint_attr_data *attr = data; | 118 | struct trackpoint_attr_data *attr = data; |
117 | unsigned char *field = (unsigned char *)((char *)tp + attr->field_offset); | 119 | unsigned char *field = (unsigned char *)((char *)tp + attr->field_offset); |
118 | unsigned long value; | 120 | unsigned int value; |
121 | int err; | ||
122 | |||
123 | err = kstrtouint(buf, 10, &value); | ||
124 | if (err) | ||
125 | return err; | ||
119 | 126 | ||
120 | if (strict_strtoul(buf, 10, &value) || value > 1) | 127 | if (value > 1) |
121 | return -EINVAL; | 128 | return -EINVAL; |
122 | 129 | ||
123 | if (attr->inverted) | 130 | if (attr->inverted) |