[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAJZ5v0jRkDx1E+mW0dhD2f9Ow8GxeT-8AvYjcZOvoYC2+J07jg@mail.gmail.com>
Date: Tue, 14 Jan 2025 14:34:15 +0100
From: "Rafael J. Wysocki" <rafael@...nel.org>
To: Kurt Borja <kuurtb@...il.com>
Cc: platform-driver-x86@...r.kernel.org, W_Armin@....de, hdegoede@...hat.com,
ilpo.jarvinen@...ux.intel.com, lenb@...nel.org, linux-acpi@...r.kernel.org,
linux-kernel@...r.kernel.org, mario.limonciello@....com,
mpearson-lenovo@...ebb.ca, rafael@...nel.org, soyer@....hu
Subject: Re: [PATCH v2 1/2] ACPI: platform_profile: Add devm_platform_profile_register()
On Tue, Dec 24, 2024 at 3:02 PM Kurt Borja <kuurtb@...il.com> wrote:
>
> Platform profile's lifetime is usually tied to a device's lifetime,
> therefore add a device managed version of platform_profile_register().
>
> Signed-off-by: Kurt Borja <kuurtb@...il.com>
This is fine by me, so
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@...el.com>
and I think that it would be better to route it via platform/x86 along
with the second patch.
> ---
> drivers/acpi/platform_profile.c | 29 +++++++++++++++++++++++++++++
> include/linux/platform_profile.h | 1 +
> 2 files changed, 30 insertions(+)
>
> diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c
> index 75a1415190ac..4c4200a0b1a6 100644
> --- a/drivers/acpi/platform_profile.c
> +++ b/drivers/acpi/platform_profile.c
> @@ -519,6 +519,35 @@ int platform_profile_remove(struct platform_profile_handler *pprof)
> }
> EXPORT_SYMBOL_GPL(platform_profile_remove);
>
> +static void devm_platform_profile_release(struct device *dev, void *res)
> +{
> + struct platform_profile_handler **pprof = res;
> +
> + platform_profile_remove(*pprof);
> +}
> +
> +int devm_platform_profile_register(struct platform_profile_handler *pprof)
> +{
> + struct platform_profile_handler **dr;
> + int ret;
> +
> + dr = devres_alloc(devm_platform_profile_release, sizeof(*dr), GFP_KERNEL);
> + if (!dr)
> + return -ENOMEM;
> +
> + ret = platform_profile_register(pprof);
> + if (ret) {
> + devres_free(dr);
> + return ret;
> + }
> +
> + *dr = pprof;
> + devres_add(pprof->dev, dr);
> +
> + return 0;
> +}
> +EXPORT_SYMBOL_GPL(devm_platform_profile_register);
> +
> static int __init platform_profile_init(void)
> {
> int err;
> diff --git a/include/linux/platform_profile.h b/include/linux/platform_profile.h
> index 0682bb4c57e5..f1cd4b65e351 100644
> --- a/include/linux/platform_profile.h
> +++ b/include/linux/platform_profile.h
> @@ -41,6 +41,7 @@ struct platform_profile_handler {
>
> 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);
> void platform_profile_notify(struct platform_profile_handler *pprof);
>
> --
> 2.47.1
>
Powered by blists - more mailing lists