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 4/6] leds: gpio: Move temporary variable for struct device to gpio_led_probe()
Date: Mon, 16 Oct 2023 19:10:03 +0300 [thread overview]
Message-ID: <20231016161005.1471768-4-andriy.shevchenko@linux.intel.com> (raw)
In-Reply-To: <20231016161005.1471768-1-andriy.shevchenko@linux.intel.com>
Use temporary variable for struct device in gpio_led_probe() in order
to make code neater.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/leds/leds-gpio.c | 19 ++++++++-----------
1 file changed, 8 insertions(+), 11 deletions(-)
diff --git a/drivers/leds/leds-gpio.c b/drivers/leds/leds-gpio.c
index 7c9c6a93dfd7..fd3f90f95fa2 100644
--- a/drivers/leds/leds-gpio.c
+++ b/drivers/leds/leds-gpio.c
@@ -142,9 +142,8 @@ struct gpio_leds_priv {
struct gpio_led_data leds[] __counted_by(num_leds);
};
-static struct gpio_leds_priv *gpio_leds_create(struct platform_device *pdev)
+static struct gpio_leds_priv *gpio_leds_create(struct device *dev)
{
- struct device *dev = &pdev->dev;
struct fwnode_handle *child;
struct gpio_leds_priv *priv;
int count, ret;
@@ -253,13 +252,13 @@ static struct gpio_desc *gpio_led_get_gpiod(struct device *dev, int idx,
static int gpio_led_probe(struct platform_device *pdev)
{
- struct gpio_led_platform_data *pdata = dev_get_platdata(&pdev->dev);
+ struct device *dev = &pdev->dev;
+ struct gpio_led_platform_data *pdata = dev_get_platdata(dev);
struct gpio_leds_priv *priv;
int i, ret = 0;
if (pdata && pdata->num_leds) {
- priv = devm_kzalloc(&pdev->dev, struct_size(priv, leds, pdata->num_leds),
- GFP_KERNEL);
+ priv = devm_kzalloc(dev, struct_size(priv, leds, pdata->num_leds), GFP_KERNEL);
if (!priv)
return -ENOMEM;
@@ -272,22 +271,20 @@ static int gpio_led_probe(struct platform_device *pdev)
led_dat->gpiod = template->gpiod;
else
led_dat->gpiod =
- gpio_led_get_gpiod(&pdev->dev,
- i, template);
+ gpio_led_get_gpiod(dev, i, template);
if (IS_ERR(led_dat->gpiod)) {
- dev_info(&pdev->dev, "Skipping unavailable LED gpio %d (%s)\n",
+ dev_info(dev, "Skipping unavailable LED gpio %d (%s)\n",
template->gpio, template->name);
continue;
}
- ret = create_gpio_led(template, led_dat,
- &pdev->dev, NULL,
+ ret = create_gpio_led(template, led_dat, dev, NULL,
pdata->gpio_blink_set);
if (ret < 0)
return ret;
}
} else {
- priv = gpio_leds_create(pdev);
+ priv = gpio_leds_create(dev);
if (IS_ERR(priv))
return PTR_ERR(priv);
}
--
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 ` [PATCH v1 2/6] leds: gpio: Utilise PTR_ERR_OR_ZERO() Andy Shevchenko
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 ` Andy Shevchenko [this message]
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-4-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