2023-08-13 20:42:01

by Angel Iglesias

[permalink] [raw]
Subject: [PATCH v2 0/3] iio: pressure: bmp280: Small driver cleanup

Minor cleanup of BMP280 i2c code and migration to the new helper functions
i2c_get_match_data() and spi_get_device_match_data().

Revise driver coding style to follow reverse christmas tree.

Changelog v2:
- Added patch 3 adopting spi_get_device_match_data().
- Updated patch 2 following advice from Uwe Kleine-König
<[email protected]> regarding unintentioned driver semantic
changes.
- Revised thoroughfully driver coding style and update more functions.

v1:
https://lore.kernel.org/all/[email protected]/

Angel Iglesias (3):
iio: pressure: bmp280: i2c: Rearrange vars in reverse xmas tree order
iio: pressure: bmp280: Use i2c_get_match_data
iio: pressure: bmp280: Use spi_get_device_match_data()

drivers/iio/pressure/bmp280-core.c | 4 ++--
drivers/iio/pressure/bmp280-i2c.c | 8 +++-----
drivers/iio/pressure/bmp280-spi.c | 10 +++-------
3 files changed, 8 insertions(+), 14 deletions(-)


base-commit: 14b7447cec15ee8dfdfe0da66ba1e280ded7e00a
--
2.41.0



2023-08-13 20:47:23

by Angel Iglesias

[permalink] [raw]
Subject: [PATCH v2 1/3] iio: pressure: bmp280: i2c: Rearrange vars in reverse xmas tree order

Minor cleanup reordering local variable declarations following reverse
christmas tree convention.

Signed-off-by: Angel Iglesias <[email protected]>

diff --git a/drivers/iio/pressure/bmp280-core.c b/drivers/iio/pressure/bmp280-core.c
index 6089f3f9d8f4..ea02a623bb58 100644
--- a/drivers/iio/pressure/bmp280-core.c
+++ b/drivers/iio/pressure/bmp280-core.c
@@ -766,8 +766,8 @@ static const struct iio_info bmp280_info = {

static int bmp280_chip_config(struct bmp280_data *data)
{
- u8 osrs = FIELD_PREP(BMP280_OSRS_TEMP_MASK, data->oversampling_temp + 1) |
- FIELD_PREP(BMP280_OSRS_PRESS_MASK, data->oversampling_press + 1);
+ u8 osrs = FIELD_PREP(BMP280_OSRS_PRESS_MASK, data->oversampling_press + 1) |
+ FIELD_PREP(BMP280_OSRS_TEMP_MASK, data->oversampling_temp + 1);
int ret;

ret = regmap_write_bits(data->regmap, BMP280_REG_CTRL_MEAS,
diff --git a/drivers/iio/pressure/bmp280-i2c.c b/drivers/iio/pressure/bmp280-i2c.c
index dbe630ad05b5..693eb1975fdc 100644
--- a/drivers/iio/pressure/bmp280-i2c.c
+++ b/drivers/iio/pressure/bmp280-i2c.c
@@ -7,9 +7,9 @@

static int bmp280_i2c_probe(struct i2c_client *client)
{
- struct regmap *regmap;
- const struct bmp280_chip_info *chip_info;
const struct i2c_device_id *id = i2c_client_get_device_id(client);
+ const struct bmp280_chip_info *chip_info;
+ struct regmap *regmap;

chip_info = device_get_match_data(&client->dev);
if (!chip_info)
diff --git a/drivers/iio/pressure/bmp280-spi.c b/drivers/iio/pressure/bmp280-spi.c
index 1dff9bb7c4e9..1c9c01f1b1c7 100644
--- a/drivers/iio/pressure/bmp280-spi.c
+++ b/drivers/iio/pressure/bmp280-spi.c
@@ -14,8 +14,7 @@
static int bmp280_regmap_spi_write(void *context, const void *data,
size_t count)
{
- struct device *dev = context;
- struct spi_device *spi = to_spi_device(dev);
+ struct spi_device *spi = to_spi_device(context);
u8 buf[2];

memcpy(buf, data, 2);
@@ -31,8 +30,7 @@ static int bmp280_regmap_spi_write(void *context, const void *data,
static int bmp280_regmap_spi_read(void *context, const void *reg,
size_t reg_size, void *val, size_t val_size)
{
- struct device *dev = context;
- struct spi_device *spi = to_spi_device(dev);
+ struct spi_device *spi = to_spi_device(context);

return spi_write_then_read(spi, reg, reg_size, val, val_size);
}
--
2.41.0