diff mbox series

[v2,09/28] drivers: Add generic match helper by ACPI_COMPANION device

Message ID 1560534863-15115-10-git-send-email-suzuki.poulose@arm.com (mailing list archive)
State New, archived
Headers show
Series None | expand

Commit Message

Suzuki K Poulose June 14, 2019, 5:54 p.m. UTC
Add a generic helper to match a device by the ACPI_COMPANION device.
This will be later used for providing wrappers for
(bus/class/driver)_find_device().

Cc: Len Brown <lenb@kernel.org>
Cc: linux-acpi@vger.kernel.org
Cc: linux-spi@vger.kernel.org
Cc: Mark Brown <broonie@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
 drivers/base/core.c    | 6 ++++++
 include/linux/device.h | 1 +
 2 files changed, 7 insertions(+)

Comments

Rafael J. Wysocki June 17, 2019, 10:07 p.m. UTC | #1
On Fri, Jun 14, 2019 at 7:55 PM Suzuki K Poulose <suzuki.poulose@arm.com> wrote:
>
> Add a generic helper to match a device by the ACPI_COMPANION device.
> This will be later used for providing wrappers for
> (bus/class/driver)_find_device().
>
> Cc: Len Brown <lenb@kernel.org>
> Cc: linux-acpi@vger.kernel.org
> Cc: linux-spi@vger.kernel.org
> Cc: Mark Brown <broonie@kernel.org>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: "Rafael J. Wysocki" <rafael@kernel.org>
> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>

Please fold this change into the patch adding users of device_match_acpi_dev().

> ---
>  drivers/base/core.c    | 6 ++++++
>  include/linux/device.h | 1 +
>  2 files changed, 7 insertions(+)
>
> diff --git a/drivers/base/core.c b/drivers/base/core.c
> index b827ca1..597095b 100644
> --- a/drivers/base/core.c
> +++ b/drivers/base/core.c
> @@ -3346,3 +3346,9 @@ int device_match_devt(struct device *dev, const void *pdevt)
>         return dev->devt == *(dev_t *)pdevt;
>  }
>  EXPORT_SYMBOL_GPL(device_match_devt);
> +
> +int device_match_acpi_dev(struct device *dev, const void *adev)
> +{
> +       return ACPI_COMPANION(dev) == adev;
> +}
> +EXPORT_SYMBOL(device_match_acpi_dev);
> diff --git a/include/linux/device.h b/include/linux/device.h
> index f315692..a03b50d 100644
> --- a/include/linux/device.h
> +++ b/include/linux/device.h
> @@ -166,6 +166,7 @@ void subsys_dev_iter_exit(struct subsys_dev_iter *iter);
>  int device_match_of_node(struct device *dev, const void *np);
>  int device_match_fwnode(struct device *dev, const void *fwnode);
>  int device_match_devt(struct device *dev, const void *pdevt);
> +int device_match_acpi_dev(struct device *dev, const void *adev);
>
>  int bus_for_each_dev(struct bus_type *bus, struct device *start, void *data,
>                      int (*fn)(struct device *dev, void *data));
> --
> 2.7.4
>
Suzuki K Poulose June 18, 2019, 8:38 a.m. UTC | #2
Hi Rafael,

On 17/06/2019 23:07, Rafael J. Wysocki wrote:
> On Fri, Jun 14, 2019 at 7:55 PM Suzuki K Poulose <suzuki.poulose@arm.com> wrote:
>>
>> Add a generic helper to match a device by the ACPI_COMPANION device.
>> This will be later used for providing wrappers for
>> (bus/class/driver)_find_device().
>>
>> Cc: Len Brown <lenb@kernel.org>
>> Cc: linux-acpi@vger.kernel.org
>> Cc: linux-spi@vger.kernel.org
>> Cc: Mark Brown <broonie@kernel.org>
>> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
>> Cc: "Rafael J. Wysocki" <rafael@kernel.org>
>> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
> 
> Please fold this change into the patch adding users of device_match_acpi_dev().

There are variants of this by class/bus/driver and all of them are introduced
as separate patches with the respective users. If we do for this, we have to
do the same for other matches as well.

i.e, [ device_match_by_attr + class_find_device_by_attr & users + 
driver_find_device_by_attr & users + bus_find_device_by_attr & users ]

And that becomes a large chunk, which could make the review painful.

If you would still like that approach, I could do that in the next revision.

Cheers
Suzuki
Rafael J. Wysocki June 18, 2019, 8:40 a.m. UTC | #3
On Tue, Jun 18, 2019 at 10:38 AM Suzuki K Poulose
<suzuki.poulose@arm.com> wrote:
>
> Hi Rafael,
>
> On 17/06/2019 23:07, Rafael J. Wysocki wrote:
> > On Fri, Jun 14, 2019 at 7:55 PM Suzuki K Poulose <suzuki.poulose@arm.com> wrote:
> >>
> >> Add a generic helper to match a device by the ACPI_COMPANION device.
> >> This will be later used for providing wrappers for
> >> (bus/class/driver)_find_device().
> >>
> >> Cc: Len Brown <lenb@kernel.org>
> >> Cc: linux-acpi@vger.kernel.org
> >> Cc: linux-spi@vger.kernel.org
> >> Cc: Mark Brown <broonie@kernel.org>
> >> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> >> Cc: "Rafael J. Wysocki" <rafael@kernel.org>
> >> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
> >
> > Please fold this change into the patch adding users of device_match_acpi_dev().
>
> There are variants of this by class/bus/driver and all of them are introduced
> as separate patches with the respective users. If we do for this, we have to
> do the same for other matches as well.
>
> i.e, [ device_match_by_attr + class_find_device_by_attr & users +
> driver_find_device_by_attr & users + bus_find_device_by_attr & users ]
>
> And that becomes a large chunk, which could make the review painful.
>
> If you would still like that approach, I could do that in the next revision.

Yes, please.
diff mbox series

Patch

diff --git a/drivers/base/core.c b/drivers/base/core.c
index b827ca1..597095b 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -3346,3 +3346,9 @@  int device_match_devt(struct device *dev, const void *pdevt)
 	return dev->devt == *(dev_t *)pdevt;
 }
 EXPORT_SYMBOL_GPL(device_match_devt);
+
+int device_match_acpi_dev(struct device *dev, const void *adev)
+{
+	return ACPI_COMPANION(dev) == adev;
+}
+EXPORT_SYMBOL(device_match_acpi_dev);
diff --git a/include/linux/device.h b/include/linux/device.h
index f315692..a03b50d 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -166,6 +166,7 @@  void subsys_dev_iter_exit(struct subsys_dev_iter *iter);
 int device_match_of_node(struct device *dev, const void *np);
 int device_match_fwnode(struct device *dev, const void *fwnode);
 int device_match_devt(struct device *dev, const void *pdevt);
+int device_match_acpi_dev(struct device *dev, const void *adev);
 
 int bus_for_each_dev(struct bus_type *bus, struct device *start, void *data,
 		     int (*fn)(struct device *dev, void *data));