linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 0/8] Refine _UID references across kernel
@ 2023-10-20  8:47 Raag Jadav
  2023-10-20  8:47 ` [PATCH v1 1/8] ACPI: utils: Introduce acpi_dev_uid_match() for matching _UID Raag Jadav
                   ` (7 more replies)
  0 siblings, 8 replies; 23+ messages in thread
From: Raag Jadav @ 2023-10-20  8:47 UTC (permalink / raw)
  To: rafael, len.brown, robert.moore, mika.westerberg,
	andriy.shevchenko, mark.rutland, will, linux
  Cc: linux-acpi, linux-kernel, acpica-devel, linux-gpio,
	linux-arm-kernel, linux-hwmon, mallikarjunappa.sangannavar,
	bala.senthil, 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 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
-- 
2.17.1


^ permalink raw reply	[flat|nested] 23+ messages in thread

* [PATCH v1 1/8] ACPI: utils: Introduce acpi_dev_uid_match() for matching _UID
  2023-10-20  8:47 [PATCH v1 0/8] Refine _UID references across kernel Raag Jadav
@ 2023-10-20  8:47 ` Raag Jadav
  2023-10-20 10:35   ` Andy Shevchenko
  2023-10-20 15:49   ` Jonathan Cameron
  2023-10-20  8:47 ` [PATCH v1 2/8] pinctrl: intel: use " Raag Jadav
                   ` (6 subsequent siblings)
  7 siblings, 2 replies; 23+ messages in thread
From: Raag Jadav @ 2023-10-20  8:47 UTC (permalink / raw)
  To: rafael, len.brown, robert.moore, mika.westerberg,
	andriy.shevchenko, mark.rutland, will, linux
  Cc: linux-acpi, linux-kernel, acpica-devel, linux-gpio,
	linux-arm-kernel, linux-hwmon, mallikarjunappa.sangannavar,
	bala.senthil, Raag Jadav

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

Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Raag Jadav <raag.jadav@intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/acpi/utils.c    | 40 +++++++++++++++++++++++++++++++++-------
 include/acpi/acpi_bus.h |  1 +
 include/linux/acpi.h    |  5 +++++
 3 files changed, 39 insertions(+), 7 deletions(-)

diff --git a/drivers/acpi/utils.c b/drivers/acpi/utils.c
index 2ea14648a661..664b9890b625 100644
--- a/drivers/acpi/utils.c
+++ b/drivers/acpi/utils.c
@@ -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);
 
diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
index 254685085c82..d1fe6446ffe0 100644
--- a/include/acpi/acpi_bus.h
+++ b/include/acpi/acpi_bus.h
@@ -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);
 
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index afd94c9b8b8a..db3a33e19c97 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -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)
 {
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH v1 2/8] pinctrl: intel: use acpi_dev_uid_match() for matching _UID
  2023-10-20  8:47 [PATCH v1 0/8] Refine _UID references across kernel Raag Jadav
  2023-10-20  8:47 ` [PATCH v1 1/8] ACPI: utils: Introduce acpi_dev_uid_match() for matching _UID Raag Jadav
@ 2023-10-20  8:47 ` Raag Jadav
  2023-10-20  8:47 ` [PATCH v1 3/8] ACPI: sysfs: use acpi_device_uid() for fetching _UID Raag Jadav
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 23+ messages in thread
From: Raag Jadav @ 2023-10-20  8:47 UTC (permalink / raw)
  To: rafael, len.brown, robert.moore, mika.westerberg,
	andriy.shevchenko, mark.rutland, will, linux
  Cc: linux-acpi, linux-kernel, acpica-devel, linux-gpio,
	linux-arm-kernel, linux-hwmon, mallikarjunappa.sangannavar,
	bala.senthil, Raag Jadav

Convert manual _UID references to use standard ACPI helpers.

Signed-off-by: Raag Jadav <raag.jadav@intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/pinctrl/intel/pinctrl-intel.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/pinctrl/intel/pinctrl-intel.c b/drivers/pinctrl/intel/pinctrl-intel.c
index 3be04ab760d3..999f453344d2 100644
--- a/drivers/pinctrl/intel/pinctrl-intel.c
+++ b/drivers/pinctrl/intel/pinctrl-intel.c
@@ -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;
 			}
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH v1 3/8] ACPI: sysfs: use acpi_device_uid() for fetching _UID
  2023-10-20  8:47 [PATCH v1 0/8] Refine _UID references across kernel Raag Jadav
  2023-10-20  8:47 ` [PATCH v1 1/8] ACPI: utils: Introduce acpi_dev_uid_match() for matching _UID Raag Jadav
  2023-10-20  8:47 ` [PATCH v1 2/8] pinctrl: intel: use " Raag Jadav
@ 2023-10-20  8:47 ` Raag Jadav
  2023-10-20 17:18   ` Rafael J. Wysocki
  2023-10-20  8:47 ` [PATCH v1 4/8] ACPI: utils: use acpi_dev_uid_match() for matching _UID Raag Jadav
                   ` (4 subsequent siblings)
  7 siblings, 1 reply; 23+ messages in thread
From: Raag Jadav @ 2023-10-20  8:47 UTC (permalink / raw)
  To: rafael, len.brown, robert.moore, mika.westerberg,
	andriy.shevchenko, mark.rutland, will, linux
  Cc: linux-acpi, linux-kernel, acpica-devel, linux-gpio,
	linux-arm-kernel, linux-hwmon, mallikarjunappa.sangannavar,
	bala.senthil, Raag Jadav

Convert manual _UID references to use standard ACPI helpers.

Signed-off-by: Raag Jadav <raag.jadav@intel.com>
---
 drivers/acpi/device_sysfs.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/acpi/device_sysfs.c b/drivers/acpi/device_sysfs.c
index b9bbf0746199..9d8e90744cb5 100644
--- a/drivers/acpi/device_sysfs.c
+++ b/drivers/acpi/device_sysfs.c
@@ -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);
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH v1 4/8] ACPI: utils: use acpi_dev_uid_match() for matching _UID
  2023-10-20  8:47 [PATCH v1 0/8] Refine _UID references across kernel Raag Jadav
                   ` (2 preceding siblings ...)
  2023-10-20  8:47 ` [PATCH v1 3/8] ACPI: sysfs: use acpi_device_uid() for fetching _UID Raag Jadav
@ 2023-10-20  8:47 ` Raag Jadav
  2023-10-20 10:36   ` Andy Shevchenko
  2023-10-20  8:47 ` [PATCH v1 5/8] ACPI: x86: " Raag Jadav
                   ` (3 subsequent siblings)
  7 siblings, 1 reply; 23+ messages in thread
From: Raag Jadav @ 2023-10-20  8:47 UTC (permalink / raw)
  To: rafael, len.brown, robert.moore, mika.westerberg,
	andriy.shevchenko, mark.rutland, will, linux
  Cc: linux-acpi, linux-kernel, acpica-devel, linux-gpio,
	linux-arm-kernel, linux-hwmon, mallikarjunappa.sangannavar,
	bala.senthil, Raag Jadav

Convert manual _UID references to use standard ACPI helpers.

Signed-off-by: Raag Jadav <raag.jadav@intel.com>
---
 drivers/acpi/utils.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/acpi/utils.c b/drivers/acpi/utils.c
index 664b9890b625..e3ba835e6590 100644
--- a/drivers/acpi/utils.c
+++ b/drivers/acpi/utils.c
@@ -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)
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH v1 5/8] ACPI: x86: use acpi_dev_uid_match() for matching _UID
  2023-10-20  8:47 [PATCH v1 0/8] Refine _UID references across kernel Raag Jadav
                   ` (3 preceding siblings ...)
  2023-10-20  8:47 ` [PATCH v1 4/8] ACPI: utils: use acpi_dev_uid_match() for matching _UID Raag Jadav
@ 2023-10-20  8:47 ` Raag Jadav
  2023-10-20 10:37   ` Andy Shevchenko
  2023-10-20  8:47 ` [PATCH v1 6/8] perf: qcom: use acpi_device_uid() for fetching _UID Raag Jadav
                   ` (2 subsequent siblings)
  7 siblings, 1 reply; 23+ messages in thread
From: Raag Jadav @ 2023-10-20  8:47 UTC (permalink / raw)
  To: rafael, len.brown, robert.moore, mika.westerberg,
	andriy.shevchenko, mark.rutland, will, linux
  Cc: linux-acpi, linux-kernel, acpica-devel, linux-gpio,
	linux-arm-kernel, linux-hwmon, mallikarjunappa.sangannavar,
	bala.senthil, Raag Jadav

Convert manual _UID references to use standard ACPI helpers.

Signed-off-by: Raag Jadav <raag.jadav@intel.com>
---
 drivers/acpi/x86/utils.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/acpi/x86/utils.c b/drivers/acpi/x86/utils.c
index 63d834dd3811..bc65ebfcdf76 100644
--- a/drivers/acpi/x86/utils.c
+++ b/drivers/acpi/x86/utils.c
@@ -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;
 		}
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH v1 6/8] perf: qcom: use acpi_device_uid() for fetching _UID
  2023-10-20  8:47 [PATCH v1 0/8] Refine _UID references across kernel Raag Jadav
                   ` (4 preceding siblings ...)
  2023-10-20  8:47 ` [PATCH v1 5/8] ACPI: x86: " Raag Jadav
@ 2023-10-20  8:47 ` Raag Jadav
  2023-10-20 17:22   ` Rafael J. Wysocki
  2023-10-20  8:47 ` [PATCH v1 7/8] hwmon: nct6775: use acpi_dev_hid_uid_match() for matching _HID and _UID Raag Jadav
  2023-10-20  8:47 ` [PATCH v1 8/8] perf: arm_cspmu: " Raag Jadav
  7 siblings, 1 reply; 23+ messages in thread
From: Raag Jadav @ 2023-10-20  8:47 UTC (permalink / raw)
  To: rafael, len.brown, robert.moore, mika.westerberg,
	andriy.shevchenko, mark.rutland, will, linux
  Cc: linux-acpi, linux-kernel, acpica-devel, linux-gpio,
	linux-arm-kernel, linux-hwmon, mallikarjunappa.sangannavar,
	bala.senthil, Raag Jadav

Convert manual _UID references to use standard ACPI helpers.

Signed-off-by: Raag Jadav <raag.jadav@intel.com>
---
 drivers/perf/qcom_l3_pmu.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/perf/qcom_l3_pmu.c b/drivers/perf/qcom_l3_pmu.c
index 2887edb4eb0b..f16783d03db7 100644
--- a/drivers/perf/qcom_l3_pmu.c
+++ b/drivers/perf/qcom_l3_pmu.c
@@ -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;
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH v1 7/8] hwmon: nct6775: use acpi_dev_hid_uid_match() for matching _HID and _UID
  2023-10-20  8:47 [PATCH v1 0/8] Refine _UID references across kernel Raag Jadav
                   ` (5 preceding siblings ...)
  2023-10-20  8:47 ` [PATCH v1 6/8] perf: qcom: use acpi_device_uid() for fetching _UID Raag Jadav
@ 2023-10-20  8:47 ` Raag Jadav
  2023-10-20  8:47 ` [PATCH v1 8/8] perf: arm_cspmu: " Raag Jadav
  7 siblings, 0 replies; 23+ messages in thread
From: Raag Jadav @ 2023-10-20  8:47 UTC (permalink / raw)
  To: rafael, len.brown, robert.moore, mika.westerberg,
	andriy.shevchenko, mark.rutland, will, linux
  Cc: linux-acpi, linux-kernel, acpica-devel, linux-gpio,
	linux-arm-kernel, linux-hwmon, mallikarjunappa.sangannavar,
	bala.senthil, Raag Jadav

Convert manual _UID references to use standard ACPI helpers.

Signed-off-by: Raag Jadav <raag.jadav@intel.com>
---
 drivers/hwmon/nct6775-platform.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/hwmon/nct6775-platform.c b/drivers/hwmon/nct6775-platform.c
index 81bf03dad6bb..0adeeab7ee03 100644
--- a/drivers/hwmon/nct6775-platform.c
+++ b/drivers/hwmon/nct6775-platform.c
@@ -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;
 	}
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH v1 8/8] perf: arm_cspmu: use acpi_dev_hid_uid_match() for matching _HID and _UID
  2023-10-20  8:47 [PATCH v1 0/8] Refine _UID references across kernel Raag Jadav
                   ` (6 preceding siblings ...)
  2023-10-20  8:47 ` [PATCH v1 7/8] hwmon: nct6775: use acpi_dev_hid_uid_match() for matching _HID and _UID Raag Jadav
@ 2023-10-20  8:47 ` Raag Jadav
  7 siblings, 0 replies; 23+ messages in thread
From: Raag Jadav @ 2023-10-20  8:47 UTC (permalink / raw)
  To: rafael, len.brown, robert.moore, mika.westerberg,
	andriy.shevchenko, mark.rutland, will, linux
  Cc: linux-acpi, linux-kernel, acpica-devel, linux-gpio,
	linux-arm-kernel, linux-hwmon, mallikarjunappa.sangannavar,
	bala.senthil, Raag Jadav

Convert manual _UID references to use standard ACPI helpers.

Signed-off-by: Raag Jadav <raag.jadav@intel.com>
---
 drivers/perf/arm_cspmu/arm_cspmu.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/perf/arm_cspmu/arm_cspmu.c b/drivers/perf/arm_cspmu/arm_cspmu.c
index e2b7827c4563..f0e6d14281d6 100644
--- a/drivers/perf/arm_cspmu/arm_cspmu.c
+++ b/drivers/perf/arm_cspmu/arm_cspmu.c
@@ -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);
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* Re: [PATCH v1 1/8] ACPI: utils: Introduce acpi_dev_uid_match() for matching _UID
  2023-10-20  8:47 ` [PATCH v1 1/8] ACPI: utils: Introduce acpi_dev_uid_match() for matching _UID Raag Jadav
@ 2023-10-20 10:35   ` Andy Shevchenko
  2023-10-20 15:49   ` Jonathan Cameron
  1 sibling, 0 replies; 23+ messages in thread
From: Andy Shevchenko @ 2023-10-20 10:35 UTC (permalink / raw)
  To: Raag Jadav
  Cc: rafael, len.brown, robert.moore, mika.westerberg, mark.rutland,
	will, linux, linux-acpi, linux-kernel, acpica-devel, linux-gpio,
	linux-arm-kernel, linux-hwmon, mallikarjunappa.sangannavar,
	bala.senthil

On Fri, Oct 20, 2023 at 02:17:25PM +0530, Raag Jadav wrote:
> Introduce acpi_dev_uid_match() helper that matches the device with
> supplied _UID string.

...

> +/**
> + * 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".

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

...

>  /**
>   * 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.

Ditto.

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

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v1 4/8] ACPI: utils: use acpi_dev_uid_match() for matching _UID
  2023-10-20  8:47 ` [PATCH v1 4/8] ACPI: utils: use acpi_dev_uid_match() for matching _UID Raag Jadav
@ 2023-10-20 10:36   ` Andy Shevchenko
  2023-10-20 11:38     ` Raag Jadav
  0 siblings, 1 reply; 23+ messages in thread
From: Andy Shevchenko @ 2023-10-20 10:36 UTC (permalink / raw)
  To: Raag Jadav
  Cc: rafael, len.brown, robert.moore, mika.westerberg, mark.rutland,
	will, linux, linux-acpi, linux-kernel, acpica-devel, linux-gpio,
	linux-arm-kernel, linux-hwmon, mallikarjunappa.sangannavar,
	bala.senthil

On Fri, Oct 20, 2023 at 02:17:28PM +0530, Raag Jadav wrote:
> Convert manual _UID references to use standard ACPI helpers.

Yes, while not so obvious this is the correct replacement.
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v1 5/8] ACPI: x86: use acpi_dev_uid_match() for matching _UID
  2023-10-20  8:47 ` [PATCH v1 5/8] ACPI: x86: " Raag Jadav
@ 2023-10-20 10:37   ` Andy Shevchenko
  2023-10-20 17:05     ` Rafael J. Wysocki
  0 siblings, 1 reply; 23+ messages in thread
From: Andy Shevchenko @ 2023-10-20 10:37 UTC (permalink / raw)
  To: Raag Jadav
  Cc: rafael, len.brown, robert.moore, mika.westerberg, mark.rutland,
	will, linux, linux-acpi, linux-kernel, acpica-devel, linux-gpio,
	linux-arm-kernel, linux-hwmon, mallikarjunappa.sangannavar,
	bala.senthil

On Fri, Oct 20, 2023 at 02:17:29PM +0530, Raag Jadav wrote:
> Convert manual _UID references to use standard ACPI helpers.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

...

> -			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.

>  				continue;


-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v1 4/8] ACPI: utils: use acpi_dev_uid_match() for matching _UID
  2023-10-20 10:36   ` Andy Shevchenko
@ 2023-10-20 11:38     ` Raag Jadav
  2023-10-20 13:42       ` Andy Shevchenko
  2023-10-20 17:11       ` Rafael J. Wysocki
  0 siblings, 2 replies; 23+ messages in thread
From: Raag Jadav @ 2023-10-20 11:38 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: rafael, len.brown, robert.moore, mika.westerberg, mark.rutland,
	will, linux, linux-acpi, linux-kernel, acpica-devel, linux-gpio,
	linux-arm-kernel, linux-hwmon, mallikarjunappa.sangannavar,
	bala.senthil

On Fri, Oct 20, 2023 at 01:36:27PM +0300, Andy Shevchenko wrote:
> On Fri, Oct 20, 2023 at 02:17:28PM +0530, Raag Jadav wrote:
> > Convert manual _UID references to use standard ACPI helpers.
> 
> Yes, while not so obvious this is the correct replacement.
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

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

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v1 4/8] ACPI: utils: use acpi_dev_uid_match() for matching _UID
  2023-10-20 11:38     ` Raag Jadav
@ 2023-10-20 13:42       ` Andy Shevchenko
  2023-10-20 14:00         ` Raag Jadav
  2023-10-20 17:11       ` Rafael J. Wysocki
  1 sibling, 1 reply; 23+ messages in thread
From: Andy Shevchenko @ 2023-10-20 13:42 UTC (permalink / raw)
  To: Raag Jadav
  Cc: rafael, len.brown, robert.moore, mika.westerberg, mark.rutland,
	will, linux, linux-acpi, linux-kernel, acpica-devel, linux-gpio,
	linux-arm-kernel, linux-hwmon, mallikarjunappa.sangannavar,
	bala.senthil

On Fri, Oct 20, 2023 at 02:38:06PM +0300, Raag Jadav wrote:
> On Fri, Oct 20, 2023 at 01:36:27PM +0300, Andy Shevchenko wrote:
> > On Fri, Oct 20, 2023 at 02:17:28PM +0530, Raag Jadav wrote:
> > > Convert manual _UID references to use standard ACPI helpers.
> > 
> > Yes, while not so obvious this is the correct replacement.
> > Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> 
> 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.

> 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.

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v1 4/8] ACPI: utils: use acpi_dev_uid_match() for matching _UID
  2023-10-20 13:42       ` Andy Shevchenko
@ 2023-10-20 14:00         ` Raag Jadav
  0 siblings, 0 replies; 23+ messages in thread
From: Raag Jadav @ 2023-10-20 14:00 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: rafael, len.brown, robert.moore, mika.westerberg, mark.rutland,
	will, linux, linux-acpi, linux-kernel, acpica-devel, linux-gpio,
	linux-arm-kernel, linux-hwmon, mallikarjunappa.sangannavar,
	bala.senthil

On Fri, Oct 20, 2023 at 04:42:08PM +0300, Andy Shevchenko wrote:
> On Fri, Oct 20, 2023 at 02:38:06PM +0300, Raag Jadav wrote:
> > On Fri, Oct 20, 2023 at 01:36:27PM +0300, Andy Shevchenko wrote:
> > > On Fri, Oct 20, 2023 at 02:17:28PM +0530, Raag Jadav wrote:
> > > > Convert manual _UID references to use standard ACPI helpers.
> > > 
> > > Yes, while not so obvious this is the correct replacement.
> > > Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> > 
> > 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

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v1 1/8] ACPI: utils: Introduce acpi_dev_uid_match() for matching _UID
  2023-10-20  8:47 ` [PATCH v1 1/8] ACPI: utils: Introduce acpi_dev_uid_match() for matching _UID Raag Jadav
  2023-10-20 10:35   ` Andy Shevchenko
@ 2023-10-20 15:49   ` Jonathan Cameron
  1 sibling, 0 replies; 23+ messages in thread
From: Jonathan Cameron @ 2023-10-20 15:49 UTC (permalink / raw)
  To: Raag Jadav
  Cc: rafael, len.brown, robert.moore, mika.westerberg,
	andriy.shevchenko, mark.rutland, will, linux, linux-acpi,
	linux-kernel, acpica-devel, linux-gpio, linux-arm-kernel,
	linux-hwmon, mallikarjunappa.sangannavar, bala.senthil

On Fri, 20 Oct 2023 14:17:25 +0530
Raag Jadav <raag.jadav@intel.com> wrote:

> Introduce acpi_dev_uid_match() helper that matches the device with
> supplied _UID string.
> 
> Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Signed-off-by: Raag Jadav <raag.jadav@intel.com>
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
>  /**
>   * 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.

> + *
> + * 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);
>  
> diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
> index 254685085c82..d1fe6446ffe0 100644
> --- a/include/acpi/acpi_bus.h
> +++ b/include/acpi/acpi_bus.h
> @@ -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);
>  
> diff --git a/include/linux/acpi.h b/include/linux/acpi.h
> index afd94c9b8b8a..db3a33e19c97 100644
> --- a/include/linux/acpi.h
> +++ b/include/linux/acpi.h
> @@ -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)
>  {


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v1 5/8] ACPI: x86: use acpi_dev_uid_match() for matching _UID
  2023-10-20 10:37   ` Andy Shevchenko
@ 2023-10-20 17:05     ` Rafael J. Wysocki
  2023-10-20 18:42       ` Andy Shevchenko
  0 siblings, 1 reply; 23+ messages in thread
From: Rafael J. Wysocki @ 2023-10-20 17:05 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Raag Jadav, rafael, len.brown, robert.moore, mika.westerberg,
	mark.rutland, will, linux, linux-acpi, linux-kernel, acpica-devel,
	linux-gpio, linux-arm-kernel, linux-hwmon,
	mallikarjunappa.sangannavar, bala.senthil

On Fri, Oct 20, 2023 at 12:38 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
>
> On Fri, Oct 20, 2023 at 02:17:29PM +0530, Raag Jadav wrote:
> > Convert manual _UID references to use standard ACPI helpers.
>
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
>
> ...
>
> > -                     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?

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v1 4/8] ACPI: utils: use acpi_dev_uid_match() for matching _UID
  2023-10-20 11:38     ` Raag Jadav
  2023-10-20 13:42       ` Andy Shevchenko
@ 2023-10-20 17:11       ` Rafael J. Wysocki
  2023-10-20 18:11         ` Raag Jadav
  1 sibling, 1 reply; 23+ messages in thread
From: Rafael J. Wysocki @ 2023-10-20 17:11 UTC (permalink / raw)
  To: Raag Jadav
  Cc: Andy Shevchenko, rafael, len.brown, robert.moore, mika.westerberg,
	mark.rutland, will, linux, linux-acpi, linux-kernel, acpica-devel,
	linux-gpio, linux-arm-kernel, linux-hwmon,
	mallikarjunappa.sangannavar, bala.senthil

On Fri, Oct 20, 2023 at 1:38 PM Raag Jadav <raag.jadav@intel.com> wrote:
>
> On Fri, Oct 20, 2023 at 01:36:27PM +0300, Andy Shevchenko wrote:
> > On Fri, Oct 20, 2023 at 02:17:28PM +0530, Raag Jadav wrote:
> > > Convert manual _UID references to use standard ACPI helpers.
> >
> > Yes, while not so obvious this is the correct replacement.
> > Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
>
> 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.

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.

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v1 3/8] ACPI: sysfs: use acpi_device_uid() for fetching _UID
  2023-10-20  8:47 ` [PATCH v1 3/8] ACPI: sysfs: use acpi_device_uid() for fetching _UID Raag Jadav
@ 2023-10-20 17:18   ` Rafael J. Wysocki
  0 siblings, 0 replies; 23+ messages in thread
From: Rafael J. Wysocki @ 2023-10-20 17:18 UTC (permalink / raw)
  To: Raag Jadav
  Cc: rafael, len.brown, robert.moore, mika.westerberg,
	andriy.shevchenko, mark.rutland, will, linux, linux-acpi,
	linux-kernel, acpica-devel, linux-gpio, linux-arm-kernel,
	linux-hwmon, mallikarjunappa.sangannavar, bala.senthil

On Fri, Oct 20, 2023 at 10:48 AM Raag Jadav <raag.jadav@intel.com> wrote:
>
> Convert manual _UID references to use standard ACPI helpers.
>
> Signed-off-by: Raag Jadav <raag.jadav@intel.com>
> ---
>  drivers/acpi/device_sysfs.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/acpi/device_sysfs.c b/drivers/acpi/device_sysfs.c
> index b9bbf0746199..9d8e90744cb5 100644
> --- a/drivers/acpi/device_sysfs.c
> +++ b/drivers/acpi/device_sysfs.c
> @@ -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);
> --

Applied as 6.7 material, thanks!

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v1 6/8] perf: qcom: use acpi_device_uid() for fetching _UID
  2023-10-20  8:47 ` [PATCH v1 6/8] perf: qcom: use acpi_device_uid() for fetching _UID Raag Jadav
@ 2023-10-20 17:22   ` Rafael J. Wysocki
  0 siblings, 0 replies; 23+ messages in thread
From: Rafael J. Wysocki @ 2023-10-20 17:22 UTC (permalink / raw)
  To: Raag Jadav
  Cc: rafael, len.brown, robert.moore, mika.westerberg,
	andriy.shevchenko, mark.rutland, will, linux, linux-acpi,
	linux-kernel, acpica-devel, linux-gpio, linux-arm-kernel,
	linux-hwmon, mallikarjunappa.sangannavar, bala.senthil

On Fri, Oct 20, 2023 at 10:48 AM Raag Jadav <raag.jadav@intel.com> wrote:
>
> Convert manual _UID references to use standard ACPI helpers.
>
> Signed-off-by: Raag Jadav <raag.jadav@intel.com>
> ---
>  drivers/perf/qcom_l3_pmu.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/perf/qcom_l3_pmu.c b/drivers/perf/qcom_l3_pmu.c
> index 2887edb4eb0b..f16783d03db7 100644
> --- a/drivers/perf/qcom_l3_pmu.c
> +++ b/drivers/perf/qcom_l3_pmu.c
> @@ -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;
>
> --

Applied as 6.7 material.

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

Thanks!

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v1 4/8] ACPI: utils: use acpi_dev_uid_match() for matching _UID
  2023-10-20 17:11       ` Rafael J. Wysocki
@ 2023-10-20 18:11         ` Raag Jadav
  2023-10-21  6:51           ` Raag Jadav
  0 siblings, 1 reply; 23+ messages in thread
From: Raag Jadav @ 2023-10-20 18:11 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Andy Shevchenko, len.brown, robert.moore, mika.westerberg,
	mark.rutland, will, linux, linux-acpi, linux-kernel, acpica-devel,
	linux-gpio, linux-arm-kernel, linux-hwmon,
	mallikarjunappa.sangannavar, bala.senthil

On Fri, Oct 20, 2023 at 07:11:53PM +0200, Rafael J. Wysocki wrote:
> On Fri, Oct 20, 2023 at 1:38 PM Raag Jadav <raag.jadav@intel.com> wrote:
> >
> > On Fri, Oct 20, 2023 at 01:36:27PM +0300, Andy Shevchenko wrote:
> > > On Fri, Oct 20, 2023 at 02:17:28PM +0530, Raag Jadav wrote:
> > > > Convert manual _UID references to use standard ACPI helpers.
> > >
> > > Yes, while not so obvious this is the correct replacement.
> > > Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> >
> > 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.
> 
> 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

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v1 5/8] ACPI: x86: use acpi_dev_uid_match() for matching _UID
  2023-10-20 17:05     ` Rafael J. Wysocki
@ 2023-10-20 18:42       ` Andy Shevchenko
  0 siblings, 0 replies; 23+ messages in thread
From: Andy Shevchenko @ 2023-10-20 18:42 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Raag Jadav, len.brown, robert.moore, mika.westerberg,
	mark.rutland, will, linux, linux-acpi, linux-kernel, acpica-devel,
	linux-gpio, linux-arm-kernel, linux-hwmon,
	mallikarjunappa.sangannavar, bala.senthil

On Fri, Oct 20, 2023 at 07:05:37PM +0200, Rafael J. Wysocki wrote:
> On Fri, Oct 20, 2023 at 12:38 PM Andy Shevchenko
> <andriy.shevchenko@linux.intel.com> wrote:
> > On Fri, Oct 20, 2023 at 02:17:29PM +0530, Raag Jadav wrote:

...

> > > -                     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.

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v1 4/8] ACPI: utils: use acpi_dev_uid_match() for matching _UID
  2023-10-20 18:11         ` Raag Jadav
@ 2023-10-21  6:51           ` Raag Jadav
  0 siblings, 0 replies; 23+ messages in thread
From: Raag Jadav @ 2023-10-21  6:51 UTC (permalink / raw)
  To: Rafael J. Wysocki, Andy Shevchenko
  Cc: Andy Shevchenko, len.brown, robert.moore, mika.westerberg,
	mark.rutland, will, linux, linux-acpi, linux-kernel, acpica-devel,
	linux-gpio, linux-arm-kernel, linux-hwmon,
	mallikarjunappa.sangannavar, bala.senthil

On Fri, Oct 20, 2023 at 09:11:56PM +0300, Raag Jadav wrote:
> On Fri, Oct 20, 2023 at 07:11:53PM +0200, Rafael J. Wysocki wrote:
> > On Fri, Oct 20, 2023 at 1:38 PM Raag Jadav <raag.jadav@intel.com> wrote:
> > >
> > > On Fri, Oct 20, 2023 at 01:36:27PM +0300, Andy Shevchenko wrote:
> > > > On Fri, Oct 20, 2023 at 02:17:28PM +0530, Raag Jadav wrote:
> > > > > Convert manual _UID references to use standard ACPI helpers.
> > > >
> > > > Yes, while not so obvious this is the correct replacement.
> > > > Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> > >
> > > 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.
> > 
> > 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

^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2023-10-21  6:51 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-20  8:47 [PATCH v1 0/8] Refine _UID references across kernel Raag Jadav
2023-10-20  8:47 ` [PATCH v1 1/8] ACPI: utils: Introduce acpi_dev_uid_match() for matching _UID Raag Jadav
2023-10-20 10:35   ` Andy Shevchenko
2023-10-20 15:49   ` Jonathan Cameron
2023-10-20  8:47 ` [PATCH v1 2/8] pinctrl: intel: use " Raag Jadav
2023-10-20  8:47 ` [PATCH v1 3/8] ACPI: sysfs: use acpi_device_uid() for fetching _UID Raag Jadav
2023-10-20 17:18   ` Rafael J. Wysocki
2023-10-20  8:47 ` [PATCH v1 4/8] ACPI: utils: use acpi_dev_uid_match() for matching _UID Raag Jadav
2023-10-20 10:36   ` Andy Shevchenko
2023-10-20 11:38     ` Raag Jadav
2023-10-20 13:42       ` Andy Shevchenko
2023-10-20 14:00         ` Raag Jadav
2023-10-20 17:11       ` Rafael J. Wysocki
2023-10-20 18:11         ` Raag Jadav
2023-10-21  6:51           ` Raag Jadav
2023-10-20  8:47 ` [PATCH v1 5/8] ACPI: x86: " Raag Jadav
2023-10-20 10:37   ` Andy Shevchenko
2023-10-20 17:05     ` Rafael J. Wysocki
2023-10-20 18:42       ` Andy Shevchenko
2023-10-20  8:47 ` [PATCH v1 6/8] perf: qcom: use acpi_device_uid() for fetching _UID Raag Jadav
2023-10-20 17:22   ` Rafael J. Wysocki
2023-10-20  8:47 ` [PATCH v1 7/8] hwmon: nct6775: use acpi_dev_hid_uid_match() for matching _HID and _UID Raag Jadav
2023-10-20  8:47 ` [PATCH v1 8/8] perf: arm_cspmu: " Raag Jadav

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).