diff options
author | Marek BehĂșn <[email protected]> | 2020-09-18 00:33:25 +0200 |
---|---|---|
committer | Pavel Machek <[email protected]> | 2020-09-26 21:56:41 +0200 |
commit | 19d4deb7b24024fa01c6dcaa781b9e508d4f09c0 (patch) | |
tree | 26c30ae8bae1d45bf6dd1c702bcea9933126ccdf | |
parent | 40f97281ff0540d43d3d0343d74a8e96573ed227 (diff) |
leds: ns2: alloc simple array instead of struct ns2_led_priv
Since .remove method is not needed now that we use devres, there is no
need to remember the number of LEDs in struct ns2_led_priv. Alloc simple
array of ns2_led_data structs.
Signed-off-by: Marek BehĂșn <[email protected]>
Cc: Simon Guinot <[email protected]>
Cc: Simon Guinot <[email protected]>
Cc: Vincent Donnefort <[email protected]>
Cc: Thomas Petazzoni <[email protected]>
Cc: Linus Walleij <[email protected]>
Signed-off-by: Pavel Machek <[email protected]>
-rw-r--r-- | drivers/leds/leds-ns2.c | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/drivers/leds/leds-ns2.c b/drivers/leds/leds-ns2.c index 1a7ef66464b5..8cd020b34084 100644 --- a/drivers/leds/leds-ns2.c +++ b/drivers/leds/leds-ns2.c @@ -334,15 +334,10 @@ static const struct of_device_id of_ns2_leds_match[] = { MODULE_DEVICE_TABLE(of, of_ns2_leds_match); #endif /* CONFIG_OF_GPIO */ -struct ns2_led_priv { - int num_leds; - struct ns2_led_data leds_data[]; -}; - static int ns2_led_probe(struct platform_device *pdev) { struct ns2_led_platform_data *pdata = dev_get_platdata(&pdev->dev); - struct ns2_led_priv *priv; + struct ns2_led_data *leds; int i; int ret; @@ -363,20 +358,18 @@ static int ns2_led_probe(struct platform_device *pdev) return -EINVAL; #endif /* CONFIG_OF_GPIO */ - priv = devm_kzalloc(&pdev->dev, struct_size(priv, leds_data, pdata->num_leds), GFP_KERNEL); - if (!priv) + leds = devm_kzalloc(&pdev->dev, array_size(sizeof(*leds), + pdata->num_leds), + GFP_KERNEL); + if (!leds) return -ENOMEM; - priv->num_leds = pdata->num_leds; - for (i = 0; i < priv->num_leds; i++) { - ret = create_ns2_led(pdev, &priv->leds_data[i], - &pdata->leds[i]); + for (i = 0; i < pdata->num_leds; i++) { + ret = create_ns2_led(pdev, &leds[i], &pdata->leds[i]); if (ret < 0) return ret; } - platform_set_drvdata(pdev, priv); - return 0; } |