All of lore.kernel.org
 help / color / mirror / Atom feed
From: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
To: "Dmitry Torokhov" <dmitry.torokhov@gmail.com>,
	"Hans de Goede" <hdegoede@redhat.com>,
	"Linus Walleij" <linus.walleij@linaro.org>,
	"Bastien Nocera" <hadess@hadess.net>,
	"Sangwon Jee" <jeesw@melfas.com>,
	"Eugen Hristev" <eugen.hristev@collabora.com>,
	"Mika Penttilä" <mpenttil@redhat.com>,
	linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
	platform-driver-x86@vger.kernel.org
Cc: Andi Shyti <andi.shyti@kernel.org>,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>,
	Andy Shevchenko <andy.shevchenko@gmail.com>
Subject: [PATCH v4 13/24] Input: goodix - Simplify with dev_err_probe()
Date: Sun, 25 Jun 2023 18:28:06 +0200	[thread overview]
Message-ID: <20230625162817.100397-14-krzysztof.kozlowski@linaro.org> (raw)
In-Reply-To: <20230625162817.100397-1-krzysztof.kozlowski@linaro.org>

Common pattern of handling deferred probe can be simplified with
dev_err_probe().  Less code and also it prints the error value.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
---
 drivers/input/touchscreen/goodix.c | 40 ++++++++----------------------
 1 file changed, 11 insertions(+), 29 deletions(-)

diff --git a/drivers/input/touchscreen/goodix.c b/drivers/input/touchscreen/goodix.c
index f5aa240739f9..85d4249f1065 100644
--- a/drivers/input/touchscreen/goodix.c
+++ b/drivers/input/touchscreen/goodix.c
@@ -935,7 +935,6 @@ static int goodix_add_acpi_gpio_mappings(struct goodix_ts_data *ts)
  */
 static int goodix_get_gpio_config(struct goodix_ts_data *ts)
 {
-	int error;
 	struct device *dev;
 	struct gpio_desc *gpiod;
 	bool added_acpi_mappings = false;
@@ -951,33 +950,20 @@ static int goodix_get_gpio_config(struct goodix_ts_data *ts)
 	ts->gpiod_rst_flags = GPIOD_IN;
 
 	ts->avdd28 = devm_regulator_get(dev, "AVDD28");
-	if (IS_ERR(ts->avdd28)) {
-		error = PTR_ERR(ts->avdd28);
-		if (error != -EPROBE_DEFER)
-			dev_err(dev,
-				"Failed to get AVDD28 regulator: %d\n", error);
-		return error;
-	}
+	if (IS_ERR(ts->avdd28))
+		return dev_err_probe(dev, PTR_ERR(ts->avdd28), "Failed to get AVDD28 regulator\n");
 
 	ts->vddio = devm_regulator_get(dev, "VDDIO");
-	if (IS_ERR(ts->vddio)) {
-		error = PTR_ERR(ts->vddio);
-		if (error != -EPROBE_DEFER)
-			dev_err(dev,
-				"Failed to get VDDIO regulator: %d\n", error);
-		return error;
-	}
+	if (IS_ERR(ts->vddio))
+		return dev_err_probe(dev, PTR_ERR(ts->vddio), "Failed to get VDDIO regulator\n");
 
 retry_get_irq_gpio:
 	/* Get the interrupt GPIO pin number */
 	gpiod = devm_gpiod_get_optional(dev, GOODIX_GPIO_INT_NAME, GPIOD_IN);
-	if (IS_ERR(gpiod)) {
-		error = PTR_ERR(gpiod);
-		if (error != -EPROBE_DEFER)
-			dev_err(dev, "Failed to get %s GPIO: %d\n",
-				GOODIX_GPIO_INT_NAME, error);
-		return error;
-	}
+	if (IS_ERR(gpiod))
+		return dev_err_probe(dev, PTR_ERR(gpiod), "Failed to get %s GPIO\n",
+				     GOODIX_GPIO_INT_NAME);
+
 	if (!gpiod && has_acpi_companion(dev) && !added_acpi_mappings) {
 		added_acpi_mappings = true;
 		if (goodix_add_acpi_gpio_mappings(ts) == 0)
@@ -988,13 +974,9 @@ static int goodix_get_gpio_config(struct goodix_ts_data *ts)
 
 	/* Get the reset line GPIO pin number */
 	gpiod = devm_gpiod_get_optional(dev, GOODIX_GPIO_RST_NAME, ts->gpiod_rst_flags);
-	if (IS_ERR(gpiod)) {
-		error = PTR_ERR(gpiod);
-		if (error != -EPROBE_DEFER)
-			dev_err(dev, "Failed to get %s GPIO: %d\n",
-				GOODIX_GPIO_RST_NAME, error);
-		return error;
-	}
+	if (IS_ERR(gpiod))
+		return dev_err_probe(dev, PTR_ERR(gpiod), "Failed to get %s GPIO\n",
+				     GOODIX_GPIO_RST_NAME);
 
 	ts->gpiod_rst = gpiod;
 
-- 
2.34.1


  parent reply	other threads:[~2023-06-25 16:30 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-25 16:27 [PATCH v4 00/24] Input: Simplify with dev_err_probe() Krzysztof Kozlowski
2023-06-25 16:27 ` [PATCH v4 01/24] Input: gpio_keys_polled - " Krzysztof Kozlowski
2023-06-26  7:13   ` Linus Walleij
2023-06-25 16:27 ` [PATCH v4 02/24] Input: gpio-vibra " Krzysztof Kozlowski
2023-06-26  7:14   ` Linus Walleij
2023-06-25 16:27 ` [PATCH v4 03/24] Input: pwm-vibra " Krzysztof Kozlowski
2023-06-25 16:27 ` [PATCH v4 04/24] Input: rotary_encoder " Krzysztof Kozlowski
2023-06-25 16:27 ` [PATCH v4 05/24] Input: elan_i2c " Krzysztof Kozlowski
2023-06-25 16:27 ` [PATCH v4 06/24] Input: bu21013_ts " Krzysztof Kozlowski
2023-06-25 16:28 ` [PATCH v4 07/24] Input: bu21029_ts " Krzysztof Kozlowski
2023-06-25 16:28 ` [PATCH v4 08/24] Input: chipone_icn8318 " Krzysztof Kozlowski
2023-06-25 16:28 ` [PATCH v4 09/24] Input: cy8ctma140 " Krzysztof Kozlowski
2023-06-25 16:28 ` [PATCH v4 10/24] Input: edf-ft5x06 " Krzysztof Kozlowski
2023-06-25 16:28 ` [PATCH v4 11/24] Input: ektf2127 " Krzysztof Kozlowski
2023-06-25 16:28 ` [PATCH v4 12/24] Input: elants_i2c " Krzysztof Kozlowski
2023-06-25 16:28 ` Krzysztof Kozlowski [this message]
2023-06-25 16:28 ` [PATCH v4 14/24] Input: melfas_mip4 " Krzysztof Kozlowski
2023-06-25 16:28 ` [PATCH v4 15/24] Input: pixcir_i2c_ts " Krzysztof Kozlowski
2023-06-25 16:28 ` [PATCH v4 16/24] Input: raydium_i2c_ts " Krzysztof Kozlowski
2023-06-25 16:28 ` [PATCH v4 17/24] Input: resistive-adc-touch " Krzysztof Kozlowski
2023-06-25 16:28 ` [PATCH v4 18/24] Input: silead " Krzysztof Kozlowski
2023-06-25 16:28 ` [PATCH v4 19/24] Input: sis_i2c " Krzysztof Kozlowski
2023-06-25 16:28 ` [PATCH v4 20/24] Input: surface3_spi " Krzysztof Kozlowski
2023-06-25 16:28 ` [PATCH v4 21/24] Input: sx8643 " Krzysztof Kozlowski
2023-06-25 16:28 ` [PATCH v4 22/24] Input: bcm-keypad " Krzysztof Kozlowski
2023-06-26 13:05   ` Dan Carpenter
2023-06-27  8:57     ` Krzysztof Kozlowski
2023-06-27 10:01       ` Dan Carpenter
2023-06-27 10:35         ` Krzysztof Kozlowski
2023-06-27 10:46           ` Dan Carpenter
2023-06-25 16:28 ` [PATCH v4 23/24] Input: bu21013_ts - Use local 'client->dev' variable in probe() Krzysztof Kozlowski
2023-06-25 16:28 ` [PATCH v4 24/24] Input: bu21029_ts " Krzysztof Kozlowski
2023-07-07 23:58 ` [PATCH v4 00/24] Input: Simplify with dev_err_probe() Dmitry Torokhov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230625162817.100397-14-krzysztof.kozlowski@linaro.org \
    --to=krzysztof.kozlowski@linaro.org \
    --cc=andi.shyti@kernel.org \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=eugen.hristev@collabora.com \
    --cc=hadess@hadess.net \
    --cc=hdegoede@redhat.com \
    --cc=jeesw@melfas.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mpenttil@redhat.com \
    --cc=platform-driver-x86@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.