iio: pressure: bmp280: Small driver cleanup
v2 cover 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
Signature · 1 line
2.41.0
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.
drivers/iio/pressure/bmp280-core.c +2 -2
@@ -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,
drivers/iio/pressure/bmp280-i2c.c +2 -2
@@ -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)
drivers/iio/pressure/bmp280-spi.c +2 -4
@@ -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); }
Signature · 1 line
2.41.0
PATCH v2 2/3 iio: pressure: bmp280: Use i2c_get_match_data
In reply to Angel IglesiasReplaces device_get_match_data() and fallback match_id logic by new unified helper function i2c_get_match_data().
drivers/iio/pressure/bmp280-i2c.c +1 -3
@@ -11,9 +11,7 @@ static int bmp280_i2c_probe(struct i2c_client *client)const struct bmp280_chip_info *chip_info;struct regmap *regmap; - chip_info =device_get_match_data (&client->dev); -if (!chip_info) - chip_info = (const struct bmp280_chip_info *) id->driver_data; + chip_info =i2c_get_match_data (client); regmap =devm_regmap_init_i2c (client, chip_info->regmap_config);if (IS_ERR (regmap)) {
Signature · 1 line
2.41.0
Re: [PATCH v2 2/3] iio: pressure: bmp280: Use i2c_get_match_data
Quoted 13 lines · Angel Iglesias
Replaces
device_get_match_data()and fallbackmatch_idlogic by new unified helper functioni2c_get_match_data().Signed-off-by Angel Iglesias <[email protected]>drivers/iio/pressure/bmp280- renamed from drivers/iio/pressure/bmp280-i2c.c +0
-0
i2c.c
index693eb1975fdc..34e3bc758493100644drivers/iio/pressure/bmp280-i2c.c +0
-0@@ -11,9 +11,7 @@ static int bmp280_i2c_probe(struct i2c_client *client) const struct bmp280_chip_info *chip_info; struct regmap *regmap;
Quoted 8 lines
- chip_info =device_get_match_data(&client->dev);
- if (!chip_info)
- chip_info = (const structbmp280_chip_info*)id->driver_data; + chip_info =i2c_get_match_data(client);
regmap =devm_regmap_init_i2c(client, chip_info->regmap_config); if (IS_ERR(regmap)) {
Hi,
I noticed I submitted this change that was also submitted by Biju Das on another patch:
https://lore.kernel.org/all/[email protected]/
Should I drop this patch from the series?
Kind regards,
Angel
RE: [PATCH v2 2/3] iio: pressure: bmp280: Use i2c_get_match_data
Hi Angel Iglesias,
Quoted 30 lines
Subject: Re: [PATCH v2 2/3] iio: pressure: bmp280: Use
i2c_get_match_dataQuoted 21 lines · Angel Iglesias
Replaces
device_get_match_data()and fallbackmatch_idlogic by new unified helper functioni2c_get_match_data().Signed-off-by Angel Iglesias <[email protected]>(quoted diff) +0
-0b/drivers/iio/pressure/bmp280-
i2c.cindex693eb1975fdc..34e3bc758493100644drivers/iio/pressure/bmp280-i2c.c +1
-3@@ -11,9 +11,7 @@ static int bmp280_i2c_probe(struct i2c_client *client) const struct bmp280_chip_info *chip_info; struct regmap *regmap; - chip_info = device_get_match_data(&client->dev); - if (!chip_info) - chip_info = (const struct bmp280_chip_info *) id->driver_data; + chip_info = i2c_get_match_data(client);Quoted 3 lines
regmap = devm_regmap_init_i2c(client,
chip_info->regmap_config);
if (IS_ERR(regmap)) {Hi,
Quoted 5 lines
I noticed I submitted this change that was also submitted by Biju Das on another
patch:Should I drop this patch from the series?
I think it is ok. Andy is suggesting to use unified table for SPI/I2C
Is it something do able and testable in your environment? see [1], If yes, please create another patch for using unified table for both i2c and spi.
Cheers,
Biju
Re: [PATCH v2 2/3] iio: pressure: bmp280: Use i2c_get_match_data
Quoted 37 lines · Biju Das
Hi Angel Iglesias,
Quoted 33 lines
Subject: Re: [PATCH v2 2/3] iio: pressure: bmp280: Use
i2c_get_match_dataQuoted 21 lines · Angel Iglesias
Replaces
device_get_match_data()and fallbackmatch_idlogic by new unified helper functioni2c_get_match_data().Signed-off-by Angel Iglesias <[email protected]>(quoted diff) +0
-0b/drivers/iio/pressure/bmp280-
i2c.cindex693eb1975fdc..34e3bc758493100644drivers/iio/pressure/bmp280-i2c.c +1
-3@@ -11,9 +11,7 @@ static int bmp280_i2c_probe(struct i2c_client *client) const struct bmp280_chip_info *chip_info; struct regmap *regmap; - chip_info = device_get_match_data(&client->dev); - if (!chip_info) - chip_info = (const struct bmp280_chip_info *) id->driver_data; + chip_info = i2c_get_match_data(client);Quoted 3 lines
regmap = devm_regmap_init_i2c(client,
chip_info->regmap_config);
if (IS_ERR(regmap)) {Hi,
I noticed I submitted this change that was also submitted by Biju Das on another
patch:
Quoted 7 lines
Quoted 1 line
Should I drop this patch from the series?
I think it is ok. Andy is suggesting to use unified table for SPI/I2C
Is it something do able and testable in your environment? see [1], If yes, please create another patch for using unified table for both i2c and spi.
I have around a BMP390 with the SPI pins available to test it out. In the case of the bmp280 we could unify the of_match table as they're almost the same. In the case of the spi_device_id and i2c_device_id tables, as they're different structs I'm not sure if they can be unified.
Regarding Andy's comment, I think he's referring to the duplicated chip infos. In the case of the bmp280, the chip_infos are defined on the common driver code and used for both SPI and I2C match tables.
Quoted 5 lines
Cheers,
Biju
Kind regards,
Angel
Jonathan Cameron
maintainerRe: [PATCH v2 2/3] iio: pressure: bmp280: Use i2c_get_match_data
Quoted 46 lines · On Mon, 14 Aug 2023 18:43:49 +0200 Angel Iglesias <[email protected]>…
Quoted 37 lines · Biju Das
Hi Angel Iglesias,
Quoted 33 lines
Subject: Re: [PATCH v2 2/3] iio: pressure: bmp280: Use
i2c_get_match_dataQuoted 21 lines · Angel Iglesias
Replaces
device_get_match_data()and fallbackmatch_idlogic by new unified helper functioni2c_get_match_data().Signed-off-by Angel Iglesias <[email protected]>(quoted diff) +0
-0b/drivers/iio/pressure/bmp280-
i2c.cindex693eb1975fdc..34e3bc758493100644drivers/iio/pressure/bmp280-i2c.c +1
-3@@ -11,9 +11,7 @@ static int bmp280_i2c_probe(struct i2c_client *client) const struct bmp280_chip_info *chip_info; struct regmap *regmap; - chip_info = device_get_match_data(&client->dev); - if (!chip_info) - chip_info = (const struct bmp280_chip_info *) id->driver_data; + chip_info = i2c_get_match_data(client);Quoted 3 lines
regmap = devm_regmap_init_i2c(client,
chip_info->regmap_config);
if (IS_ERR(regmap)) {Hi,
I noticed I submitted this change that was also submitted by Biju Das on another
patch:Quoted 7 lines
Quoted 1 line
Should I drop this patch from the series?
I think it is ok. Andy is suggesting to use unified table for SPI/I2C
Is it something do able and testable in your environment? see [1], If yes, please create another patch for using unified table for both i2c and spi.
Quoted 8 lines
I have around a BMP390 with the SPI pins available to test it out. In the case of the bmp280 we could unify the
of_matchtable as they're almost the same. In the case of thespi_device_idandi2c_device_idtables, as they're different structs I'm not sure if they can be unified.Regarding Andy's comment, I think he's referring to the duplicated chip infos. In the case of the bmp280, the
chip_infosare defined on the common driver code and used for both SPI and I2C match tables.
Hi,
I'm loosing track of where we are with this driver as multiple people are working on it.
Angel, as most of the work is yours, please could you manage the flow of patches for this one so I get series with clear statement of what they are dependent on.
Thanks,
Jonathan
Quoted 10 lines
Quoted 6 lines
Cheers,
BijuKind regards,
Angel
Re: [PATCH v2 2/3] iio: pressure: bmp280: Use i2c_get_match_data
Quoted 65 lines · Jonathan Cameron
Quoted 55 lines · On Mon, 14 Aug 2023 18:43:49 +0200 Angel Iglesias <[email protected]>…
Quoted 38 lines · Biju Das
Hi Angel Iglesias,
Quoted 31 lines
Subject: Re: [PATCH v2 2/3] iio: pressure: bmp280: Use
i2c_get_match_dataQuoted 21 lines · Angel Iglesias
Replaces
device_get_match_data()and fallbackmatch_idlogic by new unified helper functioni2c_get_match_data().Signed-off-by Angel Iglesias <[email protected]>(quoted diff) +0
-0b/drivers/iio/pressure/bmp280-
i2c.cindex693eb1975fdc..34e3bc758493100644drivers/iio/pressure/bmp280-i2c.c +1
-3@@ -11,9 +11,7 @@ static int bmp280_i2c_probe(struct i2c_client *client) const struct bmp280_chip_info *chip_info; struct regmap *regmap; - chip_info = device_get_match_data(&client->dev); - if (!chip_info) - chip_info = (const struct bmp280_chip_info *) id->driver_data; + chip_info = i2c_get_match_data(client);Quoted 3 lines
regmap = devm_regmap_init_i2c(client,
chip_info->regmap_config);
if (IS_ERR(regmap)) {Hi,
Quoted 3 lines
I noticed I submitted this change that was also submitted by Biju Das on another
patch:Quoted 8 lines
Quoted 1 line
Should I drop this patch from the series?
I think it is ok. Andy is suggesting to use unified table for SPI/I2C
Is it something do able and testable in your environment? see [1], If yes, please create another patch for using unified table for both i2c and
spi.I have around a BMP390 with the SPI pins available to test it out. In the case
of the bmp280 we could unify theof_matchtable as they're almost the same. In
the case of thespi_device_idandi2c_device_idtables, as they're different structs I'm not sure if they can be unified.Quoted 5 lines
Regarding Andy's comment, I think he's referring to the duplicated chip infos.
In the case of the bmp280, thechip_infosare defined on the common driver code
and used for both SPI and I2C match tables.Hi,
Quoted 7 lines
I'm loosing track of where we are with this driver as multiple people are working on it.
Angel, as most of the work is yours, please could you manage the flow of patches
for this one so I get series with clear statement of what they are dependent on.
Sure. If Biju is okay with it, maybe I should squash toghether this two series of mine:
https://patchwork.kernel.org/project/linux-iio/cover/[email protected]/
https://patchwork.kernel.org/project/linux-iio/cover/[email protected]/
And pull this patch from Biju:
https://patchwork.kernel.org/project/linux-iio/patch/[email protected]/
Sorry again from the noise introduced in the mail-list,
Kind regards,
Angel
Quoted 15 lines
Thanks,
Jonathan
Quoted 10 lines
Quoted 6 lines
Cheers,
BijuKind regards,
Angel
RE: [PATCH v2 2/3] iio: pressure: bmp280: Use i2c_get_match_data
Hi Angel Iglesias,
Quoted 72 lines
Subject: Re: [PATCH v2 2/3] iio: pressure: bmp280: Use
i2c_get_match_dataQuoted 69 lines · Jonathan Cameron
Quoted 57 lines · On Mon, 14 Aug 2023 18:43:49 +0200 Angel Iglesias <[email protected]>…
Quoted 40 lines · Biju Das
Hi Angel Iglesias,
Quoted 36 lines
Subject: Re: [PATCH v2 2/3] iio: pressure: bmp280: Use
i2c_get_match_dataQuoted 23 lines · Angel Iglesias
Replaces
device_get_match_data()and fallbackmatch_idlogic by new unified helper functioni2c_get_match_data().Signed-off-by Angel Iglesias <[email protected]>(quoted diff) +0
-0b/drivers/iio/pressure/bmp280-
i2c.cindex693eb1975fdc..34e3bc758493
100644drivers/iio/pressure/bmp280-i2c.c +0
-0@@ -11,9 +11,7 @@ static int bmp280_i2c_probe(struct
i2c_client
*client)
const structbmp280_chip_info*chip_info;
struct regmap *regmap;- chip_info =
device_get_match_data(&client->dev); - if (!chip_info)
- chip_info = (const structbmp280_chip_info*)id->driver_data;
+ chip_info =i2c_get_match_data(client);Quoted 3 lines
regmap = devm_regmap_init_i2c(client,
chip_info->regmap_config);
if (IS_ERR(regmap)) {Hi,
I noticed I submitted this change that was also submitted by Biju Das on another
patch:Quoted 8 lines
Quoted 1 line
Should I drop this patch from the series?
I think it is ok. Andy is suggesting to use unified table for SPI/I2C
Is it something do able and testable in your environment? see [1], If yes, please create another patch for using unified table for both i2c and spi.
I have around a BMP390 with the SPI pins available to test it out. In the case of the bmp280 we could unify the
of_matchtable as they're almost the same.
In
the case of thespi_device_idandi2c_device_idtables, as they're different structs I'm not sure if they can be unified.Quoted 4 lines
Regarding Andy's comment, I think he's referring to the duplicated chip infos.
In the case of the bmp280, thechip_infosare defined on the common driver code and used for both SPI and I2C match tables.Hi,
I'm loosing track of where we are with this driver as multiple people are working on it.
Quoted 6 lines
Quoted 3 lines
Angel, as most of the work is yours, please could you manage the flow of patches for this one so I get series with clear statement of what they are dependent on.
Sure. If Biju is okay with it, maybe I should squash toghether this two series of mine:
I am ok with it, as I don't have bandwidth as well as board for testing it. Please feel free to post.
Cheers,
Biju
PATCH v2 3/3 iio: pressure: bmp280: Use spi_get_device_match_data()
In reply to Angel IglesiasUse the spi_get_device_match_data() helper instead of device_get_match_data() and the fallback match_id logic.
drivers/iio/pressure/bmp280-spi.c +1 -3
@@ -56,9 +56,7 @@ static int bmp280_spi_probe(struct spi_device *spi)return ret; } - chip_info =device_get_match_data (&spi->dev); -if (!chip_info) - chip_info = (const struct bmp280_chip_info *) id->driver_data; + chip_info =spi_get_device_match_data (spi); regmap = devm_regmap_init(&spi->dev, &bmp280_regmap_bus,
Signature · 1 line
2.41.0