linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lars-Peter Clausen <lars@metafoo.de>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jonathan Cameron <jic23@cam.ac.uk>,
	devel@driverdev.osuosl.org, linux-iio@vger.kernel.org,
	Lars-Peter Clausen <lars@metafoo.de>
Subject: [PATCH 14/18] staging:iio:dac:ad5791: Use strtobool for boolean values
Date: Mon,  4 Jun 2012 11:36:24 +0200	[thread overview]
Message-ID: <1338802588-10585-14-git-send-email-lars@metafoo.de> (raw)
In-Reply-To: <1338802588-10585-1-git-send-email-lars@metafoo.de>

Use strtobool for parsing the powerdown value instead of strict_strtol, since
the powerdown attribute is a boolean value.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Acked-by: Jonathan Cameron <jic23@kernel.org>
---
 drivers/staging/iio/dac/ad5791.c |   14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/iio/dac/ad5791.c b/drivers/staging/iio/dac/ad5791.c
index 4e955ed..82b51a7 100644
--- a/drivers/staging/iio/dac/ad5791.c
+++ b/drivers/staging/iio/dac/ad5791.c
@@ -114,25 +114,23 @@ static ssize_t ad5791_write_dac_powerdown(struct iio_dev *indio_dev,
 	 uintptr_t private, const struct iio_chan_spec *chan, const char *buf,
 	 size_t len)
 {
-	long readin;
+	bool pwr_down;
 	int ret;
 	struct ad5791_state *st = iio_priv(indio_dev);
 
-	ret = strict_strtol(buf, 10, &readin);
+	ret = strtobool(buf, &pwr_down);
 	if (ret)
 		return ret;
 
-	if (readin == 0) {
-		st->pwr_down = false;
+	if (!pwr_down) {
 		st->ctrl &= ~(AD5791_CTRL_OPGND | AD5791_CTRL_DACTRI);
-	} else if (readin == 1) {
-		st->pwr_down = true;
+	} else {
 		if (st->pwr_down_mode == AD5791_DAC_PWRDN_6K)
 			st->ctrl |= AD5791_CTRL_OPGND;
 		else if (st->pwr_down_mode == AD5791_DAC_PWRDN_3STATE)
 			st->ctrl |= AD5791_CTRL_DACTRI;
-	} else
-		ret = -EINVAL;
+	}
+	st->pwr_down = pwr_down;
 
 	ret = ad5791_spi_write(st->spi, AD5791_ADDR_CTRL, st->ctrl);
 
-- 
1.7.10

  parent reply	other threads:[~2012-06-04  9:36 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-04  9:36 [PATCH 01/18] iio: Add helper functions for enum style channel attributes Lars-Peter Clausen
2012-06-04  9:36 ` [PATCH 02/18] staging:iio:dac:ad5064: Use iio_enum for powerdown modes Lars-Peter Clausen
2012-06-04  9:36 ` [PATCH 03/18] staging:iio:dac:ad5446: " Lars-Peter Clausen
2012-06-04  9:36 ` [PATCH 04/18] staging:iio:dac:ad5380: Convert to extended channel attributes Lars-Peter Clausen
2012-06-04  9:36 ` [PATCH 05/18] staging:iio:dac:ad5504: " Lars-Peter Clausen
2012-06-04  9:36 ` [PATCH 06/18] staging:iio:dac:ad5624r: " Lars-Peter Clausen
2012-06-04  9:36 ` [PATCH 07/18] staging:iio:dac:ad5686: " Lars-Peter Clausen
2012-06-04  9:36 ` [PATCH 08/18] staging:iio:dac:ad5791: " Lars-Peter Clausen
2012-06-04  9:36 ` [PATCH 09/18] staging:iio:dac: Remove unused dac.h includes Lars-Peter Clausen
2012-06-04  9:36 ` [PATCH 10/18] staging:iio:dac:max517: Convert to channel spec Lars-Peter Clausen
2012-06-04  9:36 ` [PATCH 11/18] staging:iio:dac: Remove dac.h Lars-Peter Clausen
2012-06-04  9:36 ` [PATCH 12/18] staging:iio:dac:ad5504: Use strtobool for boolean values Lars-Peter Clausen
2012-06-04  9:36 ` [PATCH 13/18] staging:iio:dac:ad5624r: " Lars-Peter Clausen
2012-06-04  9:36 ` Lars-Peter Clausen [this message]
2012-06-04  9:36 ` [PATCH 15/18] staging:iio:dac:ad5504: Check if IRQ was requested before freeing it Lars-Peter Clausen
2012-06-04  9:36 ` [PATCH 16/18] staging:iio:dac:ad5504: Move private structs and defines from header to C file Lars-Peter Clausen
2012-06-04  9:36 ` [PATCH 17/18] staging:iio:dac:ad5791: " Lars-Peter Clausen
2012-06-04  9:36 ` [PATCH 18/18] staging:iio: Move DAC drivers out of staging Lars-Peter Clausen
2012-06-04 10:55 ` [PATCH 01/18] iio: Add helper functions for enum style channel attributes Dan Carpenter
2012-06-04 20:12   ` Lars-Peter Clausen
2012-06-04 20:36     ` Dan Carpenter
2012-06-05  4:45   ` Greg Kroah-Hartman
  -- strict thread matches above, loose matches on Subject: below --
2012-05-21 11:42 Lars-Peter Clausen
2012-05-21 11:43 ` [PATCH 14/18] staging:iio:dac:ad5791: Use strtobool for boolean values Lars-Peter Clausen

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=1338802588-10585-14-git-send-email-lars@metafoo.de \
    --to=lars@metafoo.de \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jic23@cam.ac.uk \
    --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).