summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>2023-10-16 19:10:03 +0300
committerLee Jones <lee@kernel.org>2023-11-01 11:29:22 +0000
commit54e657d604ae27a30ce4f84c243661d9b744bbce (patch)
treea24fb4629c3831debf5cb970fa463a46716ac178
parent5ac50ec712921f6250188732387bf5dac33736ae (diff)
downloadlwn-54e657d604ae27a30ce4f84c243661d9b744bbce.tar.gz
lwn-54e657d604ae27a30ce4f84c243661d9b744bbce.zip
leds: gpio: Move temporary variable for struct device to gpio_led_probe()
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> Link: https://lore.kernel.org/r/20231016161005.1471768-4-andriy.shevchenko@linux.intel.com Signed-off-by: Lee Jones <lee@kernel.org>
-rw-r--r--drivers/leds/leds-gpio.c19
1 files 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);
}