All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/2] ACPI: platform-profile: Introduce object pointers to callbacks
@ 2021-01-25 11:59 Hans de Goede
  2021-01-25 11:59 ` [PATCH v2 1/2] ACPI: platform-profile: Drop const qualifier for cur_profile Hans de Goede
  2021-01-25 11:59 ` [PATCH v2 2/2] ACPI: platform-profile: Introduce object pointers to callbacks Hans de Goede
  0 siblings, 2 replies; 7+ messages in thread
From: Hans de Goede @ 2021-01-25 11:59 UTC (permalink / raw)
  To: Rafael J . Wysocki, Jiaxun Yang
  Cc: Hans de Goede, Mark Pearson, Bastien Nocera, linux-acpi,
	platform-driver-x86

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

-- 
2.29.2


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

* [PATCH v2 1/2] ACPI: platform-profile: Drop const qualifier for cur_profile
  2021-01-25 11:59 [PATCH v2 0/2] ACPI: platform-profile: Introduce object pointers to callbacks Hans de Goede
@ 2021-01-25 11:59 ` Hans de Goede
  2021-01-25 16:32   ` Rafael J. Wysocki
  2021-01-25 11:59 ` [PATCH v2 2/2] ACPI: platform-profile: Introduce object pointers to callbacks Hans de Goede
  1 sibling, 1 reply; 7+ messages in thread
From: Hans de Goede @ 2021-01-25 11:59 UTC (permalink / raw)
  To: Rafael J . Wysocki, Jiaxun Yang
  Cc: Hans de Goede, Mark Pearson, Bastien Nocera, linux-acpi,
	platform-driver-x86

From: Jiaxun Yang <jiaxun.yang@flygoat.com>

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.

Link: https://lore.kernel.org/linux-acpi/5e7a4d87-52ef-e487-9cc2-8e7094beaa08@redhat.com/
Link: https://lore.kernel.org/r/20210114073429.176462-2-jiaxun.yang@flygoat.com
Suggested-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
[hdegoede@redhat.com: Also remove const from platform_profile_register()]
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
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(-)

diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c
index 91be50a32cc8..f65c61db7921 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[] = {
@@ -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;
 
diff --git a/include/linux/platform_profile.h b/include/linux/platform_profile.h
index 3623d7108421..c797fdb3d91a 100644
--- a/include/linux/platform_profile.h
+++ b/include/linux/platform_profile.h
@@ -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


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

* [PATCH v2 2/2] ACPI: platform-profile: Introduce object pointers to callbacks
  2021-01-25 11:59 [PATCH v2 0/2] ACPI: platform-profile: Introduce object pointers to callbacks Hans de Goede
  2021-01-25 11:59 ` [PATCH v2 1/2] ACPI: platform-profile: Drop const qualifier for cur_profile Hans de Goede
@ 2021-01-25 11:59 ` Hans de Goede
  2021-01-27 17:47   ` Rafael J. Wysocki
  1 sibling, 1 reply; 7+ messages in thread
From: Hans de Goede @ 2021-01-25 11:59 UTC (permalink / raw)
  To: Rafael J . Wysocki, Jiaxun Yang
  Cc: Hans de Goede, Mark Pearson, Bastien Nocera, linux-acpi,
	platform-driver-x86

From: Jiaxun Yang <jiaxun.yang@flygoat.com>

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.

Link: https://lore.kernel.org/linux-acpi/6a29f338-d9e4-150c-81dd-2ffb54f5bc35@redhat.com/
Link: https://lore.kernel.org/r/20210114073429.176462-3-jiaxun.yang@flygoat.com
Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
Suggested-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
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(-)

diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c
index f65c61db7921..80e9df427eb8 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 c797fdb3d91a..a26542d53058 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(struct platform_profile_handler *pprof);
-- 
2.29.2


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

* Re: [PATCH v2 1/2] ACPI: platform-profile: Drop const qualifier for cur_profile
  2021-01-25 11:59 ` [PATCH v2 1/2] ACPI: platform-profile: Drop const qualifier for cur_profile Hans de Goede
@ 2021-01-25 16:32   ` Rafael J. Wysocki
  0 siblings, 0 replies; 7+ messages in thread
From: Rafael J. Wysocki @ 2021-01-25 16:32 UTC (permalink / raw)
  To: Hans de Goede
  Cc: Rafael J . Wysocki, Jiaxun Yang, Mark Pearson, Bastien Nocera,
	ACPI Devel Maling List, Platform Driver

On Mon, Jan 25, 2021 at 1:13 PM Hans de Goede <hdegoede@redhat.com> wrote:
>
> From: Jiaxun Yang <jiaxun.yang@flygoat.com>
>
> 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.
>
> Link: https://lore.kernel.org/linux-acpi/5e7a4d87-52ef-e487-9cc2-8e7094beaa08@redhat.com/
> Link: https://lore.kernel.org/r/20210114073429.176462-2-jiaxun.yang@flygoat.com
> Suggested-by: Hans de Goede <hdegoede@redhat.com>
> Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
> [hdegoede@redhat.com: Also remove const from platform_profile_register()]
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> ---
> 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

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.

> ---
>  drivers/acpi/platform_profile.c  | 4 ++--
>  include/linux/platform_profile.h | 2 +-
>  2 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c
> index 91be50a32cc8..f65c61db7921 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[] = {
> @@ -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;
>
> diff --git a/include/linux/platform_profile.h b/include/linux/platform_profile.h
> index 3623d7108421..c797fdb3d91a 100644
> --- a/include/linux/platform_profile.h
> +++ b/include/linux/platform_profile.h
> @@ -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
>

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

* Re: [PATCH v2 2/2] ACPI: platform-profile: Introduce object pointers to callbacks
  2021-01-25 11:59 ` [PATCH v2 2/2] ACPI: platform-profile: Introduce object pointers to callbacks Hans de Goede
@ 2021-01-27 17:47   ` Rafael J. Wysocki
  2021-02-01 13:55     ` Rafael J. Wysocki
  0 siblings, 1 reply; 7+ messages in thread
From: Rafael J. Wysocki @ 2021-01-27 17:47 UTC (permalink / raw)
  To: Hans de Goede
  Cc: Rafael J . Wysocki, Jiaxun Yang, Mark Pearson, Bastien Nocera,
	ACPI Devel Maling List, Platform Driver

On Tue, Jan 26, 2021 at 6:58 AM Hans de Goede <hdegoede@redhat.com> wrote:
>
> From: Jiaxun Yang <jiaxun.yang@flygoat.com>
>
> 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.
>
> Link: https://lore.kernel.org/linux-acpi/6a29f338-d9e4-150c-81dd-2ffb54f5bc35@redhat.com/
> Link: https://lore.kernel.org/r/20210114073429.176462-3-jiaxun.yang@flygoat.com
> Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
> Suggested-by: Hans de Goede <hdegoede@redhat.com>
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>

Applied on top of the previous platform-profile patches, thanks!

> ---
> 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(-)
>
> diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c
> index f65c61db7921..80e9df427eb8 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 c797fdb3d91a..a26542d53058 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(struct platform_profile_handler *pprof);
> --
> 2.29.2
>

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

* Re: [PATCH v2 2/2] ACPI: platform-profile: Introduce object pointers to callbacks
  2021-01-27 17:47   ` Rafael J. Wysocki
@ 2021-02-01 13:55     ` Rafael J. Wysocki
  2021-02-02 14:39       ` Hans de Goede
  0 siblings, 1 reply; 7+ messages in thread
From: Rafael J. Wysocki @ 2021-02-01 13:55 UTC (permalink / raw)
  To: Hans de Goede
  Cc: Rafael J . Wysocki, Jiaxun Yang, Mark Pearson, Bastien Nocera,
	ACPI Devel Maling List, Platform Driver

On Wed, Jan 27, 2021 at 6:47 PM Rafael J. Wysocki <rafael@kernel.org> wrote:
>
> On Tue, Jan 26, 2021 at 6:58 AM Hans de Goede <hdegoede@redhat.com> wrote:
> >
> > From: Jiaxun Yang <jiaxun.yang@flygoat.com>
> >
> > 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.
> >
> > Link: https://lore.kernel.org/linux-acpi/6a29f338-d9e4-150c-81dd-2ffb54f5bc35@redhat.com/
> > Link: https://lore.kernel.org/r/20210114073429.176462-3-jiaxun.yang@flygoat.com
> > Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
> > Suggested-by: Hans de Goede <hdegoede@redhat.com>
> > Signed-off-by: Hans de Goede <hdegoede@redhat.com>
>
> 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!

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

* Re: [PATCH v2 2/2] ACPI: platform-profile: Introduce object pointers to callbacks
  2021-02-01 13:55     ` Rafael J. Wysocki
@ 2021-02-02 14:39       ` Hans de Goede
  0 siblings, 0 replies; 7+ messages in thread
From: Hans de Goede @ 2021-02-02 14:39 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Rafael J . Wysocki, Jiaxun Yang, Mark Pearson, Bastien Nocera,
	ACPI Devel Maling List, Platform Driver

Hi,

On 2/1/21 2:55 PM, Rafael J. Wysocki wrote:
> On Wed, Jan 27, 2021 at 6:47 PM Rafael J. Wysocki <rafael@kernel.org> wrote:
>>
>> On Tue, Jan 26, 2021 at 6:58 AM Hans de Goede <hdegoede@redhat.com> wrote:
>>>
>>> From: Jiaxun Yang <jiaxun.yang@flygoat.com>
>>>
>>> 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.
>>>
>>> Link: https://lore.kernel.org/linux-acpi/6a29f338-d9e4-150c-81dd-2ffb54f5bc35@redhat.com/
>>> Link: https://lore.kernel.org/r/20210114073429.176462-3-jiaxun.yang@flygoat.com
>>> Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
>>> Suggested-by: Hans de Goede <hdegoede@redhat.com>
>>> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
>>
>> 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.

Thank you. I've merged this into pdx86/for-next now.

Regards,

Hans


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

end of thread, other threads:[~2021-02-02 14:43 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-25 11:59 [PATCH v2 0/2] ACPI: platform-profile: Introduce object pointers to callbacks Hans de Goede
2021-01-25 11:59 ` [PATCH v2 1/2] ACPI: platform-profile: Drop const qualifier for cur_profile Hans de Goede
2021-01-25 16:32   ` Rafael J. Wysocki
2021-01-25 11:59 ` [PATCH v2 2/2] ACPI: platform-profile: Introduce object pointers to callbacks Hans de Goede
2021-01-27 17:47   ` Rafael J. Wysocki
2021-02-01 13:55     ` Rafael J. Wysocki
2021-02-02 14:39       ` Hans de Goede

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.