Skip to contentSkip to conversation

platform/x86: asus-wireless: Replace open coded acpi_match_device()

PATCH In review Andy Shevchenko 2 participants 3 messages Oct 6, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 platform/x86: asus-wireless: Replace open coded acpi_match_device()

Replace open coded acpi_match_device() in asus_wireless_add().

---
v2: fixed compilation error

 drivers/platform/x86/asus-wireless.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
drivers/platform/x86/asus-wireless.c +3 -7
index abf01e00b799..8b9a0dde34e3 100644
@@ -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;
 
Signature · 1 line
2.40.0.1.gaa8946217a0b
#1 lore raw

Hi,

Quoted 18 lines · Andy Shevchenko

Replace open coded acpi_match_device() in asus_wireless_add().

---
v2: fixed compilation error

 drivers/platform/x86/asus-wireless.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
drivers/platform/x86/asus-wireless.c +0 -2
index abf01e00b799..8b9a0dde34e3 100644
@@ -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))) {

drivers/platform/x86/asus-wireless.c static int asus_wireless_add(struct acpi_device *adev) · line 155

Quoted 10 lines
drivers/platform/x86/asus-wireless.c +3 -5
-			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 ...

#2 lore raw
Quoted 10 lines · Hans de Goede

drivers/platform/x86/asus-wireless.c static int asus_wireless_add(struct acpi_device *adev) · line 155

Quoted 5 lines · Andy Shevchenko
drivers/platform/x86/asus-wireless.c +3 -0
+	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:

Quoted 7 lines
	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!

Signature · 2 lines
With Best Regards,
Andy Shevchenko