* [PATCH v2 1/3] driver core: Provide device_match_acpi_handle() helper
@ 2021-10-06 17:31 Andy Shevchenko
2021-10-06 17:31 ` [PATCH v2 2/3] i2c: acpi: Replace custom function with device_match_acpi_handle() Andy Shevchenko
2021-10-06 17:31 ` [PATCH v2 3/3] gpiolib: acpi: Replace custom code " Andy Shevchenko
0 siblings, 2 replies; 7+ messages in thread
From: Andy Shevchenko @ 2021-10-06 17:31 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 couple of users of this helper, make it available for them.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
v2: fixed compilation error (Greg)
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 c4a2c97a21a2..3a5623ea1369 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -4840,6 +4840,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] 7+ messages in thread
* [PATCH v2 2/3] i2c: acpi: Replace custom function with device_match_acpi_handle()
2021-10-06 17:31 [PATCH v2 1/3] driver core: Provide device_match_acpi_handle() helper Andy Shevchenko
@ 2021-10-06 17:31 ` Andy Shevchenko
2021-10-06 17:31 ` [PATCH v2 3/3] gpiolib: acpi: Replace custom code " Andy Shevchenko
1 sibling, 0 replies; 7+ messages in thread
From: Andy Shevchenko @ 2021-10-06 17:31 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>
---
v2: no changes
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] 7+ messages in thread
* [PATCH v2 3/3] gpiolib: acpi: Replace custom code with device_match_acpi_handle()
2021-10-06 17:31 [PATCH v2 1/3] driver core: Provide device_match_acpi_handle() helper Andy Shevchenko
2021-10-06 17:31 ` [PATCH v2 2/3] i2c: acpi: Replace custom function with device_match_acpi_handle() Andy Shevchenko
@ 2021-10-06 17:31 ` Andy Shevchenko
2021-10-07 16:50 ` Rafael J. Wysocki
1 sibling, 1 reply; 7+ messages in thread
From: Andy Shevchenko @ 2021-10-06 17:31 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>
---
v2: 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..32f1f720b94b 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) : false;
}
/**
--
2.33.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v2 3/3] gpiolib: acpi: Replace custom code with device_match_acpi_handle()
2021-10-06 17:31 ` [PATCH v2 3/3] gpiolib: acpi: Replace custom code " Andy Shevchenko
@ 2021-10-07 16:50 ` Rafael J. Wysocki
2021-10-07 17:01 ` Andy Shevchenko
0 siblings, 1 reply; 7+ messages in thread
From: Rafael J. Wysocki @ 2021-10-07 16:50 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 Wed, Oct 6, 2021 at 7:31 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
>
> 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>
> ---
> v2: 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..32f1f720b94b 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) : false;
return gc->parent && device_match_acpi_handle(gc->parent, data);
would work too if I'm not mistaken.
> }
>
> /**
> --
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 3/3] gpiolib: acpi: Replace custom code with device_match_acpi_handle()
2021-10-07 16:50 ` Rafael J. Wysocki
@ 2021-10-07 17:01 ` Andy Shevchenko
2021-10-07 17:07 ` Rafael J. Wysocki
0 siblings, 1 reply; 7+ messages in thread
From: Andy Shevchenko @ 2021-10-07 17: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 Thu, Oct 07, 2021 at 06:50:46PM +0200, Rafael J. Wysocki wrote:
> On Wed, Oct 6, 2021 at 7:31 PM Andy Shevchenko
> <andriy.shevchenko@linux.intel.com> wrote:
...
> > + return gc->parent ? device_match_acpi_handle(gc->parent, data) : false;
>
> return gc->parent && device_match_acpi_handle(gc->parent, data);
>
> would work too if I'm not mistaken.
Seems so.
Thanks for review, I will update for v3.
Any other comments to the series?
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 3/3] gpiolib: acpi: Replace custom code with device_match_acpi_handle()
2021-10-07 17:01 ` Andy Shevchenko
@ 2021-10-07 17:07 ` Rafael J. Wysocki
2021-10-07 17:18 ` Andy Shevchenko
0 siblings, 1 reply; 7+ messages in thread
From: Rafael J. Wysocki @ 2021-10-07 17:07 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Rafael J. Wysocki, 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 Thu, Oct 7, 2021 at 7:02 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
>
> On Thu, Oct 07, 2021 at 06:50:46PM +0200, Rafael J. Wysocki wrote:
> > On Wed, Oct 6, 2021 at 7:31 PM Andy Shevchenko
> > <andriy.shevchenko@linux.intel.com> wrote:
>
> ...
>
> > > + return gc->parent ? device_match_acpi_handle(gc->parent, data) : false;
> >
> > return gc->parent && device_match_acpi_handle(gc->parent, data);
> >
> > would work too if I'm not mistaken.
>
> Seems so.
>
> Thanks for review, I will update for v3.
> Any other comments to the series?
Not really. Patch [2/3] is correct AFAICS.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 3/3] gpiolib: acpi: Replace custom code with device_match_acpi_handle()
2021-10-07 17:07 ` Rafael J. Wysocki
@ 2021-10-07 17:18 ` Andy Shevchenko
0 siblings, 0 replies; 7+ messages in thread
From: Andy Shevchenko @ 2021-10-07 17:18 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 Thu, Oct 07, 2021 at 07:07:19PM +0200, Rafael J. Wysocki wrote:
> On Thu, Oct 7, 2021 at 7:02 PM Andy Shevchenko
> <andriy.shevchenko@linux.intel.com> wrote:
> > On Thu, Oct 07, 2021 at 06:50:46PM +0200, Rafael J. Wysocki wrote:
...
> > Thanks for review, I will update for v3.
> > Any other comments to the series?
>
> Not really. Patch [2/3] is correct AFAICS.
v3 on its way!
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2021-10-07 17:20 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-06 17:31 [PATCH v2 1/3] driver core: Provide device_match_acpi_handle() helper Andy Shevchenko
2021-10-06 17:31 ` [PATCH v2 2/3] i2c: acpi: Replace custom function with device_match_acpi_handle() Andy Shevchenko
2021-10-06 17:31 ` [PATCH v2 3/3] gpiolib: acpi: Replace custom code " Andy Shevchenko
2021-10-07 16:50 ` Rafael J. Wysocki
2021-10-07 17:01 ` Andy Shevchenko
2021-10-07 17:07 ` Rafael J. Wysocki
2021-10-07 17:18 ` Andy Shevchenko
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.