diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2019-07-16 18:25:04 +0200 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2019-07-16 18:25:04 +0200 |
commit | 50950626414a982c8ed539128c7f69a3d328a970 (patch) | |
tree | f1282c6b063ec97c111a8d255404a48bd656bf45 /drivers/video/backlight/gpio_backlight.c | |
parent | Merge tag 'for-linus-20190715' of git://git.kernel.dk/linux-block (diff) | |
parent | backlight: pwm_bl: Fix heuristic to determine number of brightness levels (diff) | |
download | linux-50950626414a982c8ed539128c7f69a3d328a970.tar.xz linux-50950626414a982c8ed539128c7f69a3d328a970.zip |
Merge tag 'backlight-next-5.3' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/backlight
Pull backlight updates from Lee Jones:
"New Functionality:
- Provide support for ACPI enumeration; gpio_backlight
Fix-ups:
- SPDX fixups; pwm_bl
- Fix linear brightness levels to include number available; pwm_bl"
* tag 'backlight-next-5.3' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/backlight:
backlight: pwm_bl: Fix heuristic to determine number of brightness levels
backlight: gpio_backlight: Enable ACPI enumeration
backlight: pwm_bl: Convert to use SPDX identifier
Diffstat (limited to 'drivers/video/backlight/gpio_backlight.c')
-rw-r--r-- | drivers/video/backlight/gpio_backlight.c | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/drivers/video/backlight/gpio_backlight.c b/drivers/video/backlight/gpio_backlight.c index b9300f3e1ee6..e84f3087e29f 100644 --- a/drivers/video/backlight/gpio_backlight.c +++ b/drivers/video/backlight/gpio_backlight.c @@ -15,6 +15,7 @@ #include <linux/of_gpio.h> #include <linux/platform_data/gpio_backlight.h> #include <linux/platform_device.h> +#include <linux/property.h> #include <linux/slab.h> struct gpio_backlight { @@ -58,11 +59,10 @@ static int gpio_backlight_probe_dt(struct platform_device *pdev, struct gpio_backlight *gbl) { struct device *dev = &pdev->dev; - struct device_node *np = dev->of_node; enum gpiod_flags flags; int ret; - gbl->def_value = of_property_read_bool(np, "default-on"); + gbl->def_value = device_property_read_bool(dev, "default-on"); flags = gbl->def_value ? GPIOD_OUT_HIGH : GPIOD_OUT_LOW; gbl->gpiod = devm_gpiod_get(dev, NULL, flags); @@ -86,26 +86,19 @@ static int gpio_backlight_probe(struct platform_device *pdev) struct backlight_properties props; struct backlight_device *bl; struct gpio_backlight *gbl; - struct device_node *np = pdev->dev.of_node; int ret; - if (!pdata && !np) { - dev_err(&pdev->dev, - "failed to find platform data or device tree node.\n"); - return -ENODEV; - } - gbl = devm_kzalloc(&pdev->dev, sizeof(*gbl), GFP_KERNEL); if (gbl == NULL) return -ENOMEM; gbl->dev = &pdev->dev; - if (np) { + if (pdev->dev.fwnode) { ret = gpio_backlight_probe_dt(pdev, gbl); if (ret) return ret; - } else { + } else if (pdata) { /* * Legacy platform data GPIO retrieveal. Do not expand * the use of this code path, currently only used by one @@ -126,6 +119,10 @@ static int gpio_backlight_probe(struct platform_device *pdev) gbl->gpiod = gpio_to_desc(pdata->gpio); if (!gbl->gpiod) return -EINVAL; + } else { + dev_err(&pdev->dev, + "failed to find platform data or device tree node.\n"); + return -ENODEV; } memset(&props, 0, sizeof(props)); @@ -146,19 +143,17 @@ static int gpio_backlight_probe(struct platform_device *pdev) return 0; } -#ifdef CONFIG_OF static struct of_device_id gpio_backlight_of_match[] = { { .compatible = "gpio-backlight" }, { /* sentinel */ } }; MODULE_DEVICE_TABLE(of, gpio_backlight_of_match); -#endif static struct platform_driver gpio_backlight_driver = { .driver = { .name = "gpio-backlight", - .of_match_table = of_match_ptr(gpio_backlight_of_match), + .of_match_table = gpio_backlight_of_match, }, .probe = gpio_backlight_probe, }; |