* [PATCH v3 1/3] driver core: Provide device_match_acpi_handle() helper
@ 2021-10-07 17:18 Andy Shevchenko
2021-10-07 17:18 ` [PATCH v3 2/3] i2c: acpi: Replace custom function with device_match_acpi_handle() Andy Shevchenko
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Andy Shevchenko @ 2021-10-07 17:18 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>
---
v3: no changes
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] 8+ messages in thread
* [PATCH v3 2/3] i2c: acpi: Replace custom function with device_match_acpi_handle()
2021-10-07 17:18 [PATCH v3 1/3] driver core: Provide device_match_acpi_handle() helper Andy Shevchenko
@ 2021-10-07 17:18 ` Andy Shevchenko
2021-10-11 9:49 ` Wolfram Sang
2021-10-07 17:18 ` [PATCH v3 3/3] gpiolib: acpi: Replace custom code " Andy Shevchenko
2021-10-13 17:47 ` [PATCH v3 1/3] driver core: Provide device_match_acpi_handle() helper Rafael J. Wysocki
2 siblings, 1 reply; 8+ messages in thread
From: Andy Shevchenko @ 2021-10-07 17:18 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>
---
v3: 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] 8+ messages in thread
* Re: [PATCH v3 2/3] i2c: acpi: Replace custom function with device_match_acpi_handle()
2021-10-07 17:18 ` [PATCH v3 2/3] i2c: acpi: Replace custom function with device_match_acpi_handle() Andy Shevchenko
@ 2021-10-11 9:49 ` Wolfram Sang
0 siblings, 0 replies; 8+ messages in thread
From: Wolfram Sang @ 2021-10-11 9:49 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Greg Kroah-Hartman, Saravana Kannan, Uwe Kleine-König,
linux-kernel, linux-gpio, linux-acpi, linux-i2c,
Rafael J. Wysocki, Mika Westerberg, Linus Walleij,
Bartosz Golaszewski
[-- Attachment #1: Type: text/plain, Size: 394 bytes --]
On Thu, Oct 07, 2021 at 08:18:14PM +0300, Andy Shevchenko wrote:
> 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>
Fine with me:
Acked-by: Wolfram Sang <wsa@kernel.org>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v3 3/3] gpiolib: acpi: Replace custom code with device_match_acpi_handle()
2021-10-07 17:18 [PATCH v3 1/3] driver core: Provide device_match_acpi_handle() helper Andy Shevchenko
2021-10-07 17:18 ` [PATCH v3 2/3] i2c: acpi: Replace custom function with device_match_acpi_handle() Andy Shevchenko
@ 2021-10-07 17:18 ` Andy Shevchenko
2021-10-13 17:47 ` [PATCH v3 1/3] driver core: Provide device_match_acpi_handle() helper Rafael J. Wysocki
2 siblings, 0 replies; 8+ messages in thread
From: Andy Shevchenko @ 2021-10-07 17:18 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>
---
v3: amended the expression (Rafael)
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] 8+ messages in thread
* Re: [PATCH v3 1/3] driver core: Provide device_match_acpi_handle() helper
2021-10-07 17:18 [PATCH v3 1/3] driver core: Provide device_match_acpi_handle() helper Andy Shevchenko
2021-10-07 17:18 ` [PATCH v3 2/3] i2c: acpi: Replace custom function with device_match_acpi_handle() Andy Shevchenko
2021-10-07 17:18 ` [PATCH v3 3/3] gpiolib: acpi: Replace custom code " Andy Shevchenko
@ 2021-10-13 17:47 ` Rafael J. Wysocki
2021-10-13 21:24 ` Andy Shevchenko
2 siblings, 1 reply; 8+ messages in thread
From: Rafael J. Wysocki @ 2021-10-13 17:47 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 7, 2021 at 7:18 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
>
> We have couple of users of this helper, make it available for them.
"a couple"?
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
> v3: no changes
> 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)
Hmmm. Should the second arg be of type acpi_handle?
And doesn't this function belong to the ACPI core? It is related to
acpi_bus_get_device() and such which are located there.
> +{
> + 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] 8+ messages in thread
* Re: [PATCH v3 1/3] driver core: Provide device_match_acpi_handle() helper
2021-10-13 17:47 ` [PATCH v3 1/3] driver core: Provide device_match_acpi_handle() helper Rafael J. Wysocki
@ 2021-10-13 21:24 ` Andy Shevchenko
2021-10-13 18:33 ` Rafael J. Wysocki
0 siblings, 1 reply; 8+ messages in thread
From: Andy Shevchenko @ 2021-10-13 21:24 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 Wed, Oct 13, 2021 at 07:47:37PM +0200, Rafael J. Wysocki wrote:
> On Thu, Oct 7, 2021 at 7:18 PM Andy Shevchenko
> <andriy.shevchenko@linux.intel.com> wrote:
> >
> > We have couple of users of this helper, make it available for them.
>
> "a couple"?
Yep.
> > EXPORT_SYMBOL(device_match_acpi_dev);
> >
> > +int device_match_acpi_handle(struct device *dev, const void *handle)
>
> Hmmm. Should the second arg be of type acpi_handle?
acpi_handle is not defined as struct and it means the header, where the
prototype is declared, will require acpi.h to be included. Besides that the
whole set of device_match_*() is done by the same prototype, so it can be used
in bus_find_device() calls.
> And doesn't this function belong to the ACPI core? It is related to
> acpi_bus_get_device() and such which are located there.
Same as above. I don't think so.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v3 1/3] driver core: Provide device_match_acpi_handle() helper
2021-10-13 21:24 ` Andy Shevchenko
@ 2021-10-13 18:33 ` Rafael J. Wysocki
2021-10-14 8:48 ` Greg Kroah-Hartman
0 siblings, 1 reply; 8+ messages in thread
From: Rafael J. Wysocki @ 2021-10-13 18:33 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 Wed, Oct 13, 2021 at 8:24 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
>
> On Wed, Oct 13, 2021 at 07:47:37PM +0200, Rafael J. Wysocki wrote:
> > On Thu, Oct 7, 2021 at 7:18 PM Andy Shevchenko
> > <andriy.shevchenko@linux.intel.com> wrote:
> > >
> > > We have couple of users of this helper, make it available for them.
> >
> > "a couple"?
>
> Yep.
>
> > > EXPORT_SYMBOL(device_match_acpi_dev);
> > >
> > > +int device_match_acpi_handle(struct device *dev, const void *handle)
> >
> > Hmmm. Should the second arg be of type acpi_handle?
>
> acpi_handle is not defined as struct and it means the header, where the
> prototype is declared, will require acpi.h to be included. Besides that the
> whole set of device_match_*() is done by the same prototype, so it can be used
> in bus_find_device() calls.
Ah, OK, it's for bus_find_device().
> > And doesn't this function belong to the ACPI core? It is related to
> > acpi_bus_get_device() and such which are located there.
>
> Same as above. I don't think so.
I see, but any chance to improve the changelog?
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v3 1/3] driver core: Provide device_match_acpi_handle() helper
2021-10-13 18:33 ` Rafael J. Wysocki
@ 2021-10-14 8:48 ` Greg Kroah-Hartman
0 siblings, 0 replies; 8+ messages in thread
From: Greg Kroah-Hartman @ 2021-10-14 8:48 UTC (permalink / raw)
To: Rafael J. Wysocki
Cc: Andy Shevchenko, 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 Wed, Oct 13, 2021 at 08:33:14PM +0200, Rafael J. Wysocki wrote:
> On Wed, Oct 13, 2021 at 8:24 PM Andy Shevchenko
> <andriy.shevchenko@linux.intel.com> wrote:
> >
> > On Wed, Oct 13, 2021 at 07:47:37PM +0200, Rafael J. Wysocki wrote:
> > > On Thu, Oct 7, 2021 at 7:18 PM Andy Shevchenko
> > > <andriy.shevchenko@linux.intel.com> wrote:
> > > >
> > > > We have couple of users of this helper, make it available for them.
> > >
> > > "a couple"?
> >
> > Yep.
> >
> > > > EXPORT_SYMBOL(device_match_acpi_dev);
> > > >
> > > > +int device_match_acpi_handle(struct device *dev, const void *handle)
> > >
> > > Hmmm. Should the second arg be of type acpi_handle?
> >
> > acpi_handle is not defined as struct and it means the header, where the
> > prototype is declared, will require acpi.h to be included. Besides that the
> > whole set of device_match_*() is done by the same prototype, so it can be used
> > in bus_find_device() calls.
>
> Ah, OK, it's for bus_find_device().
>
> > > And doesn't this function belong to the ACPI core? It is related to
> > > acpi_bus_get_device() and such which are located there.
> >
> > Same as above. I don't think so.
>
> I see, but any chance to improve the changelog?
I will drop this from my testing tree and wait for a new version with a
better changelog.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2021-10-14 8:48 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-07 17:18 [PATCH v3 1/3] driver core: Provide device_match_acpi_handle() helper Andy Shevchenko
2021-10-07 17:18 ` [PATCH v3 2/3] i2c: acpi: Replace custom function with device_match_acpi_handle() Andy Shevchenko
2021-10-11 9:49 ` Wolfram Sang
2021-10-07 17:18 ` [PATCH v3 3/3] gpiolib: acpi: Replace custom code " Andy Shevchenko
2021-10-13 17:47 ` [PATCH v3 1/3] driver core: Provide device_match_acpi_handle() helper Rafael J. Wysocki
2021-10-13 21:24 ` Andy Shevchenko
2021-10-13 18:33 ` Rafael J. Wysocki
2021-10-14 8:48 ` Greg Kroah-Hartman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).