* [PATCH] iio: bmi160: use variable names for sizeof() operator
@ 2017-01-16 5:01 Alison Schofield
2017-01-21 13:06 ` Jonathan Cameron
0 siblings, 1 reply; 2+ messages in thread
From: Alison Schofield @ 2017-01-16 5:01 UTC (permalink / raw)
To: jic23; +Cc: daniel.baluta, knaack.h, lars, pmeerw, linux-iio, linux-kernel
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>
---
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;
--
2.1.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] iio: bmi160: use variable names for sizeof() operator
2017-01-16 5:01 [PATCH] iio: bmi160: use variable names for sizeof() operator Alison Schofield
@ 2017-01-21 13:06 ` Jonathan Cameron
0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Cameron @ 2017-01-21 13:06 UTC (permalink / raw)
To: Alison Schofield
Cc: daniel.baluta, knaack.h, lars, pmeerw, linux-iio, linux-kernel
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;
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-01-21 13:06 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-01-16 5:01 [PATCH] iio: bmi160: use variable names for sizeof() operator Alison Schofield
2017-01-21 13:06 ` Jonathan Cameron
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).