From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Pavel Machek <pavel@ucw.cz>, Lee Jones <lee@kernel.org>
Subject: [PATCH v1 2/6] leds: gpio: Utilise PTR_ERR_OR_ZERO()
Date: Mon, 16 Oct 2023 19:10:01 +0300 [thread overview]
Message-ID: <20231016161005.1471768-2-andriy.shevchenko@linux.intel.com> (raw)
In-Reply-To: <20231016161005.1471768-1-andriy.shevchenko@linux.intel.com>
Avoid a boilerplate code by using PTR_ERR_OR_ZERO() in create_gpio_led().
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/leds/leds-gpio.c | 17 +++++++----------
1 file changed, 7 insertions(+), 10 deletions(-)
diff --git a/drivers/leds/leds-gpio.c b/drivers/leds/leds-gpio.c
index debadb48ceda..4071cb9eefec 100644
--- a/drivers/leds/leds-gpio.c
+++ b/drivers/leds/leds-gpio.c
@@ -125,16 +125,13 @@ static int create_gpio_led(const struct gpio_led *template,
return ret;
pinctrl = devm_pinctrl_get_select_default(led_dat->cdev.dev);
- if (IS_ERR(pinctrl)) {
- ret = PTR_ERR(pinctrl);
- if (ret != -ENODEV) {
- dev_warn(led_dat->cdev.dev,
- "Failed to select %pfw pinctrl: %d\n",
- fwnode, ret);
- } else {
- /* pinctrl-%d not present, not an error */
- ret = 0;
- }
+ ret = PTR_ERR_OR_ZERO(pinctrl);
+ /* pinctrl-%d not present, not an error */
+ if (ret == -ENODEV)
+ ret = 0;
+ if (ret) {
+ dev_warn(led_dat->cdev.dev, "Failed to select %pfw pinctrl: %d\n",
+ fwnode, ret);
}
return ret;
--
2.40.0.1.gaa8946217a0b
next prev parent reply other threads:[~2023-10-16 16:10 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-16 16:10 [PATCH v1 1/6] leds: gpio: Keep driver firmware interface agnostic Andy Shevchenko
2023-10-16 16:10 ` Andy Shevchenko [this message]
2023-10-16 16:10 ` [PATCH v1 3/6] leds: gpio: Refactor code to use devm_gpiod_get_index_optional() Andy Shevchenko
2023-10-16 16:10 ` [PATCH v1 4/6] leds: gpio: Move temporary variable for struct device to gpio_led_probe() Andy Shevchenko
2023-10-16 16:10 ` [PATCH v1 5/6] leds: gpio: Remove unneeded assignment Andy Shevchenko
2023-10-16 16:10 ` [PATCH v1 6/6] leds: gpio: Update headers Andy Shevchenko
2023-10-19 12:26 ` [PATCH v1 1/6] leds: gpio: Keep driver firmware interface agnostic Lee Jones
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=20231016161005.1471768-2-andriy.shevchenko@linux.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=lee@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-leds@vger.kernel.org \
--cc=pavel@ucw.cz \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox