* [PATCH v1 1/1] i2c: acpi: Replace custom code with device_match_acpi_handle()
@ 2025-06-23 13:45 Andy Shevchenko
2025-06-24 5:45 ` Mika Westerberg
2025-06-27 10:22 ` Wolfram Sang
0 siblings, 2 replies; 8+ messages in thread
From: Andy Shevchenko @ 2025-06-23 13:45 UTC (permalink / raw)
To: Randolph Ha, Andy Shevchenko, linux-i2c, linux-acpi, linux-kernel
Cc: Wolfram Sang, Mika Westerberg
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>
---
drivers/i2c/i2c-core-acpi.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/i2c/i2c-core-acpi.c b/drivers/i2c/i2c-core-acpi.c
index d2499f302b50..3445cc3b476b 100644
--- a/drivers/i2c/i2c-core-acpi.c
+++ b/drivers/i2c/i2c-core-acpi.c
@@ -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;
--
2.47.2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v1 1/1] i2c: acpi: Replace custom code with device_match_acpi_handle()
2025-06-23 13:45 [PATCH v1 1/1] i2c: acpi: Replace custom code with device_match_acpi_handle() Andy Shevchenko
@ 2025-06-24 5:45 ` Mika Westerberg
2025-06-24 7:19 ` Andy Shevchenko
2025-06-27 10:22 ` Wolfram Sang
1 sibling, 1 reply; 8+ messages in thread
From: Mika Westerberg @ 2025-06-24 5:45 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Randolph Ha, linux-i2c, linux-acpi, linux-kernel, Wolfram Sang,
Mika Westerberg
On Mon, Jun 23, 2025 at 04:45:21PM +0300, Andy Shevchenko wrote:
> 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 ;-)
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
> drivers/i2c/i2c-core-acpi.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/i2c/i2c-core-acpi.c b/drivers/i2c/i2c-core-acpi.c
> index d2499f302b50..3445cc3b476b 100644
> --- a/drivers/i2c/i2c-core-acpi.c
> +++ b/drivers/i2c/i2c-core-acpi.c
> @@ -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;
> --
> 2.47.2
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v1 1/1] i2c: acpi: Replace custom code with device_match_acpi_handle()
2025-06-24 5:45 ` Mika Westerberg
@ 2025-06-24 7:19 ` Andy Shevchenko
2025-06-24 7:25 ` Mika Westerberg
0 siblings, 1 reply; 8+ messages in thread
From: Andy Shevchenko @ 2025-06-24 7:19 UTC (permalink / raw)
To: Mika Westerberg
Cc: Randolph Ha, linux-i2c, linux-acpi, linux-kernel, Wolfram Sang,
Mika Westerberg
On Tue, Jun 24, 2025 at 08:45:08AM +0300, Mika Westerberg wrote:
> On Mon, Jun 23, 2025 at 04:45:21PM +0300, Andy Shevchenko wrote:
> > 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.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v1 1/1] i2c: acpi: Replace custom code with device_match_acpi_handle()
2025-06-24 7:19 ` Andy Shevchenko
@ 2025-06-24 7:25 ` Mika Westerberg
2025-06-24 7:35 ` Andy Shevchenko
0 siblings, 1 reply; 8+ messages in thread
From: Mika Westerberg @ 2025-06-24 7:25 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Randolph Ha, linux-i2c, linux-acpi, linux-kernel, Wolfram Sang,
Mika Westerberg
On Tue, Jun 24, 2025 at 10:19:02AM +0300, Andy Shevchenko wrote:
> On Tue, Jun 24, 2025 at 08:45:08AM +0300, Mika Westerberg wrote:
> > On Mon, Jun 23, 2025 at 04:45:21PM +0300, Andy Shevchenko wrote:
> > > 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".
> 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.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v1 1/1] i2c: acpi: Replace custom code with device_match_acpi_handle()
2025-06-24 7:25 ` Mika Westerberg
@ 2025-06-24 7:35 ` Andy Shevchenko
2025-06-24 10:18 ` Rafael J. Wysocki
0 siblings, 1 reply; 8+ messages in thread
From: Andy Shevchenko @ 2025-06-24 7:35 UTC (permalink / raw)
To: Mika Westerberg
Cc: Randolph Ha, linux-i2c, linux-acpi, linux-kernel, Wolfram Sang,
Mika Westerberg
On Tue, Jun 24, 2025 at 10:25:59AM +0300, Mika Westerberg wrote:
> On Tue, Jun 24, 2025 at 10:19:02AM +0300, Andy Shevchenko wrote:
> > On Tue, Jun 24, 2025 at 08:45:08AM +0300, Mika Westerberg wrote:
> > > On Mon, Jun 23, 2025 at 04:45:21PM +0300, Andy Shevchenko wrote:
> > > > 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".
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.
> > 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.
> But like I said, no objections. I just don't think this improves anything.
I think there is an improvement.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v1 1/1] i2c: acpi: Replace custom code with device_match_acpi_handle()
2025-06-24 7:35 ` Andy Shevchenko
@ 2025-06-24 10:18 ` Rafael J. Wysocki
2025-06-24 11:13 ` Andy Shevchenko
0 siblings, 1 reply; 8+ messages in thread
From: Rafael J. Wysocki @ 2025-06-24 10:18 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Mika Westerberg, Randolph Ha, linux-i2c, linux-acpi, linux-kernel,
Wolfram Sang, Mika Westerberg
On Tue, Jun 24, 2025 at 9:38 AM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
>
> On Tue, Jun 24, 2025 at 10:25:59AM +0300, Mika Westerberg wrote:
> > On Tue, Jun 24, 2025 at 10:19:02AM +0300, Andy Shevchenko wrote:
> > > On Tue, Jun 24, 2025 at 08:45:08AM +0300, Mika Westerberg wrote:
> > > > On Mon, Jun 23, 2025 at 04:45:21PM +0300, Andy Shevchenko wrote:
> > > > > 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".
>
> 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.
>
> > > 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.
>
> > 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.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v1 1/1] i2c: acpi: Replace custom code with device_match_acpi_handle()
2025-06-24 10:18 ` Rafael J. Wysocki
@ 2025-06-24 11:13 ` Andy Shevchenko
0 siblings, 0 replies; 8+ messages in thread
From: Andy Shevchenko @ 2025-06-24 11:13 UTC (permalink / raw)
To: Rafael J. Wysocki
Cc: Mika Westerberg, Randolph Ha, linux-i2c, linux-acpi, linux-kernel,
Wolfram Sang, Mika Westerberg
On Tue, Jun 24, 2025 at 12:18:22PM +0200, Rafael J. Wysocki wrote:
> On Tue, Jun 24, 2025 at 9:38 AM Andy Shevchenko
> <andriy.shevchenko@linux.intel.com> wrote:
> > On Tue, Jun 24, 2025 at 10:25:59AM +0300, Mika Westerberg wrote:
> > > On Tue, Jun 24, 2025 at 10:19:02AM +0300, Andy Shevchenko wrote:
...
> > > 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).
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v1 1/1] i2c: acpi: Replace custom code with device_match_acpi_handle()
2025-06-23 13:45 [PATCH v1 1/1] i2c: acpi: Replace custom code with device_match_acpi_handle() Andy Shevchenko
2025-06-24 5:45 ` Mika Westerberg
@ 2025-06-27 10:22 ` Wolfram Sang
1 sibling, 0 replies; 8+ messages in thread
From: Wolfram Sang @ 2025-06-27 10:22 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Randolph Ha, linux-i2c, linux-acpi, linux-kernel, Mika Westerberg
[-- Attachment #1: Type: text/plain, Size: 284 bytes --]
On Mon, Jun 23, 2025 at 04:45:21PM +0300, Andy Shevchenko 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>
Applied to for-next, thanks!
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2025-06-27 10:22 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-23 13:45 [PATCH v1 1/1] i2c: acpi: Replace custom code with device_match_acpi_handle() Andy Shevchenko
2025-06-24 5:45 ` Mika Westerberg
2025-06-24 7:19 ` Andy Shevchenko
2025-06-24 7:25 ` Mika Westerberg
2025-06-24 7:35 ` Andy Shevchenko
2025-06-24 10:18 ` Rafael J. Wysocki
2025-06-24 11:13 ` Andy Shevchenko
2025-06-27 10:22 ` Wolfram Sang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox