2018-07-04 14:43:08

by Andy Shevchenko

[permalink] [raw]
Subject: Re: [PATCH v2] ACPI: bus.c: Let acpi_device_get_match_data() return DT compatibility data

On Tue, Jul 3, 2018 at 9:09 AM, Nikolaus Voss <[email protected]> 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.
>

Reviewed-by: Andy Shevchenko <[email protected]>

with a caveat that this is only an improvement for a _temporary_
PRP0001 users like I2C or SPI slave devices.
Please, don't consider this change as a valid point to (ab)use PRP0001
in a cases where devices are not "hotpluggable".

> v2: improve readability (as suggested by Andy Shevchenko)
>
> Signed-off-by: Nikolaus Voss <[email protected]>
> ---
> drivers/acpi/bus.c | 15 ++++++++++++---
> 1 file changed, 12 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
> index 84b4a62018eb..58575fdace78 100644
> --- a/drivers/acpi/bus.c
> +++ b/drivers/acpi/bus.c
> @@ -832,13 +832,22 @@ 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;
> + bool match;
> +
> + match = __acpi_match_device(acpi_companion_match(dev),
> + drv->acpi_match_table,
> + drv->of_match_table, &acpi_id, &of_id);
>
> - match = acpi_match_device(dev->driver->acpi_match_table, dev);
> if (!match)
> return NULL;
> +
> + if (of_id)
> + return (const void*)of_id->data;
>
> - return (const void *)match->driver_data;
> + return (const void*)acpi_id->driver_data;
> }
> EXPORT_SYMBOL_GPL(acpi_device_get_match_data);
>
> --
> 2.17.1
>



--
With Best Regards,
Andy Shevchenko


2018-07-09 09:23:26

by Rafael J. Wysocki

[permalink] [raw]
Subject: Re: [PATCH v2] ACPI: bus.c: Let acpi_device_get_match_data() return DT compatibility data

On Wednesday, July 4, 2018 4:40:34 PM CEST Andy Shevchenko wrote:
> On Tue, Jul 3, 2018 at 9:09 AM, Nikolaus Voss <[email protected]> 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.
> >
>
> Reviewed-by: Andy Shevchenko <[email protected]>
>
> with a caveat that this is only an improvement for a _temporary_
> PRP0001 users like I2C or SPI slave devices.
> Please, don't consider this change as a valid point to (ab)use PRP0001
> in a cases where devices are not "hotpluggable".
>
> > v2: improve readability (as suggested by Andy Shevchenko)
> >
> > Signed-off-by: Nikolaus Voss <[email protected]>

Nikolaus, please resend the v2 with the Andy's tag to [email protected]

It won't be applied otherwise.

Thanks,
Rafael


2018-07-24 13:31:43

by Nikolaus Voss

[permalink] [raw]
Subject: Re: [PATCH v2] ACPI: bus.c: Let acpi_device_get_match_data() return DT compatibility data

On Wed, 4 Jul 2018, Andy Shevchenko wrote:
> On Tue, Jul 3, 2018 at 9:09 AM, Nikolaus Voss <[email protected]> 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.
>>
>
> Reviewed-by: Andy Shevchenko <[email protected]>
>
> with a caveat that this is only an improvement for a _temporary_
> PRP0001 users like I2C or SPI slave devices.
> Please, don't consider this change as a valid point to (ab)use PRP0001
> in a cases where devices are not "hotpluggable".

Will add the caveat and resend. Andy, thanks for reviewing!

Niko


2018-07-24 13:33:12

by Nikolaus Voss

[permalink] [raw]
Subject: Re: [PATCH v2] ACPI: bus.c: Let acpi_device_get_match_data() return DT compatibility data

On Mon, 9 Jul 2018, Rafael J. Wysocki wrote:
> On Wednesday, July 4, 2018 4:40:34 PM CEST Andy Shevchenko wrote:
>> On Tue, Jul 3, 2018 at 9:09 AM, Nikolaus Voss <[email protected]> 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.
>>>
>>
>> Reviewed-by: Andy Shevchenko <[email protected]>
>>
>> with a caveat that this is only an improvement for a _temporary_
>> PRP0001 users like I2C or SPI slave devices.
>> Please, don't consider this change as a valid point to (ab)use PRP0001
>> in a cases where devices are not "hotpluggable".
>>
>>> v2: improve readability (as suggested by Andy Shevchenko)
>>>
>>> Signed-off-by: Nikolaus Voss <[email protected]>
>
> Nikolaus, please resend the v2 with the Andy's tag to [email protected]
>
> It won't be applied otherwise.

Ok, thanks for the hint!

Niko