Skip to content

Commit

Permalink
Input: convert obsolete strict_strtox to kstrtox
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
JJ Ding authored and Dmitry Torokhov committed Nov 10, 2011
1 parent 7cf801c commit 76496e7
Show file tree
Hide file tree
Showing 15 changed files with 173 additions and 104 deletions.
8 changes: 5 additions & 3 deletions drivers/input/input-polldev.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,12 @@ static ssize_t input_polldev_set_poll(struct device *dev,
{
struct input_polled_dev *polldev = dev_get_drvdata(dev);
struct input_dev *input = polldev->input;
unsigned long interval;
unsigned int interval;
int err;

if (strict_strtoul(buf, 0, &interval))
return -EINVAL;
err = kstrtouint(buf, 0, &interval);
if (err)
return err;

if (interval < polldev->poll_interval_min)
return -EINVAL;
Expand Down
40 changes: 30 additions & 10 deletions drivers/input/keyboard/atkbd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1305,15 +1305,19 @@ static ssize_t atkbd_show_extra(struct atkbd *atkbd, char *buf)
static ssize_t atkbd_set_extra(struct atkbd *atkbd, const char *buf, size_t count)
{
struct input_dev *old_dev, *new_dev;
unsigned long value;
unsigned int value;
int err;
bool old_extra;
unsigned char old_set;

if (!atkbd->write)
return -EIO;

if (strict_strtoul(buf, 10, &value) || value > 1)
err = kstrtouint(buf, 10, &value);
if (err)
return err;

if (value > 1)
return -EINVAL;

if (atkbd->extra != value) {
Expand Down Expand Up @@ -1389,11 +1393,15 @@ static ssize_t atkbd_show_scroll(struct atkbd *atkbd, char *buf)
static ssize_t atkbd_set_scroll(struct atkbd *atkbd, const char *buf, size_t count)
{
struct input_dev *old_dev, *new_dev;
unsigned long value;
unsigned int value;
int err;
bool old_scroll;

if (strict_strtoul(buf, 10, &value) || value > 1)
err = kstrtouint(buf, 10, &value);
if (err)
return err;

if (value > 1)
return -EINVAL;

if (atkbd->scroll != value) {
Expand Down Expand Up @@ -1433,15 +1441,19 @@ static ssize_t atkbd_show_set(struct atkbd *atkbd, char *buf)
static ssize_t atkbd_set_set(struct atkbd *atkbd, const char *buf, size_t count)
{
struct input_dev *old_dev, *new_dev;
unsigned long value;
unsigned int value;
int err;
unsigned char old_set;
bool old_extra;

if (!atkbd->write)
return -EIO;

if (strict_strtoul(buf, 10, &value) || (value != 2 && value != 3))
err = kstrtouint(buf, 10, &value);
if (err)
return err;

if (value != 2 && value != 3)
return -EINVAL;

if (atkbd->set != value) {
Expand Down Expand Up @@ -1484,14 +1496,18 @@ static ssize_t atkbd_show_softrepeat(struct atkbd *atkbd, char *buf)
static ssize_t atkbd_set_softrepeat(struct atkbd *atkbd, const char *buf, size_t count)
{
struct input_dev *old_dev, *new_dev;
unsigned long value;
unsigned int value;
int err;
bool old_softrepeat, old_softraw;

if (!atkbd->write)
return -EIO;

if (strict_strtoul(buf, 10, &value) || value > 1)
err = kstrtouint(buf, 10, &value);
if (err)
return err;

if (value > 1)
return -EINVAL;

if (atkbd->softrepeat != value) {
Expand Down Expand Up @@ -1534,11 +1550,15 @@ static ssize_t atkbd_show_softraw(struct atkbd *atkbd, char *buf)
static ssize_t atkbd_set_softraw(struct atkbd *atkbd, const char *buf, size_t count)
{
struct input_dev *old_dev, *new_dev;
unsigned long value;
unsigned int value;
int err;
bool old_softraw;

if (strict_strtoul(buf, 10, &value) || value > 1)
err = kstrtouint(buf, 10, &value);
if (err)
return err;

if (value > 1)
return -EINVAL;

if (atkbd->softraw != value) {
Expand Down
11 changes: 5 additions & 6 deletions drivers/input/keyboard/lm8323.c
Original file line number Diff line number Diff line change
Expand Up @@ -545,13 +545,12 @@ static ssize_t lm8323_pwm_store_time(struct device *dev,
{
struct led_classdev *led_cdev = dev_get_drvdata(dev);
struct lm8323_pwm *pwm = cdev_to_pwm(led_cdev);
int ret;
unsigned long time;
int ret, time;

ret = strict_strtoul(buf, 10, &time);
ret = kstrtoint(buf, 10, &time);
/* Numbers only, please. */
if (ret)
return -EINVAL;
return ret;

pwm->fade_time = time;

Expand Down Expand Up @@ -613,9 +612,9 @@ static ssize_t lm8323_set_disable(struct device *dev,
{
struct lm8323_chip *lm = dev_get_drvdata(dev);
int ret;
unsigned long i;
unsigned int i;

ret = strict_strtoul(buf, 10, &i);
ret = kstrtouint(buf, 10, &i);

mutex_lock(&lm->lock);
lm->kp_enabled = !i;
Expand Down
16 changes: 8 additions & 8 deletions drivers/input/misc/adxl34x.c
Original file line number Diff line number Diff line change
Expand Up @@ -451,10 +451,10 @@ static ssize_t adxl34x_disable_store(struct device *dev,
const char *buf, size_t count)
{
struct adxl34x *ac = dev_get_drvdata(dev);
unsigned long val;
unsigned int val;
int error;

error = strict_strtoul(buf, 10, &val);
error = kstrtouint(buf, 10, &val);
if (error)
return error;

Expand Down Expand Up @@ -540,10 +540,10 @@ static ssize_t adxl34x_rate_store(struct device *dev,
const char *buf, size_t count)
{
struct adxl34x *ac = dev_get_drvdata(dev);
unsigned long val;
unsigned char val;
int error;

error = strict_strtoul(buf, 10, &val);
error = kstrtou8(buf, 10, &val);
if (error)
return error;

Expand Down Expand Up @@ -575,10 +575,10 @@ static ssize_t adxl34x_autosleep_store(struct device *dev,
const char *buf, size_t count)
{
struct adxl34x *ac = dev_get_drvdata(dev);
unsigned long val;
unsigned int val;
int error;

error = strict_strtoul(buf, 10, &val);
error = kstrtouint(buf, 10, &val);
if (error)
return error;

Expand Down Expand Up @@ -622,13 +622,13 @@ static ssize_t adxl34x_write_store(struct device *dev,
const char *buf, size_t count)
{
struct adxl34x *ac = dev_get_drvdata(dev);
unsigned long val;
unsigned int val;
int error;

/*
* This allows basic ADXL register write access for debug purposes.
*/
error = strict_strtoul(buf, 16, &val);
error = kstrtouint(buf, 16, &val);
if (error)
return error;

Expand Down
19 changes: 11 additions & 8 deletions drivers/input/misc/ati_remote2.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ static int ati_remote2_set_mask(const char *val,
const struct kernel_param *kp,
unsigned int max)
{
unsigned long mask;
unsigned int mask;
int ret;

if (!val)
return -EINVAL;

ret = strict_strtoul(val, 0, &mask);
ret = kstrtouint(val, 0, &mask);
if (ret)
return ret;

Expand Down Expand Up @@ -719,11 +719,12 @@ static ssize_t ati_remote2_store_channel_mask(struct device *dev,
struct usb_device *udev = to_usb_device(dev);
struct usb_interface *intf = usb_ifnum_to_if(udev, 0);
struct ati_remote2 *ar2 = usb_get_intfdata(intf);
unsigned long mask;
unsigned int mask;
int r;

if (strict_strtoul(buf, 0, &mask))
return -EINVAL;
r = kstrtouint(buf, 0, &mask);
if (r)
return r;

if (mask & ~ATI_REMOTE2_MAX_CHANNEL_MASK)
return -EINVAL;
Expand Down Expand Up @@ -768,10 +769,12 @@ static ssize_t ati_remote2_store_mode_mask(struct device *dev,
struct usb_device *udev = to_usb_device(dev);
struct usb_interface *intf = usb_ifnum_to_if(udev, 0);
struct ati_remote2 *ar2 = usb_get_intfdata(intf);
unsigned long mask;
unsigned int mask;
int err;

if (strict_strtoul(buf, 0, &mask))
return -EINVAL;
err = kstrtouint(buf, 0, &mask);
if (err)
return err;

if (mask & ~ATI_REMOTE2_MAX_MODE_MASK)
return -EINVAL;
Expand Down
7 changes: 2 additions & 5 deletions drivers/input/mouse/elantech.c
Original file line number Diff line number Diff line change
Expand Up @@ -1031,16 +1031,13 @@ static ssize_t elantech_set_int_attr(struct psmouse *psmouse,
struct elantech_data *etd = psmouse->private;
struct elantech_attr_data *attr = data;
unsigned char *reg = (unsigned char *) etd + attr->field_offset;
unsigned long value;
unsigned char value;
int err;

err = strict_strtoul(buf, 16, &value);
err = kstrtou8(buf, 16, &value);
if (err)
return err;

if (value > 0xff)
return -EINVAL;

/* Do we need to preserve some bits for version 2 hardware too? */
if (etd->hw_version == 1) {
if (attr->reg == 0x10)
Expand Down
18 changes: 12 additions & 6 deletions drivers/input/mouse/hgpk.c
Original file line number Diff line number Diff line change
Expand Up @@ -789,11 +789,14 @@ static ssize_t hgpk_set_powered(struct psmouse *psmouse, void *data,
const char *buf, size_t count)
{
struct hgpk_data *priv = psmouse->private;
unsigned long value;
unsigned int value;
int err;

err = strict_strtoul(buf, 10, &value);
if (err || value > 1)
err = kstrtouint(buf, 10, &value);
if (err)
return err;

if (value > 1)
return -EINVAL;

if (value != priv->powered) {
Expand Down Expand Up @@ -881,11 +884,14 @@ static ssize_t hgpk_trigger_recal(struct psmouse *psmouse, void *data,
const char *buf, size_t count)
{
struct hgpk_data *priv = psmouse->private;
unsigned long value;
unsigned int value;
int err;

err = strict_strtoul(buf, 10, &value);
if (err || value != 1)
err = kstrtouint(buf, 10, &value);
if (err)
return err;

if (value != 1)
return -EINVAL;

/*
Expand Down
9 changes: 7 additions & 2 deletions drivers/input/mouse/logips2pp.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,14 @@ static ssize_t ps2pp_attr_show_smartscroll(struct psmouse *psmouse,
static ssize_t ps2pp_attr_set_smartscroll(struct psmouse *psmouse, void *data,
const char *buf, size_t count)
{
unsigned long value;
unsigned int value;
int err;

if (strict_strtoul(buf, 10, &value) || value > 1)
err = kstrtouint(buf, 10, &value);
if (err)
return err;

if (value > 1)
return -EINVAL;

ps2pp_set_smartscroll(psmouse, value);
Expand Down
27 changes: 15 additions & 12 deletions drivers/input/mouse/psmouse-base.c
Original file line number Diff line number Diff line change
Expand Up @@ -1558,13 +1558,12 @@ static ssize_t psmouse_show_int_attr(struct psmouse *psmouse, void *offset, char
static ssize_t psmouse_set_int_attr(struct psmouse *psmouse, void *offset, const char *buf, size_t count)
{
unsigned int *field = (unsigned int *)((char *)psmouse + (size_t)offset);
unsigned long value;

if (strict_strtoul(buf, 10, &value))
return -EINVAL;
unsigned int value;
int err;

if ((unsigned int)value != value)
return -EINVAL;
err = kstrtouint(buf, 10, &value);
if (err)
return err;

*field = value;

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

static ssize_t psmouse_attr_set_rate(struct psmouse *psmouse, void *data, const char *buf, size_t count)
{
unsigned long value;
unsigned int value;
int err;

if (strict_strtoul(buf, 10, &value))
return -EINVAL;
err = kstrtouint(buf, 10, &value);
if (err)
return err;

psmouse->set_rate(psmouse, value);
return count;
}

static ssize_t psmouse_attr_set_resolution(struct psmouse *psmouse, void *data, const char *buf, size_t count)
{
unsigned long value;
unsigned int value;
int err;

if (strict_strtoul(buf, 10, &value))
return -EINVAL;
err = kstrtouint(buf, 10, &value);
if (err)
return err;

psmouse->set_resolution(psmouse, value);
return count;
Expand Down
Loading

0 comments on commit 76496e7

Please sign in to comment.