Re: [PATCH 1/2] hwmon: (lm63) Fix checkpatch errors

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Guenter,

On Mon, Nov 21, 2011 at 4:12 AM, Guenter Roeck
<guenter.roeck@xxxxxxxxxxxx> wrote:
> Signed-off-by: Guenter Roeck <guenter.roeck@xxxxxxxxxxxx>
> ---
>  drivers/hwmon/lm63.c |   74 +++++++++++++++++++++++++++++++++++--------------
>  1 files changed, 53 insertions(+), 21 deletions(-)
>
> diff --git a/drivers/hwmon/lm63.c b/drivers/hwmon/lm63.c
> index 508cb29..e02d7f0 100644
> --- a/drivers/hwmon/lm63.c
> +++ b/drivers/hwmon/lm63.c
> @@ -204,7 +204,12 @@ static ssize_t set_fan(struct device *dev, struct device_attribute *dummy,
>  {
>        struct i2c_client *client = to_i2c_client(dev);
>        struct lm63_data *data = i2c_get_clientdata(client);
> -       unsigned long val = simple_strtoul(buf, NULL, 10);
> +       unsigned long val;
> +       int err;
> +
> +       err = kstrtoul(buf, 10, &val);
> +       if (err)
> +               return err;
>
>        mutex_lock(&data->update_lock);
>        data->fan[1] = FAN_TO_REG(val);
> @@ -231,11 +236,15 @@ static ssize_t set_pwm1(struct device *dev, struct device_attribute *dummy,
>        struct i2c_client *client = to_i2c_client(dev);
>        struct lm63_data *data = i2c_get_clientdata(client);
>        unsigned long val;
> -
> +       int err;
> +
>        if (!(data->config_fan & 0x20)) /* register is read-only */
>                return -EPERM;
>
> -       val = simple_strtoul(buf, NULL, 10);
> +       err = kstrtoul(buf, 10, &val);
> +       if (err)
> +               return err;
> +
Since the valid range is upto 255 do we still need string to long ?


>        mutex_lock(&data->update_lock);
>        data->pwm1_value = val <= 0 ? 0 :
>                           val >= 255 ? 2 * data->pwm1_freq :
> @@ -245,8 +254,8 @@ static ssize_t set_pwm1(struct device *dev, struct device_attribute *dummy,
>        return count;
>  }
>

_______________________________________________
lm-sensors mailing list
lm-sensors@xxxxxxxxxxxxxx
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors



[Index of Archives]     [Linux Kernel]     [Linux Hardware Monitoring]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux