Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3654085pxf; Mon, 29 Mar 2021 08:00:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx4tRm9VBJeh+lCPV8Gdg9aKJ83O9chU3MVcQxK+px55FBgp31OyPtMJ4hFqsButb6cVCHK X-Received: by 2002:a17:906:4d94:: with SMTP id s20mr29645225eju.286.1617030049258; Mon, 29 Mar 2021 08:00:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617030049; cv=none; d=google.com; s=arc-20160816; b=tuBleICDHuMqq6WpEL5ylxbZzo7QZ6nCRigSaJCeStmsIkKhJO/W5MxYweg7bYTYmu b/9hxW5oG22ljZ6QaqSV4N10WMTYSwkNwV5jCP9TJsD2P4y2MWGGSUF1bT7WFYGjQfsP H6PWmwtFmvF17UV1sjcpnvJC9EIruvJAefbzW87zrIYFIAUe4X2zMv5jxebud9rAtbKX R+bapOWj3nmnnkCD16p6goU4W7jH5Bgtbj2j5XmQMa2/S9FgAQQ7nrgSssxIXJ8hNbV9 mDjGMpDOw5jlmNxyUPVXdW6KAFn2R17WmWyvDb3mCdUq8ytzQvftT+5KWA7KmYwWBT7B 41KQ== 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=fsqeaQs7TaEjGDnB6TCaTLu5bFpw9zQgXcY7tad9X6A=; b=PnmejfLugU/sW8GVfkL2o7dA0W5FTtwPufvGkHnHWWGqzfZJPfSDcFuQg2AyVPdqPa cGPW32Fk7av5Upd/AzfBEhSaGGGeMi7FZxgCpnculr6TdTO7UdPjPouEzp7ew31K2lYC 39qNTq4kz88ndZIWwGqvIlW8iknDCgta8phf3oyhH07DDCt9eEIywa4cupVnn5PYwNwE mjkCI8lKMU22KZD8M31hne/wtJrzYB3a8oXYiFAMYvLhlnGkOrr9wDIAlnt6J0LF7ITT hh7h6nwgteTr5xnGaFFpiio+RrY6LaksAk+v0ri1BsDkfluQUU0Oj9vmv3DYvDeX8gSA +rzA== 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 x21si14035818ejb.180.2021.03.29.08.00.26; Mon, 29 Mar 2021 08:00:49 -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 S230180AbhC2O5Y (ORCPT + 99 others); Mon, 29 Mar 2021 10:57:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:43218 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231304AbhC2O5K (ORCPT ); Mon, 29 Mar 2021 10:57:10 -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 68CAF60C3D; Mon, 29 Mar 2021 14:57:07 +0000 (UTC) Date: Mon, 29 Mar 2021 15:57:13 +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 08/10] platform/x86: toshiba_acpi: use device-managed for wwan_rfkill management Message-ID: <20210329155713.3c19c0d1@jic23-huawei> In-Reply-To: <20210324125548.45983-9-aardelean@deviqon.com> References: <20210324125548.45983-1-aardelean@deviqon.com> <20210324125548.45983-9-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:46 +0200 Alexandru Ardelean wrote: > This change converts the wwan_rfkill object to be free'd automatically when > the parent refcount goes to zero. > There are 2 cleanup operations required: rfkill_unregister() and > rfkill_destroy(). Since they don't have any devm_ variants, they are hooked > via devm_add_action_or_reset(). > > The main reason to do this is to enforce ordering on cleanup, when the > Toshiba ACPI device is cleaned up. > > Signed-off-by: Alexandru Ardelean Superficially looks fine to me though I don't know much about rfkill. Reviewed-by: Jonathan Cameron > --- > drivers/platform/x86/toshiba_acpi.c | 40 ++++++++++++++++++++++------- > 1 file changed, 31 insertions(+), 9 deletions(-) > > diff --git a/drivers/platform/x86/toshiba_acpi.c b/drivers/platform/x86/toshiba_acpi.c > index 12860ef60e4d..a1249f6dde9a 100644 > --- a/drivers/platform/x86/toshiba_acpi.c > +++ b/drivers/platform/x86/toshiba_acpi.c > @@ -2591,7 +2591,22 @@ static const struct rfkill_ops wwan_rfk_ops = { > .poll = toshiba_acpi_wwan_poll, > }; > > -static int toshiba_acpi_setup_wwan_rfkill(struct toshiba_acpi_dev *dev) > +static void toshiba_acpi_rfkill_destroy(void *data) > +{ > + struct rfkill *wwan_rfk = data; > + > + rfkill_destroy(wwan_rfk); > +} > + > +static void toshiba_acpi_rfkill_unreg(void *data) > +{ > + struct rfkill *wwan_rfk = data; > + > + rfkill_unregister(wwan_rfk); > +} > + > +static int toshiba_acpi_setup_wwan_rfkill(struct device *parent, > + struct toshiba_acpi_dev *dev) > { > int ret = toshiba_wireless_status(dev); > > @@ -2608,15 +2623,27 @@ static int toshiba_acpi_setup_wwan_rfkill(struct toshiba_acpi_dev *dev) > return -ENOMEM; > } > > + ret = devm_add_action_or_reset(parent, toshiba_acpi_rfkill_destroy, > + dev->wwan_rfk); > + if (ret) > + return ret; > + > rfkill_set_hw_state(dev->wwan_rfk, !dev->killswitch); > > ret = rfkill_register(dev->wwan_rfk); > if (ret) { > pr_err("Unable to register WWAN rfkill device\n"); > - rfkill_destroy(dev->wwan_rfk); > + return ret; > } > > - return ret; > + ret = devm_add_action_or_reset(parent, toshiba_acpi_rfkill_unreg, > + dev->wwan_rfk); > + if (ret) { > + dev->wwan_rfk = NULL; > + return ret; > + } > + > + return 0; > } > > /* > @@ -2996,11 +3023,6 @@ static int toshiba_acpi_remove(struct acpi_device *acpi_dev) > sysfs_remove_group(&dev->acpi_dev->dev.kobj, > &toshiba_attr_group); > > - if (dev->wwan_rfk) { > - rfkill_unregister(dev->wwan_rfk); > - rfkill_destroy(dev->wwan_rfk); > - } > - > return 0; > } > > @@ -3189,7 +3211,7 @@ static int toshiba_acpi_add(struct acpi_device *acpi_dev) > > toshiba_wwan_available(dev); > if (dev->wwan_supported) > - toshiba_acpi_setup_wwan_rfkill(dev); > + toshiba_acpi_setup_wwan_rfkill(parent, dev); > > toshiba_cooling_method_available(dev); >