提交 4468cb55 编写于 作者: L Lars-Peter Clausen 提交者: Greg Kroah-Hartman

staging:iio:dac:ad5791: Use strtobool for boolean values

Use strtobool for parsing the powerdown value instead of strict_strtol, since
the powerdown attribute is a boolean value.
Signed-off-by: NLars-Peter Clausen <lars@metafoo.de>
Acked-by: NJonathan Cameron <jic23@kernel.org>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 2490594e
...@@ -114,25 +114,23 @@ static ssize_t ad5791_write_dac_powerdown(struct iio_dev *indio_dev, ...@@ -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, uintptr_t private, const struct iio_chan_spec *chan, const char *buf,
size_t len) size_t len)
{ {
long readin; bool pwr_down;
int ret; int ret;
struct ad5791_state *st = iio_priv(indio_dev); struct ad5791_state *st = iio_priv(indio_dev);
ret = strict_strtol(buf, 10, &readin); ret = strtobool(buf, &pwr_down);
if (ret) if (ret)
return ret; return ret;
if (readin == 0) { if (!pwr_down) {
st->pwr_down = false;
st->ctrl &= ~(AD5791_CTRL_OPGND | AD5791_CTRL_DACTRI); st->ctrl &= ~(AD5791_CTRL_OPGND | AD5791_CTRL_DACTRI);
} else if (readin == 1) { } else {
st->pwr_down = true;
if (st->pwr_down_mode == AD5791_DAC_PWRDN_6K) if (st->pwr_down_mode == AD5791_DAC_PWRDN_6K)
st->ctrl |= AD5791_CTRL_OPGND; st->ctrl |= AD5791_CTRL_OPGND;
else if (st->pwr_down_mode == AD5791_DAC_PWRDN_3STATE) else if (st->pwr_down_mode == AD5791_DAC_PWRDN_3STATE)
st->ctrl |= AD5791_CTRL_DACTRI; st->ctrl |= AD5791_CTRL_DACTRI;
} else }
ret = -EINVAL; st->pwr_down = pwr_down;
ret = ad5791_spi_write(st->spi, AD5791_ADDR_CTRL, st->ctrl); ret = ad5791_spi_write(st->spi, AD5791_ADDR_CTRL, st->ctrl);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册