Skip to contentSkip to conversation

media: i2c: propagate GPIO errors

PATCH In review [email protected] 2 participants 5 messages Oct 7

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

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
#1 lore raw

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.

Fixes 0482fbb1c1cc ("media: i2c: ov2685: Make reset gpio optional")
Fixes e3861d9118c8 ("media: ov2685: add support for OV2685 sensor")
---
 drivers/media/i2c/ov2685.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/media/i2c/ov2685.c +3 -4
index 4911a4eea126..92d0f90b3d37 100644
@@ -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
#2 lore raw

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.

Fixes 247b8b855876 ("media: i2c: Add ov2732 image sensor driver")
---
 drivers/media/i2c/ov2732.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/media/i2c/ov2732.c +6 -0
index 40035320fec6..b8009c392d4d 100644
@@ -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
#3 lore raw

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.

Fixes b050791d287a ("media: ov5647: Add support for PWDN GPIO.")
---
 drivers/media/i2c/ov5647.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/media/i2c/ov5647.c +3 -4
index 3facf92b3841..b3049761a5fb 100644
@@ -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
maintainer Reviewed-by on v1 3/3
#4 lore raw

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, but ov5647_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.")

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
index 3facf92b3841..b3049761a5fb 100644
@@ -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