Skip to contentSkip to conversation

Refine _UID references across kernel

PATCH Applied Raag Jadav 5 participants 15 messages Oct 24, 2023 – Oct 25, 2023

Subsystems (7)
lore
Share & tools
lore

Raag Jadav

author
#0 lore raw

v3 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 the standard ACPI helpers.

Changes since v2:
- Drop review tags as suggested by Andy.

Changes since v1:
- Change acpi_dev_uid_match() to return false in case of NULL argument.
- Drop accepted patches.

Raag Jadav (6):
ACPI: utils: Introduce acpi_dev_uid_match() for matching _UID
pinctrl: intel: use acpi_dev_uid_match() for matching _UID
ACPI: utils: use acpi_dev_uid_match() for matching _UID
ACPI: x86: use acpi_dev_uid_match() for matching _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/utils.c                  | 34 ++++++++++++++++++++++-----
 drivers/acpi/x86/utils.c              |  3 +--
 drivers/hwmon/nct6775-platform.c      |  4 +---
 drivers/perf/arm_cspmu/arm_cspmu.c    |  8 +++----
 drivers/pinctrl/intel/pinctrl-intel.c |  2 +-
 include/acpi/acpi_bus.h               |  1 +
 include/linux/acpi.h                  |  5 ++++
 7 files changed, 40 insertions(+), 17 deletions(-)

base-commit: a4ed5bffbeb19cfb7e21ac3b3f09d7bfe39a849b

Signature · 1 line
2.17.1
author
#1 lore raw

PATCH v3 1/6 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    | 31 +++++++++++++++++++++++++++----
 include/acpi/acpi_bus.h |  1 +
 include/linux/acpi.h    |  5 +++++
 3 files changed, 33 insertions(+), 4 deletions(-)
drivers/acpi/utils.c +27 -4
index 79915d4a0031..be21b77059af 100644
@@ -824,20 +824,43 @@ 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.
+ *
+ * Matches UID in @adev with given @uid2.
+ *
+ * Returns:
+ *  - %true if matches.
+ *  - %false otherwise.
+ */
+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);
+}
+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.
+ *
+ * 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;
@@ -845,7 +868,7 @@ bool acpi_dev_hid_uid_match(struct acpi_device *adev,
 	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 756b3f3c2c45..afeed6e72049 100644
@@ -763,6 +763,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
maintainer
#2 lore raw

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

Quoted 10 lines · Raag Jadav

+/**
+ * acpi_dev_uid_match - Match device by supplied UID
+ * @adev: ACPI device to match.
+ * @uid2: Unique ID of the device.
+ *
+ * Matches UID in @adev with given @uid2.
+ *
+ * Returns:
+ * - %true if matches.
+ * - %false otherwise.

Nit: these actually do not get formatted like above so you can just write it as

Returns: %true in case UIDs match, %false otherwise.

If it is even needed, I think it is pretty obvious from the function name what it returns.

#3 lore raw

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

Quoted 1 line · Mika Westerberg

On Tue, Oct 24, 2023 at 11:50:13AM +0530, Raag Jadav wrote:

...

Quoted 11 lines
Quoted 3 lines

+ * Returns:
+ * - %true if matches.
+ * - %false otherwise.

Nit: these actually do not get formatted like above so you can just write it as

Returns: %true in case UIDs match, %false otherwise.

If it is even needed, I think it is pretty obvious from the function name what it returns.

kernel-doc complains if there is no Return: section in the text.

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

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

In reply to Raag Jadav

Convert manual _UID references to use the standard ACPI helper.

---
 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 v3 3/6 ACPI: utils: use acpi_dev_uid_match() for matching _UID

In reply to Raag Jadav

Convert manual _UID references to use the standard ACPI helper.

---
 drivers/acpi/utils.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/acpi/utils.c +1 -2
index be21b77059af..28c75242fca9 100644
@@ -942,8 +942,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 (match->uid && !acpi_dev_uid_match(adev, match->uid))
 		return 0;
 
 	if (match->hrv == -1)
Signature · 1 line
2.17.1
author
#6 lore raw

PATCH v3 4/6 ACPI: x86: use acpi_dev_uid_match() for matching _UID

In reply to Raag Jadav

Convert manual _UID references to use the standard ACPI helper.

---
 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
#7 lore raw

PATCH v3 5/6 hwmon: nct6775: use acpi_dev_hid_uid_match() for matching _HID and _UID

In reply to Raag Jadav

Convert manual _UID references to use the standard ACPI helper.

---
 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
maintainer Applied
#8 lore raw

Re: [PATCH v3 5/6] hwmon: nct6775: use acpi_dev_hid_uid_match() for matching _HID and _UID

Quoted 3 lines · Raag Jadav

Convert manual _UID references to use the standard ACPI helper.

Applied.

Guenter

author
#9 lore raw

PATCH v3 6/6 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 the 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
maintainer Reviewed-by Acked-by on the v3 series
#10 lore raw
In reply to Raag Jadav
Quoted 14 lines · Raag Jadav

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 the standard ACPI helpers.

Changes since v2:
- Drop review tags as suggested by Andy.

Changes since v1:
- Change acpi_dev_uid_match() to return false in case of NULL argument.
- Drop accepted patches.

Quoted 9 lines

Raag Jadav (6):
ACPI: utils: Introduce acpi_dev_uid_match() for matching _UID
pinctrl: intel: use acpi_dev_uid_match() for matching _UID
ACPI: utils: use acpi_dev_uid_match() for matching _UID
ACPI: x86: use acpi_dev_uid_match() for matching _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

For the series,

Quoted 5 lines
 drivers/acpi/utils.c                  | 34 ++++++++++++++++++++++-----
 drivers/acpi/x86/utils.c              |  3 +--
 drivers/hwmon/nct6775-platform.c      |  4 +---
 drivers/perf/arm_cspmu/arm_cspmu.c    |  8 +++----
 drivers/pinctrl/intel/pinctrl-intel.c |  2 +-

This pinctrl one is also fine by me so if Andy does not have objections, feel free to add my,

Quoted 8 lines
 include/acpi/acpi_bus.h               |  1 +
 include/linux/acpi.h                  |  5 ++++
 7 files changed, 40 insertions(+), 17 deletions(-)

base-commit: a4ed5bffbeb19cfb7e21ac3b3f09d7bfe39a849b

Signature · 1 line
2.17.1
#11 lore raw
Quoted 2 lines · Mika Westerberg
Quoted 1 line · Raag Jadav

This series refines _UID references across kernel by:

...

Quoted 4 lines
Quoted 1 line
 drivers/pinctrl/intel/pinctrl-intel.c |  2 +-

This pinctrl one is also fine by me so if Andy does not have objections, feel free to add my,

TL;DR: I had, but Rafael seems wanted your opinion. Whatever, I'm not preventing this from happening, but I still consider that the uid check for NULL in the helper should mimic the same logic as in acpi_dev_hid_uid_match(). That's why I asked to drop my tags from this series.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#12 lore raw
In reply to Mika Westerberg
Quoted 36 lines · Mika Westerberg
Quoted 14 lines · Raag Jadav

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 the standard ACPI helpers.

Changes since v2:
- Drop review tags as suggested by Andy.

Changes since v1:
- Change acpi_dev_uid_match() to return false in case of NULL argument.
- Drop accepted patches.

Quoted 9 lines

Raag Jadav (6):
ACPI: utils: Introduce acpi_dev_uid_match() for matching _UID
pinctrl: intel: use acpi_dev_uid_match() for matching _UID
ACPI: utils: use acpi_dev_uid_match() for matching _UID
ACPI: x86: use acpi_dev_uid_match() for matching _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

For the series,

Quoted 5 lines
 drivers/acpi/utils.c                  | 34 ++++++++++++++++++++++-----
 drivers/acpi/x86/utils.c              |  3 +--
 drivers/hwmon/nct6775-platform.c      |  4 +---
 drivers/perf/arm_cspmu/arm_cspmu.c    |  8 +++----
 drivers/pinctrl/intel/pinctrl-intel.c |  2 +-
Quoted 4 lines

This pinctrl one is also fine by me so if Andy does not have objections, feel free to add my,

Whole series applied as 6.7 material with tags as per the above, thanks!

maintainer
#13 lore raw
Quoted 38 lines · Rafael J. Wysocki
Quoted 36 lines · Mika Westerberg
Quoted 14 lines · Raag Jadav

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 the standard ACPI helpers.

Changes since v2:
- Drop review tags as suggested by Andy.

Changes since v1:
- Change acpi_dev_uid_match() to return false in case of NULL argument.
- Drop accepted patches.

Quoted 9 lines

Raag Jadav (6):
ACPI: utils: Introduce acpi_dev_uid_match() for matching _UID
pinctrl: intel: use acpi_dev_uid_match() for matching _UID
ACPI: utils: use acpi_dev_uid_match() for matching _UID
ACPI: x86: use acpi_dev_uid_match() for matching _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

For the series,

Quoted 5 lines
 drivers/acpi/utils.c                  | 34 ++++++++++++++++++++++-----
 drivers/acpi/x86/utils.c              |  3 +--
 drivers/hwmon/nct6775-platform.c      |  4 +---
 drivers/perf/arm_cspmu/arm_cspmu.c    |  8 +++----
 drivers/pinctrl/intel/pinctrl-intel.c |  2 +-
Quoted 6 lines
Quoted 4 lines

This pinctrl one is also fine by me so if Andy does not have objections, feel free to add my,

Whole series applied as 6.7 material with tags as per the above, thanks!

Ok, that means I will _not_ apply the hwmon patch through the hwmon tree.

FWIW, please note that I would have very much preferred applying it through the hwmon tree, and I did _not_ Ack it.

Guenter

#14 lore raw
Quoted 45 lines · Guenter Roeck
Quoted 43 lines · Rafael J. Wysocki
Quoted 40 lines · Mika Westerberg
Quoted 14 lines · Raag Jadav

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 the standard ACPI helpers.

Changes since v2:
- Drop review tags as suggested by Andy.

Changes since v1:
- Change acpi_dev_uid_match() to return false in case of NULL argument.
- Drop accepted patches.

Quoted 9 lines

Raag Jadav (6):
ACPI: utils: Introduce acpi_dev_uid_match() for matching _UID
pinctrl: intel: use acpi_dev_uid_match() for matching _UID
ACPI: utils: use acpi_dev_uid_match() for matching _UID
ACPI: x86: use acpi_dev_uid_match() for matching _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

For the series,

Quoted 5 lines
 drivers/acpi/utils.c                  | 34 ++++++++++++++++++++++-----
 drivers/acpi/x86/utils.c              |  3 +--
 drivers/hwmon/nct6775-platform.c      |  4 +---
 drivers/perf/arm_cspmu/arm_cspmu.c    |  8 +++----
 drivers/pinctrl/intel/pinctrl-intel.c |  2 +-

This pinctrl one is also fine by me so if Andy does not have objections, feel free to add my,

Quoted 7 lines
Quoted 1 line

Whole series applied as 6.7 material with tags as per the above, thanks!

Ok, that means I will _not_ apply the hwmon patch through the hwmon tree.

FWIW, please note that I would have very much preferred applying it through the hwmon tree, and I did _not_ Ack it.

OK, I'll drop it now and please feel free to pick it up (whenever it is convenient to do so), or if you'd rather let me carry it, please let me know.

It's only been in my bleeding-edge branch so far.