* [PATCH v4 1/3] driver core: Provide device_match_acpi_handle() helper
@ 2021-10-14 13:47 Andy Shevchenko
2021-10-14 13:47 ` [PATCH v4 2/3] i2c: acpi: Replace custom function with device_match_acpi_handle() Andy Shevchenko
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Andy Shevchenko @ 2021-10-14 13:47 UTC (permalink / raw)
To: Greg Kroah-Hartman, Saravana Kannan, Andy Shevchenko,
Uwe Kleine-König, linux-kernel, linux-gpio, linux-acpi,
linux-i2c
Cc: Rafael J. Wysocki, Mika Westerberg, Linus Walleij,
Bartosz Golaszewski, Wolfram Sang
We have a couple of users of this helper, make it available for them.
The prototype for the helper is specifically crafted in order to be
easily used with bus_find_device() call. That's why its location is
in the driver core rather than ACPI.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
v4: amended changelog to clarify implementation details (Rafael)
drivers/base/core.c | 6 ++++++
include/linux/device/bus.h | 1 +
2 files changed, 7 insertions(+)
diff --git a/drivers/base/core.c b/drivers/base/core.c
index b67ebe6a323c..fd034d742447 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -4838,6 +4838,12 @@ int device_match_acpi_dev(struct device *dev, const void *adev)
}
EXPORT_SYMBOL(device_match_acpi_dev);
+int device_match_acpi_handle(struct device *dev, const void *handle)
+{
+ return ACPI_HANDLE(dev) == handle;
+}
+EXPORT_SYMBOL(device_match_acpi_handle);
+
int device_match_any(struct device *dev, const void *unused)
{
return 1;
diff --git a/include/linux/device/bus.h b/include/linux/device/bus.h
index 062777a45a74..a039ab809753 100644
--- a/include/linux/device/bus.h
+++ b/include/linux/device/bus.h
@@ -143,6 +143,7 @@ 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 device_match_acpi_handle(struct device *dev, const void *handle);
int device_match_any(struct device *dev, const void *unused);
/* iterator helpers for buses */
--
2.33.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v4 2/3] i2c: acpi: Replace custom function with device_match_acpi_handle()
2021-10-14 13:47 [PATCH v4 1/3] driver core: Provide device_match_acpi_handle() helper Andy Shevchenko
@ 2021-10-14 13:47 ` Andy Shevchenko
2021-10-14 13:47 ` [PATCH v4 3/3] gpiolib: acpi: Replace custom code " Andy Shevchenko
2021-10-15 11:42 ` [PATCH v4 1/3] driver core: Provide device_match_acpi_handle() helper Rafael J. Wysocki
2 siblings, 0 replies; 6+ messages in thread
From: Andy Shevchenko @ 2021-10-14 13:47 UTC (permalink / raw)
To: Greg Kroah-Hartman, Saravana Kannan, Andy Shevchenko,
Uwe Kleine-König, linux-kernel, linux-gpio, linux-acpi,
linux-i2c
Cc: Rafael J. Wysocki, Mika Westerberg, Linus Walleij,
Bartosz Golaszewski, Wolfram Sang
Since driver core provides a generic device_match_acpi_handle()
we may replace the custom one with it. This unifies code to find
an adapter with the similar one which finds a client.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Wolfram Sang <wsa@kernel.org>
---
v4: added tag (Wolfram)
drivers/i2c/i2c-core-acpi.c | 22 +++++++++-------------
1 file changed, 9 insertions(+), 13 deletions(-)
diff --git a/drivers/i2c/i2c-core-acpi.c b/drivers/i2c/i2c-core-acpi.c
index 7ea2ac712a57..0aea776cd4c9 100644
--- a/drivers/i2c/i2c-core-acpi.c
+++ b/drivers/i2c/i2c-core-acpi.c
@@ -398,24 +398,20 @@ u32 i2c_acpi_find_bus_speed(struct device *dev)
}
EXPORT_SYMBOL_GPL(i2c_acpi_find_bus_speed);
-static int i2c_acpi_find_match_adapter(struct device *dev, const void *data)
-{
- struct i2c_adapter *adapter = i2c_verify_adapter(dev);
-
- if (!adapter)
- return 0;
-
- return ACPI_HANDLE(dev) == (acpi_handle)data;
-}
-
struct i2c_adapter *i2c_acpi_find_adapter_by_handle(acpi_handle handle)
{
+ struct i2c_adapter *adapter;
struct device *dev;
- dev = bus_find_device(&i2c_bus_type, NULL, handle,
- i2c_acpi_find_match_adapter);
+ dev = bus_find_device(&i2c_bus_type, NULL, handle, device_match_acpi_handle);
+ if (!dev)
+ return NULL;
+
+ adapter = i2c_verify_adapter(dev);
+ if (!adapter)
+ put_device(dev);
- return dev ? i2c_verify_adapter(dev) : NULL;
+ return adapter;
}
EXPORT_SYMBOL_GPL(i2c_acpi_find_adapter_by_handle);
--
2.33.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v4 3/3] gpiolib: acpi: Replace custom code with device_match_acpi_handle()
2021-10-14 13:47 [PATCH v4 1/3] driver core: Provide device_match_acpi_handle() helper Andy Shevchenko
2021-10-14 13:47 ` [PATCH v4 2/3] i2c: acpi: Replace custom function with device_match_acpi_handle() Andy Shevchenko
@ 2021-10-14 13:47 ` Andy Shevchenko
2021-10-15 11:42 ` [PATCH v4 1/3] driver core: Provide device_match_acpi_handle() helper Rafael J. Wysocki
2 siblings, 0 replies; 6+ messages in thread
From: Andy Shevchenko @ 2021-10-14 13:47 UTC (permalink / raw)
To: Greg Kroah-Hartman, Saravana Kannan, Andy Shevchenko,
Uwe Kleine-König, linux-kernel, linux-gpio, linux-acpi,
linux-i2c
Cc: Rafael J. Wysocki, Mika Westerberg, Linus Walleij,
Bartosz Golaszewski, Wolfram Sang
Since driver core provides a generic device_match_acpi_handle()
we may replace the custom code with it.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
v4: no changes
drivers/gpio/gpiolib-acpi.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c
index 47712b6903b5..985e8589c58b 100644
--- a/drivers/gpio/gpiolib-acpi.c
+++ b/drivers/gpio/gpiolib-acpi.c
@@ -95,10 +95,7 @@ static bool acpi_gpio_deferred_req_irqs_done;
static int acpi_gpiochip_find(struct gpio_chip *gc, void *data)
{
- if (!gc->parent)
- return false;
-
- return ACPI_HANDLE(gc->parent) == data;
+ return gc->parent && device_match_acpi_handle(gc->parent, data);
}
/**
--
2.33.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v4 1/3] driver core: Provide device_match_acpi_handle() helper
2021-10-14 13:47 [PATCH v4 1/3] driver core: Provide device_match_acpi_handle() helper Andy Shevchenko
2021-10-14 13:47 ` [PATCH v4 2/3] i2c: acpi: Replace custom function with device_match_acpi_handle() Andy Shevchenko
2021-10-14 13:47 ` [PATCH v4 3/3] gpiolib: acpi: Replace custom code " Andy Shevchenko
@ 2021-10-15 11:42 ` Rafael J. Wysocki
2021-10-19 12:01 ` Andy Shevchenko
2 siblings, 1 reply; 6+ messages in thread
From: Rafael J. Wysocki @ 2021-10-15 11:42 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Greg Kroah-Hartman, Saravana Kannan, Uwe Kleine-König,
Linux Kernel Mailing List, open list:GPIO SUBSYSTEM,
ACPI Devel Maling List, linux-i2c, Rafael J. Wysocki,
Mika Westerberg, Linus Walleij, Bartosz Golaszewski,
Wolfram Sang
On Thu, Oct 14, 2021 at 3:48 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
>
> We have a couple of users of this helper, make it available for them.
>
> The prototype for the helper is specifically crafted in order to be
> easily used with bus_find_device() call. That's why its location is
> in the driver core rather than ACPI.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
OK, please feel free to add
Reviewed-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
to all of the patches in this series.
> ---
> v4: amended changelog to clarify implementation details (Rafael)
> drivers/base/core.c | 6 ++++++
> include/linux/device/bus.h | 1 +
> 2 files changed, 7 insertions(+)
>
> diff --git a/drivers/base/core.c b/drivers/base/core.c
> index b67ebe6a323c..fd034d742447 100644
> --- a/drivers/base/core.c
> +++ b/drivers/base/core.c
> @@ -4838,6 +4838,12 @@ int device_match_acpi_dev(struct device *dev, const void *adev)
> }
> EXPORT_SYMBOL(device_match_acpi_dev);
>
> +int device_match_acpi_handle(struct device *dev, const void *handle)
> +{
> + return ACPI_HANDLE(dev) == handle;
> +}
> +EXPORT_SYMBOL(device_match_acpi_handle);
> +
> int device_match_any(struct device *dev, const void *unused)
> {
> return 1;
> diff --git a/include/linux/device/bus.h b/include/linux/device/bus.h
> index 062777a45a74..a039ab809753 100644
> --- a/include/linux/device/bus.h
> +++ b/include/linux/device/bus.h
> @@ -143,6 +143,7 @@ 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 device_match_acpi_handle(struct device *dev, const void *handle);
> int device_match_any(struct device *dev, const void *unused);
>
> /* iterator helpers for buses */
> --
> 2.33.0
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v4 1/3] driver core: Provide device_match_acpi_handle() helper
2021-10-15 11:42 ` [PATCH v4 1/3] driver core: Provide device_match_acpi_handle() helper Rafael J. Wysocki
@ 2021-10-19 12:01 ` Andy Shevchenko
2021-10-20 17:38 ` Greg Kroah-Hartman
0 siblings, 1 reply; 6+ messages in thread
From: Andy Shevchenko @ 2021-10-19 12:01 UTC (permalink / raw)
To: Rafael J. Wysocki
Cc: Greg Kroah-Hartman, Saravana Kannan, Uwe Kleine-König,
Linux Kernel Mailing List, open list:GPIO SUBSYSTEM,
ACPI Devel Maling List, linux-i2c, Mika Westerberg,
Linus Walleij, Bartosz Golaszewski, Wolfram Sang
On Fri, Oct 15, 2021 at 01:42:37PM +0200, Rafael J. Wysocki wrote:
> On Thu, Oct 14, 2021 at 3:48 PM Andy Shevchenko
> <andriy.shevchenko@linux.intel.com> wrote:
> >
> > We have a couple of users of this helper, make it available for them.
> >
> > The prototype for the helper is specifically crafted in order to be
> > easily used with bus_find_device() call. That's why its location is
> > in the driver core rather than ACPI.
> >
> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
>
> OK, please feel free to add
>
> Reviewed-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>
> to all of the patches in this series.
Thank you, Rafael!
Greg, can it be applied now?
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v4 1/3] driver core: Provide device_match_acpi_handle() helper
2021-10-19 12:01 ` Andy Shevchenko
@ 2021-10-20 17:38 ` Greg Kroah-Hartman
0 siblings, 0 replies; 6+ messages in thread
From: Greg Kroah-Hartman @ 2021-10-20 17:38 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Rafael J. Wysocki, Saravana Kannan, Uwe Kleine-König,
Linux Kernel Mailing List, open list:GPIO SUBSYSTEM,
ACPI Devel Maling List, linux-i2c, Mika Westerberg,
Linus Walleij, Bartosz Golaszewski, Wolfram Sang
On Tue, Oct 19, 2021 at 03:01:14PM +0300, Andy Shevchenko wrote:
> On Fri, Oct 15, 2021 at 01:42:37PM +0200, Rafael J. Wysocki wrote:
> > On Thu, Oct 14, 2021 at 3:48 PM Andy Shevchenko
> > <andriy.shevchenko@linux.intel.com> wrote:
> > >
> > > We have a couple of users of this helper, make it available for them.
> > >
> > > The prototype for the helper is specifically crafted in order to be
> > > easily used with bus_find_device() call. That's why its location is
> > > in the driver core rather than ACPI.
> > >
> > > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> >
> > OK, please feel free to add
> >
> > Reviewed-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> >
> > to all of the patches in this series.
>
> Thank you, Rafael!
>
> Greg, can it be applied now?
Yes, will go do so now, thanks.
greg k-h
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2021-10-20 17:38 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-14 13:47 [PATCH v4 1/3] driver core: Provide device_match_acpi_handle() helper Andy Shevchenko
2021-10-14 13:47 ` [PATCH v4 2/3] i2c: acpi: Replace custom function with device_match_acpi_handle() Andy Shevchenko
2021-10-14 13:47 ` [PATCH v4 3/3] gpiolib: acpi: Replace custom code " Andy Shevchenko
2021-10-15 11:42 ` [PATCH v4 1/3] driver core: Provide device_match_acpi_handle() helper Rafael J. Wysocki
2021-10-19 12:01 ` Andy Shevchenko
2021-10-20 17:38 ` Greg Kroah-Hartman
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.