media: i2c: propagate GPIO errors
Subsystems (5)
cover media: i2c: propagate GPIO errors
From: bui duc phuc <[email protected]>
Hi all,
Some drivers use devm_gpiod_get_optional(), but do not properly handle errors returned by the GPIO lookup.
This series fixes the error handling in three drivers by propagating the errors returned by devm_gpiod_get_optional().
Compile-tested only.
Best regards,
Phuc
bui duc phuc (3):
media: i2c: ov2685: propagate reset GPIO errors
media: i2c: ov2732: propagate GPIO errors
media: i2c: ov5647: propagate pwdn GPIO errors
drivers/media/i2c/ov2685.c | 7 +++---- drivers/media/i2c/ov2732.c | 6 ++++++ drivers/media/i2c/ov5647.c | 7 +++---- 3 files changed, 12 insertions(+), 8 deletions(-)
Signature · 1 line
2.43.0
PATCH 1/3 media: i2c: ov2685: propagate reset GPIO errors
From: bui duc phuc <[email protected]>
devm_gpiod_get_optional() may return -EPROBE_DEFER or other errors, but ov2685_probe() currently converts them all to -EINVAL.
Use dev_err_probe() to propagate the original error from the reset GPIO lookup.
--- drivers/media/i2c/ov2685.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/media/i2c/ov2685.c +3 -4
@@ -793,10 +793,9 @@ static int ov2685_probe(struct i2c_client *client)dev_warn (dev,"xvclk mismatched, modes are based on 24MHz\n" ); ov2685->reset_gpio =devm_gpiod_get_optional (dev,"reset" ,GPIOD_OUT_LOW ); -if (IS_ERR (ov2685->reset_gpio)) { -dev_err (dev,"Failed to get reset-gpios\n" ); -return -EINVAL ; - } +if (IS_ERR (ov2685->reset_gpio)) +return dev_err_probe (dev,PTR_ERR (ov2685->reset_gpio), +"Failed to get reset-gpios\n" ); ret =ov2685_configure_regulators (ov2685);if (ret) {
Signature · 1 line
2.43.0
PATCH 2/3 media: i2c: ov2732: propagate GPIO errors
In reply to [email protected]From: bui duc phuc <[email protected]>
devm_gpiod_get_optional() returns NULL when an optional GPIO is not present, but may return -EPROBE_DEFER or other errors.
Check the return values and propagate errors from the powerdown and reset GPIO lookups.
--- drivers/media/i2c/ov2732.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/media/i2c/ov2732.c +6 -0
@@ -665,9 +665,15 @@ static int ov2732_probe(struct i2c_client *client) ov2732->powerdown_gpio =devm_gpiod_get_optional (ov2732->dev,"powerdown" ,GPIOD_OUT_HIGH ); +if (IS_ERR (ov2732->powerdown_gpio)) +return dev_err_probe (ov2732->dev,PTR_ERR (ov2732->powerdown_gpio), +"failed to get powerdown GPIO\n" ); ov2732->reset_gpio =devm_gpiod_get_optional (ov2732->dev,"reset" ,GPIOD_OUT_HIGH ); +if (IS_ERR (ov2732->reset_gpio)) +return dev_err_probe (ov2732->dev,PTR_ERR (ov2732->reset_gpio), +"failed to get reset GPIO\n" ); ov2732->regmap =devm_cci_regmap_init_i2c (client,16 );if (IS_ERR (ov2732->regmap))
Signature · 1 line
2.43.0
PATCH 3/3 media: i2c: ov5647: propagate pwdn GPIO errors
In reply to [email protected]From: bui duc phuc <[email protected]>
devm_gpiod_get_optional() may return -EPROBE_DEFER or other errors, but ov5647_probe() currently converts them to -EINVAL.
Use dev_err_probe() to propagate the original error from the pwdn GPIO lookup.
--- drivers/media/i2c/ov5647.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/media/i2c/ov5647.c +3 -4
@@ -1186,10 +1186,9 @@ static int ov5647_probe(struct i2c_client *client)/* Request the power down GPIO asserted. */ sensor->pwdn =devm_gpiod_get_optional (dev,"pwdn" ,GPIOD_OUT_HIGH ); -if (IS_ERR (sensor->pwdn)) { -dev_err (dev,"Failed to get 'pwdn' gpio\n" ); -return -EINVAL ; - } +if (IS_ERR (sensor->pwdn)) +return dev_err_probe (dev,PTR_ERR (sensor->pwdn), +"Failed to get 'pwdn' gpio\n" ); ret =ov5647_configure_regulators (dev, sensor);if (ret)
Signature · 1 line
2.43.0
Re: [PATCH 3/3] media: i2c: ov5647: propagate pwdn GPIO errors
Quoted 11 lines · On Wed, 7 Oct 2026 at 11:50, <[email protected]> wrote:
From: bui duc phuc <[email protected]>
devm_gpiod_get_optional()may return -EPROBE_DEFER or other errors, butov5647_probe()currently converts them to-EINVAL.Use
dev_err_probe()to propagate the original error from the pwdn GPIO lookup.Fixes b050791d287a ("media: ov5647: Add support for PWDN GPIO.")Signed-off-by bui duc phuc <[email protected]>
Thanks for the patch.
Quoted 25 lines
--- drivers/media/i2c/ov5647.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)drivers/media/i2c/ov5647.c +3
-5@@ -1186,10 +1186,9 @@ static int ov5647_probe(struct i2c_client *client)/* Request the power down GPIO asserted. */ sensor->pwdn =devm_gpiod_get_optional (dev,"pwdn" ,GPIOD_OUT_HIGH ); -if (IS_ERR (sensor->pwdn)) { -dev_err (dev,"Failed to get 'pwdn' gpio\n" ); -return -EINVAL ; - } +if (IS_ERR (sensor->pwdn)) +return dev_err_probe (dev,PTR_ERR (sensor->pwdn), +"Failed to get 'pwdn' gpio\n" ); ret =ov5647_configure_regulators (dev, sensor);if (ret) --2.43.0