[openwrt/openwrt] ath79: gpio-latch-mikrotik: use dev_err_probe

LEDE Commits lede-commits at lists.infradead.org
Wed Sep 25 13:57:01 PDT 2024


robimarko pushed a commit to openwrt/openwrt.git, branch main:
https://git.openwrt.org/1e8dde776a25f2bedaf530f13ac8c45a18d47d00

commit 1e8dde776a25f2bedaf530f13ac8c45a18d47d00
Author: Rosen Penev <rosenp at gmail.com>
AuthorDate: Wed Aug 14 18:45:55 2024 -0700

    ath79: gpio-latch-mikrotik: use dev_err_probe
    
    It automatically adds the error code at the end of the message. It also
    deals with -EPROBE_DEFER automatically (doesn't output). Simpler code.
    
    Signed-off-by: Rosen Penev <rosenp at gmail.com>
    Link: https://github.com/openwrt/openwrt/pull/16350
    Signed-off-by: Robert Marko <robimarko at gmail.com>
---
 .../ath79/files/drivers/gpio/gpio-latch-mikrotik.c | 27 +++++++---------------
 1 file changed, 8 insertions(+), 19 deletions(-)

diff --git a/target/linux/ath79/files/drivers/gpio/gpio-latch-mikrotik.c b/target/linux/ath79/files/drivers/gpio/gpio-latch-mikrotik.c
index 8f53974e46..80c3cc6748 100644
--- a/target/linux/ath79/files/drivers/gpio/gpio-latch-mikrotik.c
+++ b/target/linux/ath79/files/drivers/gpio/gpio-latch-mikrotik.c
@@ -121,24 +121,19 @@ static int gpio_latch_probe(struct platform_device *pdev)
 	mutex_init(&glc->latch_mutex);
 
 	n = gpiod_count(dev, NULL);
-	if (n <= 0) {
-		dev_err(dev, "failed to get gpios: %d\n", n);
-		return n;
-	} else if (n != GPIO_LATCH_LINES) {
-		dev_err(dev, "expected %d gpios\n", GPIO_LATCH_LINES);
+	if (n <= 0)
+		return dev_err_probe(dev, n, "failed to get gpios");
+	if (n != GPIO_LATCH_LINES) {
+		dev_err(dev, "expected %d gpios", GPIO_LATCH_LINES);
 		return -EINVAL;
 	}
 
 	for (i = 0; i < n; i++) {
 		glc->gpios[i] = devm_gpiod_get_index_optional(dev, NULL, i,
 			GPIOD_OUT_LOW);
-		if (IS_ERR(glc->gpios[i])) {
-			if (PTR_ERR(glc->gpios[i]) != -EPROBE_DEFER) {
-				dev_err(dev, "failed to get gpio %d: %ld\n", i,
-					PTR_ERR(glc->gpios[i]));
-			}
-			return PTR_ERR(glc->gpios[i]);
-		}
+		if (IS_ERR(glc->gpios[i]))
+			return dev_err_probe(dev, PTR_ERR(glc->gpios[i]),
+					     "failed to get gpio %d", i);
 	}
 
 	glc->le_gpio = 8;
@@ -162,13 +157,7 @@ static int gpio_latch_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, glc);
 
-	i = gpiochip_add(&glc->gc);
-	if (i) {
-		dev_err(dev, "gpiochip_add() failed: %d\n", i);
-		return i;
-	}
-
-	return 0;
+	return gpiochip_add(&glc->gc);
 }
 
 static int gpio_latch_remove(struct platform_device *pdev)




More information about the lede-commits mailing list