From: Jonathan Cameron <jic23@kernel.org>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: linux-iio@vger.kernel.org, Hartmut Knaack <knaack.h@gmx.de>,
Lars-Peter Clausen <lars@metafoo.de>,
Peter Meerwald-Stadler <pmeerw@pmeerw.net>
Subject: Re: [PATCH v1 4/5] iio: pressure: bmp280: Drop unneeded explicit castings
Date: Sun, 22 Mar 2020 17:21:56 +0000 [thread overview]
Message-ID: <20200322172156.6c6ffb3b@archlinux> (raw)
In-Reply-To: <20200317101813.30829-4-andriy.shevchenko@linux.intel.com>
On Tue, 17 Mar 2020 12:18:12 +0200
Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:
> In few places the unnecessary explicit castings are being used.
> Drop them for good.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
A passing comment inline, but seems sensible to me.
Jonathan
> ---
> drivers/iio/pressure/bmp280-core.c | 17 +++++++----------
> 1 file changed, 7 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/iio/pressure/bmp280-core.c b/drivers/iio/pressure/bmp280-core.c
> index 6c2e47d92a11..5db41b1df7eb 100644
> --- a/drivers/iio/pressure/bmp280-core.c
> +++ b/drivers/iio/pressure/bmp280-core.c
> @@ -337,8 +337,7 @@ static int bmp280_read_temp(struct bmp280_data *data,
> __be32 tmp = 0;
> s32 adc_temp, comp_temp;
>
> - ret = regmap_bulk_read(data->regmap, BMP280_REG_TEMP_MSB,
> - (u8 *) &tmp, 3);
> + ret = regmap_bulk_read(data->regmap, BMP280_REG_TEMP_MSB, &tmp, 3);
> if (ret < 0) {
> dev_err(data->dev, "failed to read temperature\n");
> return ret;
> @@ -377,8 +376,7 @@ static int bmp280_read_press(struct bmp280_data *data,
> if (ret < 0)
> return ret;
>
> - ret = regmap_bulk_read(data->regmap, BMP280_REG_PRESS_MSB,
> - (u8 *) &tmp, 3);
> + ret = regmap_bulk_read(data->regmap, BMP280_REG_PRESS_MSB, &tmp, 3);
> if (ret < 0) {
> dev_err(data->dev, "failed to read pressure\n");
> return ret;
> @@ -400,8 +398,8 @@ static int bmp280_read_press(struct bmp280_data *data,
>
> static int bmp280_read_humid(struct bmp280_data *data, int *val, int *val2)
> {
> + __be16 tmp;
> int ret;
> - __be16 tmp = 0;
I haven't checked it but normally that sort of initialization got added
because a compiler got 'clever' and decided that it might be used uninitialized.
However, it's a bit odd in this case as there are lots of other calls
of the same thing that don't bother initializing. So must not be that...
> s32 adc_humidity;
> u32 comp_humidity;
>
> @@ -410,8 +408,7 @@ static int bmp280_read_humid(struct bmp280_data *data, int *val, int *val2)
> if (ret < 0)
> return ret;
>
> - ret = regmap_bulk_read(data->regmap, BMP280_REG_HUMIDITY_MSB,
> - (u8 *) &tmp, 2);
> + ret = regmap_bulk_read(data->regmap, BMP280_REG_HUMIDITY_MSB, &tmp, 2);
> if (ret < 0) {
> dev_err(data->dev, "failed to read humidity\n");
> return ret;
> @@ -747,14 +744,14 @@ static int bmp180_measure(struct bmp280_data *data, u8 ctrl_meas)
>
> static int bmp180_read_adc_temp(struct bmp280_data *data, int *val)
> {
> + __be16 tmp;
> int ret;
> - __be16 tmp = 0;
>
> ret = bmp180_measure(data, BMP180_MEAS_TEMP);
> if (ret)
> return ret;
>
> - ret = regmap_bulk_read(data->regmap, BMP180_REG_OUT_MSB, (u8 *)&tmp, 2);
> + ret = regmap_bulk_read(data->regmap, BMP180_REG_OUT_MSB, &tmp, 2);
> if (ret)
> return ret;
>
> @@ -851,7 +848,7 @@ static int bmp180_read_adc_press(struct bmp280_data *data, int *val)
> if (ret)
> return ret;
>
> - ret = regmap_bulk_read(data->regmap, BMP180_REG_OUT_MSB, (u8 *)&tmp, 3);
> + ret = regmap_bulk_read(data->regmap, BMP180_REG_OUT_MSB, &tmp, 3);
> if (ret)
> return ret;
>
next prev parent reply other threads:[~2020-03-22 17:22 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-17 10:18 [PATCH v1 1/5] iio: pressure: bmp280: Tolerate IRQ before registering Andy Shevchenko
2020-03-17 10:18 ` [PATCH v1 2/5] iio: pressure: bmp280: Use IIO_DEVICE_ATTR_RO macro Andy Shevchenko
2020-03-22 17:16 ` Jonathan Cameron
2020-03-22 21:17 ` Andy Shevchenko
2020-03-23 9:38 ` Jonathan Cameron
2020-03-17 10:18 ` [PATCH v1 3/5] iio: pressure: bmp280: Explicitly mark GPIO optional Andy Shevchenko
2020-03-17 10:18 ` [PATCH v1 4/5] iio: pressure: bmp280: Drop unneeded explicit castings Andy Shevchenko
2020-03-22 17:21 ` Jonathan Cameron [this message]
2020-03-22 21:20 ` Andy Shevchenko
2020-03-17 10:18 ` [PATCH v1 5/5] iio: pressure: bmp280: Join string literals back Andy Shevchenko
2020-03-22 17:12 ` [PATCH v1 1/5] iio: pressure: bmp280: Tolerate IRQ before registering Jonathan Cameron
2020-03-22 21:15 ` Andy Shevchenko
2020-03-23 9:40 ` Jonathan Cameron
2020-03-23 10:08 ` Andy Shevchenko
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=20200322172156.6c6ffb3b@archlinux \
--to=jic23@kernel.org \
--cc=andriy.shevchenko@linux.intel.com \
--cc=knaack.h@gmx.de \
--cc=lars@metafoo.de \
--cc=linux-iio@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).