ACPI: platform-profile: Introduce object pointers to callbacks
Subsystems (2)
v2 cover ACPI: platform-profile: Introduce object pointers to callbacks
Hi Rafael, Jiaxun,
Here is a v2 of Jiaxun's series to introduce object pointers to the profile_get() and profile_set() callbacks.
I've taken the liberty to fix the issue of the platform_profile_register() function argument still having a const and post this v2, as I would like to at least merge the thinkpad_acpi platform_profile support for 5.12 and we are slowly running out of time.
Rafael, you please add these 2 to your acpi-platform branch and then once you are happy with these (once the bots have tested them) send me a PR for an immutable branch with all 4 patches from acpi-platform ?
Regards,
Hans
Jiaxun Yang (2):
ACPI: platform-profile: Drop const qualifier for cur_profile
ACPI: platform-profile: Introduce object pointers to callbacks
drivers/acpi/platform_profile.c | 8 ++++---- include/linux/platform_profile.h | 8 +++++--- 2 files changed, 9 insertions(+), 7 deletions(-)
Signature · 1 line
2.29.2
PATCH v2 1/2 ACPI: platform-profile: Drop const qualifier for cur_profile
From: Jiaxun Yang <[email protected]>
Drop the const qualifier from the static global cur_profile pointer declaration.
This is a preparation patch for passing the cur_profile pointer as parameter to the profile_get() and profile_set() callbacks so that drivers dynamically allocating their driver-data struct, with their platform_profile_handler struct embedded, can use this pointer to get to their driver-data.
Note this also requires dropping the const from the pprof platform_profile_register() function argument. Dropping this const is not a problem, non of the queued up consumers of platform_profile_register() actually pass in a const pointer.
---
Changes in v2 (Hans de Goede):
- Not only remove the const from the global cur_profile variable declaration, but also from the platform_profile_register() argument
- Reword commit message to match
--- drivers/acpi/platform_profile.c | 4 ++-- include/linux/platform_profile.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/acpi/platform_profile.c +2 -2
@@ -9,7 +9,7 @@#include <linux/platform_profile.h> #include <linux/sysfs.h> -static const struct platform_profile_handler *cur_profile; +static struct platform_profile_handler *cur_profile;static DEFINE_MUTEX (profile_lock);static const char *const profile_names[] = {
@@ -132,7 +132,7 @@ void platform_profile_notify(void) }EXPORT_SYMBOL_GPL (platform_profile_notify); -int platform_profile_register (const struct platform_profile_handler *pprof) +int platform_profile_register (struct platform_profile_handler *pprof) {int err;
include/linux/platform_profile.h +1 -1
@@ -32,7 +32,7 @@ struct platform_profile_handler {int (*profile_set)(enum platform_profile_option profile); }; -int platform_profile_register (const struct platform_profile_handler *pprof); +int platform_profile_register (struct platform_profile_handler *pprof);int platform_profile_remove (void );void platform_profile_notify (void );
Signature · 1 line
2.29.2
Rafael J. Wysocki
maintainerRe: [PATCH v2 1/2] ACPI: platform-profile: Drop const qualifier for cur_profile
Quoted 23 lines · Hans de Goede
From: Jiaxun Yang <[email protected]>
Drop the const qualifier from the static global
cur_profilepointer declaration.This is a preparation patch for passing the
cur_profilepointer as parameter to theprofile_get()andprofile_set()callbacks so that drivers dynamically allocating their driver-data struct, with theirplatform_profile_handlerstruct embedded, can use this pointer to get to their driver-data.Note this also requires dropping the const from the pprof
platform_profile_register()function argument. Dropping this const is not a problem, non of the queued up consumers ofplatform_profile_register()actually pass in a const pointer.Suggested-by Hans de Goede <[email protected]>Signed-off-by Jiaxun Yang <[email protected]>[[email protected]: Also remove const from platform_profile_register()]Signed-off-by Hans de Goede <[email protected]>
Quoted 5 lines
---
Changes in v2 (Hans de Goede):
- Not only remove the const from the globalcur_profilevariable declaration, but also from theplatform_profile_register()argument
- Reword commit message to match
Applied as 5.12 material on top of the previous platform-profile commits, thanks!
I will expose a separate branch with these commits when they get some linux-next build coverage.
Quoted 43 lines
--- drivers/acpi/platform_profile.c | 4 ++-- include/linux/platform_profile.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)drivers/acpi/platform_profile.c +2
-2@@ -9,7 +9,7 @@#include <linux/platform_profile.h> #include <linux/sysfs.h> -static const struct platform_profile_handler *cur_profile; +static struct platform_profile_handler *cur_profile;static DEFINE_MUTEX (profile_lock);static const char *const profile_names[] = {@@ -132,7 +132,7 @@ void platform_profile_notify(void) }EXPORT_SYMBOL_GPL (platform_profile_notify); -int platform_profile_register (const struct platform_profile_handler *pprof) +int platform_profile_register (struct platform_profile_handler *pprof) {int err;include/linux/platform_profile.h +1
-2@@ -32,7 +32,7 @@ struct platform_profile_handler {int (*profile_set)(enum platform_profile_option profile); }; -int platform_profile_register (const struct platform_profile_handler *pprof); +int platform_profile_register (struct platform_profile_handler *pprof);int platform_profile_remove (void );void platform_profile_notify (void ); --2.29.2
PATCH v2 2/2 ACPI: platform-profile: Introduce object pointers to callbacks
In reply to Hans de GoedeFrom: Jiaxun Yang <[email protected]>
Add an object pointer to handler callbacks to avoid the need for drivers to have a global variable to get to their driver-data struct.
---
Changes in v2 (Hans de Goede):
- Tweak the commit message wording a bit
--- drivers/acpi/platform_profile.c | 4 ++-- include/linux/platform_profile.h | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-)
drivers/acpi/platform_profile.c +2 -2
@@ -64,7 +64,7 @@ static ssize_t platform_profile_show(struct device *dev,return -ENODEV ; } - err = cur_profile->profile_get (&profile); + err = cur_profile->profile_get (cur_profile, &profile);mutex_unlock (&profile_lock);if (err)return err;
@@ -104,7 +104,7 @@ static ssize_t platform_profile_store(struct device *dev,return -EOPNOTSUPP ; } - err = cur_profile->profile_set (i); + err = cur_profile->profile_set (cur_profile, i);mutex_unlock (&profile_lock);if (err)return err;
include/linux/platform_profile.h +4 -2
@@ -28,8 +28,10 @@ enum platform_profile_option {struct platform_profile_handler {unsigned long choices[BITS_TO_LONGS (PLATFORM_PROFILE_LAST )]; -int (*profile_get)(enum platform_profile_option *profile); -int (*profile_set)(enum platform_profile_option profile); +int (*profile_get)(struct platform_profile_handler *pprof, +enum platform_profile_option *profile); +int (*profile_set)(struct platform_profile_handler *pprof, +enum platform_profile_option profile); };int platform_profile_register (struct platform_profile_handler *pprof);
Signature · 1 line
2.29.2
Rafael J. Wysocki
maintainerQuoted 7 lines · Hans de Goede
From: Jiaxun Yang <[email protected]>
Add an object pointer to handler callbacks to avoid the need for drivers to have a global variable to get to their driver-data struct.
Quoted 5 lines
Signed-off-by Jiaxun Yang <[email protected]>Suggested-by Hans de Goede <[email protected]>Signed-off-by Hans de Goede <[email protected]>
Applied on top of the previous platform-profile patches, thanks!
Quoted 50 lines
---
Changes in v2 (Hans de Goede):
- Tweak the commit message wording a bit--- drivers/acpi/platform_profile.c | 4 ++-- include/linux/platform_profile.h | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-)drivers/acpi/platform_profile.c +2
-2@@ -64,7 +64,7 @@ static ssize_t platform_profile_show(struct device *dev,return -ENODEV ; } - err = cur_profile->profile_get (&profile); + err = cur_profile->profile_get (cur_profile, &profile);mutex_unlock (&profile_lock);if (err)return err;@@ -104,7 +104,7 @@ static ssize_t platform_profile_store(struct device *dev,return -EOPNOTSUPP ; } - err = cur_profile->profile_set (i); + err = cur_profile->profile_set (cur_profile, i);mutex_unlock (&profile_lock);if (err)return err;include/linux/platform_profile.h +4
-3@@ -28,8 +28,10 @@ enum platform_profile_option {struct platform_profile_handler {unsigned long choices[BITS_TO_LONGS (PLATFORM_PROFILE_LAST )]; -int (*profile_get)(enum platform_profile_option *profile); -int (*profile_set)(enum platform_profile_option profile); +int (*profile_get)(struct platform_profile_handler *pprof, +enum platform_profile_option *profile); +int (*profile_set)(struct platform_profile_handler *pprof, +enum platform_profile_option profile); };int platform_profile_register (struct platform_profile_handler *pprof); --2.29.2
Rafael J. Wysocki
maintainerQuoted 9 lines · Rafael J. Wysocki
Quoted 7 lines · Hans de Goede
From: Jiaxun Yang <[email protected]>
Add an object pointer to handler callbacks to avoid the need for drivers to have a global variable to get to their driver-data struct.
Quoted 7 lines
Quoted 5 lines
Signed-off-by Jiaxun Yang <[email protected]>Suggested-by Hans de Goede <[email protected]>Signed-off-by Hans de Goede <[email protected]>Applied on top of the previous platform-profile patches, thanks!
And the entire acpi-platform-profile material is now available for you to pull in the git branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git \
acpi-platform
which is not going to be rebased going forward.
Thanks!
Hi,
Quoted 18 lines · Rafael J. Wysocki
Quoted 9 lines · Rafael J. Wysocki
Quoted 7 lines · Hans de Goede
From: Jiaxun Yang <[email protected]>
Add an object pointer to handler callbacks to avoid the need for drivers to have a global variable to get to their driver-data struct.
Quoted 7 lines
Quoted 5 lines
Signed-off-by Jiaxun Yang <[email protected]>Suggested-by Hans de Goede <[email protected]>Signed-off-by Hans de Goede <[email protected]>Applied on top of the previous platform-profile patches, thanks!
Quoted 7 lines
And the entire acpi-platform-profile material is now available for you to pull in the git branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git\
acpi-platformwhich is not going to be rebased going forward.
Thank you. I've merged this into pdx86/for-next now.
Regards,
Hans