diff options
author | Marek BehĂșn <marek.behun@nic.cz> | 2020-09-18 00:33:26 +0200 |
---|---|---|
committer | Pavel Machek <pavel@ucw.cz> | 2020-09-26 21:56:41 +0200 |
commit | 01d0b14d0e52d74ff7e0fc9b39c13be04acf27dd (patch) | |
tree | 794fa959cb9bd8ce17dd45a2af2aa773bf281a88 /drivers/leds | |
parent | leds: ns2: alloc simple array instead of struct ns2_led_priv (diff) | |
download | linux-01d0b14d0e52d74ff7e0fc9b39c13be04acf27dd.tar.xz linux-01d0b14d0e52d74ff7e0fc9b39c13be04acf27dd.zip |
leds: ns2: support OF probing only, forget platdata
Move forward from platform data to device tree only.
Since commit c7896490dd1a ("leds: ns2: Absorb platform data") the
platform data structure is absorbed into the driver, because nothing
else in the source tree uses it. Since nobody complained and all usage
of this driver is via device tree, change the code to work with device
tree only. As Linus Walleij wrote, the device tree should be the
preferred way forward anyway.
Signed-off-by: Marek BehĂșn <marek.behun@nic.cz>
Cc: Simon Guinot <simon.guinot@sequanux.org>
Cc: Simon Guinot <sguinot@lacie.com>
Cc: Vincent Donnefort <vdonnefort@gmail.com>
Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Cc: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Pavel Machek <pavel@ucw.cz>
Diffstat (limited to 'drivers/leds')
-rw-r--r-- | drivers/leds/leds-ns2.c | 40 |
1 files changed, 15 insertions, 25 deletions
diff --git a/drivers/leds/leds-ns2.c b/drivers/leds/leds-ns2.c index 8cd020b34084..0e9c2f49b635 100644 --- a/drivers/leds/leds-ns2.c +++ b/drivers/leds/leds-ns2.c @@ -39,7 +39,7 @@ struct ns2_led { struct ns2_led_modval *modval; }; -struct ns2_led_platform_data { +struct ns2_led_of { int num_leds; struct ns2_led *leds; }; @@ -230,12 +230,11 @@ create_ns2_led(struct platform_device *pdev, struct ns2_led_data *led_dat, return devm_led_classdev_register(&pdev->dev, &led_dat->cdev); } -#ifdef CONFIG_OF_GPIO /* * Translate OpenFirmware node properties into platform_data. */ static int -ns2_leds_get_of_pdata(struct device *dev, struct ns2_led_platform_data *pdata) +ns2_leds_parse_of(struct device *dev, struct ns2_led_of *ofdata) { struct device_node *np = dev_of_node(dev); struct device_node *child; @@ -317,8 +316,8 @@ ns2_leds_get_of_pdata(struct device *dev, struct ns2_led_platform_data *pdata) led++; } - pdata->leds = leds; - pdata->num_leds = num_leds; + ofdata->leds = leds; + ofdata->num_leds = num_leds; return 0; @@ -332,40 +331,31 @@ static const struct of_device_id of_ns2_leds_match[] = { {}, }; MODULE_DEVICE_TABLE(of, of_ns2_leds_match); -#endif /* CONFIG_OF_GPIO */ static int ns2_led_probe(struct platform_device *pdev) { - struct ns2_led_platform_data *pdata = dev_get_platdata(&pdev->dev); + struct ns2_led_of *ofdata; struct ns2_led_data *leds; int i; int ret; -#ifdef CONFIG_OF_GPIO - if (!pdata) { - pdata = devm_kzalloc(&pdev->dev, - sizeof(struct ns2_led_platform_data), - GFP_KERNEL); - if (!pdata) - return -ENOMEM; + ofdata = devm_kzalloc(&pdev->dev, sizeof(struct ns2_led_of), + GFP_KERNEL); + if (!ofdata) + return -ENOMEM; - ret = ns2_leds_get_of_pdata(&pdev->dev, pdata); - if (ret) - return ret; - } -#else - if (!pdata) - return -EINVAL; -#endif /* CONFIG_OF_GPIO */ + ret = ns2_leds_parse_of(&pdev->dev, ofdata); + if (ret) + return ret; leds = devm_kzalloc(&pdev->dev, array_size(sizeof(*leds), - pdata->num_leds), + ofdata->num_leds), GFP_KERNEL); if (!leds) return -ENOMEM; - for (i = 0; i < pdata->num_leds; i++) { - ret = create_ns2_led(pdev, &leds[i], &pdata->leds[i]); + for (i = 0; i < ofdata->num_leds; i++) { + ret = create_ns2_led(pdev, &leds[i], &ofdata->leds[i]); if (ret < 0) return ret; } |