* [PATCH] iio: pressure: bmp280 endian tidy ups
@ 2019-10-13 10:17 jic23
2019-10-16 12:20 ` Linus Walleij
0 siblings, 1 reply; 3+ messages in thread
From: jic23 @ 2019-10-13 10:17 UTC (permalink / raw)
To: linux-iio; +Cc: Jonathan Cameron, Linus Walleij
From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
There is a somewhat interesting mixture of be16 and le16 going on in
this one function. Changes here formalize that a little more.
CHECK drivers/iio/pressure/bmp280-core.c
drivers/iio/pressure/bmp280-core.c:215:35: warning: cast to restricted __le16
drivers/iio/pressure/bmp280-core.c:229:37: warning: cast to restricted __be16
drivers/iio/pressure/bmp280-core.c:229:37: warning: cast to restricted __be16
drivers/iio/pressure/bmp280-core.c:229:37: warning: cast to restricted __be16
drivers/iio/pressure/bmp280-core.c:229:37: warning: cast to restricted __be16
drivers/iio/pressure/bmp280-core.c:230:36: warning: cast to restricted __be16
drivers/iio/pressure/bmp280-core.c:230:36: warning: cast to restricted __be16
drivers/iio/pressure/bmp280-core.c:230:36: warning: cast to restricted __be16
drivers/iio/pressure/bmp280-core.c:230:36: warning: cast to restricted __be16
drivers/iio/pressure/bmp280-core.c:237:37: warning: cast to restricted __le16
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Linus Walleij <linus.walleij@linaro.org>
---
drivers/iio/pressure/bmp280-core.c | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/drivers/iio/pressure/bmp280-core.c b/drivers/iio/pressure/bmp280-core.c
index c3b5c1f6614d..d3c817c03722 100644
--- a/drivers/iio/pressure/bmp280-core.c
+++ b/drivers/iio/pressure/bmp280-core.c
@@ -148,6 +148,8 @@ static int bmp280_read_calib(struct bmp280_data *data,
{
int ret;
unsigned int tmp;
+ __le16 l16;
+ __be16 b16;
struct device *dev = data->dev;
__le16 t_buf[BMP280_COMP_TEMP_REG_COUNT / 2];
__le16 p_buf[BMP280_COMP_PRESS_REG_COUNT / 2];
@@ -207,12 +209,12 @@ static int bmp280_read_calib(struct bmp280_data *data,
}
calib->H1 = tmp;
- ret = regmap_bulk_read(data->regmap, BMP280_REG_COMP_H2, &tmp, 2);
+ ret = regmap_bulk_read(data->regmap, BMP280_REG_COMP_H2, &l16, 2);
if (ret < 0) {
dev_err(dev, "failed to read H2 comp value\n");
return ret;
}
- calib->H2 = sign_extend32(le16_to_cpu(tmp), 15);
+ calib->H2 = sign_extend32(le16_to_cpu(l16), 15);
ret = regmap_read(data->regmap, BMP280_REG_COMP_H3, &tmp);
if (ret < 0) {
@@ -221,20 +223,20 @@ static int bmp280_read_calib(struct bmp280_data *data,
}
calib->H3 = tmp;
- ret = regmap_bulk_read(data->regmap, BMP280_REG_COMP_H4, &tmp, 2);
+ ret = regmap_bulk_read(data->regmap, BMP280_REG_COMP_H4, &b16, 2);
if (ret < 0) {
dev_err(dev, "failed to read H4 comp value\n");
return ret;
}
- calib->H4 = sign_extend32(((be16_to_cpu(tmp) >> 4) & 0xff0) |
- (be16_to_cpu(tmp) & 0xf), 11);
+ calib->H4 = sign_extend32(((be16_to_cpu(b16) >> 4) & 0xff0) |
+ (be16_to_cpu(b16) & 0xf), 11);
- ret = regmap_bulk_read(data->regmap, BMP280_REG_COMP_H5, &tmp, 2);
+ ret = regmap_bulk_read(data->regmap, BMP280_REG_COMP_H5, &l16, 2);
if (ret < 0) {
dev_err(dev, "failed to read H5 comp value\n");
return ret;
}
- calib->H5 = sign_extend32(((le16_to_cpu(tmp) >> 4) & 0xfff), 11);
+ calib->H5 = sign_extend32(((le16_to_cpu(l16) >> 4) & 0xfff), 11);
ret = regmap_read(data->regmap, BMP280_REG_COMP_H6, &tmp);
if (ret < 0) {
--
2.23.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] iio: pressure: bmp280 endian tidy ups
2019-10-13 10:17 [PATCH] iio: pressure: bmp280 endian tidy ups jic23
@ 2019-10-16 12:20 ` Linus Walleij
2019-10-18 18:57 ` Jonathan Cameron
0 siblings, 1 reply; 3+ messages in thread
From: Linus Walleij @ 2019-10-16 12:20 UTC (permalink / raw)
To: Jonathan Cameron; +Cc: linux-iio, Jonathan Cameron
On Sun, Oct 13, 2019 at 12:19 PM <jic23@kernel.org> wrote:
> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
>
> There is a somewhat interesting mixture of be16 and le16 going on in
> this one function. Changes here formalize that a little more.
>
> CHECK drivers/iio/pressure/bmp280-core.c
> drivers/iio/pressure/bmp280-core.c:215:35: warning: cast to restricted __le16
> drivers/iio/pressure/bmp280-core.c:229:37: warning: cast to restricted __be16
> drivers/iio/pressure/bmp280-core.c:229:37: warning: cast to restricted __be16
> drivers/iio/pressure/bmp280-core.c:229:37: warning: cast to restricted __be16
> drivers/iio/pressure/bmp280-core.c:229:37: warning: cast to restricted __be16
> drivers/iio/pressure/bmp280-core.c:230:36: warning: cast to restricted __be16
> drivers/iio/pressure/bmp280-core.c:230:36: warning: cast to restricted __be16
> drivers/iio/pressure/bmp280-core.c:230:36: warning: cast to restricted __be16
> drivers/iio/pressure/bmp280-core.c:230:36: warning: cast to restricted __be16
> drivers/iio/pressure/bmp280-core.c:237:37: warning: cast to restricted __le16
>
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Cc: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] iio: pressure: bmp280 endian tidy ups
2019-10-16 12:20 ` Linus Walleij
@ 2019-10-18 18:57 ` Jonathan Cameron
0 siblings, 0 replies; 3+ messages in thread
From: Jonathan Cameron @ 2019-10-18 18:57 UTC (permalink / raw)
To: Linus Walleij; +Cc: linux-iio, Jonathan Cameron
On Wed, 16 Oct 2019 14:20:29 +0200
Linus Walleij <linus.walleij@linaro.org> wrote:
> On Sun, Oct 13, 2019 at 12:19 PM <jic23@kernel.org> wrote:
>
> > From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> >
> > There is a somewhat interesting mixture of be16 and le16 going on in
> > this one function. Changes here formalize that a little more.
> >
> > CHECK drivers/iio/pressure/bmp280-core.c
> > drivers/iio/pressure/bmp280-core.c:215:35: warning: cast to restricted __le16
> > drivers/iio/pressure/bmp280-core.c:229:37: warning: cast to restricted __be16
> > drivers/iio/pressure/bmp280-core.c:229:37: warning: cast to restricted __be16
> > drivers/iio/pressure/bmp280-core.c:229:37: warning: cast to restricted __be16
> > drivers/iio/pressure/bmp280-core.c:229:37: warning: cast to restricted __be16
> > drivers/iio/pressure/bmp280-core.c:230:36: warning: cast to restricted __be16
> > drivers/iio/pressure/bmp280-core.c:230:36: warning: cast to restricted __be16
> > drivers/iio/pressure/bmp280-core.c:230:36: warning: cast to restricted __be16
> > drivers/iio/pressure/bmp280-core.c:230:36: warning: cast to restricted __be16
> > drivers/iio/pressure/bmp280-core.c:237:37: warning: cast to restricted __le16
> >
> > Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> > Cc: Linus Walleij <linus.walleij@linaro.org>
>
> Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
>
Applied. Thanks,
Jonathan
> Yours,
> Linus Walleij
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-10-18 18:57 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-13 10:17 [PATCH] iio: pressure: bmp280 endian tidy ups jic23
2019-10-16 12:20 ` Linus Walleij
2019-10-18 18:57 ` Jonathan Cameron
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.