Skip to contentSkip to conversation

drm/panel: Use dev_err_probe() to simplify code

PATCH Applied Yuan Can 2 participants 6 messages Sep 29, 2022 – Sep 30, 2022

Subsystems (4)
lore
Share & tools
lore

Yuan Can

author
#0 lore raw

v2 cover drm/panel: Use dev_err_probe() to simplify code

This series contains two patchs simplify the error handling in probe function by switching from dev_err() to dev_err_probe().
---
changes in v2:
- simplify the same case in panel_edp_probe
- add Reviewed-by from Douglas Anderson

Yuan Can (2):
drm/panel: panel-edp: Use dev_err_probe() to simplify code drm/panel: simple: Use dev_err_probe() to simplify code

 drivers/gpu/drm/panel/panel-edp.c    | 22 ++++++----------------
 drivers/gpu/drm/panel/panel-simple.c |  9 +++------
 2 files changed, 9 insertions(+), 22 deletions(-)
Signature · 1 line
2.17.1
author
#1 lore raw

PATCH v2 1/2 drm/panel: panel-edp: Use dev_err_probe() to simplify code

In the probe path, dev_err() can be replaced with dev_err_probe() which will check if error code is -EPROBE_DEFER and prints the error name. It also sets the defer probe reason which can be checked later through debugfs.

---
 drivers/gpu/drm/panel/panel-edp.c | 22 ++++++----------------
 1 file changed, 6 insertions(+), 16 deletions(-)
drivers/gpu/drm/panel/panel-edp.c +6 -16
index 7b90016b8408..e323a6331143 100644
@@ -403,17 +403,10 @@ static int panel_edp_unprepare(struct drm_panel *panel)
 
 static int panel_edp_get_hpd_gpio(struct device *dev, struct panel_edp *p)
 {
-	int err;
-
 	p->hpd_gpio = devm_gpiod_get_optional(dev, "hpd", GPIOD_IN);
-	if (IS_ERR(p->hpd_gpio)) {
-		err = PTR_ERR(p->hpd_gpio);
-
-		if (err != -EPROBE_DEFER)
-			dev_err(dev, "failed to get 'hpd' GPIO: %d\n", err);
-
-		return err;
-	}
+	if (IS_ERR(p->hpd_gpio))
+		return dev_err_probe(dev, PTR_ERR(p->hpd_gpio),
+				     "failed to get 'hpd' GPIO\n");
 
 	return 0;
 }
@@ -832,12 +825,9 @@ static int panel_edp_probe(struct device *dev, const struct panel_desc *desc,
 
 	panel->enable_gpio = devm_gpiod_get_optional(dev, "enable",
 						     GPIOD_OUT_LOW);
-	if (IS_ERR(panel->enable_gpio)) {
-		err = PTR_ERR(panel->enable_gpio);
-		if (err != -EPROBE_DEFER)
-			dev_err(dev, "failed to request GPIO: %d\n", err);
-		return err;
-	}
+	if (IS_ERR(panel->enable_gpio))
+		return dev_err_probe(dev, PTR_ERR(panel->enable_gpio),
+				     "failed to request GPIO\n");
 
 	err = of_drm_get_panel_orientation(dev->of_node, &panel->orientation);
 	if (err) {
Signature · 1 line
2.17.1
reviewer Applied
#2 lore raw

Re: [PATCH v2 1/2] drm/panel: panel-edp: Use dev_err_probe() to simplify code

Hi,

Quoted 11 lines · Yuan Can

In the probe path, dev_err() can be replaced with dev_err_probe() which will check if error code is -EPROBE_DEFER and prints the error name. It also sets the defer probe reason which can be checked later through debugfs.

---
 drivers/gpu/drm/panel/panel-edp.c | 22 ++++++----------------
 1 file changed, 6 insertions(+), 16 deletions(-)

Pushed to drm-misc-next:

b28d204a7c19 drm/panel: panel-edp: Use dev_err_probe() to simplify code

author
#3 lore raw

PATCH v2 2/2 drm/panel: simple: Use dev_err_probe() to simplify code

In reply to Yuan Can

In the probe path, dev_err() can be replaced with dev_err_probe() which will check if error code is -EPROBE_DEFER and prints the error name. It also sets the defer probe reason which can be checked later through debugfs.

---
 drivers/gpu/drm/panel/panel-simple.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/gpu/drm/panel/panel-simple.c +3 -6
index 0cb3be26e2e6..1607824dc2b3 100644
@@ -575,12 +575,9 @@ static int panel_simple_probe(struct device *dev, const struct panel_desc *desc)
 
 	panel->enable_gpio = devm_gpiod_get_optional(dev, "enable",
 						     GPIOD_OUT_LOW);
-	if (IS_ERR(panel->enable_gpio)) {
-		err = PTR_ERR(panel->enable_gpio);
-		if (err != -EPROBE_DEFER)
-			dev_err(dev, "failed to request GPIO: %d\n", err);
-		return err;
-	}
+	if (IS_ERR(panel->enable_gpio))
+		return dev_err_probe(dev, PTR_ERR(panel->enable_gpio),
+				     "failed to request GPIO\n");
 
 	err = of_drm_get_panel_orientation(dev->of_node, &panel->orientation);
 	if (err) {
Signature · 1 line
2.17.1
reviewer Applied
#4 lore raw

Re: [PATCH v2 2/2] drm/panel: simple: Use dev_err_probe() to simplify code

Hi,

Quoted 11 lines · Yuan Can

In the probe path, dev_err() can be replaced with dev_err_probe() which will check if error code is -EPROBE_DEFER and prints the error name. It also sets the defer probe reason which can be checked later through debugfs.

---
 drivers/gpu/drm/panel/panel-simple.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

Pushed to drm-misc-next:

c9b48b91e2fb drm/panel: simple: Use dev_err_probe() to simplify code

For the other patches in your original series, I'll assume folks paying more attention to those panel drivers will commit them. If they totally stall for a while, though, then yell and I can try taking a look at them. :-)

-Doug

author
#5 lore raw

Re: [PATCH v2 2/2] drm/panel: simple: Use dev_err_probe() to simplify code

Quoted 13 lines · Doug Anderson

Hi,

Quoted 10 lines · Yuan Can

In the probe path, dev_err() can be replaced with dev_err_probe() which will check if error code is -EPROBE_DEFER and prints the error name. It also sets the defer probe reason which can be checked later through debugfs.

---
  drivers/gpu/drm/panel/panel-simple.c | 9 +++------
  1 file changed, 3 insertions(+), 6 deletions(-)
Quoted 8 lines

Pushed to drm-misc-next:

c9b48b91e2fb drm/panel: simple: Use dev_err_probe() to simplify code

For the other patches in your original series, I'll assume folks paying more attention to those panel drivers will commit them. If they totally stall for a while, though, then yell and I can try taking a look at them. :-)

That's great, Thanks!😁

Signature · 2 lines
Best regards,
Yuan Can