linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH] ACPI: bus.c: Let acpi_device_get_match_data() return DT compatibility data
       [not found] <93a290d7082ed2e4d3e2b91dc7f6e941c9242a41.1530600804.git.nikolaus.voss@loewensteinmedical.de>
@ 2018-07-03 21:31 ` Andy Shevchenko
  2018-07-03 21:36   ` Andy Shevchenko
  2018-07-03 22:31   ` Andy Shevchenko
  2018-07-03 22:49 ` Andy Shevchenko
  1 sibling, 2 replies; 7+ messages in thread
From: Andy Shevchenko @ 2018-07-03 21:31 UTC (permalink / raw)
  To: Nikolaus Voss
  Cc: Rafael J. Wysocki, Len Brown, Jonathan Cameron, Hartmut Knaack,
	Lars-Peter Clausen, Peter Meerwald-Stadler, Lorenzo Bianconi,
	Linus Walleij, Xiongfeng Wang, nv, ACPI Devel Maling List,
	Linux Kernel Mailing List

On Tue, Jul 3, 2018 at 9:09 AM, Nikolaus Voss
<nikolaus.voss@loewensteinmedical.de> wrote:
> When using ACPI with ACPI_DT_NAMESPACE_HID/ PRP0001 HID and referring to
> of_device_id table "compatible" strings in DSD, a pointer to the
> corresponding DT table entry should be returned instead of a null
> pointer. An acpi_device_id match still takes precedence.

I'm not sure what you are trying to achieve here.
This works solely for ACPI case.
For PRP0001 (which is just a _temporary_ solution for device in
question) we have special code path in SPI and I2C cores.

https://elixir.bootlin.com/linux/v4.18-rc3/ident/acpi_driver_match_device


-- 
With Best Regards,
Andy Shevchenko

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

* Re: [PATCH] ACPI: bus.c: Let acpi_device_get_match_data() return DT compatibility data
  2018-07-03 21:31 ` [PATCH] ACPI: bus.c: Let acpi_device_get_match_data() return DT compatibility data Andy Shevchenko
@ 2018-07-03 21:36   ` Andy Shevchenko
  2018-07-03 22:31   ` Andy Shevchenko
  1 sibling, 0 replies; 7+ messages in thread
From: Andy Shevchenko @ 2018-07-03 21:36 UTC (permalink / raw)
  To: Nikolaus Voss
  Cc: Rafael J. Wysocki, Len Brown, Jonathan Cameron, Hartmut Knaack,
	Lars-Peter Clausen, Peter Meerwald-Stadler, Lorenzo Bianconi,
	Linus Walleij, Xiongfeng Wang, nv, ACPI Devel Maling List,
	Linux Kernel Mailing List

On Wed, Jul 4, 2018 at 12:31 AM, Andy Shevchenko
<andy.shevchenko@gmail.com> wrote:
> On Tue, Jul 3, 2018 at 9:09 AM, Nikolaus Voss
> <nikolaus.voss@loewensteinmedical.de> wrote:
>> When using ACPI with ACPI_DT_NAMESPACE_HID/ PRP0001 HID and referring to
>> of_device_id table "compatible" strings in DSD, a pointer to the
>> corresponding DT table entry should be returned instead of a null
>> pointer. An acpi_device_id match still takes precedence.
>
> I'm not sure what you are trying to achieve here.
> This works solely for ACPI case.
> For PRP0001 (which is just a _temporary_ solution for device in
> question) we have special code path in SPI and I2C cores.
>
> https://elixir.bootlin.com/linux/v4.18-rc3/ident/acpi_driver_match_device

Just have to add, that PRP0001 is enumerated via OF per se.
It means the driver in question must have compatible strings and
MODULE_DEVICE_TABLE(of,...).
Also don't forget to enable CONFIG_OF in your kernel.

-- 
With Best Regards,
Andy Shevchenko

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

* Re: [PATCH] ACPI: bus.c: Let acpi_device_get_match_data() return DT compatibility data
  2018-07-03 21:31 ` [PATCH] ACPI: bus.c: Let acpi_device_get_match_data() return DT compatibility data Andy Shevchenko
  2018-07-03 21:36   ` Andy Shevchenko
@ 2018-07-03 22:31   ` Andy Shevchenko
  1 sibling, 0 replies; 7+ messages in thread
From: Andy Shevchenko @ 2018-07-03 22:31 UTC (permalink / raw)
  To: Nikolaus Voss
  Cc: Rafael J. Wysocki, Len Brown, Jonathan Cameron, Hartmut Knaack,
	Lars-Peter Clausen, Peter Meerwald-Stadler, Lorenzo Bianconi,
	Linus Walleij, Xiongfeng Wang, nv, ACPI Devel Maling List,
	Linux Kernel Mailing List

On Wed, Jul 4, 2018 at 12:31 AM, Andy Shevchenko
<andy.shevchenko@gmail.com> wrote:
> On Tue, Jul 3, 2018 at 9:09 AM, Nikolaus Voss
> <nikolaus.voss@loewensteinmedical.de> wrote:
>> When using ACPI with ACPI_DT_NAMESPACE_HID/ PRP0001 HID and referring to
>> of_device_id table "compatible" strings in DSD, a pointer to the
>> corresponding DT table entry should be returned instead of a null
>> pointer. An acpi_device_id match still takes precedence.
>
> I'm not sure what you are trying to achieve here.
> This works solely for ACPI case.

Okay, now, after a bit of browsing sources, I got your problem.
Indeed, we have acpi_of_match_device() which returns matched OF item,
but no caller is interested in it...


-- 
With Best Regards,
Andy Shevchenko

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

* Re: [PATCH] ACPI: bus.c: Let acpi_device_get_match_data() return DT compatibility data
       [not found] <93a290d7082ed2e4d3e2b91dc7f6e941c9242a41.1530600804.git.nikolaus.voss@loewensteinmedical.de>
  2018-07-03 21:31 ` [PATCH] ACPI: bus.c: Let acpi_device_get_match_data() return DT compatibility data Andy Shevchenko
@ 2018-07-03 22:49 ` Andy Shevchenko
  2018-07-04 13:00   ` Nikolaus Voss
  1 sibling, 1 reply; 7+ messages in thread
From: Andy Shevchenko @ 2018-07-03 22:49 UTC (permalink / raw)
  To: Nikolaus Voss
  Cc: Rafael J. Wysocki, Len Brown, Jonathan Cameron, Hartmut Knaack,
	Lars-Peter Clausen, Peter Meerwald-Stadler, Lorenzo Bianconi,
	Linus Walleij, Xiongfeng Wang, nv, ACPI Devel Maling List,
	Linux Kernel Mailing List

On Tue, Jul 3, 2018 at 9:09 AM, Nikolaus Voss
<nikolaus.voss@loewensteinmedical.de> wrote:

Thanks for the patch, now I completely got it and agree on approach.
Few comments below.

> When using ACPI with ACPI_DT_NAMESPACE_HID/ PRP0001 HID and referring to
> of_device_id table "compatible" strings in DSD, a pointer to the

_DSD

> corresponding DT table entry should be returned instead of a null
> pointer. An acpi_device_id match still takes precedence.

>  const void *acpi_device_get_match_data(const struct device *dev)
>  {
> -       const struct acpi_device_id *match;
> +       const struct acpi_device_id *acpi_id = NULL;
> +       const struct of_device_id *of_id = NULL;
> +       const struct device_driver *drv = dev->driver;
>
> -       match = acpi_match_device(dev->driver->acpi_match_table, dev);
> -       if (!match)

> +       __acpi_match_device(acpi_companion_match(dev), drv->acpi_match_table,
> +                           drv->of_match_table, &acpi_id, &of_id);

Perhaps,

bool match;

match = __acpi_match_device(..);
if (!match)
 return NULL;

...
> +       if (acpi_id)
> +               return (const void*)acpi_id->driver_data;
> +       else if (of_id)
> +               return (const void*)of_id->data;

Actually (dbesides redundant 'else') there is no difference in which
order you test these.
Thus, perhaps

if (of_id)
 return ...of_id...;

return ...acpi_id...;

> -       return (const void *)match->driver_data;
>  }


-- 
With Best Regards,
Andy Shevchenko

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

* Re: [PATCH] ACPI: bus.c: Let acpi_device_get_match_data() return DT compatibility data
  2018-07-03 22:49 ` Andy Shevchenko
@ 2018-07-04 13:00   ` Nikolaus Voss
  0 siblings, 0 replies; 7+ messages in thread
From: Nikolaus Voss @ 2018-07-04 13:00 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Rafael J. Wysocki, Len Brown, Jonathan Cameron, Hartmut Knaack,
	Lars-Peter Clausen, Peter Meerwald-Stadler, Lorenzo Bianconi,
	Linus Walleij, Xiongfeng Wang, ACPI Devel Maling List,
	Linux Kernel Mailing List

On Wed, 4 Jul 2018, Andy Shevchenko wrote:
> On Tue, Jul 3, 2018 at 9:09 AM, Nikolaus Voss
> <nikolaus.voss@loewensteinmedical.de> wrote:
>
> Thanks for the patch, now I completely got it and agree on approach.
> Few comments below.
>
>> When using ACPI with ACPI_DT_NAMESPACE_HID/ PRP0001 HID and referring to
>> of_device_id table "compatible" strings in DSD, a pointer to the
>
> _DSD
>
>> corresponding DT table entry should be returned instead of a null
>> pointer. An acpi_device_id match still takes precedence.
>
>>  const void *acpi_device_get_match_data(const struct device *dev)
>>  {
>> -       const struct acpi_device_id *match;
>> +       const struct acpi_device_id *acpi_id = NULL;
>> +       const struct of_device_id *of_id = NULL;
>> +       const struct device_driver *drv = dev->driver;
>>
>> -       match = acpi_match_device(dev->driver->acpi_match_table, dev);
>> -       if (!match)
>
>> +       __acpi_match_device(acpi_companion_match(dev), drv->acpi_match_table,
>> +                           drv->of_match_table, &acpi_id, &of_id);
>
> Perhaps,
>
> bool match;
>
> match = __acpi_match_device(..);
> if (!match)
> return NULL;
>
> ...
>> +       if (acpi_id)
>> +               return (const void*)acpi_id->driver_data;
>> +       else if (of_id)
>> +               return (const void*)of_id->data;
>
> Actually (dbesides redundant 'else') there is no difference in which
> order you test these.
> Thus, perhaps
>
> if (of_id)
> return ...of_id...;
>
> return ...acpi_id...;
>
>> -       return (const void *)match->driver_data;
>>  }

Thanks for reviewing and feedback, posted v2...

Niko


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

* Re: [PATCH] ACPI: bus.c: Let acpi_device_get_match_data() return DT compatibility data
  2018-07-03  6:09 Nikolaus Voss
@ 2018-07-04 10:36 ` Andy Shevchenko
  0 siblings, 0 replies; 7+ messages in thread
From: Andy Shevchenko @ 2018-07-04 10:36 UTC (permalink / raw)
  To: Nikolaus Voss
  Cc: Sudeep Holla, Ray Jui, Vladimir Olovyannikov, Vikram Prakash,
	Scott Branden, ACPI Devel Maling List, Linux Kernel Mailing List,
	Srinath Mannam, nv

On Tue, Jul 3, 2018 at 9:09 AM, Nikolaus Voss
<nikolaus.voss@loewensteinmedical.de> wrote:
> When using ACPI with ACPI_DT_NAMESPACE_HID/ PRP0001 HID and referring to
> of_device_id table "compatible" strings in DSD, a pointer to the
> corresponding DT table entry should be returned instead of a null
> pointer. An acpi_device_id match still takes precedence.

AFAIU it's just bounce for new comers to the discussion.
The patch is in its original form and didn't incorporate any review
comments so far.

> Signed-off-by: Nikolaus Voss <nikolaus.voss@loewensteinmedical.de>
> ---
>  drivers/acpi/bus.c | 15 ++++++++++-----
>  1 file changed, 10 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
> index 84b4a62018eb..c2deffea842e 100644
> --- a/drivers/acpi/bus.c
> +++ b/drivers/acpi/bus.c
> @@ -832,13 +832,18 @@ EXPORT_SYMBOL_GPL(acpi_match_device);
>
>  const void *acpi_device_get_match_data(const struct device *dev)
>  {
> -       const struct acpi_device_id *match;
> +       const struct acpi_device_id *acpi_id = NULL;
> +       const struct of_device_id *of_id = NULL;
> +       const struct device_driver *drv = dev->driver;
>
> -       match = acpi_match_device(dev->driver->acpi_match_table, dev);
> -       if (!match)
> +       __acpi_match_device(acpi_companion_match(dev), drv->acpi_match_table,
> +                           drv->of_match_table, &acpi_id, &of_id);
> +       if (acpi_id)
> +               return (const void*)acpi_id->driver_data;
> +       else if (of_id)
> +               return (const void*)of_id->data;
> +       else
>                 return NULL;
> -
> -       return (const void *)match->driver_data;
>  }
>  EXPORT_SYMBOL_GPL(acpi_device_get_match_data);
>
> --
> 2.17.1
>



-- 
With Best Regards,
Andy Shevchenko

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

* [PATCH] ACPI: bus.c: Let acpi_device_get_match_data() return DT compatibility data
@ 2018-07-03  6:09 Nikolaus Voss
  2018-07-04 10:36 ` Andy Shevchenko
  0 siblings, 1 reply; 7+ messages in thread
From: Nikolaus Voss @ 2018-07-03  6:09 UTC (permalink / raw)
  To: Sudeep Holla, Ray Jui, Vladimir Olovyannikov, Vikram Prakash,
	Scott Branden, ACPI Devel Maling List, Linux Kernel Mailing List,
	Srinath Mannam, nv

When using ACPI with ACPI_DT_NAMESPACE_HID/ PRP0001 HID and referring to
of_device_id table "compatible" strings in DSD, a pointer to the
corresponding DT table entry should be returned instead of a null
pointer. An acpi_device_id match still takes precedence.

Signed-off-by: Nikolaus Voss <nikolaus.voss@loewensteinmedical.de>
---
 drivers/acpi/bus.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
index 84b4a62018eb..c2deffea842e 100644
--- a/drivers/acpi/bus.c
+++ b/drivers/acpi/bus.c
@@ -832,13 +832,18 @@ EXPORT_SYMBOL_GPL(acpi_match_device);
 
 const void *acpi_device_get_match_data(const struct device *dev)
 {
-	const struct acpi_device_id *match;
+	const struct acpi_device_id *acpi_id = NULL;
+	const struct of_device_id *of_id = NULL;
+	const struct device_driver *drv = dev->driver;
 
-	match = acpi_match_device(dev->driver->acpi_match_table, dev);
-	if (!match)
+	__acpi_match_device(acpi_companion_match(dev), drv->acpi_match_table,
+			    drv->of_match_table, &acpi_id, &of_id);
+	if (acpi_id)
+		return (const void*)acpi_id->driver_data;
+	else if (of_id)
+		return (const void*)of_id->data;
+	else
 		return NULL;
-
-	return (const void *)match->driver_data;
 }
 EXPORT_SYMBOL_GPL(acpi_device_get_match_data);
 
-- 
2.17.1


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

end of thread, other threads:[~2018-07-04 13:00 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <93a290d7082ed2e4d3e2b91dc7f6e941c9242a41.1530600804.git.nikolaus.voss@loewensteinmedical.de>
2018-07-03 21:31 ` [PATCH] ACPI: bus.c: Let acpi_device_get_match_data() return DT compatibility data Andy Shevchenko
2018-07-03 21:36   ` Andy Shevchenko
2018-07-03 22:31   ` Andy Shevchenko
2018-07-03 22:49 ` Andy Shevchenko
2018-07-04 13:00   ` Nikolaus Voss
2018-07-03  6:09 Nikolaus Voss
2018-07-04 10:36 ` Andy Shevchenko

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