driver core: Provide device_match_acpi_handle() helper
Subsystems (6)
PATCH v2 1/3 driver core: Provide device_match_acpi_handle() helper
We have couple of users of this helper, make it available for them.
---
v2: fixed compilation error (Greg)
drivers/base/core.c | 6 ++++++ include/linux/device/bus.h | 1 + 2 files changed, 7 insertions(+)
drivers/base/core.c +6 -0
@@ -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 ;
include/linux/device/bus.h +1 -0
@@ -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 */
Signature · 1 line
2.33.0
PATCH v2 2/3 i2c: acpi: Replace custom function with device_match_acpi_handle()
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.
---
v2: no changes
drivers/i2c/i2c-core-acpi.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-)
drivers/i2c/i2c-core-acpi.c +9 -13
@@ -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);
Signature · 1 line
2.33.0
PATCH v2 3/3 gpiolib: acpi: Replace custom code with device_match_acpi_handle()
In reply to Andy ShevchenkoSince driver core provides a generic device_match_acpi_handle() we may replace the custom code with it.
---
v2: no changes
drivers/gpio/gpiolib-acpi.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/gpio/gpiolib-acpi.c +1 -4
@@ -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; }/**
Signature · 1 line
2.33.0
Rafael J. Wysocki
maintainerRe: [PATCH v2 3/3] gpiolib: acpi: Replace custom code with device_match_acpi_handle()
Quoted 15 lines · Andy Shevchenko
Since driver core provides a generic
device_match_acpi_handle()we may replace the custom code with it.Signed-off-by Andy Shevchenko <[email protected]>---
v2: no changesdrivers/gpio/gpiolib-acpi.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)drivers/gpio/gpiolib-acpi.c +0
-0
drivers/gpio/gpiolib-acpi.c static bool acpi_gpio_deferred_req_irqs_done; · line 98
Quoted 8 lines
drivers/gpio/gpiolib-acpi.c +1
-4@@ -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.
Quoted 4 lines
drivers/gpio/gpiolib-acpi.c +0
-1}/** --
Re: [PATCH v2 3/3] gpiolib: acpi: Replace custom code with device_match_acpi_handle()
Quoted 2 lines · Rafael J. Wysocki
On Wed, Oct 6, 2021 at 7:31 PM Andy Shevchenko
<[email protected]> wrote:
...
Quoted 5 lines
Quoted 1 line
+ 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?
Signature · 2 lines
With Best Regards, Andy Shevchenko
Rafael J. Wysocki
maintainerRe: [PATCH v2 3/3] gpiolib: acpi: Replace custom code with device_match_acpi_handle()
Quoted 9 lines · Andy Shevchenko
Quoted 2 lines · Rafael J. Wysocki
On Wed, Oct 6, 2021 at 7:31 PM Andy Shevchenko
<[email protected]> wrote:...
Quoted 2 lines
Quoted 1 line
+ return
gc->parent?device_match_acpi_handle(gc->parent, data): false;
Quoted 8 lines
Quoted 3 lines
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.
Re: [PATCH v2 3/3] gpiolib: acpi: Replace custom code with device_match_acpi_handle()
Quoted 3 lines · Rafael J. Wysocki
Quoted 1 line · Andy Shevchenko
On Thu, Oct 07, 2021 at 06:50:46PM +0200, Rafael J. Wysocki wrote:
...
Quoted 4 lines
Quoted 2 lines
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!
Signature · 2 lines
With Best Regards, Andy Shevchenko