linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rjw@rjwysocki.net>
To: Mika Westerberg <mika.westerberg@linux.intel.com>
Cc: Linux PM list <linux-pm@vger.kernel.org>,
	ACPI Devel Maling List <linux-acpi@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>
Subject: [RFC/RFT][PATCH 4-1/5] ACPI / scan: Add bind/unbind callbacks to struct acpi_scan_handler
Date: Wed, 22 Jan 2014 00:24:19 +0100	[thread overview]
Message-ID: <3008927.otxYIj8S9K@vostro.rjw.lan> (raw)
In-Reply-To: <5380624.AVmYnxjkQF@vostro.rjw.lan>

From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

In some cases it may be necessary to perform certain setup/cleanup
operations on a device object representing a physical device after
it has been associated with an ACPI companion by acpi_bind_one() or
before disassociating it from that companion by acpi_unbind_one(),
respectively.  If there is a struct acpi_bus_type object for the
given device's bus type, the .setup()/.cleanup() callbacks from there
are executed for these purposes.  However, an analogous mechanism will
be necessary for devices whose bus types don't have corresponding
struct acpi_bus_type objects and that have specific ACPI scan handlers.

For those devices, add new .bind() and .unbind() callbacks to struct
acpi_scan_handler that will be executed by acpi_platform_notify()
right after the given device has been associated with an ACPI
comapnion and by acpi_platform_notify_remove() right before calling
acpi_unbind_one() for that device, respectively.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 drivers/acpi/glue.c     |   12 ++++++++++++
 include/acpi/acpi_bus.h |    2 ++
 2 files changed, 14 insertions(+)

Index: linux-pm/drivers/acpi/glue.c
===================================================================
--- linux-pm.orig/drivers/acpi/glue.c
+++ linux-pm/drivers/acpi/glue.c
@@ -287,6 +287,7 @@ EXPORT_SYMBOL_GPL(acpi_unbind_one);
 static int acpi_platform_notify(struct device *dev)
 {
 	struct acpi_bus_type *type = acpi_get_bus_type(dev);
+	struct acpi_device *adev;
 	int ret;
 
 	ret = acpi_bind_one(dev, NULL);
@@ -303,9 +304,14 @@ static int acpi_platform_notify(struct d
 		if (ret)
 			goto out;
 	}
+	adev = ACPI_COMPANION(dev);
+	if (!adev)
+		goto out;
 
 	if (type && type->setup)
 		type->setup(dev);
+	else if (adev->handler && adev->handler->bind)
+		adev->handler->bind(dev);
 
  out:
 #if ACPI_GLUE_DEBUG
@@ -324,11 +330,17 @@ static int acpi_platform_notify(struct d
 
 static int acpi_platform_notify_remove(struct device *dev)
 {
+	struct acpi_device *adev = ACPI_COMPANION(dev);
 	struct acpi_bus_type *type;
 
+	if (!adev)
+		return 0;
+
 	type = acpi_get_bus_type(dev);
 	if (type && type->cleanup)
 		type->cleanup(dev);
+	else if (adev->handler && adev->handler->unbind)
+		adev->handler->unbind(dev);
 
 	acpi_unbind_one(dev);
 	return 0;
Index: linux-pm/include/acpi/acpi_bus.h
===================================================================
--- linux-pm.orig/include/acpi/acpi_bus.h
+++ linux-pm/include/acpi/acpi_bus.h
@@ -133,6 +133,8 @@ struct acpi_scan_handler {
 	struct list_head list_node;
 	int (*attach)(struct acpi_device *dev, const struct acpi_device_id *id);
 	void (*detach)(struct acpi_device *dev);
+	void (*bind)(struct device *phys_dev);
+	void (*unbind)(struct device *phys_dev);
 	struct acpi_hotplug_profile hotplug;
 };
 


  reply	other threads:[~2014-01-21 23:11 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-17 14:42 [RFC/RFT][PATCH 0/5] PM / QoS: Introduce latency tolerance device PM QoS type Rafael J. Wysocki
2014-01-17 14:43 ` [RFC/RFT][PATCH 1/5] PM / QoS: Rename device resume latency QoS items Rafael J. Wysocki
2014-01-17 14:44 ` [RFC/RFT][PATCH 2/5] PM / QoS: Add no_constraints_value field to struct pm_qos_constraints Rafael J. Wysocki
2014-01-17 14:45 ` [RFC/RFT][PATCH 3/5] PM / QoS: Introduce latency tolerance device PM QoS type Rafael J. Wysocki
2014-01-17 14:46 ` [RFC/RFT][PATCH 4/5] ACPI / LPSS: Support for device latency tolerance PM QoS Rafael J. Wysocki
2014-01-20 11:15   ` Mika Westerberg
2014-01-20 13:10     ` Rafael J. Wysocki
2014-01-21 23:23       ` Rafael J. Wysocki
2014-01-21 23:24         ` Rafael J. Wysocki [this message]
2014-01-21 23:25         ` [RFC/RFT][PATCH 4-2/5] " Rafael J. Wysocki
2014-01-17 14:49 ` [RFC/RFT][PATCH 5/5] PM / QoS: Add type to dev_pm_qos_add_ancestor_request() arguments Rafael J. Wysocki
2014-01-23 13:34 ` [RFC/RFT][PATCH v2 0/6] PM / QoS: Introduce latency tolerance device PM QoS type Rafael J. Wysocki
2014-01-23 13:36   ` [RFC/RFT][PATCH v2 1/6] PM / QoS: Rename device resume latency QoS items Rafael J. Wysocki
2014-01-23 13:37   ` [RFC/RFT][PATCH v2 2/6] PM / QoS: Add no_constraints_value field to struct pm_qos_constraints Rafael J. Wysocki
2014-01-23 13:37   ` [RFC/RFT][PATCH v2 3/6] PM / QoS: Introcuce latency tolerance device PM QoS type Rafael J. Wysocki
2014-01-24 22:30     ` [Update][RFC/RFT][PATCH " Rafael J. Wysocki
2014-01-23 13:38   ` [RFC/RFT][PATCH v2 4/6] ACPI / scan: Add bind/unbind callbacks to struct acpi_scan_handler Rafael J. Wysocki
2014-01-23 13:39   ` [RFC/RFT][PATCH v2 5/6] ACPI / LPSS: Support for device latency tolerance PM QoS Rafael J. Wysocki
2014-01-24 22:31     ` [Update][RFC/RFT][PATCH " Rafael J. Wysocki
2014-01-23 13:40   ` [RFC/RFT][PATCH v2 6/6] PM / QoS: Add type to dev_pm_qos_add_ancestor_request() arguments Rafael J. Wysocki
2014-01-24 14:19   ` [RFC/RFT][PATCH v2 0/6] PM / QoS: Introduce latency tolerance device PM QoS type Mika Westerberg
2014-01-24 15:30     ` Rafael J. Wysocki
2014-02-06 13:22   ` [PATCH v3 " Rafael J. Wysocki
2014-02-06 13:23     ` [PATCH v3 1/6] PM / QoS: Rename device resume latency QoS items Rafael J. Wysocki
2014-02-06 13:23     ` [PATCH v3 2/6] PM / QoS: Add no_constraints_value field to struct pm_qos_constraints Rafael J. Wysocki
2014-02-06 13:24     ` [PATCH v3 3/6] PM / QoS: Introcuce latency tolerance device PM QoS type Rafael J. Wysocki
2014-02-06 13:25     ` [PATCH v3 4/6] ACPI / scan: Add bind/unbind callbacks to struct acpi_scan_handler Rafael J. Wysocki
2014-02-06 13:26     ` [PATCH v3 5/6] ACPI / LPSS: Support for device latency tolerance PM QoS Rafael J. Wysocki
2014-02-07  1:22       ` [Update][PATCH " Rafael J. Wysocki
2014-02-06 13:27     ` [PATCH v3 6/6] PM / QoS: Add type to dev_pm_qos_add_ancestor_request() arguments 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=3008927.otxYIj8S9K@vostro.rjw.lan \
    --to=rjw@rjwysocki.net \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=mika.westerberg@linux.intel.com \
    /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).