iio: pressure: bmp280: Use i2c_get_match_data()
cover iio: pressure: bmp280: Use i2c_get_match_data()
Minor cleanup of BMP280 i2c code and migration to the new helper function i2c_get_match_data() instead of device_get_match_data().
Patch 1 reorders local variable declarations on probe function following the reverse xmas tree to unify styles with other parts of the driver.
Patch 2 ports adtops the i2c_get_match_data() helper on the i2c probe.
Angel Iglesias (2):
iio: pressure: bmp280: i2c: Rearrange vars in reverse xmas tree order
iio: pressure: bmp280: Use i2c_get_match_data
drivers/iio/pressure/bmp280-i2c.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
base-commit: 6d9c5ae6a70c9e1017a7a252bc730d9168e219ce
Signature · 1 line
2.41.0
PATCH 1/2 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-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)
Signature · 1 line
2.41.0
Re: [PATCH 1/2] iio: pressure: bmp280: i2c: Rearrange vars in reverse xmas tree order
Quoted 2 lines · Angel Iglesias
Minor cleanup reordering local variable declarations following reverse christmas tree convention.
What about other functions there? Are all of them ordered correctly?
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH 1/2] iio: pressure: bmp280: i2c: Rearrange vars in reverse xmas tree order
Quoted 6 lines · Andy Shevchenko
Quoted 2 lines · Angel Iglesias
Minor cleanup reordering local variable declarations following reverse christmas tree convention.
What about other functions there? Are all of them ordered correctly?
This one was a leftover from previous work I did on this driver. I will check the rest of the drive and update it to follow the same convention if required. Thank you for your time.
Kind regards
Angel
PATCH 2/2 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 +2 -2
@@ -11,9 +11,9 @@ 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); + chip_info =i2c_get_match_data (client);if (!chip_info) - chip_info = (const struct bmp280_chip_info *) id->driver_data; +return -ENODEV ; regmap =devm_regmap_init_i2c (client, chip_info->regmap_config);if (IS_ERR (regmap)) {
Signature · 1 line
2.41.0
Re: [PATCH 2/2] iio: pressure: bmp280: Use i2c_get_match_data
Quoted 10 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-i2c.c +0
-0
drivers/iio/pressure/bmp280-i2c.c static int bmp280_i2c_probe(struct i2c_client *client) · line 16
Quoted 8 lines
drivers/iio/pressure/bmp280-i2c.c +2
-2@@ -11,9 +11,9 @@ 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); + chip_info =i2c_get_match_data (client);if (!chip_info) - chip_info = (const struct bmp280_chip_info *) id->driver_data; +return -ENODEV ;
the old code assumed that chip_info isn't NULL (implicitly by dereferencing that pointer in the line below). I wouldn't change semantics in a patch converting to a helper and so just do:
- chip_info = device_get_match_data(&client->dev);
+ chip_info = i2c_get_match_data(client);
- if (!chip_info)
- chip_info = (const struct bmp280_chip_info *) id->driver_data;
or alternatively, if you think adding a check is a good idea, add an error message in the error path and mention the semantic change in the commit log.
Best regards
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-König | Industrial Linux Solutions | https://www.pengutronix.de/ |
Re: [PATCH 2/2] iio: pressure: bmp280: Use i2c_get_match_data
Quoted 26 lines · Uwe Kleine-König
Quoted 18 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-i2c.c +0
-0@@ -11,9 +11,9 @@ 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); + chip_info =i2c_get_match_data(client);
if (!chip_info)
- chip_info = (const structbmp280_chip_info*) id-Quoted 2 lines
Quoted 1 line
driver_data;+ return
-ENODEV;the old code assumed that
chip_infoisn't NULL (implicitly by dereferencing that pointer in the line below). I wouldn't change semantics in a patch converting to a helper and so just do:
Quoted 9 lines
- chip_info =
device_get_match_data(&client->dev);
+ chip_info =i2c_get_match_data(client);
- if (!chip_info)
- chip_info = (const structbmp280_chip_info*)id->driver_data;or alternatively, if you think adding a check is a good idea, add an error message in the error path and mention the semantic change in the commit log.
Oh I see. I didn't take into account all this. Thanks for your time
Quoted 3 lines
Best regards
Uwe
Kind regards
Angel