lkml.org 
[lkml]   [2021]   [Mar]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 03/10] platform/x86: toshiba_acpi: bind registration of miscdev object to parent
On Wed, 24 Mar 2021 14:55:41 +0200
Alexandru Ardelean <aardelean@deviqon.com> wrote:

> This change moves the registration of the Toshiba ACPI miscdev to be
> handled by the devm_add_action_or_reset() hook. This way, the miscdev will
> be unregistered when the reference count of the parent device object goes
> to zero.
>
> This also changes the order of cleanup in toshiba_acpi_remove(), where the
> miscdev was deregistered first. Now it will be deregistered right before
> the toshiba_acpi_dev object is free'd.
>
> Signed-off-by: Alexandru Ardelean <aardelean@deviqon.com>
Reorder looks right to me, but maybe I'm missing something subtle.

Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

One unrelated comment inline.

Jonathan

> ---
> drivers/platform/x86/toshiba_acpi.c | 14 ++++++++++++--
> 1 file changed, 12 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/platform/x86/toshiba_acpi.c b/drivers/platform/x86/toshiba_acpi.c
> index c5284601bc2a..53ef565378ef 100644
> --- a/drivers/platform/x86/toshiba_acpi.c
> +++ b/drivers/platform/x86/toshiba_acpi.c
> @@ -2963,8 +2963,6 @@ static int toshiba_acpi_remove(struct acpi_device *acpi_dev)
> {
> struct toshiba_acpi_dev *dev = acpi_driver_data(acpi_dev);
>
> - misc_deregister(&dev->miscdev);
> -
> remove_toshiba_proc_entries(dev);
>
> if (dev->accelerometer_supported && dev->indio_dev) {
> @@ -3014,6 +3012,13 @@ static void toshiba_acpi_singleton_clear(void *data)
> toshiba_acpi = NULL;
> }
>
> +static void toshiba_acpi_misc_deregister(void *data)
> +{
> + struct miscdevice *miscdev = data;
> +
> + misc_deregister(miscdev);
> +}
> +
> static int toshiba_acpi_add(struct acpi_device *acpi_dev)
> {
> struct device *parent = &acpi_dev->dev;
> @@ -3056,6 +3061,11 @@ static int toshiba_acpi_add(struct acpi_device *acpi_dev)
> return ret;
> }
>
> + ret = devm_add_action_or_reset(parent, toshiba_acpi_misc_deregister,
> + &dev->miscdev);
> + if (ret)
> + return ret;
> +
> acpi_dev->driver_data = dev;
> dev_set_drvdata(&acpi_dev->dev, dev);

Why are we carrying two copies of the same thing? (obviously unrelated
to your patch :)

>

\
 
 \ /
  Last update: 2021-03-29 16:35    [W:0.188 / U:0.120 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site