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: <20210329161051.3bc500cf@jic23-huawei>
Date:   Mon, 29 Mar 2021 16:10:51 +0100
From:   Jonathan Cameron <jic23@...nel.org>
To:     Alexandru Ardelean <aardelean@...iqon.com>
Cc:     platform-driver-x86@...r.kernel.org, linux-kernel@...r.kernel.org,
        linux-iio@...r.kernel.org, coproscefalo@...il.com,
        hdegoede@...hat.com, mgross@...ux.intel.com, linux@...iqon.com
Subject: Re: [PATCH 10/10] platform/x86: toshiba_acpi: bind proc entries
 creation to parent

On Wed, 24 Mar 2021 14:55:48 +0200
Alexandru Ardelean <aardelean@...iqon.com> wrote:

> This change binds the creation of the proc entries to the parent object,
> via the devm_add_action_or_reset() call.
> This way when the parent object's refcount goes to zero, the proc entries
> are removed in the reverse other in which they were created.
> 
> This is the last bit of the toshiba_acpi_remove() function, so in this
> change this function is removed.
> 
> Signed-off-by: Alexandru Ardelean <aardelean@...iqon.com>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@...wei.com>

I'm not 100% sure the series is worth the effort, but it does clean up
some of the ordering which definitely looks like a plus point.

Jonathan

> ---
>  drivers/platform/x86/toshiba_acpi.c | 45 ++++++++++++++---------------
>  1 file changed, 21 insertions(+), 24 deletions(-)
> 
> diff --git a/drivers/platform/x86/toshiba_acpi.c b/drivers/platform/x86/toshiba_acpi.c
> index 8e8917979047..56ee5cd1e90c 100644
> --- a/drivers/platform/x86/toshiba_acpi.c
> +++ b/drivers/platform/x86/toshiba_acpi.c
> @@ -1671,7 +1671,23 @@ static int __maybe_unused version_proc_show(struct seq_file *m, void *v)
>  
>  #define PROC_TOSHIBA		"toshiba"
>  
> -static void create_toshiba_proc_entries(struct toshiba_acpi_dev *dev)
> +static void remove_toshiba_proc_entries(void *data)
> +{
> +	struct toshiba_acpi_dev *dev = data;
> +
> +	if (dev->backlight_dev)
> +		remove_proc_entry("lcd", toshiba_proc_dir);
> +	if (dev->video_supported)
> +		remove_proc_entry("video", toshiba_proc_dir);
> +	if (dev->fan_supported)
> +		remove_proc_entry("fan", toshiba_proc_dir);
> +	if (dev->hotkey_dev)
> +		remove_proc_entry("keys", toshiba_proc_dir);
> +	remove_proc_entry("version", toshiba_proc_dir);
> +}
> +
> +static int create_toshiba_proc_entries(struct device *parent,
> +				       struct toshiba_acpi_dev *dev)
>  {
>  	if (dev->backlight_dev)
>  		proc_create_data("lcd", S_IRUGO | S_IWUSR, toshiba_proc_dir,
> @@ -1687,19 +1703,8 @@ static void create_toshiba_proc_entries(struct toshiba_acpi_dev *dev)
>  				 &keys_proc_ops, dev);
>  	proc_create_single_data("version", S_IRUGO, toshiba_proc_dir,
>  			version_proc_show, dev);
> -}
>  
> -static void remove_toshiba_proc_entries(struct toshiba_acpi_dev *dev)
> -{
> -	if (dev->backlight_dev)
> -		remove_proc_entry("lcd", toshiba_proc_dir);
> -	if (dev->video_supported)
> -		remove_proc_entry("video", toshiba_proc_dir);
> -	if (dev->fan_supported)
> -		remove_proc_entry("fan", toshiba_proc_dir);
> -	if (dev->hotkey_dev)
> -		remove_proc_entry("keys", toshiba_proc_dir);
> -	remove_proc_entry("version", toshiba_proc_dir);
> +	return devm_add_action_or_reset(parent, remove_toshiba_proc_entries, dev);
>  }
>  
>  static const struct backlight_ops toshiba_backlight_data = {
> @@ -3012,15 +3017,6 @@ static void print_supported_features(struct toshiba_acpi_dev *dev)
>  	pr_cont("\n");
>  }
>  
> -static int toshiba_acpi_remove(struct acpi_device *acpi_dev)
> -{
> -	struct toshiba_acpi_dev *dev = acpi_driver_data(acpi_dev);
> -
> -	remove_toshiba_proc_entries(dev);
> -
> -	return 0;
> -}
> -
>  static const char *find_hci_method(acpi_handle handle)
>  {
>  	if (acpi_has_method(handle, "GHCI"))
> @@ -3230,7 +3226,9 @@ static int toshiba_acpi_add(struct acpi_device *acpi_dev)
>  	if (ret)
>  		return ret;
>  
> -	create_toshiba_proc_entries(dev);
> +	ret = create_toshiba_proc_entries(parent, dev);
> +	if (ret)
> +		return ret;
>  
>  	toshiba_acpi = dev;
>  
> @@ -3340,7 +3338,6 @@ static struct acpi_driver toshiba_acpi_driver = {
>  	.flags	= ACPI_DRIVER_ALL_NOTIFY_EVENTS,
>  	.ops	= {
>  		.add		= toshiba_acpi_add,
> -		.remove		= toshiba_acpi_remove,
>  		.notify		= toshiba_acpi_notify,
>  	},
>  	.drv.pm	= &toshiba_acpi_pm,

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ