public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Toshi Kani <toshi.kani@hp.com>
To: "Rafael J. Wysocki" <rjw@sisk.pl>
Cc: ACPI Devel Maling List <linux-acpi@vger.kernel.org>,
	Bjorn Helgaas <bhelgaas@google.com>,
	LKML <linux-kernel@vger.kernel.org>,
	Yinghai Lu <yinghai@kernel.org>, Jiang Liu <jiang.liu@huawei.com>,
	Taku Izumi <izumi.taku@jp.fujitsu.com>
Subject: Re: [PATCH 5/5] ACPI / scan: Add second pass to acpi_bus_trim()
Date: Mon, 14 Jan 2013 16:13:43 -0700	[thread overview]
Message-ID: <1358205223.14145.108.camel@misato.fc.hp.com> (raw)
In-Reply-To: <9393976.KUs5xrSxYx@vostro.rjw.lan>

On Mon, 2013-01-14 at 22:39 +0100, Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> 
> Make acpi_bus_trim() work in analogy with acpi_bus_scan() and carry
> out two passes such that ACPI drivers will be detached from device
> nodes being removed in the first pass and the device nodes themselves
> will be removed in the second pass.
> 
> For this purpose split the driver unregistration out of
> acpi_bus_remove() into a new routine, acpi_bus_device_detach(), that
> will be executed by acpi_bus_trim() in the additional first pass as
> a post-order callback.
> 
> This is necessary, because some ACPI drivers' .remove() routines
> unregister struct device objects associated with the ACPI device
> nodes being removed and that needs to happen while the ACPI
> device nodes are still around (for example, in case they need to be
> used for power management or similar things at that time).
> 
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

I'd suggest to add some comment stating that acpi_bus_device_detach()
acpi_bus_remove() are post-order callbacks.  I do not think many people
recognize it by just looking the calls to acpi_walk_namespace().

Otherwise, the patchset looks good.  For the patch series:
Acked-by: Toshi Kani <toshi.kani@hp.com>

Thanks,
-Toshi

> ---
>  drivers/acpi/scan.c |   44 ++++++++++++++++++++++++++++----------------
>  1 file changed, 28 insertions(+), 16 deletions(-)
> 
> Index: linux-pm/drivers/acpi/scan.c
> ===================================================================
> --- linux-pm.orig/drivers/acpi/scan.c
> +++ linux-pm/drivers/acpi/scan.c
> @@ -1425,22 +1425,6 @@ static void acpi_device_set_id(struct ac
>  	}
>  }
>  
> -static acpi_status acpi_bus_remove(acpi_handle handle, u32 lvl_not_used,
> -				   void *not_used, void **ret_not_used)
> -{
> -	struct acpi_device *dev = NULL;
> -
> -	if (acpi_bus_get_device(handle, &dev))
> -		return AE_OK;
> -
> -	dev->removal_type = ACPI_BUS_REMOVAL_EJECT;
> -	device_release_driver(&dev->dev);
> -
> -	acpi_device_unregister(dev);
> -
> -	return AE_OK;
> -}
> -
>  void acpi_init_device_object(struct acpi_device *device, acpi_handle handle,
>  			     int type, unsigned long long sta)
>  {
> @@ -1647,8 +1631,36 @@ int acpi_bus_add(acpi_handle handle)
>  }
>  EXPORT_SYMBOL(acpi_bus_add);
>  
> +static acpi_status acpi_bus_device_detach(acpi_handle handle, u32 lvl_not_used,
> +					  void *not_used, void **ret_not_used)
> +{
> +	struct acpi_device *device = NULL;
> +
> +	if (!acpi_bus_get_device(handle, &device)) {
> +		device->removal_type = ACPI_BUS_REMOVAL_EJECT;
> +		device_release_driver(&device->dev);
> +	}
> +	return AE_OK;
> +}
> +
> +static acpi_status acpi_bus_remove(acpi_handle handle, u32 lvl_not_used,
> +				   void *not_used, void **ret_not_used)
> +{
> +	struct acpi_device *device = NULL;
> +
> +	if (!acpi_bus_get_device(handle, &device))
> +		acpi_device_unregister(device);
> +
> +	return AE_OK;
> +}
> +
>  int acpi_bus_trim(struct acpi_device *start)
>  {
> +	/* Detach all ACPI drivers from the device nodes being removed. */
> +	acpi_walk_namespace(ACPI_TYPE_ANY, start->handle, ACPI_UINT32_MAX, NULL,
> +			    acpi_bus_device_detach, NULL, NULL);
> +	acpi_bus_device_detach(start->handle, 0, NULL, NULL);
> +	/* Remove the device nodes. */
>  	acpi_walk_namespace(ACPI_TYPE_ANY, start->handle, ACPI_UINT32_MAX, NULL,
>  			    acpi_bus_remove, NULL, NULL);
>  	acpi_bus_remove(start->handle, 0, NULL, NULL);
> 



  reply	other threads:[~2013-01-14 23:23 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-14 21:33 [PATCH 0/5] ACPI: Rework acpi_bus_trim() Rafael J. Wysocki
2013-01-14 21:37 ` [PATCH 1/5] ACPI: Remove the ops field from struct acpi_device Rafael J. Wysocki
2013-01-14 21:37 ` [PATCH 2/5] ACPI / scan: Drop the second argument of acpi_device_unregister() Rafael J. Wysocki
2013-01-14 21:37 ` [PATCH 3/5] ACPI / scan: Drop the second argument of acpi_bus_trim() Rafael J. Wysocki
2013-01-14 21:38 ` [PATCH 4/5] ACPI / scan: Change the implementation " Rafael J. Wysocki
2013-01-14 21:39 ` [PATCH 5/5] ACPI / scan: Add second pass to acpi_bus_trim() Rafael J. Wysocki
2013-01-14 23:13   ` Toshi Kani [this message]
2013-01-14 23:44     ` Rafael J. Wysocki
2013-01-14 22:21 ` [PATCH 0/5] ACPI: Rework acpi_bus_trim() Yinghai Lu
2013-01-14 23:51   ` Rafael J. Wysocki
2013-01-15  0:38 ` Yasuaki Ishimatsu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1358205223.14145.108.camel@misato.fc.hp.com \
    --to=toshi.kani@hp.com \
    --cc=bhelgaas@google.com \
    --cc=izumi.taku@jp.fujitsu.com \
    --cc=jiang.liu@huawei.com \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rjw@sisk.pl \
    --cc=yinghai@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox