linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V2] leds: pca963x: Add ACPI support
@ 2016-11-29 10:21 ` Tin Huynh
  2016-11-29 10:47   ` Mika Westerberg
  2016-11-29 10:55   ` Jacek Anaszewski
  0 siblings, 2 replies; 6+ messages in thread
From: Tin Huynh @ 2016-11-29 10:21 UTC (permalink / raw)
  To: Mika Westerberg, Rafael J. Wysocki, Richard Purdie, Jacek Anaszewski
  Cc: linux-leds, linux-kernel, linux-acpi, Loc Ho, Thang Nguyen,
	Phong Vo, patches, Tin Huynh

This patch enables ACPI support for leds-pca963x driver.

Signed-off-by: Tin Huynh <tnhuynh@apm.com>
---
 drivers/leds/leds-pca963x.c |   25 ++++++++++++++++++++++++-
 1 files changed, 24 insertions(+), 1 deletions(-)

Change from V1:
  -Add CONFIG_ACPI.

diff --git a/drivers/leds/leds-pca963x.c b/drivers/leds/leds-pca963x.c
index 407eba1..57f11e3 100644
--- a/drivers/leds/leds-pca963x.c
+++ b/drivers/leds/leds-pca963x.c
@@ -25,6 +25,7 @@
  * or by adding the 'nxp,hw-blink' property to the DTS.
  */
 
+#include <linux/acpi.h>
 #include <linux/module.h>
 #include <linux/delay.h>
 #include <linux/string.h>
@@ -95,6 +96,17 @@ struct pca963x_chipdef {
 };
 MODULE_DEVICE_TABLE(i2c, pca963x_id);
 
+#ifdef CONFIG_ACPI
+static const struct acpi_device_id pca963x_acpi_ids[] = {
+	{ "PCA9632", pca9633 },
+	{ "PCA9633", pca9633 },
+	{ "PCA9634", pca9634 },
+	{ "PCA9635", pca9635 },
+	{ }
+};
+MODULE_DEVICE_TABLE(acpi, pca963x_acpi_ids);
+#endif
+
 struct pca963x_led;
 
 struct pca963x {
@@ -322,7 +334,17 @@ static int pca963x_probe(struct i2c_client *client,
 	struct pca963x_chipdef *chip;
 	int i, err;
 
-	chip = &pca963x_chipdefs[id->driver_data];
+	if (id) {
+		chip = &pca963x_chipdefs[id->driver_data];
+	} else {
+		const struct acpi_device_id *acpi_id;
+
+		acpi_id = acpi_match_device(ACPI_PTR(pca963x_acpi_ids),
+						&client->dev);
+		if (!acpi_id)
+			return -ENODEV;
+		chip = &pca963x_chipdefs[acpi_id->driver_data];
+	}
 	pdata = dev_get_platdata(&client->dev);
 
 	if (!pdata) {
@@ -426,6 +448,7 @@ static int pca963x_remove(struct i2c_client *client)
 	.driver = {
 		.name	= "leds-pca963x",
 		.of_match_table = of_match_ptr(of_pca963x_match),
+		.acpi_match_table = ACPI_PTR(pca963x_acpi_ids),
 	},
 	.probe	= pca963x_probe,
 	.remove	= pca963x_remove,
-- 
1.7.1

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

* Re: [PATCH V2] leds: pca963x: Add ACPI support
  2016-11-29 10:21 ` [PATCH V2] leds: pca963x: Add ACPI support Tin Huynh
@ 2016-11-29 10:47   ` Mika Westerberg
  2016-11-29 10:55   ` Jacek Anaszewski
  1 sibling, 0 replies; 6+ messages in thread
From: Mika Westerberg @ 2016-11-29 10:47 UTC (permalink / raw)
  To: Tin Huynh
  Cc: Rafael J. Wysocki, Richard Purdie, Jacek Anaszewski, linux-leds,
	linux-kernel, linux-acpi, Loc Ho, Thang Nguyen, Phong Vo,
	patches

On Tue, Nov 29, 2016 at 05:21:50PM +0700, Tin Huynh wrote:
> This patch enables ACPI support for leds-pca963x driver.
> 
> Signed-off-by: Tin Huynh <tnhuynh@apm.com>

Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>

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

* Re: [PATCH V2] leds: pca963x: Add ACPI support
  2016-11-29 10:21 ` [PATCH V2] leds: pca963x: Add ACPI support Tin Huynh
  2016-11-29 10:47   ` Mika Westerberg
@ 2016-11-29 10:55   ` Jacek Anaszewski
  2016-11-29 11:04     ` Mika Westerberg
  1 sibling, 1 reply; 6+ messages in thread
From: Jacek Anaszewski @ 2016-11-29 10:55 UTC (permalink / raw)
  To: Tin Huynh, Mika Westerberg, Rafael J. Wysocki, Richard Purdie
  Cc: linux-leds, linux-kernel, linux-acpi, Loc Ho, Thang Nguyen,
	Phong Vo, patches

On 11/29/2016 11:21 AM, Tin Huynh wrote:
> This patch enables ACPI support for leds-pca963x driver.
>
> Signed-off-by: Tin Huynh <tnhuynh@apm.com>
> ---
>  drivers/leds/leds-pca963x.c |   25 ++++++++++++++++++++++++-
>  1 files changed, 24 insertions(+), 1 deletions(-)
>
> Change from V1:
>   -Add CONFIG_ACPI.
>
> diff --git a/drivers/leds/leds-pca963x.c b/drivers/leds/leds-pca963x.c
> index 407eba1..57f11e3 100644
> --- a/drivers/leds/leds-pca963x.c
> +++ b/drivers/leds/leds-pca963x.c
> @@ -25,6 +25,7 @@
>   * or by adding the 'nxp,hw-blink' property to the DTS.
>   */
>
> +#include <linux/acpi.h>
>  #include <linux/module.h>
>  #include <linux/delay.h>
>  #include <linux/string.h>
> @@ -95,6 +96,17 @@ struct pca963x_chipdef {
>  };
>  MODULE_DEVICE_TABLE(i2c, pca963x_id);
>
> +#ifdef CONFIG_ACPI
> +static const struct acpi_device_id pca963x_acpi_ids[] = {
> +	{ "PCA9632", pca9633 },
> +	{ "PCA9633", pca9633 },
> +	{ "PCA9634", pca9634 },
> +	{ "PCA9635", pca9635 },
> +	{ }
> +};
> +MODULE_DEVICE_TABLE(acpi, pca963x_acpi_ids);
> +#endif
> +
>  struct pca963x_led;
>
>  struct pca963x {
> @@ -322,7 +334,17 @@ static int pca963x_probe(struct i2c_client *client,
>  	struct pca963x_chipdef *chip;
>  	int i, err;
>
> -	chip = &pca963x_chipdefs[id->driver_data];
> +	if (id) {
> +		chip = &pca963x_chipdefs[id->driver_data];
> +	} else {
> +		const struct acpi_device_id *acpi_id;
> +
> +		acpi_id = acpi_match_device(ACPI_PTR(pca963x_acpi_ids),
> +						&client->dev);

What kind of problem did you get while compiling without ACPI_PTR here,
when CONFIG_ACPI is disabled? I also tried this configuration but
nothing wrong happened. Also at first glance I don't see why lack of
ACPI_PTR macro could cause problems.

Grep also doesn't show any call to acpi_match_device
with ACPI_PTR as the first argument in the existing drivers.

> +		if (!acpi_id)
> +			return -ENODEV;
> +		chip = &pca963x_chipdefs[acpi_id->driver_data];
> +	}
>  	pdata = dev_get_platdata(&client->dev);
>
>  	if (!pdata) {
> @@ -426,6 +448,7 @@ static int pca963x_remove(struct i2c_client *client)
>  	.driver = {
>  		.name	= "leds-pca963x",
>  		.of_match_table = of_match_ptr(of_pca963x_match),
> +		.acpi_match_table = ACPI_PTR(pca963x_acpi_ids),
>  	},
>  	.probe	= pca963x_probe,
>  	.remove	= pca963x_remove,
>


-- 
Best regards,
Jacek Anaszewski

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

* Re: [PATCH V2] leds: pca963x: Add ACPI support
  2016-11-29 10:55   ` Jacek Anaszewski
@ 2016-11-29 11:04     ` Mika Westerberg
  2016-11-29 14:47       ` Tin Huynh
  0 siblings, 1 reply; 6+ messages in thread
From: Mika Westerberg @ 2016-11-29 11:04 UTC (permalink / raw)
  To: Jacek Anaszewski
  Cc: Tin Huynh, Rafael J. Wysocki, Richard Purdie, linux-leds,
	linux-kernel, linux-acpi, Loc Ho, Thang Nguyen, Phong Vo,
	patches

On Tue, Nov 29, 2016 at 11:55:47AM +0100, Jacek Anaszewski wrote:
> On 11/29/2016 11:21 AM, Tin Huynh wrote:
> > This patch enables ACPI support for leds-pca963x driver.
> > 
> > Signed-off-by: Tin Huynh <tnhuynh@apm.com>
> > ---
> >  drivers/leds/leds-pca963x.c |   25 ++++++++++++++++++++++++-
> >  1 files changed, 24 insertions(+), 1 deletions(-)
> > 
> > Change from V1:
> >   -Add CONFIG_ACPI.
> > 
> > diff --git a/drivers/leds/leds-pca963x.c b/drivers/leds/leds-pca963x.c
> > index 407eba1..57f11e3 100644
> > --- a/drivers/leds/leds-pca963x.c
> > +++ b/drivers/leds/leds-pca963x.c
> > @@ -25,6 +25,7 @@
> >   * or by adding the 'nxp,hw-blink' property to the DTS.
> >   */
> > 
> > +#include <linux/acpi.h>
> >  #include <linux/module.h>
> >  #include <linux/delay.h>
> >  #include <linux/string.h>
> > @@ -95,6 +96,17 @@ struct pca963x_chipdef {
> >  };
> >  MODULE_DEVICE_TABLE(i2c, pca963x_id);
> > 
> > +#ifdef CONFIG_ACPI
> > +static const struct acpi_device_id pca963x_acpi_ids[] = {
> > +	{ "PCA9632", pca9633 },
> > +	{ "PCA9633", pca9633 },
> > +	{ "PCA9634", pca9634 },
> > +	{ "PCA9635", pca9635 },
> > +	{ }
> > +};
> > +MODULE_DEVICE_TABLE(acpi, pca963x_acpi_ids);
> > +#endif
> > +
> >  struct pca963x_led;
> > 
> >  struct pca963x {
> > @@ -322,7 +334,17 @@ static int pca963x_probe(struct i2c_client *client,
> >  	struct pca963x_chipdef *chip;
> >  	int i, err;
> > 
> > -	chip = &pca963x_chipdefs[id->driver_data];
> > +	if (id) {
> > +		chip = &pca963x_chipdefs[id->driver_data];
> > +	} else {
> > +		const struct acpi_device_id *acpi_id;
> > +
> > +		acpi_id = acpi_match_device(ACPI_PTR(pca963x_acpi_ids),
> > +						&client->dev);
> 
> What kind of problem did you get while compiling without ACPI_PTR here,
> when CONFIG_ACPI is disabled? I also tried this configuration but
> nothing wrong happened. Also at first glance I don't see why lack of
> ACPI_PTR macro could cause problems.
> 
> Grep also doesn't show any call to acpi_match_device
> with ACPI_PTR as the first argument in the existing drivers.

Indeed, that is not needed at all.

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

* Re: [PATCH V2] leds: pca963x: Add ACPI support
  2016-11-29 11:04     ` Mika Westerberg
@ 2016-11-29 14:47       ` Tin Huynh
  2016-11-29 15:34         ` Jacek Anaszewski
  0 siblings, 1 reply; 6+ messages in thread
From: Tin Huynh @ 2016-11-29 14:47 UTC (permalink / raw)
  To: Mika Westerberg
  Cc: Jacek Anaszewski, Rafael J. Wysocki, Richard Purdie, linux-leds,
	linux-kernel, linux-acpi, Loc Ho, Thang Nguyen, Phong Vo,
	patches

On Tue, Nov 29, 2016 at 6:04 PM, Mika Westerberg
<mika.westerberg@linux.intel.com> wrote:
> On Tue, Nov 29, 2016 at 11:55:47AM +0100, Jacek Anaszewski wrote:
>> On 11/29/2016 11:21 AM, Tin Huynh wrote:
>> > This patch enables ACPI support for leds-pca963x driver.
>> >
>> > Signed-off-by: Tin Huynh <tnhuynh@apm.com>
>> > ---
>> >  drivers/leds/leds-pca963x.c |   25 ++++++++++++++++++++++++-
>> >  1 files changed, 24 insertions(+), 1 deletions(-)
>> >
>> > Change from V1:
>> >   -Add CONFIG_ACPI.
>> >
>> > diff --git a/drivers/leds/leds-pca963x.c b/drivers/leds/leds-pca963x.c
>> > index 407eba1..57f11e3 100644
>> > --- a/drivers/leds/leds-pca963x.c
>> > +++ b/drivers/leds/leds-pca963x.c
>> > @@ -25,6 +25,7 @@
>> >   * or by adding the 'nxp,hw-blink' property to the DTS.
>> >   */
>> >
>> > +#include <linux/acpi.h>
>> >  #include <linux/module.h>
>> >  #include <linux/delay.h>
>> >  #include <linux/string.h>
>> > @@ -95,6 +96,17 @@ struct pca963x_chipdef {
>> >  };
>> >  MODULE_DEVICE_TABLE(i2c, pca963x_id);
>> >
>> > +#ifdef CONFIG_ACPI
>> > +static const struct acpi_device_id pca963x_acpi_ids[] = {
>> > +   { "PCA9632", pca9633 },
>> > +   { "PCA9633", pca9633 },
>> > +   { "PCA9634", pca9634 },
>> > +   { "PCA9635", pca9635 },
>> > +   { }
>> > +};
>> > +MODULE_DEVICE_TABLE(acpi, pca963x_acpi_ids);
>> > +#endif
>> > +
>> >  struct pca963x_led;
>> >
>> >  struct pca963x {
>> > @@ -322,7 +334,17 @@ static int pca963x_probe(struct i2c_client *client,
>> >     struct pca963x_chipdef *chip;
>> >     int i, err;
>> >
>> > -   chip = &pca963x_chipdefs[id->driver_data];
>> > +   if (id) {
>> > +           chip = &pca963x_chipdefs[id->driver_data];
>> > +   } else {
>> > +           const struct acpi_device_id *acpi_id;
>> > +
>> > +           acpi_id = acpi_match_device(ACPI_PTR(pca963x_acpi_ids),
>> > +                                           &client->dev);
>>
>> What kind of problem did you get while compiling without ACPI_PTR here,
>> when CONFIG_ACPI is disabled? I also tried this configuration but
>> nothing wrong happened. Also at first glance I don't see why lack of
>> ACPI_PTR macro could cause problems.
>>
>> Grep also doesn't show any call to acpi_match_device
>> with ACPI_PTR as the first argument in the existing drivers.
>
> Indeed, that is not needed at all.
Sorry about that . The PATCH V1 should work fine both with or without
CONFIG_ACPI.
So V1 should be better . Please ignore PATCH V2

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

* Re: [PATCH V2] leds: pca963x: Add ACPI support
  2016-11-29 14:47       ` Tin Huynh
@ 2016-11-29 15:34         ` Jacek Anaszewski
  0 siblings, 0 replies; 6+ messages in thread
From: Jacek Anaszewski @ 2016-11-29 15:34 UTC (permalink / raw)
  To: Tin Huynh, Mika Westerberg
  Cc: Rafael J. Wysocki, Richard Purdie, linux-leds, linux-kernel,
	linux-acpi, Loc Ho, Thang Nguyen, Phong Vo, patches

Hi Tin,

On 11/29/2016 03:47 PM, Tin Huynh wrote:
> On Tue, Nov 29, 2016 at 6:04 PM, Mika Westerberg
> <mika.westerberg@linux.intel.com> wrote:
>> On Tue, Nov 29, 2016 at 11:55:47AM +0100, Jacek Anaszewski wrote:
>>> On 11/29/2016 11:21 AM, Tin Huynh wrote:
>>>> This patch enables ACPI support for leds-pca963x driver.
>>>>
>>>> Signed-off-by: Tin Huynh <tnhuynh@apm.com>
>>>> ---
>>>>  drivers/leds/leds-pca963x.c |   25 ++++++++++++++++++++++++-
>>>>  1 files changed, 24 insertions(+), 1 deletions(-)
>>>>
>>>> Change from V1:
>>>>   -Add CONFIG_ACPI.
>>>>
>>>> diff --git a/drivers/leds/leds-pca963x.c b/drivers/leds/leds-pca963x.c
>>>> index 407eba1..57f11e3 100644
>>>> --- a/drivers/leds/leds-pca963x.c
>>>> +++ b/drivers/leds/leds-pca963x.c
>>>> @@ -25,6 +25,7 @@
>>>>   * or by adding the 'nxp,hw-blink' property to the DTS.
>>>>   */
>>>>
>>>> +#include <linux/acpi.h>
>>>>  #include <linux/module.h>
>>>>  #include <linux/delay.h>
>>>>  #include <linux/string.h>
>>>> @@ -95,6 +96,17 @@ struct pca963x_chipdef {
>>>>  };
>>>>  MODULE_DEVICE_TABLE(i2c, pca963x_id);
>>>>
>>>> +#ifdef CONFIG_ACPI
>>>> +static const struct acpi_device_id pca963x_acpi_ids[] = {
>>>> +   { "PCA9632", pca9633 },
>>>> +   { "PCA9633", pca9633 },
>>>> +   { "PCA9634", pca9634 },
>>>> +   { "PCA9635", pca9635 },
>>>> +   { }
>>>> +};
>>>> +MODULE_DEVICE_TABLE(acpi, pca963x_acpi_ids);
>>>> +#endif
>>>> +
>>>>  struct pca963x_led;
>>>>
>>>>  struct pca963x {
>>>> @@ -322,7 +334,17 @@ static int pca963x_probe(struct i2c_client *client,
>>>>     struct pca963x_chipdef *chip;
>>>>     int i, err;
>>>>
>>>> -   chip = &pca963x_chipdefs[id->driver_data];
>>>> +   if (id) {
>>>> +           chip = &pca963x_chipdefs[id->driver_data];
>>>> +   } else {
>>>> +           const struct acpi_device_id *acpi_id;
>>>> +
>>>> +           acpi_id = acpi_match_device(ACPI_PTR(pca963x_acpi_ids),
>>>> +                                           &client->dev);
>>>
>>> What kind of problem did you get while compiling without ACPI_PTR here,
>>> when CONFIG_ACPI is disabled? I also tried this configuration but
>>> nothing wrong happened. Also at first glance I don't see why lack of
>>> ACPI_PTR macro could cause problems.
>>>
>>> Grep also doesn't show any call to acpi_match_device
>>> with ACPI_PTR as the first argument in the existing drivers.
>>
>> Indeed, that is not needed at all.
> Sorry about that . The PATCH V1 should work fine both with or without
> CONFIG_ACPI.
> So V1 should be better . Please ignore PATCH V2

Reapplied V1.

-- 
Best regards,
Jacek Anaszewski

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

end of thread, other threads:[~2016-11-29 15:35 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CGME20161129102236epcas1p36ba8b4160c78cfd62d5748538174ca05@epcas1p3.samsung.com>
2016-11-29 10:21 ` [PATCH V2] leds: pca963x: Add ACPI support Tin Huynh
2016-11-29 10:47   ` Mika Westerberg
2016-11-29 10:55   ` Jacek Anaszewski
2016-11-29 11:04     ` Mika Westerberg
2016-11-29 14:47       ` Tin Huynh
2016-11-29 15:34         ` Jacek Anaszewski

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).