Skip to content

Commit 0205055

Browse files
andy-shevrafaeljw
authored andcommitted
ACPI: scan: Utilize match_string() API
We have already an API to match a string in the array of strings. Utilize it instead of open coded analogues. Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent c830dbc commit 0205055

1 file changed

Lines changed: 10 additions & 12 deletions

File tree

drivers/acpi/scan.c

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -757,27 +757,25 @@ static bool acpi_info_matches_ids(struct acpi_device_info *info,
757757
const char * const ids[])
758758
{
759759
struct acpi_pnp_device_id_list *cid_list = NULL;
760-
int i;
760+
int i, index;
761761

762762
if (!(info->valid & ACPI_VALID_HID))
763763
return false;
764764

765+
index = match_string(ids, -1, info->hardware_id.string);
766+
if (index >= 0)
767+
return true;
768+
765769
if (info->valid & ACPI_VALID_CID)
766770
cid_list = &info->compatible_id_list;
767771

768-
for (i = 0; ids[i]; i++) {
769-
int j;
772+
if (!cid_list)
773+
return false;
770774

771-
if (!strcmp(info->hardware_id.string, ids[i]))
775+
for (i = 0; i < cid_list->count; i++) {
776+
index = match_string(ids, -1, cid_list->ids[i].string);
777+
if (index >= 0)
772778
return true;
773-
774-
if (!cid_list)
775-
continue;
776-
777-
for (j = 0; j < cid_list->count; j++) {
778-
if (!strcmp(cid_list->ids[j].string, ids[i]))
779-
return true;
780-
}
781779
}
782780

783781
return false;

0 commit comments

Comments
 (0)