Linux IIO development
 help / color / mirror / Atom feed
From: Michael Hennerich <michael.hennerich@analog.com>
To: Jonathan Cameron <jic23@cam.ac.uk>
Cc: Randy Dunlap <rdunlap@xenotime.net>,
	driverdevel <devel@driverdev.osuosl.org>,
	"linux-iio@vger.kernel.org" <linux-iio@vger.kernel.org>,
	"device-drivers-devel@blackfin.uclinux.org"
	<device-drivers-devel@blackfin.uclinux.org>
Subject: Re: staging/iio/meter/ade7753: 406:19: warning: right shift by bigger than source value
Date: Thu, 14 Jul 2011 11:36:14 +0200	[thread overview]
Message-ID: <4E1EB88E.30004@analog.com> (raw)
In-Reply-To: <4E1EB5B2.6000105@cam.ac.uk>

On 07/14/2011 11:24 AM, Jonathan Cameron wrote:
> On 07/13/11 16:49, Randy Dunlap wrote:
>> static ssize_t ade7753_read_frequency(struct device *dev,
>> 		struct device_attribute *attr,
>> 		char *buf)
>> {
>> 	int ret, len = 0;
>> 	u8 t;
>> 	int sps;
>> 	ret = ade7753_spi_read_reg_8(dev, ADE7753_MODE,	&t);
>> 	if (ret)
>> 		return ret;
>>
>> 	t = (t>>  11)&  0x3; /// HUH?
>>
> Excellent question. Honestly I've passed that line by several times but always whilst
> working on something else and had no real idea of what it is actually meant to be
> doing.  Clearly it's garbage.
Agreed.

> So time for some datasheet trawling.  The mode register is 16 bit, so I'm guessing that
> should have been u16 t; and ade7753_spi_read_reg_16.  I think this is a cut and paste
> bug form the ade7754 driver where the equivalent is an 8 bit register.  Patch below.
>
> Michael, do you have access to test hardware for this one?  I might do a more general
> tidy up of that driver whilst I'm here. Something fun to do before coffee ;)
At the moment I only have HW for the ADE7758.

> Thanks,
>
> Jonathan
>
> Subject: [PATCH] staging:iio:meter:ade7753 should be 16 bit read not 8 bit for mode register.
>
> Build tested only.
>
> Signed-off-by: Jonathan Cameron<jic23@cam.ac.uk>
> Reported-by: Randy Dunlap<rdunlap@xenotime.net>
Acked-by: Michael Hennerich <michael.hennerich@analog.com>
> ---
>   drivers/staging/iio/meter/ade7753.c |    4 ++--
>   1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/staging/iio/meter/ade7753.c b/drivers/staging/iio/meter/ade7753.c
> index 59f47fd..482e16a 100644
> --- a/drivers/staging/iio/meter/ade7753.c
> +++ b/drivers/staging/iio/meter/ade7753.c
> @@ -398,9 +398,9 @@ static ssize_t ade7753_read_frequency(struct device *dev,
>   		char *buf)
>   {
>   	int ret, len = 0;
> -	u8 t;
> +	u16 t;
>   	int sps;
> -	ret = ade7753_spi_read_reg_8(dev, ADE7753_MODE,	&t);
> +	ret = ade7753_spi_read_reg_16(dev, ADE7753_MODE,&t);
>   	if (ret)
>   		return ret;
>


-- 
Greetings,
Michael

--
Analog Devices GmbH      Wilhelm-Wagenfeld-Str. 6      80807 Muenchen
Sitz der Gesellschaft: Muenchen; Registergericht: Muenchen HRB 40368;
Geschaeftsfuehrer:Dr.Carsten Suckrow, Thomas Wessel, William A. Martin,
Margaret Seif

  reply	other threads:[~2011-07-14  9:36 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-13 15:49 staging/iio/meter/ade7753: 406:19: warning: right shift by bigger than source value Randy Dunlap
2011-07-14  9:24 ` Jonathan Cameron
2011-07-14  9:36   ` Michael Hennerich [this message]
2011-07-14 10:05     ` Jonathan Cameron
2011-07-17 17:57   ` Randy Dunlap

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=4E1EB88E.30004@analog.com \
    --to=michael.hennerich@analog.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=device-drivers-devel@blackfin.uclinux.org \
    --cc=jic23@cam.ac.uk \
    --cc=linux-iio@vger.kernel.org \
    --cc=rdunlap@xenotime.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