Skip to contentSkip to conversation

Refine _UID references across kernel

PATCH Applied Raag Jadav 4 participants 23 messages Oct 20, 2023 – Oct 21, 2023

Subsystems (8)

v1 of 3 Applied Latest is v3 →

lore
Share & tools
lore

Raag Jadav

author
#0 lore raw

cover Refine _UID references across kernel

This series refines _UID references across kernel by:

- Extracting _UID matching functionality from acpi_dev_hid_uid_match() helper and introducing it as a separate acpi_dev_uid_match() helper.

- Converting manual _UID references to use standard ACPI helpers.

Raag Jadav (8):
ACPI: utils: Introduce acpi_dev_uid_match() for matching _UID
pinctrl: intel: use acpi_dev_uid_match() for matching _UID
ACPI: sysfs: use acpi_device_uid() for fetching _UID
ACPI: utils: use acpi_dev_uid_match() for matching _UID
ACPI: x86: use acpi_dev_uid_match() for matching _UID
perf: qcom: use acpi_device_uid() for fetching _UID
hwmon: nct6775: use acpi_dev_hid_uid_match() for matching _HID and
_UID
perf: arm_cspmu: use acpi_dev_hid_uid_match() for matching _HID and
_UID

 drivers/acpi/device_sysfs.c           |  6 ++--
 drivers/acpi/utils.c                  | 43 +++++++++++++++++++++------
 drivers/acpi/x86/utils.c              |  3 +-
 drivers/hwmon/nct6775-platform.c      |  4 +--
 drivers/perf/arm_cspmu/arm_cspmu.c    |  8 ++---
 drivers/perf/qcom_l3_pmu.c            |  4 +--
 drivers/pinctrl/intel/pinctrl-intel.c |  2 +-
 include/acpi/acpi_bus.h               |  1 +
 include/linux/acpi.h                  |  5 ++++
 9 files changed, 51 insertions(+), 25 deletions(-)

base-commit: 9bc2fb9a7e41542a193658deff3df572fa24cb68

Signature · 1 line
2.17.1
author
#1 lore raw

PATCH 1/8 ACPI: utils: Introduce acpi_dev_uid_match() for matching _UID

Introduce acpi_dev_uid_match() helper that matches the device with supplied _UID string.

---
 drivers/acpi/utils.c    | 40 +++++++++++++++++++++++++++++++++-------
 include/acpi/acpi_bus.h |  1 +
 include/linux/acpi.h    |  5 +++++
 3 files changed, 39 insertions(+), 7 deletions(-)
drivers/acpi/utils.c +33 -7
index 2ea14648a661..664b9890b625 100644
@@ -768,28 +768,54 @@ bool acpi_check_dsm(acpi_handle handle, const guid_t *guid, u64 rev, u64 funcs)
 }
 EXPORT_SYMBOL(acpi_check_dsm);
 
+/**
+ * acpi_dev_uid_match - Match device by supplied UID
+ * @adev: ACPI device to match.
+ * @uid2: Unique ID of the device, pass NULL to not check _UID.
+ *
+ * Matches UID in @adev with given @uid2. Absence of @uid2 will be treated as
+ * a match. If user wants to validate @uid2, it should be done before calling
+ * this function. This behaviour is as needed by most of its current users.
+ *
+ * Returns:
+ *  - %true if matches or @uid2 is NULL.
+ *  - %false otherwise.
+ */
+bool acpi_dev_uid_match(struct acpi_device *adev, const char *uid2)
+{
+	const char *uid1 = acpi_device_uid(adev);
+
+	if (!uid2)
+		return true;
+
+	return uid1 && !strcmp(uid1, uid2);
+}
+EXPORT_SYMBOL_GPL(acpi_dev_uid_match);
+
 /**
  * acpi_dev_hid_uid_match - Match device by supplied HID and UID
  * @adev: ACPI device to match.
  * @hid2: Hardware ID of the device.
  * @uid2: Unique ID of the device, pass NULL to not check _UID.
  *
- * Matches HID and UID in @adev with given @hid2 and @uid2.
- * Returns true if matches.
+ * Matches HID and UID in @adev with given @hid2 and @uid2. Absence of @uid2
+ * will be treated as a match. If user wants to validate @uid2, it should be
+ * done before calling this function. This behaviour is as needed by most of
+ * its current users.
+ *
+ * Returns:
+ *  - %true if matches or @uid2 is NULL.
+ *  - %false otherwise.
  */
 bool acpi_dev_hid_uid_match(struct acpi_device *adev,
 			    const char *hid2, const char *uid2)
 {
 	const char *hid1 = acpi_device_hid(adev);
-	const char *uid1 = acpi_device_uid(adev);
 
 	if (strcmp(hid1, hid2))
 		return false;
 
-	if (!uid2)
-		return true;
-
-	return uid1 && !strcmp(uid1, uid2);
+	return acpi_dev_uid_match(adev, uid2);
 }
 EXPORT_SYMBOL(acpi_dev_hid_uid_match);
 
include/acpi/acpi_bus.h +1 -0
index 254685085c82..d1fe6446ffe0 100644
@@ -760,6 +760,7 @@ static inline bool acpi_device_can_poweroff(struct acpi_device *adev)
 		adev->power.states[ACPI_STATE_D3_HOT].flags.explicit_set);
 }
 
+bool acpi_dev_uid_match(struct acpi_device *adev, const char *uid2);
 bool acpi_dev_hid_uid_match(struct acpi_device *adev, const char *hid2, const char *uid2);
 int acpi_dev_uid_to_integer(struct acpi_device *adev, u64 *integer);
 
include/linux/acpi.h +5 -0
index afd94c9b8b8a..db3a33e19c97 100644
@@ -787,6 +787,11 @@ static inline bool acpi_dev_present(const char *hid, const char *uid, s64 hrv)
 
 struct acpi_device;
 
+static inline bool acpi_dev_uid_match(struct acpi_device *adev, const char *uid2)
+{
+	return false;
+}
+
 static inline bool
 acpi_dev_hid_uid_match(struct acpi_device *adev, const char *hid2, const char *uid2)
 {
Signature · 1 line
2.17.1
author
#4 lore raw

PATCH 2/8 pinctrl: intel: use acpi_dev_uid_match() for matching _UID

In reply to Raag Jadav

Convert manual _UID references to use standard ACPI helpers.

---
 drivers/pinctrl/intel/pinctrl-intel.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pinctrl/intel/pinctrl-intel.c +1 -1
index 3be04ab760d3..999f453344d2 100644
@@ -1694,7 +1694,7 @@ const struct intel_pinctrl_soc_data *intel_pinctrl_get_soc_data(struct platform_
 		unsigned int i;
 
 		for (i = 0; table[i]; i++) {
-			if (!strcmp(adev->pnp.unique_id, table[i]->uid)) {
+			if (acpi_dev_uid_match(adev, table[i]->uid)) {
 				data = table[i];
 				break;
 			}
Signature · 1 line
2.17.1
author
#5 lore raw

PATCH 3/8 ACPI: sysfs: use acpi_device_uid() for fetching _UID

In reply to Raag Jadav

Convert manual _UID references to use standard ACPI helpers.

---
 drivers/acpi/device_sysfs.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/acpi/device_sysfs.c +3 -3
index b9bbf0746199..9d8e90744cb5 100644
@@ -410,7 +410,7 @@ static ssize_t uid_show(struct device *dev,
 {
 	struct acpi_device *acpi_dev = to_acpi_device(dev);
 
-	return sprintf(buf, "%s\n", acpi_dev->pnp.unique_id);
+	return sprintf(buf, "%s\n", acpi_device_uid(acpi_dev));
 }
 static DEVICE_ATTR_RO(uid);
 
@@ -554,7 +554,7 @@ int acpi_device_setup_files(struct acpi_device *dev)
 
 	if (dev->pnp.type.bus_address)
 		result = device_create_file(&dev->dev, &dev_attr_adr);
-	if (dev->pnp.unique_id)
+	if (acpi_device_uid(dev))
 		result = device_create_file(&dev->dev, &dev_attr_uid);
 
 	if (acpi_has_method(dev->handle, "_SUN")) {
@@ -635,7 +635,7 @@ void acpi_device_remove_files(struct acpi_device *dev)
 	if (acpi_has_method(dev->handle, "_HRV"))
 		device_remove_file(&dev->dev, &dev_attr_hrv);
 
-	if (dev->pnp.unique_id)
+	if (acpi_device_uid(dev))
 		device_remove_file(&dev->dev, &dev_attr_uid);
 	if (dev->pnp.type.bus_address)
 		device_remove_file(&dev->dev, &dev_attr_adr);
Signature · 1 line
2.17.1
author
#7 lore raw

PATCH 4/8 ACPI: utils: use acpi_dev_uid_match() for matching _UID

In reply to Raag Jadav

Convert manual _UID references to use standard ACPI helpers.

---
 drivers/acpi/utils.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/acpi/utils.c +1 -2
index 664b9890b625..e3ba835e6590 100644
@@ -889,8 +889,7 @@ static int acpi_dev_match_cb(struct device *dev, const void *data)
 	if (acpi_match_device_ids(adev, match->hid))
 		return 0;
 
-	if (match->uid && (!adev->pnp.unique_id ||
-	    strcmp(adev->pnp.unique_id, match->uid)))
+	if (!acpi_dev_uid_match(adev, match->uid))
 		return 0;
 
 	if (match->hrv == -1)
Signature · 1 line
2.17.1
author
#15 lore raw

PATCH 5/8 ACPI: x86: use acpi_dev_uid_match() for matching _UID

In reply to Raag Jadav

Convert manual _UID references to use standard ACPI helpers.

---
 drivers/acpi/x86/utils.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/acpi/x86/utils.c +1 -2
index 63d834dd3811..bc65ebfcdf76 100644
@@ -184,8 +184,7 @@ bool acpi_device_override_status(struct acpi_device *adev, unsigned long long *s
 			if (acpi_match_device_ids(adev, override_status_ids[i].hid))
 				continue;
 
-			if (!adev->pnp.unique_id ||
-			    strcmp(adev->pnp.unique_id, override_status_ids[i].uid))
+			if (!acpi_dev_uid_match(adev, override_status_ids[i].uid))
 				continue;
 		}
 
Signature · 1 line
2.17.1
author
#19 lore raw

PATCH 6/8 perf: qcom: use acpi_device_uid() for fetching _UID

In reply to Raag Jadav

Convert manual _UID references to use standard ACPI helpers.

---
 drivers/perf/qcom_l3_pmu.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/perf/qcom_l3_pmu.c +2 -2
index 2887edb4eb0b..f16783d03db7 100644
@@ -742,8 +742,8 @@ static int qcom_l3_cache_pmu_probe(struct platform_device *pdev)
 
 	l3pmu = devm_kzalloc(&pdev->dev, sizeof(*l3pmu), GFP_KERNEL);
 	name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "l3cache_%s_%s",
-		      acpi_dev_parent(acpi_dev)->pnp.unique_id,
-		      acpi_dev->pnp.unique_id);
+		      acpi_device_uid(acpi_dev_parent(acpi_dev)),
+		      acpi_device_uid(acpi_dev));
 	if (!l3pmu || !name)
 		return -ENOMEM;
 
Signature · 1 line
2.17.1
author
#21 lore raw

PATCH 7/8 hwmon: nct6775: use acpi_dev_hid_uid_match() for matching _HID and _UID

In reply to Raag Jadav

Convert manual _UID references to use standard ACPI helpers.

---
 drivers/hwmon/nct6775-platform.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/hwmon/nct6775-platform.c +1 -3
index 81bf03dad6bb..0adeeab7ee03 100644
@@ -1465,10 +1465,8 @@ static const char * const asus_msi_boards[] = {
 static int nct6775_asuswmi_device_match(struct device *dev, void *data)
 {
 	struct acpi_device *adev = to_acpi_device(dev);
-	const char *uid = acpi_device_uid(adev);
-	const char *hid = acpi_device_hid(adev);
 
-	if (hid && !strcmp(hid, ASUSWMI_DEVICE_HID) && uid && !strcmp(uid, data)) {
+	if (acpi_dev_hid_uid_match(adev, ASUSWMI_DEVICE_HID, data)) {
 		asus_acpi_dev = adev;
 		return 1;
 	}
Signature · 1 line
2.17.1
author
#22 lore raw

PATCH 8/8 perf: arm_cspmu: use acpi_dev_hid_uid_match() for matching _HID and _UID

In reply to Raag Jadav

Convert manual _UID references to use standard ACPI helpers.

---
 drivers/perf/arm_cspmu/arm_cspmu.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/perf/arm_cspmu/arm_cspmu.c +3 -5
index e2b7827c4563..f0e6d14281d6 100644
@@ -1061,7 +1061,7 @@ static int arm_cspmu_request_irq(struct arm_cspmu *cspmu)
 
 static inline int arm_cspmu_find_cpu_container(int cpu, u32 container_uid)
 {
-	u32 acpi_uid;
+	u64 acpi_uid;
 	struct device *cpu_dev;
 	struct acpi_device *acpi_dev;
 
@@ -1071,10 +1071,8 @@ static inline int arm_cspmu_find_cpu_container(int cpu, u32 container_uid)
 
 	acpi_dev = ACPI_COMPANION(cpu_dev);
 	while (acpi_dev) {
-		if (!strcmp(acpi_device_hid(acpi_dev),
-			    ACPI_PROCESSOR_CONTAINER_HID) &&
-		    !kstrtouint(acpi_device_uid(acpi_dev), 0, &acpi_uid) &&
-		    acpi_uid == container_uid)
+		if (acpi_dev_hid_uid_match(acpi_dev, ACPI_PROCESSOR_CONTAINER_HID, NULL) &&
+		    !acpi_dev_uid_to_integer(acpi_dev, &acpi_uid) && acpi_uid == container_uid)
 			return 0;
 
 		acpi_dev = acpi_dev_parent(acpi_dev);
Signature · 1 line
2.17.1
#2 lore raw

Re: [PATCH v1 1/8] ACPI: utils: Introduce acpi_dev_uid_match() for matching _UID

In reply to Raag Jadav
Quoted 2 lines · Raag Jadav

Introduce acpi_dev_uid_match() helper that matches the device with supplied _UID string.

...

Quoted 8 lines

+/**
+ * acpi_dev_uid_match - Match device by supplied UID
+ * @adev: ACPI device to match.
+ * @uid2: Unique ID of the device, pass NULL to not check _UID.
+ *
+ * Matches UID in @adev with given @uid2. Absence of @uid2 will be treated as
+ * a match. If user wants to validate @uid2, it should be done before calling
+ * this function. This behaviour is as needed by most of its current users.

The "current" internally I applied to the result of the series. So reading this again I think the better wording is "potential".

Quoted 5 lines

+ *
+ * Returns:
+ * - %true if matches or @uid2 is NULL.
+ * - %false otherwise.
+ */

...

Quoted 4 lines

/**
* acpi_dev_hid_uid_match - Match device by supplied HID and UID
* @adev: ACPI device to match.
* @hid2: Hardware ID of the device.

Quoted 8 lines

* @uid2: Unique ID of the device, pass NULL to not check _UID. *
- * Matches HID and UID in @adev with given @hid2 and @uid2.
- * Returns true if matches.
+ * Matches HID and UID in @adev with given @hid2 and @uid2. Absence of @uid2
+ * will be treated as a match. If user wants to validate @uid2, it should be
+ * done before calling this function. This behaviour is as needed by most of
+ * its current users.

Ditto.

Quoted 4 lines

+ * Returns:
+ * - %true if matches or @uid2 is NULL.
+ * - %false otherwise.
*/

Signature · 2 lines
With Best Regards,
Andy Shevchenko
Reviewed-by on v1 4/8
#8 lore raw

Re: [PATCH v1 4/8] ACPI: utils: use acpi_dev_uid_match() for matching _UID

In reply to Raag Jadav
Quoted 1 line · Raag Jadav

Convert manual _UID references to use standard ACPI helpers.

Yes, while not so obvious this is the correct replacement.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
Reviewed-by on v1 5/8
#16 lore raw

Re: [PATCH v1 5/8] ACPI: x86: use acpi_dev_uid_match() for matching _UID

In reply to Raag Jadav
Quoted 1 line · Raag Jadav

Convert manual _UID references to use standard ACPI helpers.

...

drivers/acpi/x86/utils.c bool acpi_device_override_status(struct acpi_device *adev, unsigned long long *s · line 187

Quoted 3 lines
drivers/acpi/x86/utils.c +1 -2
-			if (!adev->pnp.unique_id ||
-			    strcmp(adev->pnp.unique_id, override_status_ids[i].uid))
+			if (!acpi_dev_uid_match(adev, override_status_ids[i].uid))

The check for NULL argument inside that API does not affect the behaviour as otherwise it will be a crash with the current implementation.

Quoted 1 line

continue;

Signature · 2 lines
With Best Regards,
Andy Shevchenko
author
#9 lore raw

Re: [PATCH v1 4/8] ACPI: utils: use acpi_dev_uid_match() for matching _UID

In reply to Andy Shevchenko
Quoted 5 lines · Andy Shevchenko
Quoted 1 line · Raag Jadav

Convert manual _UID references to use standard ACPI helpers.

Yes, while not so obvious this is the correct replacement.

I think this is the only case which would suffer from the more obvious behaviour, i.e.

bool acpi_dev_uid_match(struct acpi_device *adev, const char *uid2)

{
        const char *uid1 = acpi_device_uid(adev);

        return uid1 && uid2 && !strcmp(uid1, uid2);
}

That said, we can't be particularly sure about it's potential future users, especially when the usage will not be limited to just ACPI core since we're exporting it.

Raag

#10 lore raw

Re: [PATCH v1 4/8] ACPI: utils: use acpi_dev_uid_match() for matching _UID

Quoted 9 lines · Raag Jadav
Quoted 5 lines · Andy Shevchenko
Quoted 1 line · Raag Jadav

Convert manual _UID references to use standard ACPI helpers.

Yes, while not so obvious this is the correct replacement.

I think this is the only case which would suffer from the more obvious behaviour, i.e.

No, that's not true. The same with override CPU in the other patch, where the check is simply absent, but the result will be the same. So, all with negation will suffer from the "obvious" implementation.

Quoted 10 lines

bool acpi_dev_uid_match(struct acpi_device *adev, const char *uid2)

{
        const char *uid1 = acpi_device_uid(adev);

        return uid1 && uid2 && !strcmp(uid1, uid2);
}

That said, we can't be particularly sure about it's potential future users, especially when the usage will not be limited to just ACPI core since we're exporting it.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
author
#11 lore raw

Re: [PATCH v1 4/8] ACPI: utils: use acpi_dev_uid_match() for matching _UID

Quoted 8 lines · Andy Shevchenko
Quoted 7 lines · Raag Jadav
Quoted 5 lines · Andy Shevchenko
Quoted 1 line · Raag Jadav

Convert manual _UID references to use standard ACPI helpers.

Yes, while not so obvious this is the correct replacement.

Quoted 6 lines
Quoted 2 lines

I think this is the only case which would suffer from the more obvious behaviour, i.e.

No, that's not true. The same with override CPU in the other patch, where the check is simply absent, but the result will be the same. So, all with negation will suffer from the "obvious" implementation.

Forgot to add, we don't need to change the original acpi_dev_hid_uid_match() behaviour, i.e.

bool acpi_dev_hid_uid_match(struct acpi_device *adev,
const char *hid2, const char *uid2)

{
        const char *hid1 = acpi_device_hid(adev);

        if (strcmp(hid1, hid2))
                return false;

        if (!uid2)
                return true;

        return acpi_dev_uid_match(adev, uid2);
}

I'm fine with both, this just makes more sense to me.

Raag

#3 lore raw

Re: [PATCH v1 1/8] ACPI: utils: Introduce acpi_dev_uid_match() for matching _UID

In reply to Raag Jadav
Quoted 6 lines · On Fri, 20 Oct 2023 14:17:25 +0530 Raag Jadav <[email protected]> wrote:

Introduce acpi_dev_uid_match() helper that matches the device with supplied _UID string.

Quoted 12 lines

/**
* acpi_dev_hid_uid_match - Match device by supplied HID and UID
* @adev: ACPI device to match.
* @hid2: Hardware ID of the device.
* @uid2: Unique ID of the device, pass NULL to not check _UID. *
- * Matches HID and UID in @adev with given @hid2 and @uid2.
- * Returns true if matches.
+ * Matches HID and UID in @adev with given @hid2 and @uid2. Absence of @uid2
+ * will be treated as a match. If user wants to validate @uid2, it should be
+ * done before calling this function. This behaviour is as needed by most of
+ * its current users.

If there are other other users that need different behavior are they buggy? Also what behavior is this referring to?

I'd just drop the at last sentence as confusing and not adding much.

Quoted 50 lines

+ *
+ * Returns:
+ * - %true if matches or @uid2 is NULL.
+ * - %false otherwise.
*/
bool acpi_dev_hid_uid_match(struct acpi_device *adev,

drivers/acpi/utils.c +1 -5
 			    const char *hid2, const char *uid2)
 {
 	const char *hid1 = acpi_device_hid(adev);
-	const char *uid1 = acpi_device_uid(adev);
 
 	if (strcmp(hid1, hid2))
 		return false;
 
-	if (!uid2)
-		return true;
-
-	return uid1 && !strcmp(uid1, uid2);
+	return acpi_dev_uid_match(adev, uid2);
 }
 EXPORT_SYMBOL(acpi_dev_hid_uid_match);
include/acpi/acpi_bus.h +1 -0
index 254685085c82..d1fe6446ffe0 100644
@@ -760,6 +760,7 @@ static inline bool acpi_device_can_poweroff(struct acpi_device *adev)
 		adev->power.states[ACPI_STATE_D3_HOT].flags.explicit_set);
 }
 
+bool acpi_dev_uid_match(struct acpi_device *adev, const char *uid2);
 bool acpi_dev_hid_uid_match(struct acpi_device *adev, const char *hid2, const char *uid2);
 int acpi_dev_uid_to_integer(struct acpi_device *adev, u64 *integer);
 
include/linux/acpi.h +5 -0
index afd94c9b8b8a..db3a33e19c97 100644
@@ -787,6 +787,11 @@ static inline bool acpi_dev_present(const char *hid, const char *uid, s64 hrv)
 
 struct acpi_device;
 
+static inline bool acpi_dev_uid_match(struct acpi_device *adev, const char *uid2)
+{
+	return false;
+}
+
 static inline bool
 acpi_dev_hid_uid_match(struct acpi_device *adev, const char *hid2, const char *uid2)
 {
#17 lore raw

Re: [PATCH v1 5/8] ACPI: x86: use acpi_dev_uid_match() for matching _UID

In reply to Andy Shevchenko
Quoted 6 lines · Andy Shevchenko
Quoted 1 line · Raag Jadav

Convert manual _UID references to use standard ACPI helpers.

Quoted 8 lines

...

drivers/acpi/x86/utils.c bool acpi_device_override_status(struct acpi_device *adev, unsigned long long *s · line 187

Quoted 3 lines
drivers/acpi/x86/utils.c +1 -2
-                     if (!adev->pnp.unique_id ||
-                         strcmp(adev->pnp.unique_id, override_status_ids[i].uid))
+                     if (!acpi_dev_uid_match(adev, override_status_ids[i].uid))

The check for NULL argument inside that API does not affect the behaviour as otherwise it will be a crash with the current implementation.

What current implementation do you mean, exactly?

#12 lore raw

Re: [PATCH v1 4/8] ACPI: utils: use acpi_dev_uid_match() for matching _UID

In reply to Raag Jadav
Quoted 18 lines · Raag Jadav
Quoted 5 lines · Andy Shevchenko
Quoted 1 line · Raag Jadav

Convert manual _UID references to use standard ACPI helpers.

Yes, while not so obvious this is the correct replacement.

I think this is the only case which would suffer from the more obvious behaviour, i.e.

bool acpi_dev_uid_match(struct acpi_device *adev, const char *uid2)

{
        const char *uid1 = acpi_device_uid(adev);

        return uid1 && uid2 && !strcmp(uid1, uid2);
}
Quoted 3 lines

That said, we can't be particularly sure about it's potential future users, especially when the usage will not be limited to just ACPI core since we're exporting it.

I actually agree with this, so please switch over to the above.

The above is straightforward and easy to understand and if somebody wants to treat uid2 == NULL as a match, let them check that explicitly before calling this function.

maintainer Applied
#6 lore raw

Re: [PATCH v1 3/8] ACPI: sysfs: use acpi_device_uid() for fetching _UID

In reply to Raag Jadav
Quoted 31 lines · Raag Jadav

Convert manual _UID references to use standard ACPI helpers.

---
 drivers/acpi/device_sysfs.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/acpi/device_sysfs.c +2 -2
index b9bbf0746199..9d8e90744cb5 100644
@@ -410,7 +410,7 @@ static ssize_t uid_show(struct device *dev,
 {
        struct acpi_device *acpi_dev = to_acpi_device(dev);
 
-       return sprintf(buf, "%s\n", acpi_dev->pnp.unique_id);
+       return sprintf(buf, "%s\n", acpi_device_uid(acpi_dev));
 }
 static DEVICE_ATTR_RO(uid);
 
@@ -554,7 +554,7 @@ int acpi_device_setup_files(struct acpi_device *dev)
 
        if (dev->pnp.type.bus_address)
                result = device_create_file(&dev->dev, &dev_attr_adr);
-       if (dev->pnp.unique_id)
+       if (acpi_device_uid(dev))
                result = device_create_file(&dev->dev, &dev_attr_uid);
 
        if (acpi_has_method(dev->handle, "_SUN")) {

drivers/acpi/device_sysfs.c void acpi_device_remove_files(struct acpi_device *dev)

Quoted 9 lines
drivers/acpi/device_sysfs.c +1 -2
@@ -635,7 +635,7 @@ void acpi_device_remove_files(struct acpi_device *dev)
        if (acpi_has_method(dev->handle, "_HRV"))
                device_remove_file(&dev->dev, &dev_attr_hrv);
 
-       if (dev->pnp.unique_id)
+       if (acpi_device_uid(dev))
                device_remove_file(&dev->dev, &dev_attr_uid);
        if (dev->pnp.type.bus_address)
                device_remove_file(&dev->dev, &dev_attr_adr);
--

Applied as 6.7 material, thanks!

maintainer Applied
#20 lore raw

Re: [PATCH v1 6/8] perf: qcom: use acpi_device_uid() for fetching _UID

In reply to Raag Jadav
Quoted 14 lines · Raag Jadav

Convert manual _UID references to use standard ACPI helpers.

---
 drivers/perf/qcom_l3_pmu.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/perf/qcom_l3_pmu.c +0 -0
index 2887edb4eb0b..f16783d03db7 100644
@@ -742,8 +742,8 @@ static int qcom_l3_cache_pmu_probe(struct platform_device *pdev)
 

drivers/perf/qcom_l3_pmu.c static int qcom_l3_cache_pmu_probe(struct platform_device *pdev)

Quoted 10 lines
drivers/perf/qcom_l3_pmu.c +2 -3
        l3pmu = devm_kzalloc(&pdev->dev, sizeof(*l3pmu), GFP_KERNEL);
        name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "l3cache_%s_%s",
-                     acpi_dev_parent(acpi_dev)->pnp.unique_id,
-                     acpi_dev->pnp.unique_id);
+                     acpi_device_uid(acpi_dev_parent(acpi_dev)),
+                     acpi_device_uid(acpi_dev));
        if (!l3pmu || !name)
                return -ENOMEM;
 
--

Applied as 6.7 material.

QCom perf maintainers, if you'd rather take this yourselves, please let me know.

Thanks!

author
#13 lore raw

Re: [PATCH v1 4/8] ACPI: utils: use acpi_dev_uid_match() for matching _UID

In reply to Rafael J. Wysocki
Quoted 16 lines · Rafael J. Wysocki
Quoted 15 lines · Raag Jadav
Quoted 5 lines · Andy Shevchenko
Quoted 1 line · Raag Jadav

Convert manual _UID references to use standard ACPI helpers.

Yes, while not so obvious this is the correct replacement.

I think this is the only case which would suffer from the more obvious behaviour, i.e.

bool acpi_dev_uid_match(struct acpi_device *adev, const char *uid2)

{
        const char *uid1 = acpi_device_uid(adev);
Quoted 8 lines
Quoted 6 lines
        return uid1 && uid2 && !strcmp(uid1, uid2);
}

That said, we can't be particularly sure about it's potential future users, especially when the usage will not be limited to just ACPI core since we're exporting it.

I actually agree with this, so please switch over to the above.

Will send out a v2, thanks.

Andy, can I add your review for this?

Raag

#18 lore raw

Re: [PATCH v1 5/8] ACPI: x86: use acpi_dev_uid_match() for matching _UID

In reply to Rafael J. Wysocki
Quoted 3 lines · Rafael J. Wysocki
Quoted 1 line · Andy Shevchenko

On Fri, Oct 20, 2023 at 02:17:29PM +0530, Raag Jadav wrote:

...

Quoted 8 lines
Quoted 6 lines

drivers/acpi/x86/utils.c bool acpi_device_override_status(struct acpi_device *adev, unsigned long long *s · line 187

Quoted 3 lines
drivers/acpi/x86/utils.c +1 -2
-                     if (!adev->pnp.unique_id ||
-                         strcmp(adev->pnp.unique_id, override_status_ids[i].uid))
+                     if (!acpi_dev_uid_match(adev, override_status_ids[i].uid))

The check for NULL argument inside that API does not affect the behaviour as otherwise it will be a crash with the current implementation.

What current implementation do you mean, exactly?

strcmp() against NULL will crash the system.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
author
#14 lore raw

Re: [PATCH v1 4/8] ACPI: utils: use acpi_dev_uid_match() for matching _UID

In reply to Raag Jadav
Quoted 24 lines · Raag Jadav
Quoted 23 lines · Rafael J. Wysocki
Quoted 21 lines · Raag Jadav
Quoted 5 lines · Andy Shevchenko
Quoted 1 line · Raag Jadav

Convert manual _UID references to use standard ACPI helpers.

Yes, while not so obvious this is the correct replacement.

I think this is the only case which would suffer from the more obvious behaviour, i.e.

bool acpi_dev_uid_match(struct acpi_device *adev, const char *uid2)

{
        const char *uid1 = acpi_device_uid(adev);

        return uid1 && uid2 && !strcmp(uid1, uid2);
}

That said, we can't be particularly sure about it's potential future users, especially when the usage will not be limited to just ACPI core since we're exporting it.

Quoted 5 lines
Quoted 1 line

I actually agree with this, so please switch over to the above.

Will send out a v2, thanks.

Andy, can I add your review for this?

IIUC you agree with the usage format, but not the actual helper. So I'm gonna drop it from the first patch and keep it for the rest, except this one.

Let me know if I'm doing this wrong.

Raag