Re: [PATCH 3/3] staging:iio:light:tsl2583 switch to kstrto and strtobool

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

 



On 01/06/2013 04:23 PM, Jonathan Cameron wrote:
> Doing this results in cleaner code and better error handling.
> 
Ooops. kstotoul is a typo.  Not sure how I missed the build failure.
Will repost with that fixed in a few mins.

Sorry about that.

> Signed-off-by: Jonathan Cameron <jic23@xxxxxxxxxx>
> ---
>  drivers/staging/iio/light/tsl2583.c | 36 ++++++++++++++++++++++--------------
>  1 file changed, 22 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/staging/iio/light/tsl2583.c b/drivers/staging/iio/light/tsl2583.c
> index 944db26..f45114f 100644
> --- a/drivers/staging/iio/light/tsl2583.c
> +++ b/drivers/staging/iio/light/tsl2583.c
> @@ -493,15 +493,17 @@ static ssize_t taos_power_state_store(struct device *dev,
>  	struct device_attribute *attr, const char *buf, size_t len)
>  {
>  	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
> -	unsigned long value;
> +	bool state;
> +	int ret;
>  
> -	if (strict_strtoul(buf, 0, &value))
> -		return -EINVAL;
> +	ret = strtobool(buf, &state);
> +	if (ret < 0)
> +		return ret;
>  
> -	if (value == 0)
> -		taos_chip_off(indio_dev);
> -	else
> +	if (state)
>  		taos_chip_on(indio_dev);
> +	else
> +		taos_chip_off(indio_dev);		
>  
>  	return len;
>  }
> @@ -527,9 +529,11 @@ static ssize_t taos_als_time_store(struct device *dev,
>  	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
>  	struct tsl2583_chip *chip = iio_priv(indio_dev);
>  	unsigned long value;
> +	int ret;
>  
> -	if (strict_strtoul(buf, 0, &value))
> -		return -EINVAL;
> +	ret = kstrtoul(buf, 0, &value);
> +	if (ret < 0)
> +		return ret;
>  
>  	if ((value < 50) || (value > 650))
>  		return -EINVAL;
> @@ -564,9 +568,11 @@ static ssize_t taos_als_cal_target_store(struct device *dev,
>  	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
>  	struct tsl2583_chip *chip = iio_priv(indio_dev);
>  	unsigned long value;
> +	int ret;
>  
> -	if (strict_strtoul(buf, 0, &value))
> -		return -EINVAL;
> +	ret = kstrotoul(buf, 0, &value);
> +	if (ret < 0)
> +		return ret;
>  
>  	if (value)
>  		chip->taos_settings.als_cal_target = value;
> @@ -578,12 +584,14 @@ static ssize_t taos_do_calibrate(struct device *dev,
>  	struct device_attribute *attr, const char *buf, size_t len)
>  {
>  	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
> -	unsigned long value;
> +	bool cal;
> +	int ret;
>  
> -	if (strict_strtoul(buf, 0, &value))
> -		return -EINVAL;
> +	ret = strtobool(buf, &cal);
> +	if (ret < 0)
> +		return ret;
>  
> -	if (value == 1)
> +	if (cal)
>  		taos_als_calibrate(indio_dev);
>  
>  	return len;
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux