Refine _UID references across kernel
Subsystems (7)
v2 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 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: 64b6555f2fe6b43fb6782aa3e2cbb34bfe39047d
Signature · 1 line
2.17.1
PATCH v2 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
@@ -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
@@ -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
@@ -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
Re: [PATCH v2 1/6] ACPI: utils: Introduce acpi_dev_uid_match() for matching _UID
Quoted 2 lines · Raag Jadav
Introduce
acpi_dev_uid_match()helper that matches the device with supplied_UIDstring.
...
Quoted 1 line
Suggested-by Andy Shevchenko <[email protected]>
Sorry, I suggested another helper. Please either drop this tag, or change helper to what I suggested (as in your v1 I assume).
Signature · 2 lines
With Best Regards, Andy Shevchenko
PATCH v2 2/6 pinctrl: intel: use acpi_dev_uid_match() for matching _UID
In reply to Raag JadavConvert 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
@@ -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
Re: [PATCH v2 2/6] pinctrl: intel: use acpi_dev_uid_match() for matching _UID
Quoted 4 lines · Raag Jadav
Convert manual
_UIDreferences to use the standard ACPI helper.Signed-off-by Raag Jadav <[email protected]>Reviewed-by Andy Shevchenko <[email protected]>
As I asked you, please drop this one. It has a hidden logic that is not aligned with acpi_dev_hid_uid_match(). Or revert to your v1 I assume.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v2 2/6] pinctrl: intel: use acpi_dev_uid_match() for matching _UID
Quoted 8 lines · Andy Shevchenko
Quoted 4 lines · Raag Jadav
Convert manual
_UIDreferences to use the standard ACPI helper.Signed-off-by Raag Jadav <[email protected]>Reviewed-by Andy Shevchenko <[email protected]>It has a hidden logic that is not aligned with
acpi_dev_hid_uid_match(). Or revert to your v1 I assume.
I don't see how this has to be aligned with acpi_dev_hid_uid_match() or if acpi_dev_hid_uid_match() implementation concerns this specific change, since that's not what we intend to do here.
Also, I think acpi_dev_uid_match() implementation in v2 is actually more aligned with the previous logic that we're replacing here, since it gives us a guaranteed match result as originally intended with strcmp in this case. And the "hidden logic" in v1 implementation (match with @uid2 == NULL) is what ends up breaking it in my opinion.
Regardless, for any version (v1 or v2) the usage still remains the same in this case.
Quoted 1 line
As I asked you, please drop this one.
But okay, as you wish :(
Rafael, should I send a v3 with dropped tags?
Raag
Rafael J. Wysocki
maintainerRe: [PATCH v2 2/6] pinctrl: intel: use acpi_dev_uid_match() for matching _UID
Quoted 15 lines · Raag Jadav
Quoted 8 lines · Andy Shevchenko
Quoted 4 lines · Raag Jadav
Convert manual
_UIDreferences to use the standard ACPI helper.Signed-off-by Raag Jadav <[email protected]>Reviewed-by Andy Shevchenko <[email protected]>It has a hidden logic that is not aligned with
acpi_dev_hid_uid_match(). Or revert to your v1 I assume.I don't see how this has to be aligned with
acpi_dev_hid_uid_match()or ifacpi_dev_hid_uid_match()implementation concerns this specific change, since that's not what we intend to do here.
Quoted 8 lines
Also, I think
acpi_dev_uid_match()implementation in v2 is actually more aligned with the previous logic that we're replacing here, since it gives us a guaranteed match result as originally intended with strcmp in this case. And the "hidden logic" in v1 implementation (match with @uid2 == NULL) is what ends up breaking it in my opinion.Regardless, for any version (v1 or v2) the usage still remains the same in this case.
Right, so it is a bit unclear what all of the fuss is about.
Quoted 5 lines
Quoted 1 line
As I asked you, please drop this one.
But okay, as you wish :(
Rafael, should I send a v3 with dropped tags?
No need to resend in general, I can drop tags from the patches just fine.
For this one, though, I'd like to get a maintainer's ACK, so it may be necessary to resend it without the tag.
PATCH v2 3/6 ACPI: utils: use acpi_dev_uid_match() for matching _UID
In reply to Raag JadavConvert 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
@@ -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
PATCH v2 4/6 ACPI: x86: use acpi_dev_uid_match() for matching _UID
In reply to Raag JadavConvert 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
@@ -184,8 +184,7 @@ bool acpi_device_override_status(struct acpi_device *adev, unsigned long long *sif (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
Re: [PATCH v2 4/6] ACPI: x86: use acpi_dev_uid_match() for matching _UID
Quoted 4 lines · Raag Jadav
Convert manual
_UIDreferences to use the standard ACPI helper.Signed-off-by Raag Jadav <[email protected]>Reviewed-by Andy Shevchenko <[email protected]>
Please, drop this tag, since I disagree with patch 1 implementation.
Signature · 2 lines
With Best Regards, Andy Shevchenko
PATCH v2 5/6 hwmon: nct6775: use acpi_dev_hid_uid_match() for matching _HID and _UID
In reply to Raag JadavConvert 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
@@ -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
PATCH v2 6/6 perf: arm_cspmu: use acpi_dev_hid_uid_match() for matching _HID and _UID
In reply to Raag JadavConvert 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
@@ -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