dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1] backlight: gpio_backlight: Enable ACPI enumeration
@ 2019-06-19 15:21 Andy Shevchenko
  2019-06-20 14:12 ` Daniel Thompson
  2019-06-26 10:57 ` Lee Jones
  0 siblings, 2 replies; 4+ messages in thread
From: Andy Shevchenko @ 2019-06-19 15:21 UTC (permalink / raw)
  To: Lee Jones, Daniel Thompson, Jingoo Han, dri-devel; +Cc: Andy Shevchenko

ACPI allows to enumerate specific devices by using compatible strings.
Enable that enumeration for GPIO based backlight devices.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/video/backlight/gpio_backlight.c | 23 +++++++++--------------
 1 file changed, 9 insertions(+), 14 deletions(-)

diff --git a/drivers/video/backlight/gpio_backlight.c b/drivers/video/backlight/gpio_backlight.c
index e470da95d806..05c12df62b27 100644
--- a/drivers/video/backlight/gpio_backlight.c
+++ b/drivers/video/backlight/gpio_backlight.c
@@ -18,6 +18,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 {
@@ -61,11 +62,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);
@@ -89,26 +89,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
@@ -129,6 +122,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));
@@ -149,19 +146,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,
 };
-- 
2.20.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v1] backlight: gpio_backlight: Enable ACPI enumeration
  2019-06-19 15:21 [PATCH v1] backlight: gpio_backlight: Enable ACPI enumeration Andy Shevchenko
@ 2019-06-20 14:12 ` Daniel Thompson
  2019-06-20 15:12   ` Andy Shevchenko
  2019-06-26 10:57 ` Lee Jones
  1 sibling, 1 reply; 4+ messages in thread
From: Daniel Thompson @ 2019-06-20 14:12 UTC (permalink / raw)
  To: Andy Shevchenko, Lee Jones, Jingoo Han, dri-devel

On 19/06/2019 16:21, Andy Shevchenko wrote:
> ACPI allows to enumerate specific devices by using compatible strings.
> Enable that enumeration for GPIO based backlight devices.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>   drivers/video/backlight/gpio_backlight.c | 23 +++++++++--------------
>   1 file changed, 9 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/video/backlight/gpio_backlight.c b/drivers/video/backlight/gpio_backlight.c
> index e470da95d806..05c12df62b27 100644
> --- a/drivers/video/backlight/gpio_backlight.c
> +++ b/drivers/video/backlight/gpio_backlight.c
> @@ -18,6 +18,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 {
> @@ -61,11 +62,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);
> @@ -89,26 +89,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
> @@ -129,6 +122,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");

Should the string also be updated?

If what is updated to acknoledge option to use ACPI then:
Acked-by: Daniel Thompson <daniel.thompson@linaro.org>




> +		return -ENODEV;
>   	}
>   
>   	memset(&props, 0, sizeof(props));
> @@ -149,19 +146,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,
>   };
> 

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v1] backlight: gpio_backlight: Enable ACPI enumeration
  2019-06-20 14:12 ` Daniel Thompson
@ 2019-06-20 15:12   ` Andy Shevchenko
  0 siblings, 0 replies; 4+ messages in thread
From: Andy Shevchenko @ 2019-06-20 15:12 UTC (permalink / raw)
  To: Daniel Thompson; +Cc: Jingoo Han, Lee Jones, dri-devel

On Thu, Jun 20, 2019 at 03:12:05PM +0100, Daniel Thompson wrote:
> On 19/06/2019 16:21, Andy Shevchenko wrote:
> > ACPI allows to enumerate specific devices by using compatible strings.
> > Enable that enumeration for GPIO based backlight devices.

> > +		dev_err(&pdev->dev,
> > +			"failed to find platform data or device tree node.\n");
> 
> Should the string also be updated?

I don't think it's necessary. The device tree compatible mode is for DT
drivers, so, it is assumed that person knows much enough and this message would
be useful as is.

> If what is updated to acknoledge option to use ACPI then:
> Acked-by: Daniel Thompson <daniel.thompson@linaro.org>

Thanks!

-- 
With Best Regards,
Andy Shevchenko


_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v1] backlight: gpio_backlight: Enable ACPI enumeration
  2019-06-19 15:21 [PATCH v1] backlight: gpio_backlight: Enable ACPI enumeration Andy Shevchenko
  2019-06-20 14:12 ` Daniel Thompson
@ 2019-06-26 10:57 ` Lee Jones
  1 sibling, 0 replies; 4+ messages in thread
From: Lee Jones @ 2019-06-26 10:57 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: Jingoo Han, Daniel Thompson, dri-devel

On Wed, 19 Jun 2019, Andy Shevchenko wrote:

> ACPI allows to enumerate specific devices by using compatible strings.
> Enable that enumeration for GPIO based backlight devices.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  drivers/video/backlight/gpio_backlight.c | 23 +++++++++--------------
>  1 file changed, 9 insertions(+), 14 deletions(-)

Applied, thanks.

-- 
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-06-26 10:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-19 15:21 [PATCH v1] backlight: gpio_backlight: Enable ACPI enumeration Andy Shevchenko
2019-06-20 14:12 ` Daniel Thompson
2019-06-20 15:12   ` Andy Shevchenko
2019-06-26 10:57 ` Lee Jones

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).