Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Andy Shevchenko and committed by
Rafael J. Wysocki
02050558 c830dbcf

+10 -12
+10 -12
drivers/acpi/scan.c
··· 757 757 const char * const ids[]) 758 758 { 759 759 struct acpi_pnp_device_id_list *cid_list = NULL; 760 - int i; 760 + int i, index; 761 761 762 762 if (!(info->valid & ACPI_VALID_HID)) 763 763 return false; 764 764 765 + index = match_string(ids, -1, info->hardware_id.string); 766 + if (index >= 0) 767 + return true; 768 + 765 769 if (info->valid & ACPI_VALID_CID) 766 770 cid_list = &info->compatible_id_list; 767 771 768 - for (i = 0; ids[i]; i++) { 769 - int j; 772 + if (!cid_list) 773 + return false; 770 774 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) 772 778 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 - } 781 779 } 782 780 783 781 return false;