From: Jonathan Cameron <jic23@kernel.org>
To: Mircea Caprioru <mircea.caprioru@analog.com>
Cc: <Michael.Hennerich@analog.com>, <knaack.h@gmx.de>,
<lars@metafoo.de>, <pmeerw@pmeerw.net>,
<gregkh@linuxfoundation.org>, <linux-kernel@vger.kernel.org>,
<linux-iio@vger.kernel.org>, <devel@driverdev.osuosl.org>
Subject: Re: [PATCH] iio: dac: ad5686: fix bit shift read register
Date: Sat, 8 Dec 2018 15:44:32 +0000 [thread overview]
Message-ID: <20181208154432.34e248bd@archlinux> (raw)
In-Reply-To: <20181206135315.22805-1-mircea.caprioru@analog.com>
On Thu, 6 Dec 2018 15:53:15 +0200
Mircea Caprioru <mircea.caprioru@analog.com> wrote:
> This patch solves the register readback issue with the bit shift. When the
> dac resolution was lower than the register size (ex. 12 bits out of 16
> bits) the readback value was not shifted with the difference in bits and
> the value was higher. Also a mask is applied on the read value in order to
> get the value relative to the actual bit size.
>
> Fixes: 0357e488b8 ("iio:dac:ad5686: Refactor the driver")
> Signed-off-by: Mircea Caprioru <mircea.caprioru@analog.com>
This seems obvious, but a little strange we've not noticed it
before. Ah well. Given the time in the cycle I'm going to
take it for the next merge window rather than rushing it it.
Applied to the togreg branch of iio.git and pushed out as
testing for the autobuilders to play with it.
Thanks,
Jonathan
> ---
> drivers/iio/dac/ad5686.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/iio/dac/ad5686.c b/drivers/iio/dac/ad5686.c
> index 54ff76b93366..a332b93ca2c4 100644
> --- a/drivers/iio/dac/ad5686.c
> +++ b/drivers/iio/dac/ad5686.c
> @@ -128,7 +128,8 @@ static int ad5686_read_raw(struct iio_dev *indio_dev,
> mutex_unlock(&indio_dev->mlock);
> if (ret < 0)
> return ret;
> - *val = ret;
> + *val = (ret >> chan->scan_type.shift) &
> + GENMASK(chan->scan_type.realbits - 1, 0);
> return IIO_VAL_INT;
> case IIO_CHAN_INFO_SCALE:
> *val = st->vref_mv;
prev parent reply other threads:[~2018-12-08 15:44 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-06 13:53 [PATCH] iio: dac: ad5686: fix bit shift read register Mircea Caprioru
2018-12-08 15:44 ` Jonathan Cameron [this message]
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=20181208154432.34e248bd@archlinux \
--to=jic23@kernel.org \
--cc=Michael.Hennerich@analog.com \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--cc=knaack.h@gmx.de \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mircea.caprioru@analog.com \
--cc=pmeerw@pmeerw.net \
/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