Linux IIO development
 help / color / mirror / Atom feed
From: Lars-Peter Clausen <lars@metafoo.de>
To: Daniel Baluta <daniel.baluta@gmail.com>,
	Somya Anand <somyaanand214@gmail.com>
Cc: outreachy-kernel@googlegroups.com,
	Jonathan Cameron <jic23@kernel.org>,
	"linux-iio@vger.kernel.org" <linux-iio@vger.kernel.org>
Subject: Re: [Outreachy kernel] [PATCH] Staging: iio: Change data type in adis16220_read_16bit to u16
Date: Fri, 06 Mar 2015 10:15:55 +0100	[thread overview]
Message-ID: <54F9704B.3040501@metafoo.de> (raw)
In-Reply-To: <CAEnQRZB9hGx1jR9YVJgQUPRzewNrj4TQ=_SnPLSK4rHvUtcU=w@mail.gmail.com>

On 03/06/2015 09:58 AM, Daniel Baluta wrote:
> Hi Somya,
>
> On Fri, Mar 6, 2015 at 10:36 AM, Somya Anand <somyaanand214@gmail.com> wrote:
>> In the adis16220_read16bit() function we earlier used a s16 value 'val'
>> which is used by the adis_read_reg_16 function to read data and takes a
>> u16 value as a parameter.
>>
>> So, this patch changes the data type of 'val' from s16 to u16 for further
>> simplification of code and thereby avoiding unnecessary typecast.
>>
>> Signed-off-by: Somya Anand <somyaanand214@gmail.com>

Patch looks ok. But it changes the semantics of the function, the reason why 
this is a s16 instead of a u16 is because at some point the function was 
used to read register that contained signed 16 bit values. The code is 
essentially the short version of:

	u16 uval;
	adis_read_reg_16(&st->adis, this_attr->address, &uval);
	sprintf("%d\n", sign_extend32(uval, 15));

This patch removes the extra sign extension. Which is ok, since the only 
user of the function uses it to read a 10 unsigned value which will lead to 
the same result in both cases. But the commit message should mention this, 
since it is not just the removal of a unnecessary type cast.

- Lars

  reply	other threads:[~2015-03-06  9:15 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1425630960-7142-1-git-send-email-somyaanand214@gmail.com>
2015-03-06  8:58 ` [Outreachy kernel] [PATCH] Staging: iio: Change data type in adis16220_read_16bit to u16 Daniel Baluta
2015-03-06  9:15   ` Lars-Peter Clausen [this message]
2015-03-06  9:55     ` Somya Anand

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=54F9704B.3040501@metafoo.de \
    --to=lars@metafoo.de \
    --cc=daniel.baluta@gmail.com \
    --cc=jic23@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=outreachy-kernel@googlegroups.com \
    --cc=somyaanand214@gmail.com \
    /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