public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
From: Kurt Borja <kuurtb@gmail.com>
To: platform-driver-x86@vger.kernel.org
Cc: josh@joshuagrisham.com, hridesh699@gmail.com,
	derekjohn.clark@gmail.com, "Kurt Borja" <kuurtb@gmail.com>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	"Len Brown" <lenb@kernel.org>,
	"Maximilian Luz" <luzmaximilian@gmail.com>,
	"Hans de Goede" <hdegoede@redhat.com>,
	"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
	"Lee, Chun-Yi" <jlee@suse.com>,
	"Shyam Sundar S K" <Shyam-sundar.S-k@amd.com>,
	"Corentin Chary" <corentin.chary@gmail.com>,
	"Luke D. Jones" <luke@ljones.dev>,
	"Lyndon Sanche" <lsanche@lyndeno.ca>,
	"Ike Panhc" <ike.pan@canonical.com>,
	"Henrique de Moraes Holschuh" <hmh@hmh.eng.br>,
	"Armin Wolf" <W_Armin@gmx.de>,
	"Mario Limonciello" <mario.limonciello@amd.com>,
	"Mark Pearson" <mpearson-lenovo@squebb.ca>,
	"Colin Ian King" <colin.i.king@gmail.com>,
	"Alexis Belmonte" <alexbelm48@gmail.com>,
	"Ai Chao" <aichao@kylinos.cn>,
	"Uwe Kleine-König" <u.kleine-koenig@baylibre.com>,
	"Gergo Koteles" <soyer@irl.hu>,
	linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org,
	Dell.Client.Kernel@dell.com,
	ibm-acpi-devel@lists.sourceforge.net
Subject: [RFC PATCH 3/3] ACPI: platform_profile: Add platform_profile_refresh_choices()
Date: Sun,  5 Jan 2025 23:45:51 -0500	[thread overview]
Message-ID: <20250106044605.12494-4-kuurtb@gmail.com> (raw)
In-Reply-To: <20250106044605.12494-1-kuurtb@gmail.com>

Let drivers dynamically refresh selected choices safely, while holding
`profile_lock`.

Signed-off-by: Kurt Borja <kuurtb@gmail.com>
---
 drivers/acpi/platform_profile.c  | 23 +++++++++++++++++++++++
 include/linux/platform_profile.h |  1 +
 2 files changed, 24 insertions(+)

diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c
index ec749c2d0695..087280d786b1 100644
--- a/drivers/acpi/platform_profile.c
+++ b/drivers/acpi/platform_profile.c
@@ -459,6 +459,29 @@ int platform_profile_cycle(void)
 }
 EXPORT_SYMBOL_GPL(platform_profile_cycle);
 
+int platform_profile_refresh_choices(struct platform_profile_handler *pprof)
+{
+	unsigned long backup[BITS_TO_LONGS(PLATFORM_PROFILE_LAST)];
+	int err;
+
+	scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) {
+		bitmap_copy(backup, pprof->choices, PLATFORM_PROFILE_LAST);
+
+		err = pprof->ops->choices(pprof);
+		if (err) {
+			bitmap_copy(pprof->choices, backup, PLATFORM_PROFILE_LAST);
+			return err;
+		}
+
+		_notify_class_profile(pprof->class_dev, NULL);
+	}
+
+	sysfs_notify(acpi_kobj, NULL, "platform_profile");
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(platform_profile_refresh_choices);
+
 int platform_profile_register(struct platform_profile_handler *pprof)
 {
 	int err;
diff --git a/include/linux/platform_profile.h b/include/linux/platform_profile.h
index 7f266a60b41a..7d543dd8c164 100644
--- a/include/linux/platform_profile.h
+++ b/include/linux/platform_profile.h
@@ -50,6 +50,7 @@ int platform_profile_register(struct platform_profile_handler *pprof);
 int platform_profile_remove(struct platform_profile_handler *pprof);
 int devm_platform_profile_register(struct platform_profile_handler *pprof);
 int platform_profile_cycle(void);
+int platform_profile_refresh_choices(struct platform_profile_handler *pprof);
 void platform_profile_notify(struct platform_profile_handler *pprof);
 
 #endif  /*_PLATFORM_PROFILE_H_*/
-- 
2.47.1


  parent reply	other threads:[~2025-01-06  4:47 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-06  4:45 [RFC PATCH 0/3] ACPI: platform_profile: Let drivers dynamically refresh choices Kurt Borja
2025-01-06  4:45 ` [RFC PATCH 1/3] ACPI: platform_profile: Add ops member to handlers Kurt Borja
2025-01-06  4:45 ` [RFC PATCH 2/3] ACPI: platform_profile: Add `choices` to platform_profile_ops Kurt Borja
2025-01-06  4:45 ` Kurt Borja [this message]
2025-01-07  2:19 ` [RFC PATCH 0/3] ACPI: platform_profile: Let drivers dynamically refresh choices Mark Pearson
2025-01-07 13:14   ` Hridesh MG
2025-01-07 15:51     ` Mario Limonciello
2025-01-07 16:33       ` Hridesh MG
2025-01-07 16:47         ` Limonciello, Mario
2025-01-07 17:25           ` Kurt Borja
2025-01-07 17:28             ` Limonciello, Mario
2025-01-08  6:39               ` Kurt Borja

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250106044605.12494-4-kuurtb@gmail.com \
    --to=kuurtb@gmail.com \
    --cc=Dell.Client.Kernel@dell.com \
    --cc=Shyam-sundar.S-k@amd.com \
    --cc=W_Armin@gmx.de \
    --cc=aichao@kylinos.cn \
    --cc=alexbelm48@gmail.com \
    --cc=colin.i.king@gmail.com \
    --cc=corentin.chary@gmail.com \
    --cc=derekjohn.clark@gmail.com \
    --cc=hdegoede@redhat.com \
    --cc=hmh@hmh.eng.br \
    --cc=hridesh699@gmail.com \
    --cc=ibm-acpi-devel@lists.sourceforge.net \
    --cc=ike.pan@canonical.com \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=jlee@suse.com \
    --cc=josh@joshuagrisham.com \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lsanche@lyndeno.ca \
    --cc=luke@ljones.dev \
    --cc=luzmaximilian@gmail.com \
    --cc=mario.limonciello@amd.com \
    --cc=mpearson-lenovo@squebb.ca \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=rafael@kernel.org \
    --cc=soyer@irl.hu \
    --cc=u.kleine-koenig@baylibre.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox