i2c: acpi: Replace custom code with device_match_acpi_handle()
Subsystems (4)
PATCH 1/1 i2c: acpi: Replace custom code with device_match_acpi_handle()
Since driver core provides a generic device_match_acpi_handle() we may replace the custom code with it.
--- drivers/i2c/i2c-core-acpi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/i2c/i2c-core-acpi.c +1 -1
@@ -250,7 +250,7 @@ static int i2c_acpi_get_info(struct acpi_device *adev,if (adapter) {/* The adapter must match the one in I2cSerialBus() connector */ -if (ACPI_HANDLE (&adapter->dev) != lookup.adapter_handle) +if (!device_match_acpi_handle (&adapter->dev, lookup.adapter_handle))return -ENODEV ; }else {struct acpi_device *adapter_adev;
Signature · 1 line
2.47.2
Quoted 2 lines · Andy Shevchenko
Since driver core provides a generic
device_match_acpi_handle()we may replace the custom code with it.
Well okay but now you replace a simple comparison with a function call. I'm fine with the patch but I also don't think this is an improvement ;-)
Quoted 20 lines
Signed-off-by Andy Shevchenko <[email protected]>--- drivers/i2c/i2c-core-acpi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/i2c/i2c-core-acpi.c +1
-1@@ -250,7 +250,7 @@ static int i2c_acpi_get_info(struct acpi_device *adev,if (adapter) {/* The adapter must match the one in I2cSerialBus() connector */ -if (ACPI_HANDLE (&adapter->dev) != lookup.adapter_handle) +if (!device_match_acpi_handle (&adapter->dev, lookup.adapter_handle))return -ENODEV ; }else {struct acpi_device *adapter_adev;Signature · 1 line
2.47.2
Quoted 6 lines · Mika Westerberg
Quoted 2 lines · Andy Shevchenko
Since driver core provides a generic
device_match_acpi_handle()we may replace the custom code with it.Well okay but now you replace a simple comparison with a function call. I'm fine with the patch but I also don't think this is an improvement ;-)
The improvement is in using standard API for such cases. You may argue on many things that may be open coded in the kernel while we have helpers (in some cases exported) functions that are one-liners or so. Note, the helper also performs an additional check and having an open coded copy may miss such a change. To me it's an improvement.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 9 lines · Andy Shevchenko
Quoted 6 lines · Mika Westerberg
Quoted 2 lines · Andy Shevchenko
Since driver core provides a generic
device_match_acpi_handle()we may replace the custom code with it.Well okay but now you replace a simple comparison with a function call. I'm fine with the patch but I also don't think this is an improvement ;-)
The improvement is in using standard API for such cases.
Well ACPI_HANDLE() and comparing handles is also a "standard API".
Quoted 5 lines
You may argue on many things that may be open coded in the kernel while we have helpers (in some cases exported) functions that are one-liners or so. Note, the helper also performs an additional check and having an open coded copy may miss such a change. To me it's an improvement.
Which is unnecessary check in this case.
But like I said, no objections. I just don't think this improves anything.
Quoted 6 lines · Mika Westerberg
Quoted 5 lines · Andy Shevchenko
Quoted 4 lines · Mika Westerberg
Quoted 2 lines · Andy Shevchenko
Since driver core provides a generic
device_match_acpi_handle()we may replace the custom code with it.
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
Well okay but now you replace a simple comparison with a function call. I'm fine with the patch but I also don't think this is an improvement ;-)
The improvement is in using standard API for such cases.
Well
ACPI_HANDLE()and comparing handles is also a "standard API".
In some [rare] cases this might lead to removing acpi.h which is a monsteur that slows down a build and provokes developer to avoid IWYU principle from enforcement.
Quoted 7 lines
Quoted 5 lines
You may argue on many things that may be open coded in the kernel while we have helpers (in some cases exported) functions that are one-liners or so. Note, the helper also performs an additional check and having an open coded copy may miss such a change. To me it's an improvement.
Which is unnecessary check in this case.
In this perhaps, but my point is that any of such amendments will be applied in one place for all, while open coding prevents this.
Quoted 1 line
But like I said, no objections. I just don't think this improves anything.
I think there is an improvement.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Rafael J. Wysocki
maintainerQuoted 25 lines · Andy Shevchenko
Quoted 6 lines · Mika Westerberg
Quoted 5 lines · Andy Shevchenko
Quoted 4 lines · Mika Westerberg
Quoted 2 lines · Andy Shevchenko
Since driver core provides a generic
device_match_acpi_handle()we may replace the custom code with it.Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
Well okay but now you replace a simple comparison with a function call. I'm fine with the patch but I also don't think this is an improvement ;-)
The improvement is in using standard API for such cases.
Well
ACPI_HANDLE()and comparing handles is also a "standard API".In some [rare] cases this might lead to removing
acpi.hwhich is a monsteur that slows down a build and provokes developer to avoid IWYU principle from enforcement.Quoted 6 lines
Quoted 5 lines
You may argue on many things that may be open coded in the kernel while we have helpers (in some cases exported) functions that are one-liners or so. Note, the helper also performs an additional check and having an open coded copy may miss such a change. To me it's an improvement.
Quoted 8 lines
Quoted 1 line
Which is unnecessary check in this case.
In this perhaps, but my point is that any of such amendments will be applied in one place for all, while open coding prevents this.
Quoted 1 line
But like I said, no objections. I just don't think this improves anything.
I think there is an improvement.
For example, this helps (I think) when someone uses something like LXR to look for places where a device is matched against a given ACPI handle, but only as long as device_match_acpi_handle() is used in all of those places consistently.
Quoted 4 lines · Rafael J. Wysocki
Quoted 2 lines · Andy Shevchenko
Quoted 1 line · Mika Westerberg
On Tue, Jun 24, 2025 at 10:19:02AM +0300, Andy Shevchenko wrote:
...
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
But like I said, no objections. I just don't think this improves anything.
I think there is an improvement.
For example, this helps (I think) when someone uses something like LXR to look for places where a device is matched against a given ACPI handle, but only as long as
device_match_acpi_handle()is used in all of those places consistently.
Yeah, this is a problem in the kernel that we may have a lot of legacy code here and there. Unfortunately I have no plan to go all over, this is just an ad-hoc change while debugging a regression (I hope not related to this piece of code).
Signature · 2 lines
With Best Regards, Andy Shevchenko
Wolfram Sang
AppliedQuoted 4 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]>
Applied to for-next, thanks!