diff options
author | Andy Shevchenko <andriy.shevchenko@linux.intel.com> | 2022-09-13 19:31:40 +0300 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2022-09-19 18:34:42 +0200 |
commit | 5db72fdb74983a1e81331aadf99ae2305f277562 (patch) | |
tree | 444ffced842b0004702246255eba057e06a98d0e /drivers/acpi/utils.c | |
parent | 521a547ced6477c54b4b0cc206000406c221b4d6 (diff) | |
download | linux-stable-5db72fdb74983a1e81331aadf99ae2305f277562.tar.gz linux-stable-5db72fdb74983a1e81331aadf99ae2305f277562.tar.bz2 linux-stable-5db72fdb74983a1e81331aadf99ae2305f277562.zip |
ACPI: utils: Add acpi_dev_uid_to_integer() helper to get _UID as integer
Some users interpret _UID only as integer and for them it's easier to
have an integer representation of _UID. Add respective helper for that.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/acpi/utils.c')
-rw-r--r-- | drivers/acpi/utils.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/drivers/acpi/utils.c b/drivers/acpi/utils.c index 5a7b8065e77f..febf9b8da3a0 100644 --- a/drivers/acpi/utils.c +++ b/drivers/acpi/utils.c @@ -794,6 +794,30 @@ bool acpi_dev_hid_uid_match(struct acpi_device *adev, EXPORT_SYMBOL(acpi_dev_hid_uid_match); /** + * acpi_dev_uid_to_integer - treat ACPI device _UID as integer + * @adev: ACPI device to get _UID from + * @integer: output buffer for integer + * + * Considers _UID as integer and converts it to @integer. + * + * Returns 0 on success, or negative error code otherwise. + */ +int acpi_dev_uid_to_integer(struct acpi_device *adev, u64 *integer) +{ + const char *uid; + + if (!adev) + return -ENODEV; + + uid = acpi_device_uid(adev); + if (!uid) + return -ENODATA; + + return kstrtou64(uid, 0, integer); +} +EXPORT_SYMBOL(acpi_dev_uid_to_integer); + +/** * acpi_dev_found - Detect presence of a given ACPI device in the namespace. * @hid: Hardware ID of the device. * |