Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3638090pxf; Mon, 29 Mar 2021 07:36:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyjaiXh157PxagoiM4FXVPdZevf7iThfNBw8PhZaAlo7fKL3PMY1/pKLQO3d90srC37+U9e X-Received: by 2002:a17:906:ecb8:: with SMTP id qh24mr29689713ejb.162.1617028567259; Mon, 29 Mar 2021 07:36:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617028567; cv=none; d=google.com; s=arc-20160816; b=FwSN7IAhwllq88ZRQRvQPl7ZEeEgbIS506XfR3OhW9OpvQoJjJMA2l+CsHkCA3Vr6r 2OXV06JzUQCcnkiInw1yOsb9xf+rLApgv2k6wxoiMHKos38IoTOtQp2glRw/ip5syyiX cg0hFiV6ZrERIT2JGP/DPQNT+8LaB3b0C6fhl0l+CFNg1w0dTPnPyb82NH/E6FZCRWDh jpFTt5nzz1W9A9eqme4DaPzJNVIpzwqO8w62qG4x04pajkktFEuiiVuUuwnjLzA9GoUv 32+54vVhheFT2dx/DUZvVyA05EWR5iSdIIALI4QNkiHzEeZKHzP1aASOMTZOpqs+G0Js S+BQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=8gg83jiJ8sqNu4rL3Blrdq+GEXQdAkEoEjgFrW+pmdk=; b=nMAwQ7cehWoYDZPkW2L1wvZsfDu92+E3l+wfzds9qP5PFoMiBwsyQWMjWKICzkUzU+ 1/RT3wMR0n2m/Sf+6cXIJK3hudbDMCLfR2HD00EA3NCpuogwPm6K+4hruO8AbBIsMu1W sVj5svvfiSm2TkZ8ufVY8PAndz1VcvTIIYKcraW/1vaILaqRYXCE/ZGPGDRVm91A0yu7 gxzhxDfydaXkpmSCMXZsH+N+f6H+vNglldwhmscWrDkgxs/Av8qHvG1LAXPMeFWQU6fN Qv41BdKhiuaO6Edr0mqNchEBy+u561lr5awLc/Evwoxl8x1/v2c6pparwRp5GDpIDZRO BPUQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u18si13331815ejk.68.2021.03.29.07.35.44; Mon, 29 Mar 2021 07:36:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230503AbhC2OeX (ORCPT + 99 others); Mon, 29 Mar 2021 10:34:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:39594 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230467AbhC2Odv (ORCPT ); Mon, 29 Mar 2021 10:33:51 -0400 Received: from jic23-huawei (cpc108967-cmbg20-2-0-cust86.5-4.cable.virginm.net [81.101.6.87]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 98A7961922; Mon, 29 Mar 2021 14:33:48 +0000 (UTC) Date: Mon, 29 Mar 2021 15:33:56 +0100 From: Jonathan Cameron To: Alexandru Ardelean Cc: platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, coproscefalo@gmail.com, hdegoede@redhat.com, mgross@linux.intel.com, linux@deviqon.com Subject: Re: [PATCH 03/10] platform/x86: toshiba_acpi: bind registration of miscdev object to parent Message-ID: <20210329153356.1e817912@jic23-huawei> In-Reply-To: <20210324125548.45983-4-aardelean@deviqon.com> References: <20210324125548.45983-1-aardelean@deviqon.com> <20210324125548.45983-4-aardelean@deviqon.com> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 24 Mar 2021 14:55:41 +0200 Alexandru Ardelean 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 Reorder looks right to me, but maybe I'm missing something subtle. Acked-by: Jonathan Cameron 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 :) >