ACPI: LPSS: Refactor _UID handling to use acpi_dev_uid_to_integer()
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Tue, 13 Sep 2022 16:31:41 +0000 (19:31 +0300)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Mon, 19 Sep 2022 16:34:42 +0000 (18:34 +0200)
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 <andriy.shevchenko@linux.intel.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/acpi/acpi_lpss.c

index c4d4d21391d7b11e8d072d8e6fd16cf067df94ac..4d415e210c32f5097fd9c9c4689c8e794b4b7ee0 100644 (file)
@@ -167,10 +167,10 @@ static struct pwm_lookup byt_pwm_lookup[] = {
 
 static void byt_pwm_setup(struct lpss_private_data *pdata)
 {
-       struct acpi_device *adev = pdata->adev;
+       u64 uid;
 
        /* Only call pwm_add_table for the first PWM controller */
-       if (!adev->pnp.unique_id || strcmp(adev->pnp.unique_id, "1"))
+       if (acpi_dev_uid_to_integer(pdata->adev, &uid) || uid != 1)
                return;
 
        pwm_add_table(byt_pwm_lookup, ARRAY_SIZE(byt_pwm_lookup));
@@ -180,14 +180,13 @@ static void byt_pwm_setup(struct lpss_private_data *pdata)
 
 static void byt_i2c_setup(struct lpss_private_data *pdata)
 {
-       const char *uid_str = acpi_device_uid(pdata->adev);
        acpi_handle handle = pdata->adev->handle;
        unsigned long long shared_host = 0;
        acpi_status status;
-       long uid = 0;
+       u64 uid;
 
-       /* Expected to always be true, but better safe then sorry */
-       if (uid_str && !kstrtol(uid_str, 10, &uid) && uid) {
+       /* Expected to always be successfull, but better safe then sorry */
+       if (!acpi_dev_uid_to_integer(pdata->adev, &uid) && uid) {
                /* Detect I2C bus shared with PUNIT and ignore its d3 status */
                status = acpi_evaluate_integer(handle, "_SEM", NULL, &shared_host);
                if (ACPI_SUCCESS(status) && shared_host)
@@ -211,10 +210,10 @@ static struct pwm_lookup bsw_pwm_lookup[] = {
 
 static void bsw_pwm_setup(struct lpss_private_data *pdata)
 {
-       struct acpi_device *adev = pdata->adev;
+       u64 uid;
 
        /* Only call pwm_add_table for the first PWM controller */
-       if (!adev->pnp.unique_id || strcmp(adev->pnp.unique_id, "1"))
+       if (acpi_dev_uid_to_integer(pdata->adev, &uid) || uid != 1)
                return;
 
        pwm_add_table(bsw_pwm_lookup, ARRAY_SIZE(bsw_pwm_lookup));