diff mbox series

[v7,19/22] ACPI: platform_profile: Notify class device from platform_profile_notify()

Message ID 20241119171739.77028-20-mario.limonciello@amd.com
State New
Headers show
Series Add support for binding ACPI platform profile to multiple drivers | expand

Commit Message

Mario Limonciello Nov. 19, 2024, 5:17 p.m. UTC
When a driver has called platform_profile_notify() both the legacy sysfs
interface and the class device should be notified as userspace may listen
to either.

Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
v7:
 * Use class_for_each_device
---
 drivers/acpi/platform_profile.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Armin Wolf Nov. 21, 2024, 10:31 p.m. UTC | #1
Am 19.11.24 um 18:17 schrieb Mario Limonciello:

> When a driver has called platform_profile_notify() both the legacy sysfs
> interface and the class device should be notified as userspace may listen
> to either.
>
> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
> ---
> v7:
>   * Use class_for_each_device
> ---
>   drivers/acpi/platform_profile.c | 4 ++++
>   1 file changed, 4 insertions(+)
>
> diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c
> index ca997f4e9a5cb..e88b355a72112 100644
> --- a/drivers/acpi/platform_profile.c
> +++ b/drivers/acpi/platform_profile.c
> @@ -402,6 +402,10 @@ void platform_profile_notify(struct platform_profile_handler *pprof)
>   {
>   	if (!cur_profile)
>   		return;
> +	scoped_cond_guard(mutex_intr, return, &profile_lock) {
> +		class_for_each_device(&platform_profile_class, NULL, NULL,
> +				      _notify_class_profile);

I think that using class_for_each_device() is a bit overblown here. He only want to notify a single platform profile,
so using class_for_each_device() is a bit too much. Using _notify_class_profile() is enough.

With that being fixed:
Reviewed-by: Armin Wolf <W_Armin@gmx.de>

> +	}
>   	sysfs_notify(acpi_kobj, NULL, "platform_profile");
>   }
>   EXPORT_SYMBOL_GPL(platform_profile_notify);
diff mbox series

Patch

diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c
index ca997f4e9a5cb..e88b355a72112 100644
--- a/drivers/acpi/platform_profile.c
+++ b/drivers/acpi/platform_profile.c
@@ -402,6 +402,10 @@  void platform_profile_notify(struct platform_profile_handler *pprof)
 {
 	if (!cur_profile)
 		return;
+	scoped_cond_guard(mutex_intr, return, &profile_lock) {
+		class_for_each_device(&platform_profile_class, NULL, NULL,
+				      _notify_class_profile);
+	}
 	sysfs_notify(acpi_kobj, NULL, "platform_profile");
 }
 EXPORT_SYMBOL_GPL(platform_profile_notify);