linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Aaron Lu <aaron.lu@intel.com>
To: "Rafael J. Wysocki" <rjw@rjwysocki.net>,
	ACPI Devel Maling List <linux-acpi@vger.kernel.org>
Cc: Linux PCI <linux-pci@vger.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Bjorn Helgaas <bhelgaas@google.com>, Tejun Heo <tj@kernel.org>
Subject: Re: [PATCH 6/9] ACPI / ATA: Add hotplug contexts to ACPI companions of SATA devices
Date: Wed, 19 Feb 2014 10:42:20 +0800	[thread overview]
Message-ID: <53041A0C.4040306@intel.com> (raw)
In-Reply-To: <1707532.0BItEHDuFB@vostro.rjw.lan>

On 02/19/2014 09:30 AM, Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> 
> Modify the SATA subsystem to add hotplug contexts to ACPI companions
> of SATA devices and ports instead of registering special ACPI dock
> operations using register_hotplug_dock_device().
> 
> That change will allow the entire code handling those special ACPI
> dock operations to be dropped in the next commit.
> 
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> ---
>  drivers/ata/libata-acpi.c |   76 +++++++++++++++++++++++++++++-----------------
>  1 file changed, 49 insertions(+), 27 deletions(-)
> 
> Index: linux-pm/drivers/ata/libata-acpi.c
> ===================================================================
> --- linux-pm.orig/drivers/ata/libata-acpi.c
> +++ linux-pm/drivers/ata/libata-acpi.c
> @@ -38,6 +38,16 @@ static void ata_acpi_clear_gtf(struct at
>  	dev->gtf_cache = NULL;
>  }
>  
> +struct ata_acpi_hotplug_context {
> +	struct acpi_hotplug_context hp;
> +	union {
> +		struct ata_port *ap;
> +		struct ata_device *dev;
> +	} data;
> +};
> +
> +#define ata_hotplug_data(context) (container_of((context), struct ata_acpi_hotplug_context, hp)->data)
> +
>  /**
>   * ata_dev_acpi_handle - provide the acpi_handle for an ata_device
>   * @dev: the acpi_handle returned will correspond to this device
> @@ -121,18 +131,17 @@ static void ata_acpi_handle_hotplug(stru
>  		ata_port_wait_eh(ap);
>  }
>  
> -static void ata_acpi_dev_notify_dock(acpi_handle handle, u32 event, void *data)
> +static int ata_acpi_dev_notify_dock(struct acpi_device *adev, u32 event)
>  {
> -	struct ata_device *dev = data;
> -
> +	struct ata_device *dev = ata_hotplug_data(adev->hp).dev;
>  	ata_acpi_handle_hotplug(dev->link->ap, dev, event);
> +	return 0;
>  }
>  
> -static void ata_acpi_ap_notify_dock(acpi_handle handle, u32 event, void *data)
> +static int ata_acpi_ap_notify_dock(struct acpi_device *adev, u32 event)
>  {
> -	struct ata_port *ap = data;
> -
> -	ata_acpi_handle_hotplug(ap, NULL, event);
> +	ata_acpi_handle_hotplug(ata_hotplug_data(adev->hp).ap, NULL, event);
> +	return 0;
>  }
>  
>  static void ata_acpi_uevent(struct ata_port *ap, struct ata_device *dev,
> @@ -154,31 +163,23 @@ static void ata_acpi_uevent(struct ata_p
>  	}
>  }
>  
> -static void ata_acpi_ap_uevent(acpi_handle handle, u32 event, void *data)
> +static void ata_acpi_ap_uevent(struct acpi_device *adev, u32 event)
>  {
> -	ata_acpi_uevent(data, NULL, event);
> +	ata_acpi_uevent(ata_hotplug_data(adev->hp).ap, NULL, event);
>  }
>  
> -static void ata_acpi_dev_uevent(acpi_handle handle, u32 event, void *data)
> +static void ata_acpi_dev_uevent(struct acpi_device *adev, u32 event)
>  {
> -	struct ata_device *dev = data;
> +	struct ata_device *dev = ata_hotplug_data(adev->hp).dev;
>  	ata_acpi_uevent(dev->link->ap, dev, event);
>  }
>  
> -static const struct acpi_dock_ops ata_acpi_dev_dock_ops = {
> -	.handler = ata_acpi_dev_notify_dock,
> -	.uevent = ata_acpi_dev_uevent,
> -};
> -
> -static const struct acpi_dock_ops ata_acpi_ap_dock_ops = {
> -	.handler = ata_acpi_ap_notify_dock,
> -	.uevent = ata_acpi_ap_uevent,
> -};
> -
>  /* bind acpi handle to pata port */
>  void ata_acpi_bind_port(struct ata_port *ap)
>  {
>  	struct acpi_device *host_companion = ACPI_COMPANION(ap->host->dev);
> +	struct acpi_device *adev;
> +	struct ata_acpi_hotplug_context *context;
>  
>  	if (libata_noacpi || ap->flags & ATA_FLAG_ACPI_SATA || !host_companion)
>  		return;
> @@ -188,9 +189,19 @@ void ata_acpi_bind_port(struct ata_port
>  	if (ata_acpi_gtm(ap, &ap->__acpi_init_gtm) == 0)
>  		ap->pflags |= ATA_PFLAG_INIT_GTM_VALID;
>  
> -	/* we might be on a docking station */
> -	register_hotplug_dock_device(ACPI_HANDLE(&ap->tdev),
> -				     &ata_acpi_ap_dock_ops, ap, NULL, NULL);
> +	adev = ACPI_COMPANION(&ap->tdev);
> +	if (!adev)
> +		return;
> +
> +	context = kzalloc(sizeof(*context), GFP_KERNEL);
> +	if (!context)
> +		return;

The context isn't freed on ATA driver detach, which doesn't normally
happen though.

Thanks,
Aaron

  reply	other threads:[~2014-02-19  2:42 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-19  1:26 [PATCH 0/9] ACPI / dock / PCI / SATA: Simplify ACPI dock handling Rafael J. Wysocki
2014-02-19  1:27 ` [PATCH 1/9] ACPI / hotplug / PCI: Do not clear event callback pointer for docks Rafael J. Wysocki
2014-02-19  1:27 ` [PATCH 2/9] ACPI / hotplug: Add .fixup() callback to struct acpi_hotplug_context Rafael J. Wysocki
2014-02-19  1:28 ` [PATCH 3/9] ACPI / dock: Use ACPI device object pointers instead of ACPI handles Rafael J. Wysocki
2014-02-19  1:29 ` [PATCH 4/9] ACPI / dock: Use callback pointers from devices' ACPI hotplug contexts Rafael J. Wysocki
2014-02-19  1:30 ` [PATCH 5/9] ACPI / dock: Add .uevent() callback to struct acpi_hotplug_context Rafael J. Wysocki
2014-02-19  1:30 ` [PATCH 6/9] ACPI / ATA: Add hotplug contexts to ACPI companions of SATA devices Rafael J. Wysocki
2014-02-19  2:42   ` Aaron Lu [this message]
2014-02-19 16:40     ` Rafael J. Wysocki
2014-02-20  1:47   ` [Update][PATCH " Rafael J. Wysocki
2014-02-20  8:23     ` Aaron Lu
2014-02-20 14:26     ` Tejun Heo
2014-02-20 23:59       ` Rafael J. Wysocki
2014-02-22  0:15     ` [Update 2x][PATCH " Rafael J. Wysocki
2014-02-19  1:31 ` [PATCH 7/9] ACPI / dock: Drop struct acpi_dock_ops and all code related to it Rafael J. Wysocki
2014-02-19  1:32 ` [PATCH 8/9] ACPI / dock: Drop remove_dock_dependent_devices() Rafael J. Wysocki
2014-02-19  1:32 ` [PATCH 9/9] ACPI / dock: Update copyright notice Rafael J. Wysocki

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=53041A0C.4040306@intel.com \
    --to=aaron.lu@intel.com \
    --cc=bhelgaas@google.com \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=rjw@rjwysocki.net \
    --cc=tj@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;
as well as URLs for NNTP newsgroup(s).