linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Jonathan Cameron <jic23@kernel.org>
Cc: linux-iio@vger.kernel.org, jbrenner@taosinc.com
Subject: Re: [PATCH 3/3] staging:iio:light:tsl2583 switch to kstrto and strtobool
Date: Sat, 12 Jan 2013 10:31:09 +0000	[thread overview]
Message-ID: <50F13B6D.5010708@kernel.org> (raw)
In-Reply-To: <1357489383-30811-4-git-send-email-jic23@kernel.org>

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@kernel.org>
> ---
>  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;
> 

  reply	other threads:[~2013-01-12 10:31 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-06 16:23 [PATCH 0/3] staging:iio:tsl2583 update interfaces Jonathan Cameron
2013-01-06 16:23 ` [PATCH 1/3] staging:iio:light:tsl2583 use read_raw, write_raw hooks Jonathan Cameron
2013-01-06 16:23 ` [PATCH 2/3] staging:iio:light:tsl2583 apply in_ prefix to attributes Jonathan Cameron
2013-01-06 16:23 ` [PATCH 3/3] staging:iio:light:tsl2583 switch to kstrto and strtobool Jonathan Cameron
2013-01-12 10:31   ` Jonathan Cameron [this message]
  -- strict thread matches above, loose matches on Subject: below --
2013-01-12 10:42 [PATCH 0/3 V2] staging:iio:tsl2583 update interfaces Jonathan Cameron
2013-01-12 10:42 ` [PATCH 3/3] staging:iio:light:tsl2583 switch to kstrto and strtobool Jonathan Cameron

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=50F13B6D.5010708@kernel.org \
    --to=jic23@kernel.org \
    --cc=jbrenner@taosinc.com \
    --cc=linux-iio@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).