Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3664296pxf; Mon, 29 Mar 2021 08:13:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzhVas50Ox33GqHi31In9bTeS9mB0XbBr0rbKa6+RS1yv9ylqaWsK7F0dkZT7ru4997bpDL X-Received: by 2002:a17:906:b2cd:: with SMTP id cf13mr29080796ejb.181.1617030799021; Mon, 29 Mar 2021 08:13:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617030799; cv=none; d=google.com; s=arc-20160816; b=LjFMhirXkz0Hzq6NoPogiQO76el2GAoMnm1RrmtnM5HVVqy9cTa7pMgp1Z/3/1PdL6 ux/COzax0cc4G2jgYgTioOtL/2rv1VnwCWP2XvqGr+A8Lmnh/5YYM8I+ZdCefKGXEuv8 r3K6k+Nm6a8HwehpbNnxhhQBOGDQSeUY3XaCBy114VpZvjbbgXVUCjb5Lpx52YA1MBFd kYp1SzyHI5bOIH1g7HON9Z9F5EDxJNfnzIJTNn2uspq5qOOlceTvwajEXBgqh5BDCHrH QVJF1SaVT/3nmHeDtqfh7SZqfhLYbW9NLIeJuc0Xl0cpPR+lK6jpNCoqrvtG96OwYvnQ 4ejQ== 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=rQ1rgH4JefjvvbbrjC1V5Lf8ktPLT3KC5VVrcPOd5rw=; b=Tf5a80X33EowDT4RKNAkEbq9OXo8Y5cjc3HyxQvLmpnx2emUZNlFU7qxa8SN0rSdSf OeVMSsoDI+9+MpYQjiaNxsli8nI9LZAqT9PHVAP8pMw4ggk99Mi1uiz98vtR/TFBVae3 bOiqim4CV7idGf2vn2O6vh9/Fhoi1AV5SblIBnrLCmyINZ+9KJ4LaNg3EmmwSGnnREbB KIS+L/g1yWmwAzrnrsd3o5J509RkLXVtNi6sxuhhVHrMA92lXq2PfOxmBzX2c7t8MXae 7JLGOHqnWMe/+XNrk9ende11EAPlK96hiWoma8DK7qpH+Sgk5vtQdWAjyBRWgerAffP0 iHXw== 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 hd19si13373851ejc.62.2021.03.29.08.12.55; Mon, 29 Mar 2021 08:13:19 -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 S230226AbhC2PJg (ORCPT + 99 others); Mon, 29 Mar 2021 11:09:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:51506 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230202AbhC2PJZ (ORCPT ); Mon, 29 Mar 2021 11:09:25 -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 C4E956187E; Mon, 29 Mar 2021 15:09:21 +0000 (UTC) Date: Mon, 29 Mar 2021 16:09:28 +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 09/10] platform/x86: toshiba_acpi: use device-managed for sysfs removal Message-ID: <20210329160928.0f8d6b44@jic23-huawei> In-Reply-To: <20210324125548.45983-10-aardelean@deviqon.com> References: <20210324125548.45983-1-aardelean@deviqon.com> <20210324125548.45983-10-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:47 +0200 Alexandru Ardelean wrote: > This change moves the creation of the Toshiba ACPI group to be > automatically removed when the parent refcount goes to zero. > > The main reason to do this, is to also enforce that the order of removal is > mirroring the order of initialization. > > Signed-off-by: Alexandru Ardelean Hmm. The manual handling of the sysfs_create_group() is unfortunate (as opposed to just setting a groups pointer) but there doesn't seem to be an easy way to fix that with the current architecture. Ah well Reviewed-by: Jonathan Cameron > --- > drivers/platform/x86/toshiba_acpi.c | 29 +++++++++++++++-------------- > 1 file changed, 15 insertions(+), 14 deletions(-) > > diff --git a/drivers/platform/x86/toshiba_acpi.c b/drivers/platform/x86/toshiba_acpi.c > index a1249f6dde9a..8e8917979047 100644 > --- a/drivers/platform/x86/toshiba_acpi.c > +++ b/drivers/platform/x86/toshiba_acpi.c > @@ -200,7 +200,6 @@ struct toshiba_acpi_dev { > unsigned int usb_three_supported:1; > unsigned int wwan_supported:1; > unsigned int cooling_method_supported:1; > - unsigned int sysfs_created:1; > unsigned int special_functions; > > bool kbd_event_generated; > @@ -3019,10 +3018,6 @@ static int toshiba_acpi_remove(struct acpi_device *acpi_dev) > > remove_toshiba_proc_entries(dev); > > - if (dev->sysfs_created) > - sysfs_remove_group(&dev->acpi_dev->dev.kobj, > - &toshiba_attr_group); > - > return 0; > } > > @@ -3049,6 +3044,13 @@ static void toshiba_acpi_misc_deregister(void *data) > misc_deregister(miscdev); > } > > +static void toshiba_acpi_sysfs_remove(void *data) > +{ > + struct kobject *kobj = data; > + > + sysfs_remove_group(kobj, &toshiba_attr_group); > +} > + > static int toshiba_acpi_add(struct acpi_device *acpi_dev) > { > struct device *parent = &acpi_dev->dev; > @@ -3219,21 +3221,20 @@ static int toshiba_acpi_add(struct acpi_device *acpi_dev) > > ret = sysfs_create_group(&dev->acpi_dev->dev.kobj, > &toshiba_attr_group); > - if (ret) { > - dev->sysfs_created = 0; > - goto error; > - } > - dev->sysfs_created = !ret; > + if (ret) > + return ret; > + > + ret = devm_add_action_or_reset(parent, > + toshiba_acpi_sysfs_remove, > + &dev->acpi_dev->dev.kobj); > + if (ret) > + return ret; > > create_toshiba_proc_entries(dev); > > toshiba_acpi = dev; > > return 0; > - > -error: > - toshiba_acpi_remove(acpi_dev); > - return ret; > } > > static void toshiba_acpi_notify(struct acpi_device *acpi_dev, u32 event)