linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Alison Schofield <amsfield22@gmail.com>
Cc: daniel.baluta@gmail.com, knaack.h@gmx.de, lars@metafoo.de,
	pmeerw@pmeerw.net, linux-iio@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] iio: bmi160: use variable names for sizeof() operator
Date: Sat, 21 Jan 2017 13:06:31 +0000	[thread overview]
Message-ID: <888a0b08-59cc-7f0a-86db-abdfd603a968@kernel.org> (raw)
In-Reply-To: <20170116050102.GA6310@d830.WORKGROUP>

On 16/01/17 05:01, Alison Schofield wrote:
> Replace the types with the actual variable names when using the
> sizeof() operator.  This is kernel preferred style as it protects
> against future changes to variable type.
> 
> Signed-off-by: Alison Schofield <amsfield22@gmail.com>
Sensible change from an obviously correct stand point.
Future changes to the type are a non starter here given this is a feature of
the hardware!  I've dropped that bit of the commit message and added
something about readability.

Jonathan
> ---
>  drivers/iio/imu/bmi160/bmi160_core.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/iio/imu/bmi160/bmi160_core.c b/drivers/iio/imu/bmi160/bmi160_core.c
> index 5355507..1e7c88b 100644
> --- a/drivers/iio/imu/bmi160/bmi160_core.c
> +++ b/drivers/iio/imu/bmi160/bmi160_core.c
> @@ -338,9 +338,9 @@ static int bmi160_get_data(struct bmi160_data *data, int chan_type,
>  	__le16 sample;
>  	enum bmi160_sensor_type t = bmi160_to_sensor(chan_type);
>  
> -	reg = bmi160_regs[t].data + (axis - IIO_MOD_X) * sizeof(__le16);
> +	reg = bmi160_regs[t].data + (axis - IIO_MOD_X) * sizeof(sample);
>  
> -	ret = regmap_bulk_read(data->regmap, reg, &sample, sizeof(__le16));
> +	ret = regmap_bulk_read(data->regmap, reg, &sample, sizeof(sample));
>  	if (ret < 0)
>  		return ret;
>  
> @@ -405,8 +405,8 @@ static irqreturn_t bmi160_trigger_handler(int irq, void *p)
>  
>  	for_each_set_bit(i, indio_dev->active_scan_mask,
>  			 indio_dev->masklength) {
> -		ret = regmap_bulk_read(data->regmap, base + i * sizeof(__le16),
> -				       &sample, sizeof(__le16));
> +		ret = regmap_bulk_read(data->regmap, base + i * sizeof(sample),
> +				       &sample, sizeof(sample));
>  		if (ret < 0)
>  			goto done;
>  		buf[j++] = sample;
> 


      reply	other threads:[~2017-01-21 13:06 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-16  5:01 [PATCH] iio: bmi160: use variable names for sizeof() operator Alison Schofield
2017-01-21 13:06 ` 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=888a0b08-59cc-7f0a-86db-abdfd603a968@kernel.org \
    --to=jic23@kernel.org \
    --cc=amsfield22@gmail.com \
    --cc=daniel.baluta@gmail.com \
    --cc=knaack.h@gmx.de \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --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;
as well as URLs for NNTP newsgroup(s).