iio: pressure: bmp280: GPIO error handling and cleanup
v3 cover iio: pressure: bmp280: GPIO error handling and cleanup
Hi all,
This patch series improves the GPIO handling in the bmp280 driver.
Changes in v3:
- Split into two separate patches, as suggested by Andy Shevchenko.
- Improve the error message to "failed to get reset GPIO", as suggested by David Lechner.
- Add Fixes and Cc tags where appropriate, as suggested by Markus Elfring.
Changes in v2:
- Use IS_ERR() instead of IS_ERR_OR_NULL()
- Drop dev_info()
- Use gpiod_set_value_cansleep()
- Improve commit title and message
Salah Triki (2):
iio: pressure: bmp280: Use IS_ERR() in bmp280_common_probe()
iio: pressure: bmp280: Use gpiod_set_value_cansleep()
drivers/iio/pressure/bmp280-core.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
Signature · 1 line
2.43.0
PATCH v3 1/2 iio: pressure: bmp280: Use IS_ERR() in bmp280_common_probe()
devm_gpiod_get_optional() may return non-NULL error pointer on failure. Check its return value using IS_ERR() and propagate the error if necessary.
--- drivers/iio/pressure/bmp280-core.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/iio/pressure/bmp280-core.c +5 -4
@@ -3213,11 +3213,12 @@ int bmp280_common_probe(struct device *dev,/* Bring chip out of reset if there is an assigned GPIO line */ gpiod =devm_gpiod_get_optional (dev,"reset" ,GPIOD_OUT_HIGH ); +if (IS_ERR (gpiod)) +return dev_err_probe (dev,PTR_ERR (gpiod),"failed to get reset GPIO\n" ); +/* Deassert the signal */ -if (gpiod) { -dev_info (dev,"release reset\n" ); -gpiod_set_value (gpiod,0 ); - } +dev_info (dev,"release reset\n" ); +gpiod_set_value (gpiod,0 ); data->regmap = regmap;
Signature · 1 line
2.43.0
PATCH v3 2/2 iio: pressure: bmp280: Use gpiod_set_value_cansleep()
In reply to Salah TrikiSwitch to gpiod_set_value_cansleep(), which is safe to use in sleepable contexts like the driver probe function.
The dev_info() call has been removed as it was considered noisy and is not necessary for normal driver operation.
--- drivers/iio/pressure/bmp280-core.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/iio/pressure/bmp280-core.c +1 -2
@@ -3217,8 +3217,7 @@ int bmp280_common_probe(struct device *dev,return dev_err_probe (dev,PTR_ERR (gpiod),"failed to get reset GPIO\n" );/* Deassert the signal */ -dev_info (dev,"release reset\n" ); -gpiod_set_value (gpiod,0 ); +gpiod_set_value_cansleep (gpiod,0 ); data->regmap = regmap;
Signature · 1 line
2.43.0
Re: [PATCH v3 2/2] iio: pressure: bmp280: Use gpiod_set_value_cansleep()
Quoted 5 lines
Switch to
gpiod_set_value_cansleep(), which is safe to use in sleepable contexts like the driver probe function.The
dev_info()call has been removed as it was considered noisy and is not necessary for normal driver operation.
Should such a change combination be reconsidered once more?
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.17-rc1#n81
Regards,
Markus
Quoted 3 lines · Salah Triki
Hi all,
This patch series improves the GPIO handling in the bmp280 driver.
Is this similar to what I just reviewed? I'm sorry I got lost. But if it's different, it needs to be amended in the same way.
Signature · 2 lines
With Best Regards, Andy Shevchenko