lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <5f173547-f643-4ac1-919b-cd864b2969fe@gmx.de>
Date: Sun, 22 Dec 2024 23:09:44 +0100
From: Armin Wolf <W_Armin@....de>
To: Kurt Borja <kuurtb@...il.com>, platform-driver-x86@...r.kernel.org
Cc: "Rafael J. Wysocki" <rafael@...nel.org>, Len Brown <lenb@...nel.org>,
 Ilpo Järvinen <ilpo.jarvinen@...ux.intel.com>,
 Mark Pearson <mpearson-lenovo@...ebb.ca>,
 Mario Limonciello <mario.limonciello@....com>,
 Hans de Goede <hdegoede@...hat.com>, Gergo Koteles <soyer@....hu>,
 linux-acpi@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/2] ACPI: platform_profile: Add
 devm_platform_profile_register()

Am 21.12.24 um 08:08 schrieb Kurt Borja:

> 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>
> ---
>   drivers/acpi/platform_profile.c  | 27 +++++++++++++++++++++++++++
>   include/linux/platform_profile.h |  2 +-
>   2 files changed, 28 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c
> index 75a1415190ac..d0c88decef8b 100644
> --- a/drivers/acpi/platform_profile.c
> +++ b/drivers/acpi/platform_profile.c
> @@ -519,6 +519,33 @@ 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)
> +{
> +	platform_profile_remove(*(struct platform_profile_handler **) res);

Please introduce a local variable instead of using a convoluted cast like this.

> +}
> +
> +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;

Maybe it would make sense to turn dr into a normal pointer? AFAIK there is no benefit in
having another pointer if we can just use the original pointer.

Thanks,
Armin Wolf

> +
> +	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..d8114435865b 100644
> --- a/include/linux/platform_profile.h
> +++ b/include/linux/platform_profile.h
> @@ -41,7 +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);
> -
>   #endif  /*_PLATFORM_PROFILE_H_*/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ