Linux-ACPI Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH v3 5/7] drivers: Introduce device lookup variants by ACPI_COMPANION device
       [not found] <20190723221838.12024-1-suzuki.poulose@arm.com>
@ 2019-07-23 22:18 ` Suzuki K Poulose
  2019-07-26 17:18   ` Mark Brown
  2019-07-26 20:23   ` Wolfram Sang
  0 siblings, 2 replies; 7+ messages in thread
From: Suzuki K Poulose @ 2019-07-23 22:18 UTC (permalink / raw)
  To: linux-kernel
  Cc: gregkh, rafael, linux-arm-kernel, Suzuki K Poulose, Len Brown,
	linux-acpi, linux-spi, Mark Brown, Mika Westerberg, Wolfram Sang,
	linux-i2c

Add a generic helper to match a device by the ACPI_COMPANION device
and provide wrappers for the device lookup APIs.

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: Mika Westerberg <mika.westerberg@linux.intel.com>
Cc: Wolfram Sang <wsa@the-dreams.de>
Cc: linux-i2c@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 ++++
 drivers/i2c/i2c-core-acpi.c | 11 ++-----
 drivers/spi/spi.c           |  8 +----
 include/linux/device.h      | 65 +++++++++++++++++++++++++++++++++++++
 4 files changed, 74 insertions(+), 16 deletions(-)

diff --git a/drivers/base/core.c b/drivers/base/core.c
index 3abc32b60c0a..57d71bc2c559 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -3373,3 +3373,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/drivers/i2c/i2c-core-acpi.c b/drivers/i2c/i2c-core-acpi.c
index 4dbbc9a35f65..bc80aafb521f 100644
--- a/drivers/i2c/i2c-core-acpi.c
+++ b/drivers/i2c/i2c-core-acpi.c
@@ -354,17 +354,11 @@ static int i2c_acpi_find_match_adapter(struct device *dev, const void *data)
 	return ACPI_HANDLE(dev) == (acpi_handle)data;
 }
 
-static int i2c_acpi_find_match_device(struct device *dev, const void *data)
-{
-	return ACPI_COMPANION(dev) == data;
-}
 
 struct i2c_adapter *i2c_acpi_find_adapter_by_handle(acpi_handle handle)
 {
-	struct device *dev;
+	struct device *dev = bus_find_device_by_acpi_dev(&i2c_bus_type, handle);
 
-	dev = bus_find_device(&i2c_bus_type, NULL, handle,
-			      i2c_acpi_find_match_adapter);
 	return dev ? i2c_verify_adapter(dev) : NULL;
 }
 EXPORT_SYMBOL_GPL(i2c_acpi_find_adapter_by_handle);
@@ -373,8 +367,7 @@ static struct i2c_client *i2c_acpi_find_client_by_adev(struct acpi_device *adev)
 {
 	struct device *dev;
 
-	dev = bus_find_device(&i2c_bus_type, NULL, adev,
-			      i2c_acpi_find_match_device);
+	dev = bus_find_device_by_acpi_dev(&i2c_bus_type, adev);
 	return dev ? i2c_verify_client(dev) : NULL;
 }
 
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index a591da87981a..c486a6f84c2c 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -3741,11 +3741,6 @@ static int spi_acpi_controller_match(struct device *dev, const void *data)
 	return ACPI_COMPANION(dev->parent) == data;
 }
 
-static int spi_acpi_device_match(struct device *dev, const void *data)
-{
-	return ACPI_COMPANION(dev) == data;
-}
-
 static struct spi_controller *acpi_spi_find_controller_by_adev(struct acpi_device *adev)
 {
 	struct device *dev;
@@ -3765,8 +3760,7 @@ static struct spi_device *acpi_spi_find_device_by_adev(struct acpi_device *adev)
 {
 	struct device *dev;
 
-	dev = bus_find_device(&spi_bus_type, NULL, adev, spi_acpi_device_match);
-
+	dev = bus_find_device_by_acpi_dev(&spi_bus_type, adev);
 	return dev ? to_spi_device(dev) : NULL;
 }
 
diff --git a/include/linux/device.h b/include/linux/device.h
index 93b2f55ef44e..7514ef3d3f1a 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -168,6 +168,7 @@ int device_match_name(struct device *dev, const void *name);
 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));
@@ -224,6 +225,28 @@ static inline struct device *bus_find_device_by_devt(struct bus_type *bus,
 	return bus_find_device(bus, NULL, &devt, device_match_devt);
 }
 
+#ifdef CONFIG_ACPI
+struct acpi_device;
+
+/**
+ * bus_find_device_by_acpi_dev : device iterator for locating a particular device
+ * matching the ACPI COMPANION device.
+ * @bus: bus type
+ * @adev: ACPI COMPANION device to match.
+ */
+static inline struct device *
+bus_find_device_by_acpi_dev(struct bus_type *bus, const struct acpi_device *adev)
+{
+	return bus_find_device(bus, NULL, adev, device_match_acpi_dev);
+}
+#else
+static inline struct device *
+bus_find_device_by_acpi_dev(struct bus_type *bus, const void *adev)
+{
+	return NULL;
+}
+#endif
+
 struct device *subsys_find_device_by_id(struct bus_type *bus, unsigned int id,
 					struct device *hint);
 int bus_for_each_drv(struct bus_type *bus, struct device_driver *start,
@@ -442,6 +465,27 @@ static inline struct device *driver_find_device_by_devt(struct device_driver *dr
 	return driver_find_device(drv, NULL, &devt, device_match_devt);
 }
 
+#ifdef CONFIG_ACPI
+/**
+ * driver_find_device_by_acpi_dev : device iterator for locating a particular
+ * device matching the ACPI_COMPANION device.
+ * @driver: the driver we're iterating
+ * @adev: ACPI_COMPANION device to match.
+ */
+static inline struct device *
+driver_find_device_by_acpi_dev(struct device_driver *drv,
+			       const struct acpi_device *adev)
+{
+	return driver_find_device(drv, NULL, adev, device_match_acpi_dev);
+}
+#else
+static inline struct device *
+driver_find_device_by_acpi_dev(struct device_driver *drv, const void *adev)
+{
+	return NULL;
+}
+#endif
+
 void driver_deferred_probe_add(struct device *dev);
 int driver_deferred_probe_check_state(struct device *dev);
 int driver_deferred_probe_check_state_continue(struct device *dev);
@@ -620,6 +664,27 @@ static inline struct device *class_find_device_by_devt(struct class *class,
 	return class_find_device(class, NULL, &devt, device_match_devt);
 }
 
+#ifdef CONFIG_ACPI
+struct acpi_device;
+/**
+ * class_find_device_by_acpi_dev : device iterator for locating a particular
+ * device matching the ACPI_COMPANION device.
+ * @class: class type
+ * @adev: ACPI_COMPANION device to match.
+ */
+static inline struct device *
+class_find_device_by_acpi_dev(struct class *class, const struct acpi_device *adev)
+{
+	return class_find_device(class, NULL, adev, device_match_acpi_dev);
+}
+#else
+static inline struct device *
+class_find_device_by_acpi_dev(struct class *class, const void *adev)
+{
+	return NULL;
+}
+#endif
+
 struct class_attribute {
 	struct attribute attr;
 	ssize_t (*show)(struct class *class, struct class_attribute *attr,
-- 
2.21.0


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

* Re: [PATCH v3 5/7] drivers: Introduce device lookup variants by ACPI_COMPANION device
  2019-07-23 22:18 ` [PATCH v3 5/7] drivers: Introduce device lookup variants by ACPI_COMPANION device Suzuki K Poulose
@ 2019-07-26 17:18   ` Mark Brown
  2019-07-26 20:23   ` Wolfram Sang
  1 sibling, 0 replies; 7+ messages in thread
From: Mark Brown @ 2019-07-26 17:18 UTC (permalink / raw)
  To: Suzuki K Poulose
  Cc: linux-kernel, gregkh, rafael, linux-arm-kernel, Len Brown,
	linux-acpi, linux-spi, Mika Westerberg, Wolfram Sang, linux-i2c

[-- Attachment #1: Type: text/plain, Size: 230 bytes --]

On Tue, Jul 23, 2019 at 11:18:36PM +0100, Suzuki K Poulose wrote:
> Add a generic helper to match a device by the ACPI_COMPANION device
> and provide wrappers for the device lookup APIs.

Acked-by: Mark Brown <broonie@kernel.org>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH v3 5/7] drivers: Introduce device lookup variants by ACPI_COMPANION device
  2019-07-23 22:18 ` [PATCH v3 5/7] drivers: Introduce device lookup variants by ACPI_COMPANION device Suzuki K Poulose
  2019-07-26 17:18   ` Mark Brown
@ 2019-07-26 20:23   ` Wolfram Sang
  2019-08-01 11:58     ` Andy Shevchenko
  1 sibling, 1 reply; 7+ messages in thread
From: Wolfram Sang @ 2019-07-26 20:23 UTC (permalink / raw)
  To: Suzuki K Poulose, Mika Westerberg, Andy Shevchenko, Jarkko Nikula
  Cc: linux-kernel, gregkh, rafael, linux-arm-kernel, Len Brown,
	linux-acpi, linux-spi, Mark Brown, Mika Westerberg, linux-i2c

[-- Attachment #1: Type: text/plain, Size: 7404 bytes --]

On Tue, Jul 23, 2019 at 11:18:36PM +0100, Suzuki K Poulose wrote:
> Add a generic helper to match a device by the ACPI_COMPANION device
> and provide wrappers for the device lookup APIs.
> 
> 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: Mika Westerberg <mika.westerberg@linux.intel.com>
> Cc: Wolfram Sang <wsa@the-dreams.de>
> Cc: linux-i2c@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>

From my side, OK:

Acked-by: Wolfram Sang <wsa@the-dreams.de> # I2C parts

yet you missed to cc the I2C ACPI maintainers. Done so now.

> ---
>  drivers/base/core.c         |  6 ++++
>  drivers/i2c/i2c-core-acpi.c | 11 ++-----
>  drivers/spi/spi.c           |  8 +----
>  include/linux/device.h      | 65 +++++++++++++++++++++++++++++++++++++
>  4 files changed, 74 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/base/core.c b/drivers/base/core.c
> index 3abc32b60c0a..57d71bc2c559 100644
> --- a/drivers/base/core.c
> +++ b/drivers/base/core.c
> @@ -3373,3 +3373,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/drivers/i2c/i2c-core-acpi.c b/drivers/i2c/i2c-core-acpi.c
> index 4dbbc9a35f65..bc80aafb521f 100644
> --- a/drivers/i2c/i2c-core-acpi.c
> +++ b/drivers/i2c/i2c-core-acpi.c
> @@ -354,17 +354,11 @@ static int i2c_acpi_find_match_adapter(struct device *dev, const void *data)
>  	return ACPI_HANDLE(dev) == (acpi_handle)data;
>  }
>  
> -static int i2c_acpi_find_match_device(struct device *dev, const void *data)
> -{
> -	return ACPI_COMPANION(dev) == data;
> -}
>  
>  struct i2c_adapter *i2c_acpi_find_adapter_by_handle(acpi_handle handle)
>  {
> -	struct device *dev;
> +	struct device *dev = bus_find_device_by_acpi_dev(&i2c_bus_type, handle);
>  
> -	dev = bus_find_device(&i2c_bus_type, NULL, handle,
> -			      i2c_acpi_find_match_adapter);
>  	return dev ? i2c_verify_adapter(dev) : NULL;
>  }
>  EXPORT_SYMBOL_GPL(i2c_acpi_find_adapter_by_handle);
> @@ -373,8 +367,7 @@ static struct i2c_client *i2c_acpi_find_client_by_adev(struct acpi_device *adev)
>  {
>  	struct device *dev;
>  
> -	dev = bus_find_device(&i2c_bus_type, NULL, adev,
> -			      i2c_acpi_find_match_device);
> +	dev = bus_find_device_by_acpi_dev(&i2c_bus_type, adev);
>  	return dev ? i2c_verify_client(dev) : NULL;
>  }
>  
> diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
> index a591da87981a..c486a6f84c2c 100644
> --- a/drivers/spi/spi.c
> +++ b/drivers/spi/spi.c
> @@ -3741,11 +3741,6 @@ static int spi_acpi_controller_match(struct device *dev, const void *data)
>  	return ACPI_COMPANION(dev->parent) == data;
>  }
>  
> -static int spi_acpi_device_match(struct device *dev, const void *data)
> -{
> -	return ACPI_COMPANION(dev) == data;
> -}
> -
>  static struct spi_controller *acpi_spi_find_controller_by_adev(struct acpi_device *adev)
>  {
>  	struct device *dev;
> @@ -3765,8 +3760,7 @@ static struct spi_device *acpi_spi_find_device_by_adev(struct acpi_device *adev)
>  {
>  	struct device *dev;
>  
> -	dev = bus_find_device(&spi_bus_type, NULL, adev, spi_acpi_device_match);
> -
> +	dev = bus_find_device_by_acpi_dev(&spi_bus_type, adev);
>  	return dev ? to_spi_device(dev) : NULL;
>  }
>  
> diff --git a/include/linux/device.h b/include/linux/device.h
> index 93b2f55ef44e..7514ef3d3f1a 100644
> --- a/include/linux/device.h
> +++ b/include/linux/device.h
> @@ -168,6 +168,7 @@ int device_match_name(struct device *dev, const void *name);
>  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));
> @@ -224,6 +225,28 @@ static inline struct device *bus_find_device_by_devt(struct bus_type *bus,
>  	return bus_find_device(bus, NULL, &devt, device_match_devt);
>  }
>  
> +#ifdef CONFIG_ACPI
> +struct acpi_device;
> +
> +/**
> + * bus_find_device_by_acpi_dev : device iterator for locating a particular device
> + * matching the ACPI COMPANION device.
> + * @bus: bus type
> + * @adev: ACPI COMPANION device to match.
> + */
> +static inline struct device *
> +bus_find_device_by_acpi_dev(struct bus_type *bus, const struct acpi_device *adev)
> +{
> +	return bus_find_device(bus, NULL, adev, device_match_acpi_dev);
> +}
> +#else
> +static inline struct device *
> +bus_find_device_by_acpi_dev(struct bus_type *bus, const void *adev)
> +{
> +	return NULL;
> +}
> +#endif
> +
>  struct device *subsys_find_device_by_id(struct bus_type *bus, unsigned int id,
>  					struct device *hint);
>  int bus_for_each_drv(struct bus_type *bus, struct device_driver *start,
> @@ -442,6 +465,27 @@ static inline struct device *driver_find_device_by_devt(struct device_driver *dr
>  	return driver_find_device(drv, NULL, &devt, device_match_devt);
>  }
>  
> +#ifdef CONFIG_ACPI
> +/**
> + * driver_find_device_by_acpi_dev : device iterator for locating a particular
> + * device matching the ACPI_COMPANION device.
> + * @driver: the driver we're iterating
> + * @adev: ACPI_COMPANION device to match.
> + */
> +static inline struct device *
> +driver_find_device_by_acpi_dev(struct device_driver *drv,
> +			       const struct acpi_device *adev)
> +{
> +	return driver_find_device(drv, NULL, adev, device_match_acpi_dev);
> +}
> +#else
> +static inline struct device *
> +driver_find_device_by_acpi_dev(struct device_driver *drv, const void *adev)
> +{
> +	return NULL;
> +}
> +#endif
> +
>  void driver_deferred_probe_add(struct device *dev);
>  int driver_deferred_probe_check_state(struct device *dev);
>  int driver_deferred_probe_check_state_continue(struct device *dev);
> @@ -620,6 +664,27 @@ static inline struct device *class_find_device_by_devt(struct class *class,
>  	return class_find_device(class, NULL, &devt, device_match_devt);
>  }
>  
> +#ifdef CONFIG_ACPI
> +struct acpi_device;
> +/**
> + * class_find_device_by_acpi_dev : device iterator for locating a particular
> + * device matching the ACPI_COMPANION device.
> + * @class: class type
> + * @adev: ACPI_COMPANION device to match.
> + */
> +static inline struct device *
> +class_find_device_by_acpi_dev(struct class *class, const struct acpi_device *adev)
> +{
> +	return class_find_device(class, NULL, adev, device_match_acpi_dev);
> +}
> +#else
> +static inline struct device *
> +class_find_device_by_acpi_dev(struct class *class, const void *adev)
> +{
> +	return NULL;
> +}
> +#endif
> +
>  struct class_attribute {
>  	struct attribute attr;
>  	ssize_t (*show)(struct class *class, struct class_attribute *attr,
> -- 
> 2.21.0
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH v3 5/7] drivers: Introduce device lookup variants by ACPI_COMPANION device
  2019-07-26 20:23   ` Wolfram Sang
@ 2019-08-01 11:58     ` Andy Shevchenko
  2019-08-01 12:08       ` Wolfram Sang
  0 siblings, 1 reply; 7+ messages in thread
From: Andy Shevchenko @ 2019-08-01 11:58 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: Suzuki K Poulose, Mika Westerberg, Jarkko Nikula, linux-kernel,
	gregkh, rafael, linux-arm-kernel, Len Brown, linux-acpi,
	linux-spi, Mark Brown, linux-i2c

On Fri, Jul 26, 2019 at 10:23:54PM +0200, Wolfram Sang wrote:
> On Tue, Jul 23, 2019 at 11:18:36PM +0100, Suzuki K Poulose wrote:
> > Add a generic helper to match a device by the ACPI_COMPANION device
> > and provide wrappers for the device lookup APIs.
> > 
> > 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: Mika Westerberg <mika.westerberg@linux.intel.com>
> > Cc: Wolfram Sang <wsa@the-dreams.de>
> > Cc: linux-i2c@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>
> 
> From my side, OK:
> 
> Acked-by: Wolfram Sang <wsa@the-dreams.de> # I2C parts
> 
> yet you missed to cc the I2C ACPI maintainers. Done so now.

Acked-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Thanks, Wolfram, for notifying.

> 
> > ---
> >  drivers/base/core.c         |  6 ++++
> >  drivers/i2c/i2c-core-acpi.c | 11 ++-----
> >  drivers/spi/spi.c           |  8 +----
> >  include/linux/device.h      | 65 +++++++++++++++++++++++++++++++++++++
> >  4 files changed, 74 insertions(+), 16 deletions(-)
> > 
> > diff --git a/drivers/base/core.c b/drivers/base/core.c
> > index 3abc32b60c0a..57d71bc2c559 100644
> > --- a/drivers/base/core.c
> > +++ b/drivers/base/core.c
> > @@ -3373,3 +3373,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/drivers/i2c/i2c-core-acpi.c b/drivers/i2c/i2c-core-acpi.c
> > index 4dbbc9a35f65..bc80aafb521f 100644
> > --- a/drivers/i2c/i2c-core-acpi.c
> > +++ b/drivers/i2c/i2c-core-acpi.c
> > @@ -354,17 +354,11 @@ static int i2c_acpi_find_match_adapter(struct device *dev, const void *data)
> >  	return ACPI_HANDLE(dev) == (acpi_handle)data;
> >  }
> >  
> > -static int i2c_acpi_find_match_device(struct device *dev, const void *data)
> > -{
> > -	return ACPI_COMPANION(dev) == data;
> > -}
> >  
> >  struct i2c_adapter *i2c_acpi_find_adapter_by_handle(acpi_handle handle)
> >  {
> > -	struct device *dev;
> > +	struct device *dev = bus_find_device_by_acpi_dev(&i2c_bus_type, handle);
> >  
> > -	dev = bus_find_device(&i2c_bus_type, NULL, handle,
> > -			      i2c_acpi_find_match_adapter);
> >  	return dev ? i2c_verify_adapter(dev) : NULL;
> >  }
> >  EXPORT_SYMBOL_GPL(i2c_acpi_find_adapter_by_handle);
> > @@ -373,8 +367,7 @@ static struct i2c_client *i2c_acpi_find_client_by_adev(struct acpi_device *adev)
> >  {
> >  	struct device *dev;
> >  
> > -	dev = bus_find_device(&i2c_bus_type, NULL, adev,
> > -			      i2c_acpi_find_match_device);
> > +	dev = bus_find_device_by_acpi_dev(&i2c_bus_type, adev);
> >  	return dev ? i2c_verify_client(dev) : NULL;
> >  }
> >  
> > diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
> > index a591da87981a..c486a6f84c2c 100644
> > --- a/drivers/spi/spi.c
> > +++ b/drivers/spi/spi.c
> > @@ -3741,11 +3741,6 @@ static int spi_acpi_controller_match(struct device *dev, const void *data)
> >  	return ACPI_COMPANION(dev->parent) == data;
> >  }
> >  
> > -static int spi_acpi_device_match(struct device *dev, const void *data)
> > -{
> > -	return ACPI_COMPANION(dev) == data;
> > -}
> > -
> >  static struct spi_controller *acpi_spi_find_controller_by_adev(struct acpi_device *adev)
> >  {
> >  	struct device *dev;
> > @@ -3765,8 +3760,7 @@ static struct spi_device *acpi_spi_find_device_by_adev(struct acpi_device *adev)
> >  {
> >  	struct device *dev;
> >  
> > -	dev = bus_find_device(&spi_bus_type, NULL, adev, spi_acpi_device_match);
> > -
> > +	dev = bus_find_device_by_acpi_dev(&spi_bus_type, adev);
> >  	return dev ? to_spi_device(dev) : NULL;
> >  }
> >  
> > diff --git a/include/linux/device.h b/include/linux/device.h
> > index 93b2f55ef44e..7514ef3d3f1a 100644
> > --- a/include/linux/device.h
> > +++ b/include/linux/device.h
> > @@ -168,6 +168,7 @@ int device_match_name(struct device *dev, const void *name);
> >  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));
> > @@ -224,6 +225,28 @@ static inline struct device *bus_find_device_by_devt(struct bus_type *bus,
> >  	return bus_find_device(bus, NULL, &devt, device_match_devt);
> >  }
> >  
> > +#ifdef CONFIG_ACPI
> > +struct acpi_device;
> > +
> > +/**
> > + * bus_find_device_by_acpi_dev : device iterator for locating a particular device
> > + * matching the ACPI COMPANION device.
> > + * @bus: bus type
> > + * @adev: ACPI COMPANION device to match.
> > + */
> > +static inline struct device *
> > +bus_find_device_by_acpi_dev(struct bus_type *bus, const struct acpi_device *adev)
> > +{
> > +	return bus_find_device(bus, NULL, adev, device_match_acpi_dev);
> > +}
> > +#else
> > +static inline struct device *
> > +bus_find_device_by_acpi_dev(struct bus_type *bus, const void *adev)
> > +{
> > +	return NULL;
> > +}
> > +#endif
> > +
> >  struct device *subsys_find_device_by_id(struct bus_type *bus, unsigned int id,
> >  					struct device *hint);
> >  int bus_for_each_drv(struct bus_type *bus, struct device_driver *start,
> > @@ -442,6 +465,27 @@ static inline struct device *driver_find_device_by_devt(struct device_driver *dr
> >  	return driver_find_device(drv, NULL, &devt, device_match_devt);
> >  }
> >  
> > +#ifdef CONFIG_ACPI
> > +/**
> > + * driver_find_device_by_acpi_dev : device iterator for locating a particular
> > + * device matching the ACPI_COMPANION device.
> > + * @driver: the driver we're iterating
> > + * @adev: ACPI_COMPANION device to match.
> > + */
> > +static inline struct device *
> > +driver_find_device_by_acpi_dev(struct device_driver *drv,
> > +			       const struct acpi_device *adev)
> > +{
> > +	return driver_find_device(drv, NULL, adev, device_match_acpi_dev);
> > +}
> > +#else
> > +static inline struct device *
> > +driver_find_device_by_acpi_dev(struct device_driver *drv, const void *adev)
> > +{
> > +	return NULL;
> > +}
> > +#endif
> > +
> >  void driver_deferred_probe_add(struct device *dev);
> >  int driver_deferred_probe_check_state(struct device *dev);
> >  int driver_deferred_probe_check_state_continue(struct device *dev);
> > @@ -620,6 +664,27 @@ static inline struct device *class_find_device_by_devt(struct class *class,
> >  	return class_find_device(class, NULL, &devt, device_match_devt);
> >  }
> >  
> > +#ifdef CONFIG_ACPI
> > +struct acpi_device;
> > +/**
> > + * class_find_device_by_acpi_dev : device iterator for locating a particular
> > + * device matching the ACPI_COMPANION device.
> > + * @class: class type
> > + * @adev: ACPI_COMPANION device to match.
> > + */
> > +static inline struct device *
> > +class_find_device_by_acpi_dev(struct class *class, const struct acpi_device *adev)
> > +{
> > +	return class_find_device(class, NULL, adev, device_match_acpi_dev);
> > +}
> > +#else
> > +static inline struct device *
> > +class_find_device_by_acpi_dev(struct class *class, const void *adev)
> > +{
> > +	return NULL;
> > +}
> > +#endif
> > +
> >  struct class_attribute {
> >  	struct attribute attr;
> >  	ssize_t (*show)(struct class *class, struct class_attribute *attr,
> > -- 
> > 2.21.0
> > 



-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH v3 5/7] drivers: Introduce device lookup variants by ACPI_COMPANION device
  2019-08-01 11:58     ` Andy Shevchenko
@ 2019-08-01 12:08       ` Wolfram Sang
  2019-08-01 12:21         ` Andy Shevchenko
  0 siblings, 1 reply; 7+ messages in thread
From: Wolfram Sang @ 2019-08-01 12:08 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Suzuki K Poulose, Mika Westerberg, Jarkko Nikula, linux-kernel,
	gregkh, rafael, linux-arm-kernel, Len Brown, linux-acpi,
	linux-spi, Mark Brown, linux-i2c

[-- Attachment #1: Type: text/plain, Size: 1287 bytes --]

On Thu, Aug 01, 2019 at 02:58:56PM +0300, Andy Shevchenko wrote:
> On Fri, Jul 26, 2019 at 10:23:54PM +0200, Wolfram Sang wrote:
> > On Tue, Jul 23, 2019 at 11:18:36PM +0100, Suzuki K Poulose wrote:
> > > Add a generic helper to match a device by the ACPI_COMPANION device
> > > and provide wrappers for the device lookup APIs.
> > > 
> > > 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: Mika Westerberg <mika.westerberg@linux.intel.com>
> > > Cc: Wolfram Sang <wsa@the-dreams.de>
> > > Cc: linux-i2c@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>
> > 
> > From my side, OK:
> > 
> > Acked-by: Wolfram Sang <wsa@the-dreams.de> # I2C parts
> > 
> > yet you missed to cc the I2C ACPI maintainers. Done so now.
> 
> Acked-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> 
> Thanks, Wolfram, for notifying.

Sure. There seems to be a problem, though? Please check:

[PATCH 1/3] i2c: Revert incorrect conversion to use generic helper

which came in today.


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH v3 5/7] drivers: Introduce device lookup variants by ACPI_COMPANION device
  2019-08-01 12:08       ` Wolfram Sang
@ 2019-08-01 12:21         ` Andy Shevchenko
  2019-08-01 12:27           ` Wolfram Sang
  0 siblings, 1 reply; 7+ messages in thread
From: Andy Shevchenko @ 2019-08-01 12:21 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: Suzuki K Poulose, Mika Westerberg, Jarkko Nikula, linux-kernel,
	gregkh, rafael, linux-arm-kernel, Len Brown, linux-acpi,
	linux-spi, Mark Brown, linux-i2c

On Thu, Aug 01, 2019 at 02:08:30PM +0200, Wolfram Sang wrote:
> On Thu, Aug 01, 2019 at 02:58:56PM +0300, Andy Shevchenko wrote:
> > On Fri, Jul 26, 2019 at 10:23:54PM +0200, Wolfram Sang wrote:
> > > On Tue, Jul 23, 2019 at 11:18:36PM +0100, Suzuki K Poulose wrote:
> > > > Add a generic helper to match a device by the ACPI_COMPANION device
> > > > and provide wrappers for the device lookup APIs.
> > > > 
> > > > 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: Mika Westerberg <mika.westerberg@linux.intel.com>
> > > > Cc: Wolfram Sang <wsa@the-dreams.de>
> > > > Cc: linux-i2c@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>
> > > 
> > > From my side, OK:
> > > 
> > > Acked-by: Wolfram Sang <wsa@the-dreams.de> # I2C parts
> > > 
> > > yet you missed to cc the I2C ACPI maintainers. Done so now.
> > 
> > Acked-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> > 
> > Thanks, Wolfram, for notifying.
> 
> Sure. There seems to be a problem, though? Please check:
> 
> [PATCH 1/3] i2c: Revert incorrect conversion to use generic helper
> 
> which came in today.

It's again not Cc'ed to all parties.
But OK, looks good to me.
Tough may be Jarkko can test all this.

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH v3 5/7] drivers: Introduce device lookup variants by ACPI_COMPANION device
  2019-08-01 12:21         ` Andy Shevchenko
@ 2019-08-01 12:27           ` Wolfram Sang
  0 siblings, 0 replies; 7+ messages in thread
From: Wolfram Sang @ 2019-08-01 12:27 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Suzuki K Poulose, Mika Westerberg, Jarkko Nikula, linux-kernel,
	gregkh, rafael, linux-arm-kernel, Len Brown, linux-acpi,
	linux-spi, Mark Brown, linux-i2c

[-- Attachment #1: Type: text/plain, Size: 220 bytes --]


> It's again not Cc'ed to all parties.
> But OK, looks good to me.
> Tough may be Jarkko can test all this.

To be fair, only Mika is listed as I2C ACPI maintainer. Feel free to add
more :) I assume Mika doesn't mind.


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

end of thread, back to index

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20190723221838.12024-1-suzuki.poulose@arm.com>
2019-07-23 22:18 ` [PATCH v3 5/7] drivers: Introduce device lookup variants by ACPI_COMPANION device Suzuki K Poulose
2019-07-26 17:18   ` Mark Brown
2019-07-26 20:23   ` Wolfram Sang
2019-08-01 11:58     ` Andy Shevchenko
2019-08-01 12:08       ` Wolfram Sang
2019-08-01 12:21         ` Andy Shevchenko
2019-08-01 12:27           ` Wolfram Sang

Linux-ACPI Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-acpi/0 linux-acpi/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-acpi linux-acpi/ https://lore.kernel.org/linux-acpi \
		linux-acpi@vger.kernel.org linux-acpi@archiver.kernel.org
	public-inbox-index linux-acpi


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-acpi


AGPL code for this site: git clone https://public-inbox.org/ public-inbox