* [PATCH v2 1/1] platform/x86: asus-wireless: Replace open coded acpi_match_device()
@ 2023-10-06 15:27 Andy Shevchenko
2023-10-06 15:32 ` Hans de Goede
0 siblings, 1 reply; 3+ messages in thread
From: Andy Shevchenko @ 2023-10-06 15:27 UTC (permalink / raw)
To: Andy Shevchenko, acpi4asus-user, platform-driver-x86,
linux-kernel
Cc: Corentin Chary, João Paulo Rechi Vita, Hans de Goede,
Ilpo Järvinen, Mark Gross
Replace open coded acpi_match_device() in asus_wireless_add().
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
v2: fixed compilation error
drivers/platform/x86/asus-wireless.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/drivers/platform/x86/asus-wireless.c b/drivers/platform/x86/asus-wireless.c
index abf01e00b799..8b9a0dde34e3 100644
--- a/drivers/platform/x86/asus-wireless.c
+++ b/drivers/platform/x86/asus-wireless.c
@@ -148,13 +148,9 @@ static int asus_wireless_add(struct acpi_device *adev)
if (err)
return err;
- for (id = device_ids; id->id[0]; id++) {
- if (!strcmp((char *) id->id, acpi_device_hid(adev))) {
- data->hswc_params =
- (const struct hswc_params *)id->driver_data;
- break;
- }
- }
+ id = acpi_match_device(device_ids, adev);
+ if (id)
+ data->hswc_params = (const struct hswc_params *)id->driver_data;
if (!data->hswc_params)
return 0;
--
2.40.0.1.gaa8946217a0b
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH v2 1/1] platform/x86: asus-wireless: Replace open coded acpi_match_device()
2023-10-06 15:27 [PATCH v2 1/1] platform/x86: asus-wireless: Replace open coded acpi_match_device() Andy Shevchenko
@ 2023-10-06 15:32 ` Hans de Goede
2023-10-06 15:51 ` Andy Shevchenko
0 siblings, 1 reply; 3+ messages in thread
From: Hans de Goede @ 2023-10-06 15:32 UTC (permalink / raw)
To: Andy Shevchenko, acpi4asus-user, platform-driver-x86,
linux-kernel
Cc: Corentin Chary, João Paulo Rechi Vita, Ilpo Järvinen,
Mark Gross
Hi,
On 10/6/23 17:27, Andy Shevchenko wrote:
> Replace open coded acpi_match_device() in asus_wireless_add().
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
> v2: fixed compilation error
> drivers/platform/x86/asus-wireless.c | 10 +++-------
> 1 file changed, 3 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/platform/x86/asus-wireless.c b/drivers/platform/x86/asus-wireless.c
> index abf01e00b799..8b9a0dde34e3 100644
> --- a/drivers/platform/x86/asus-wireless.c
> +++ b/drivers/platform/x86/asus-wireless.c
> @@ -148,13 +148,9 @@ static int asus_wireless_add(struct acpi_device *adev)
> if (err)
> return err;
>
> - for (id = device_ids; id->id[0]; id++) {
> - if (!strcmp((char *) id->id, acpi_device_hid(adev))) {
> - data->hswc_params =
> - (const struct hswc_params *)id->driver_data;
> - break;
> - }
> - }
> + id = acpi_match_device(device_ids, adev);
> + if (id)
> + data->hswc_params = (const struct hswc_params *)id->driver_data;
> if (!data->hswc_params)
> return 0;
Thanks, but the error checking looks a bit weird now. How about:
id = acpi_match_device(device_ids, adev);
if (!id)
return 0;
data->hswc_params = (const struct hswc_params *)id->driver_data;
That seems to better convey what the code's intention is.
Regards,
Hans
p.s.
This driver really should be converted to not be an acpi_driver
instead it should bind to the instantiated platform_device
for the adev, but that would require someone with actual
hw access to test the conversion ...
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH v2 1/1] platform/x86: asus-wireless: Replace open coded acpi_match_device()
2023-10-06 15:32 ` Hans de Goede
@ 2023-10-06 15:51 ` Andy Shevchenko
0 siblings, 0 replies; 3+ messages in thread
From: Andy Shevchenko @ 2023-10-06 15:51 UTC (permalink / raw)
To: Hans de Goede
Cc: acpi4asus-user, platform-driver-x86, linux-kernel, Corentin Chary,
João Paulo Rechi Vita, Ilpo Järvinen, Mark Gross
On Fri, Oct 06, 2023 at 05:32:10PM +0200, Hans de Goede wrote:
> On 10/6/23 17:27, Andy Shevchenko wrote:
> > + id = acpi_match_device(device_ids, adev);
> > + if (id)
> > + data->hswc_params = (const struct hswc_params *)id->driver_data;
> > if (!data->hswc_params)
> > return 0;
>
> Thanks, but the error checking looks a bit weird now. How about:
>
> id = acpi_match_device(device_ids, adev);
> if (!id)
> return 0;
>
> data->hswc_params = (const struct hswc_params *)id->driver_data;
>
> That seems to better convey what the code's intention is.
Indeed, otherwise the hswc_params seems to stay NULL anyway (due to kzalloc()
use). I'll send a v3 with your suggestion being incorporated, thank you!
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-10-06 15:51 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-06 15:27 [PATCH v2 1/1] platform/x86: asus-wireless: Replace open coded acpi_match_device() Andy Shevchenko
2023-10-06 15:32 ` Hans de Goede
2023-10-06 15:51 ` Andy Shevchenko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox