Skip to content

Commit 7fc90e8

Browse files
andy-shevrafaeljw
authored andcommitted
efi/dev-path-parser: Refactor _UID handling to use acpi_dev_uid_to_integer()
ACPI utils provide acpi_dev_uid_to_integer() helper to extract _UID as an integer. Use it instead of custom approach. Signed-off-by: Andy Shevchenko <[email protected]> Reviewed-by: Hans de Goede <[email protected]> Reviewed-by: Ard Biesheuvel <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent 2990f3a commit 7fc90e8

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

drivers/firmware/efi/dev-path-parser.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@
1515
static long __init parse_acpi_path(const struct efi_dev_path *node,
1616
struct device *parent, struct device **child)
1717
{
18-
char hid[ACPI_ID_LEN], uid[11]; /* UINT_MAX + null byte */
1918
struct acpi_device *adev;
2019
struct device *phys_dev;
20+
char hid[ACPI_ID_LEN];
21+
u64 uid;
22+
int ret;
2123

2224
if (node->header.length != 12)
2325
return -EINVAL;
@@ -27,12 +29,12 @@ static long __init parse_acpi_path(const struct efi_dev_path *node,
2729
'A' + ((node->acpi.hid >> 5) & 0x1f) - 1,
2830
'A' + ((node->acpi.hid >> 0) & 0x1f) - 1,
2931
node->acpi.hid >> 16);
30-
sprintf(uid, "%u", node->acpi.uid);
3132

3233
for_each_acpi_dev_match(adev, hid, NULL, -1) {
33-
if (adev->pnp.unique_id && !strcmp(adev->pnp.unique_id, uid))
34+
ret = acpi_dev_uid_to_integer(adev, &uid);
35+
if (ret == 0 && node->acpi.uid == uid)
3436
break;
35-
if (!adev->pnp.unique_id && node->acpi.uid == 0)
37+
if (ret == -ENODATA && node->acpi.uid == 0)
3638
break;
3739
}
3840
if (!adev)

0 commit comments

Comments
 (0)