linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RESEND 0/2] ACPI: platform-profile enhancements
@ 2021-01-14  7:34 Jiaxun Yang
  2021-01-14  7:34 ` [PATCH RESEND 1/2] ACPI: platform-profile: Drop const qualifier for cur_profile Jiaxun Yang
  2021-01-14  7:34 ` [PATCH RESEND 2/2] ACPI: platform-profile: Introduce object pointers to callbacks Jiaxun Yang
  0 siblings, 2 replies; 5+ messages in thread
From: Jiaxun Yang @ 2021-01-14  7:34 UTC (permalink / raw)
  To: linux-acpi; +Cc: linux-pm, rjw, hdegoede, Jiaxun Yang

Resend as previous mail has a typo at to address.
Replacing b417d9c7404df67b9be0104585fefb2ca8d36677 at pm/bleeding-edge.

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  | 6 +++---
 include/linux/platform_profile.h | 6 ++++--
 2 files changed, 7 insertions(+), 5 deletions(-)

-- 
2.30.0


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

* [PATCH RESEND 1/2] ACPI: platform-profile: Drop const qualifier for cur_profile
  2021-01-14  7:34 [PATCH RESEND 0/2] ACPI: platform-profile enhancements Jiaxun Yang
@ 2021-01-14  7:34 ` Jiaxun Yang
  2021-01-14 12:16   ` Rafael J. Wysocki
  2021-01-14  7:34 ` [PATCH RESEND 2/2] ACPI: platform-profile: Introduce object pointers to callbacks Jiaxun Yang
  1 sibling, 1 reply; 5+ messages in thread
From: Jiaxun Yang @ 2021-01-14  7:34 UTC (permalink / raw)
  To: linux-acpi; +Cc: linux-pm, rjw, hdegoede, Jiaxun Yang

All planned uses of cur_profile have their platform_profile_handler
defined as const, so just drop const qualifier here to prevent build
error.

Link: https://lore.kernel.org/linux-acpi/5e7a4d87-52ef-e487-9cc2-8e7094beaa08@redhat.com/
Suggested-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
---
 drivers/acpi/platform_profile.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c
index 91be50a32cc8..9dddf44b43d4 100644
--- a/drivers/acpi/platform_profile.c
+++ b/drivers/acpi/platform_profile.c
@@ -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[] = {
-- 
2.30.0


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

* [PATCH RESEND 2/2] ACPI: platform-profile: Introduce object pointers to callbacks
  2021-01-14  7:34 [PATCH RESEND 0/2] ACPI: platform-profile enhancements Jiaxun Yang
  2021-01-14  7:34 ` [PATCH RESEND 1/2] ACPI: platform-profile: Drop const qualifier for cur_profile Jiaxun Yang
@ 2021-01-14  7:34 ` Jiaxun Yang
  1 sibling, 0 replies; 5+ messages in thread
From: Jiaxun Yang @ 2021-01-14  7:34 UTC (permalink / raw)
  To: linux-acpi; +Cc: linux-pm, rjw, hdegoede, Jiaxun Yang

Add a object pointer to handler callbacks to avoid having
global variables everywhere.

Link: https://lore.kernel.org/linux-acpi/6a29f338-d9e4-150c-81dd-2ffb54f5bc35@redhat.com/
Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
Suggested-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/acpi/platform_profile.c  | 4 ++--
 include/linux/platform_profile.h | 6 ++++--
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c
index 9dddf44b43d4..6398b40e6d31 100644
--- a/drivers/acpi/platform_profile.c
+++ b/drivers/acpi/platform_profile.c
@@ -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;
diff --git a/include/linux/platform_profile.h b/include/linux/platform_profile.h
index 3623d7108421..43f4583b5259 100644
--- a/include/linux/platform_profile.h
+++ b/include/linux/platform_profile.h
@@ -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(const struct platform_profile_handler *pprof);
-- 
2.30.0


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

* Re: [PATCH RESEND 1/2] ACPI: platform-profile: Drop const qualifier for cur_profile
  2021-01-14  7:34 ` [PATCH RESEND 1/2] ACPI: platform-profile: Drop const qualifier for cur_profile Jiaxun Yang
@ 2021-01-14 12:16   ` Rafael J. Wysocki
  2021-01-14 13:54     ` Hans de Goede
  0 siblings, 1 reply; 5+ messages in thread
From: Rafael J. Wysocki @ 2021-01-14 12:16 UTC (permalink / raw)
  To: Jiaxun Yang
  Cc: ACPI Devel Maling List, Linux PM, Rafael J. Wysocki, Hans de Goede

On Thu, Jan 14, 2021 at 8:42 AM Jiaxun Yang <jiaxun.yang@flygoat.com> wrote:
>
> All planned uses of cur_profile have their platform_profile_handler
> defined as const, so just drop const qualifier here to prevent build
> error.
>
> Link: https://lore.kernel.org/linux-acpi/5e7a4d87-52ef-e487-9cc2-8e7094beaa08@redhat.com/
> Suggested-by: Hans de Goede <hdegoede@redhat.com>
> Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
> ---
>  drivers/acpi/platform_profile.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c
> index 91be50a32cc8..9dddf44b43d4 100644
> --- a/drivers/acpi/platform_profile.c
> +++ b/drivers/acpi/platform_profile.c
> @@ -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;

I think that it's not just here, but also in the
platform_profile_register() argument.

>  static DEFINE_MUTEX(profile_lock);
>
>  static const char * const profile_names[] = {
> --
> 2.30.0
>

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

* Re: [PATCH RESEND 1/2] ACPI: platform-profile: Drop const qualifier for cur_profile
  2021-01-14 12:16   ` Rafael J. Wysocki
@ 2021-01-14 13:54     ` Hans de Goede
  0 siblings, 0 replies; 5+ messages in thread
From: Hans de Goede @ 2021-01-14 13:54 UTC (permalink / raw)
  To: Rafael J. Wysocki, Jiaxun Yang
  Cc: ACPI Devel Maling List, Linux PM, Rafael J. Wysocki

Hi,

On 1/14/21 1:16 PM, Rafael J. Wysocki wrote:
> On Thu, Jan 14, 2021 at 8:42 AM Jiaxun Yang <jiaxun.yang@flygoat.com> wrote:
>>
>> All planned uses of cur_profile have their platform_profile_handler
>> defined as const, so just drop const qualifier here to prevent build
>> error.
>>
>> Link: https://lore.kernel.org/linux-acpi/5e7a4d87-52ef-e487-9cc2-8e7094beaa08@redhat.com/
>> Suggested-by: Hans de Goede <hdegoede@redhat.com>
>> Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
>> ---
>>  drivers/acpi/platform_profile.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c
>> index 91be50a32cc8..9dddf44b43d4 100644
>> --- a/drivers/acpi/platform_profile.c
>> +++ b/drivers/acpi/platform_profile.c
>> @@ -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;
> 
> I think that it's not just here, but also in the
> platform_profile_register() argument.

Correct, this needs to be fixed in platform_profile_register() too,
both in drivers/acpi/platform_profile.c and in
include/linux/platform_profile.h

Otherwise we will get a compiler warning (or maybe even an error)
about assigning a pointer pointing to const memory to a pointer not
pointing to const mem.

Regards,

Hans




> 
>>  static DEFINE_MUTEX(profile_lock);
>>
>>  static const char * const profile_names[] = {
>> --
>> 2.30.0
>>
> 


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

end of thread, other threads:[~2021-01-14 13:56 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-14  7:34 [PATCH RESEND 0/2] ACPI: platform-profile enhancements Jiaxun Yang
2021-01-14  7:34 ` [PATCH RESEND 1/2] ACPI: platform-profile: Drop const qualifier for cur_profile Jiaxun Yang
2021-01-14 12:16   ` Rafael J. Wysocki
2021-01-14 13:54     ` Hans de Goede
2021-01-14  7:34 ` [PATCH RESEND 2/2] ACPI: platform-profile: Introduce object pointers to callbacks Jiaxun Yang

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