All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] ACPI: Provide consistent PNPID match handling
@ 2013-03-04 21:30 Toshi Kani
  2013-03-04 21:30 ` [PATCH 1/3] ACPI: Remove acpi_device dependency in acpi_device_set_id() Toshi Kani
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Toshi Kani @ 2013-03-04 21:30 UTC (permalink / raw)
  To: rjw
  Cc: linux-acpi, linux-kernel, yinghai, jiang.liu, isimatu.yasuaki,
	Toshi Kani

When installing/removing a notify handler to/from an ACPI device
object, ACPI core tries to match its associated scan handler to
see if it supports hotplug.  However, the matching logic of the
notify handler is different from the matching logic of attaching
a scan handler to an ACPI device object.  This inconsistency can
lead a mismatch and prevents ACPI scan handlers from supporting
non-HID devices, such as processor objects.

This patchset first updates PNPID setup interfaces to be independent
from acpi_device, and then updates the matching logic of the notify
handlers to be consistent with the attach handling.

This patchset is based on linux-pm.git/bleeding-edge.

---
Toshi Kani (3):
  ACPI: Remove acpi_device dependency in acpi_device_set_id()
  ACPI: Update PNPID set/free interfaces
  ACPI: Update PNPID match handling for notify

---
 drivers/acpi/internal.h               |   2 +-
 drivers/acpi/power.c                  |   2 +-
 drivers/acpi/scan.c                   | 203 +++++++++++++++++++---------------
 drivers/acpi/video_detect.c           |  25 ++---
 drivers/gpu/drm/i915/intel_opregion.c |   4 +-
 include/acpi/acpi_bus.h               |  14 ++-
 include/linux/acpi.h                  |   4 +-
 7 files changed, 138 insertions(+), 116 deletions(-)

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/3] ACPI: Remove acpi_device dependency in acpi_device_set_id()
  2013-03-04 21:30 [PATCH 0/3] ACPI: Provide consistent PNPID match handling Toshi Kani
@ 2013-03-04 21:30 ` Toshi Kani
  2013-03-04 21:30 ` [PATCH 2/3] ACPI: Update PNPID set/free interfaces Toshi Kani
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Toshi Kani @ 2013-03-04 21:30 UTC (permalink / raw)
  To: rjw
  Cc: linux-acpi, linux-kernel, yinghai, jiang.liu, isimatu.yasuaki,
	Toshi Kani

This patch updates the internal operations of acpi_device_set_id()
to setup acpi_device_pnp without using acpi_device.  There is no
functional change to acpi_device_set_id() in this patch.

acpi_pnp_type is added to acpi_device_pnp, so that PNPID type is
self-contained within acpi_device_pnp.  acpi_add_id(), acpi_bay_match(),
acpi_dock_match(), acpi_ibm_smbus_match() and acpi_is_video_device()
are changed to take acpi_handle as an argument, instead of acpi_device.

Signed-off-by: Toshi Kani <toshi.kani@hp.com>
---
 drivers/acpi/scan.c                   |   69 ++++++++++++++++-----------------
 drivers/acpi/video_detect.c           |   25 +++++-------
 drivers/gpu/drm/i915/intel_opregion.c |    4 +-
 include/acpi/acpi_bus.h               |   14 +++++--
 include/linux/acpi.h                  |    4 +-
 5 files changed, 59 insertions(+), 57 deletions(-)

diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index d69d77a..f9c698d 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -526,7 +526,7 @@ static int acpi_device_setup_files(struct acpi_device *dev)
 			goto end;
 	}
 
-	if (dev->flags.bus_address)
+	if (dev->pnp.type.bus_address)
 		result = device_create_file(&dev->dev, &dev_attr_adr);
 	if (dev->pnp.unique_id)
 		result = device_create_file(&dev->dev, &dev_attr_uid);
@@ -599,7 +599,7 @@ static void acpi_device_remove_files(struct acpi_device *dev)
 
 	if (dev->pnp.unique_id)
 		device_remove_file(&dev->dev, &dev_attr_uid);
-	if (dev->flags.bus_address)
+	if (dev->pnp.type.bus_address)
 		device_remove_file(&dev->dev, &dev_attr_adr);
 	device_remove_file(&dev->dev, &dev_attr_modalias);
 	device_remove_file(&dev->dev, &dev_attr_hid);
@@ -1406,19 +1406,17 @@ static void acpi_device_get_busid(struct acpi_device *device)
 }
 
 /*
- * acpi_bay_match - see if a device is an ejectable driver bay
+ * acpi_bay_match - see if an acpi object is an ejectable driver bay
  *
  * If an acpi object is ejectable and has one of the ACPI ATA methods defined,
  * then we can safely call it an ejectable drive bay
  */
-static int acpi_bay_match(struct acpi_device *device){
+static int acpi_bay_match(acpi_handle handle)
+{
 	acpi_status status;
-	acpi_handle handle;
 	acpi_handle tmp;
 	acpi_handle phandle;
 
-	handle = device->handle;
-
 	status = acpi_get_handle(handle, "_EJ0", &tmp);
 	if (ACPI_FAILURE(status))
 		return -ENODEV;
@@ -1442,12 +1440,12 @@ static int acpi_bay_match(struct acpi_device *device){
 }
 
 /*
- * acpi_dock_match - see if a device has a _DCK method
+ * acpi_dock_match - see if an acpi object has a _DCK method
  */
-static int acpi_dock_match(struct acpi_device *device)
+static int acpi_dock_match(acpi_handle handle)
 {
 	acpi_handle tmp;
-	return acpi_get_handle(device->handle, "_DCK", &tmp);
+	return acpi_get_handle(handle, "_DCK", &tmp);
 }
 
 const char *acpi_device_hid(struct acpi_device *device)
@@ -1462,7 +1460,7 @@ const char *acpi_device_hid(struct acpi_device *device)
 }
 EXPORT_SYMBOL(acpi_device_hid);
 
-static void acpi_add_id(struct acpi_device *device, const char *dev_id)
+static void acpi_add_id(struct acpi_device_pnp *pnp, const char *dev_id)
 {
 	struct acpi_hardware_id *id;
 
@@ -1476,7 +1474,8 @@ static void acpi_add_id(struct acpi_device *device, const char *dev_id)
 		return;
 	}
 
-	list_add_tail(&id->list, &device->pnp.ids);
+	list_add_tail(&id->list, &pnp->ids);
+	pnp->type.hardware_id = 1;
 }
 
 /*
@@ -1484,7 +1483,7 @@ static void acpi_add_id(struct acpi_device *device, const char *dev_id)
  * lacks the SMBUS01 HID and the methods do not have the necessary "_"
  * prefix.  Work around this.
  */
-static int acpi_ibm_smbus_match(struct acpi_device *device)
+static int acpi_ibm_smbus_match(acpi_handle handle)
 {
 	acpi_handle h_dummy;
 	struct acpi_buffer path = {ACPI_ALLOCATE_BUFFER, NULL};
@@ -1494,7 +1493,7 @@ static int acpi_ibm_smbus_match(struct acpi_device *device)
 		return -ENODEV;
 
 	/* Look for SMBS object */
-	result = acpi_get_name(device->handle, ACPI_SINGLE_NAME, &path);
+	result = acpi_get_name(handle, ACPI_SINGLE_NAME, &path);
 	if (result)
 		return result;
 
@@ -1505,9 +1504,9 @@ static int acpi_ibm_smbus_match(struct acpi_device *device)
 
 	/* Does it have the necessary (but misnamed) methods? */
 	result = -ENODEV;
-	if (ACPI_SUCCESS(acpi_get_handle(device->handle, "SBI", &h_dummy)) &&
-	    ACPI_SUCCESS(acpi_get_handle(device->handle, "SBR", &h_dummy)) &&
-	    ACPI_SUCCESS(acpi_get_handle(device->handle, "SBW", &h_dummy)))
+	if (ACPI_SUCCESS(acpi_get_handle(handle, "SBI", &h_dummy)) &&
+	    ACPI_SUCCESS(acpi_get_handle(handle, "SBR", &h_dummy)) &&
+	    ACPI_SUCCESS(acpi_get_handle(handle, "SBW", &h_dummy)))
 		result = 0;
 out:
 	kfree(path.pointer);
@@ -1524,7 +1523,7 @@ static void acpi_device_set_id(struct acpi_device *device)
 	switch (device->device_type) {
 	case ACPI_BUS_TYPE_DEVICE:
 		if (ACPI_IS_ROOT_DEVICE(device)) {
-			acpi_add_id(device, ACPI_SYSTEM_HID);
+			acpi_add_id(&device->pnp, ACPI_SYSTEM_HID);
 			break;
 		}
 
@@ -1535,15 +1534,15 @@ static void acpi_device_set_id(struct acpi_device *device)
 		}
 
 		if (info->valid & ACPI_VALID_HID)
-			acpi_add_id(device, info->hardware_id.string);
+			acpi_add_id(&device->pnp, info->hardware_id.string);
 		if (info->valid & ACPI_VALID_CID) {
 			cid_list = &info->compatible_id_list;
 			for (i = 0; i < cid_list->count; i++)
-				acpi_add_id(device, cid_list->ids[i].string);
+				acpi_add_id(&device->pnp, cid_list->ids[i].string);
 		}
 		if (info->valid & ACPI_VALID_ADR) {
 			device->pnp.bus_address = info->address;
-			device->flags.bus_address = 1;
+			device->pnp.type.bus_address = 1;
 		}
 		if (info->valid & ACPI_VALID_UID)
 			device->pnp.unique_id = kstrdup(info->unique_id.string,
@@ -1555,36 +1554,36 @@ static void acpi_device_set_id(struct acpi_device *device)
 		 * Some devices don't reliably have _HIDs & _CIDs, so add
 		 * synthetic HIDs to make sure drivers can find them.
 		 */
-		if (acpi_is_video_device(device))
-			acpi_add_id(device, ACPI_VIDEO_HID);
-		else if (ACPI_SUCCESS(acpi_bay_match(device)))
-			acpi_add_id(device, ACPI_BAY_HID);
-		else if (ACPI_SUCCESS(acpi_dock_match(device)))
-			acpi_add_id(device, ACPI_DOCK_HID);
-		else if (!acpi_ibm_smbus_match(device))
-			acpi_add_id(device, ACPI_SMBUS_IBM_HID);
+		if (acpi_is_video_device(device->handle))
+			acpi_add_id(&device->pnp, ACPI_VIDEO_HID);
+		else if (ACPI_SUCCESS(acpi_bay_match(device->handle)))
+			acpi_add_id(&device->pnp, ACPI_BAY_HID);
+		else if (ACPI_SUCCESS(acpi_dock_match(device->handle)))
+			acpi_add_id(&device->pnp, ACPI_DOCK_HID);
+		else if (!acpi_ibm_smbus_match(device->handle))
+			acpi_add_id(&device->pnp, ACPI_SMBUS_IBM_HID);
 		else if (list_empty(&device->pnp.ids) &&
 			 ACPI_IS_ROOT_DEVICE(device->parent)) {
-			acpi_add_id(device, ACPI_BUS_HID); /* \_SB, LNXSYBUS */
+			acpi_add_id(&device->pnp, ACPI_BUS_HID); /* \_SB, LNXSYBUS */
 			strcpy(device->pnp.device_name, ACPI_BUS_DEVICE_NAME);
 			strcpy(device->pnp.device_class, ACPI_BUS_CLASS);
 		}
 
 		break;
 	case ACPI_BUS_TYPE_POWER:
-		acpi_add_id(device, ACPI_POWER_HID);
+		acpi_add_id(&device->pnp, ACPI_POWER_HID);
 		break;
 	case ACPI_BUS_TYPE_PROCESSOR:
-		acpi_add_id(device, ACPI_PROCESSOR_OBJECT_HID);
+		acpi_add_id(&device->pnp, ACPI_PROCESSOR_OBJECT_HID);
 		break;
 	case ACPI_BUS_TYPE_THERMAL:
-		acpi_add_id(device, ACPI_THERMAL_HID);
+		acpi_add_id(&device->pnp, ACPI_THERMAL_HID);
 		break;
 	case ACPI_BUS_TYPE_POWER_BUTTON:
-		acpi_add_id(device, ACPI_BUTTON_HID_POWERF);
+		acpi_add_id(&device->pnp, ACPI_BUTTON_HID_POWERF);
 		break;
 	case ACPI_BUS_TYPE_SLEEP_BUTTON:
-		acpi_add_id(device, ACPI_BUTTON_HID_SLEEPF);
+		acpi_add_id(&device->pnp, ACPI_BUTTON_HID_SLEEPF);
 		break;
 	}
 }
diff --git a/drivers/acpi/video_detect.c b/drivers/acpi/video_detect.c
index 4ac2593..66f6762 100644
--- a/drivers/acpi/video_detect.c
+++ b/drivers/acpi/video_detect.c
@@ -67,40 +67,37 @@ acpi_backlight_cap_match(acpi_handle handle, u32 level, void *context,
 	return 0;
 }
 
-/* Returns true if the device is a video device which can be handled by
- * video.ko.
+/* Returns true if the ACPI object is a video device which can be
+ * handled by video.ko.
  * The device will get a Linux specific CID added in scan.c to
  * identify the device as an ACPI graphics device
  * Be aware that the graphics device may not be physically present
  * Use acpi_video_get_capabilities() to detect general ACPI video
  * capabilities of present cards
  */
-long acpi_is_video_device(struct acpi_device *device)
+long acpi_is_video_device(acpi_handle handle)
 {
 	acpi_handle h_dummy;
 	long video_caps = 0;
 
-	if (!device)
-		return 0;
-
 	/* Is this device able to support video switching ? */
-	if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_DOD", &h_dummy)) ||
-	    ACPI_SUCCESS(acpi_get_handle(device->handle, "_DOS", &h_dummy)))
+	if (ACPI_SUCCESS(acpi_get_handle(handle, "_DOD", &h_dummy)) ||
+	    ACPI_SUCCESS(acpi_get_handle(handle, "_DOS", &h_dummy)))
 		video_caps |= ACPI_VIDEO_OUTPUT_SWITCHING;
 
 	/* Is this device able to retrieve a video ROM ? */
-	if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_ROM", &h_dummy)))
+	if (ACPI_SUCCESS(acpi_get_handle(handle, "_ROM", &h_dummy)))
 		video_caps |= ACPI_VIDEO_ROM_AVAILABLE;
 
 	/* Is this device able to configure which video head to be POSTed ? */
-	if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_VPO", &h_dummy)) &&
-	    ACPI_SUCCESS(acpi_get_handle(device->handle, "_GPD", &h_dummy)) &&
-	    ACPI_SUCCESS(acpi_get_handle(device->handle, "_SPD", &h_dummy)))
+	if (ACPI_SUCCESS(acpi_get_handle(handle, "_VPO", &h_dummy)) &&
+	    ACPI_SUCCESS(acpi_get_handle(handle, "_GPD", &h_dummy)) &&
+	    ACPI_SUCCESS(acpi_get_handle(handle, "_SPD", &h_dummy)))
 		video_caps |= ACPI_VIDEO_DEVICE_POSTING;
 
 	/* Only check for backlight functionality if one of the above hit. */
 	if (video_caps)
-		acpi_walk_namespace(ACPI_TYPE_DEVICE, device->handle,
+		acpi_walk_namespace(ACPI_TYPE_DEVICE, handle,
 				    ACPI_UINT32_MAX, acpi_backlight_cap_match, NULL,
 				    &video_caps, NULL);
 
@@ -127,7 +124,7 @@ find_video(acpi_handle handle, u32 lvl, void *context, void **rv)
 		if (!dev)
 			return AE_OK;
 		pci_dev_put(dev);
-		*cap |= acpi_is_video_device(acpi_dev);
+		*cap |= acpi_is_video_device(handle);
 	}
 	return AE_OK;
 }
diff --git a/drivers/gpu/drm/i915/intel_opregion.c b/drivers/gpu/drm/i915/intel_opregion.c
index 4d33874..a8117e6 100644
--- a/drivers/gpu/drm/i915/intel_opregion.c
+++ b/drivers/gpu/drm/i915/intel_opregion.c
@@ -350,11 +350,11 @@ static void intel_didl_outputs(struct drm_device *dev)
 	if (!handle || acpi_bus_get_device(handle, &acpi_dev))
 		return;
 
-	if (acpi_is_video_device(acpi_dev))
+	if (acpi_is_video_device(handle))
 		acpi_video_bus = acpi_dev;
 	else {
 		list_for_each_entry(acpi_cdev, &acpi_dev->children, node) {
-			if (acpi_is_video_device(acpi_cdev)) {
+			if (acpi_is_video_device(acpi_cdev->handle)) {
 				acpi_video_bus = acpi_cdev;
 				break;
 			}
diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
index e658e33..98db31d 100644
--- a/include/acpi/acpi_bus.h
+++ b/include/acpi/acpi_bus.h
@@ -161,7 +161,6 @@ struct acpi_device_status {
 
 struct acpi_device_flags {
 	u32 dynamic_status:1;
-	u32 bus_address:1;
 	u32 removable:1;
 	u32 ejectable:1;
 	u32 suprise_removal_ok:1;
@@ -169,7 +168,7 @@ struct acpi_device_flags {
 	u32 performance_manageable:1;
 	u32 eject_pending:1;
 	u32 match_driver:1;
-	u32 reserved:23;
+	u32 reserved:24;
 };
 
 /* File System */
@@ -192,10 +191,17 @@ struct acpi_hardware_id {
 	char *id;
 };
 
+struct acpi_pnp_type {
+	u32 hardware_id:1;
+	u32 bus_address:1;
+	u32 reserved:30;
+};
+
 struct acpi_device_pnp {
-	acpi_bus_id bus_id;	/* Object name */
+	acpi_bus_id bus_id;		/* Object name */
+	struct acpi_pnp_type type;	/* ID type */
 	acpi_bus_address bus_address;	/* _ADR */
-	char *unique_id;	/* _UID */
+	char *unique_id;		/* _UID */
 	struct list_head ids;		/* _HID and _CIDs */
 	acpi_device_name device_name;	/* Driver-determined */
 	acpi_device_class device_class;	/*        "          */
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index bcbdd74..edaf311 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -204,7 +204,7 @@ extern bool wmi_has_guid(const char *guid);
 #if defined(CONFIG_ACPI_VIDEO) || defined(CONFIG_ACPI_VIDEO_MODULE)
 
 extern long acpi_video_get_capabilities(acpi_handle graphics_dev_handle);
-extern long acpi_is_video_device(struct acpi_device *device);
+extern long acpi_is_video_device(acpi_handle handle);
 extern void acpi_video_dmi_promote_vendor(void);
 extern void acpi_video_dmi_demote_vendor(void);
 extern int acpi_video_backlight_support(void);
@@ -217,7 +217,7 @@ static inline long acpi_video_get_capabilities(acpi_handle graphics_dev_handle)
 	return 0;
 }
 
-static inline long acpi_is_video_device(struct acpi_device *device)
+static inline long acpi_is_video_device(acpi_handle handle)
 {
 	return 0;
 }

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/3] ACPI: Update PNPID set/free interfaces
  2013-03-04 21:30 [PATCH 0/3] ACPI: Provide consistent PNPID match handling Toshi Kani
  2013-03-04 21:30 ` [PATCH 1/3] ACPI: Remove acpi_device dependency in acpi_device_set_id() Toshi Kani
@ 2013-03-04 21:30 ` Toshi Kani
  2013-03-04 21:30 ` [PATCH 3/3] ACPI: Update PNPID match handling for notify Toshi Kani
  2013-03-26 13:11 ` [PATCH 0/3] ACPI: Provide consistent PNPID match handling Rafael J. Wysocki
  3 siblings, 0 replies; 6+ messages in thread
From: Toshi Kani @ 2013-03-04 21:30 UTC (permalink / raw)
  To: rjw
  Cc: linux-acpi, linux-kernel, yinghai, jiang.liu, isimatu.yasuaki,
	Toshi Kani

This patch introduces acpi_set_pnp_ids() and acpi_free_pnp_ids(),
which are updated from acpi_device_set_id() and acpi_free_ids(),
to setup and free acpi_device_pnp for a given acpi_handle.  They
can be called without acpi_device.

Signed-off-by: Toshi Kani <toshi.kani@hp.com>
---
 drivers/acpi/internal.h |    2 +
 drivers/acpi/power.c    |    2 +
 drivers/acpi/scan.c     |   85 ++++++++++++++++++++++++-----------------------
 3 files changed, 45 insertions(+), 44 deletions(-)

diff --git a/drivers/acpi/internal.h b/drivers/acpi/internal.h
index 7215821..7f094ad 100644
--- a/drivers/acpi/internal.h
+++ b/drivers/acpi/internal.h
@@ -71,7 +71,7 @@ int acpi_device_add(struct acpi_device *device,
 void acpi_init_device_object(struct acpi_device *device, acpi_handle handle,
 			     int type, unsigned long long sta);
 void acpi_device_add_finalize(struct acpi_device *device);
-void acpi_free_ids(struct acpi_device *device);
+void acpi_free_pnp_ids(struct acpi_device_pnp *pnp);
 
 /* --------------------------------------------------------------------------
                                   Power Resource
diff --git a/drivers/acpi/power.c b/drivers/acpi/power.c
index 34f5ef1..0481b1b 100644
--- a/drivers/acpi/power.c
+++ b/drivers/acpi/power.c
@@ -824,7 +824,7 @@ static void acpi_release_power_resource(struct device *dev)
 	list_del(&resource->list_node);
 	mutex_unlock(&power_resource_list_lock);
 
-	acpi_free_ids(device);
+	acpi_free_pnp_ids(&device->pnp);
 	kfree(resource);
 }
 
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index f9c698d..e9a71ed 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -662,17 +662,6 @@ int acpi_match_device_ids(struct acpi_device *device,
 }
 EXPORT_SYMBOL(acpi_match_device_ids);
 
-void acpi_free_ids(struct acpi_device *device)
-{
-	struct acpi_hardware_id *id, *tmp;
-
-	list_for_each_entry_safe(id, tmp, &device->pnp.ids, list) {
-		kfree(id->id);
-		kfree(id);
-	}
-	kfree(device->pnp.unique_id);
-}
-
 static void acpi_free_power_resources_lists(struct acpi_device *device)
 {
 	int i;
@@ -693,7 +682,7 @@ static void acpi_device_release(struct device *dev)
 {
 	struct acpi_device *acpi_dev = to_acpi_device(dev);
 
-	acpi_free_ids(acpi_dev);
+	acpi_free_pnp_ids(&acpi_dev->pnp);
 	acpi_free_power_resources_lists(acpi_dev);
 	kfree(acpi_dev);
 }
@@ -1513,39 +1502,41 @@ out:
 	return result;
 }
 
-static void acpi_device_set_id(struct acpi_device *device)
+static void acpi_set_pnp_ids(acpi_handle handle, struct acpi_device_pnp *pnp,
+				int device_type)
 {
 	acpi_status status;
 	struct acpi_device_info *info;
 	struct acpi_pnp_device_id_list *cid_list;
 	int i;
 
-	switch (device->device_type) {
+	switch (device_type) {
 	case ACPI_BUS_TYPE_DEVICE:
-		if (ACPI_IS_ROOT_DEVICE(device)) {
-			acpi_add_id(&device->pnp, ACPI_SYSTEM_HID);
+		if (handle == ACPI_ROOT_OBJECT) {
+			acpi_add_id(pnp, ACPI_SYSTEM_HID);
 			break;
 		}
 
-		status = acpi_get_object_info(device->handle, &info);
+		status = acpi_get_object_info(handle, &info);
 		if (ACPI_FAILURE(status)) {
-			printk(KERN_ERR PREFIX "%s: Error reading device info\n", __func__);
+			pr_err(PREFIX "%s: Error reading device info\n",
+					__func__);
 			return;
 		}
 
 		if (info->valid & ACPI_VALID_HID)
-			acpi_add_id(&device->pnp, info->hardware_id.string);
+			acpi_add_id(pnp, info->hardware_id.string);
 		if (info->valid & ACPI_VALID_CID) {
 			cid_list = &info->compatible_id_list;
 			for (i = 0; i < cid_list->count; i++)
-				acpi_add_id(&device->pnp, cid_list->ids[i].string);
+				acpi_add_id(pnp, cid_list->ids[i].string);
 		}
 		if (info->valid & ACPI_VALID_ADR) {
-			device->pnp.bus_address = info->address;
-			device->pnp.type.bus_address = 1;
+			pnp->bus_address = info->address;
+			pnp->type.bus_address = 1;
 		}
 		if (info->valid & ACPI_VALID_UID)
-			device->pnp.unique_id = kstrdup(info->unique_id.string,
+			pnp->unique_id = kstrdup(info->unique_id.string,
 							GFP_KERNEL);
 
 		kfree(info);
@@ -1554,40 +1545,50 @@ static void acpi_device_set_id(struct acpi_device *device)
 		 * Some devices don't reliably have _HIDs & _CIDs, so add
 		 * synthetic HIDs to make sure drivers can find them.
 		 */
-		if (acpi_is_video_device(device->handle))
-			acpi_add_id(&device->pnp, ACPI_VIDEO_HID);
-		else if (ACPI_SUCCESS(acpi_bay_match(device->handle)))
-			acpi_add_id(&device->pnp, ACPI_BAY_HID);
-		else if (ACPI_SUCCESS(acpi_dock_match(device->handle)))
-			acpi_add_id(&device->pnp, ACPI_DOCK_HID);
-		else if (!acpi_ibm_smbus_match(device->handle))
-			acpi_add_id(&device->pnp, ACPI_SMBUS_IBM_HID);
-		else if (list_empty(&device->pnp.ids) &&
-			 ACPI_IS_ROOT_DEVICE(device->parent)) {
-			acpi_add_id(&device->pnp, ACPI_BUS_HID); /* \_SB, LNXSYBUS */
-			strcpy(device->pnp.device_name, ACPI_BUS_DEVICE_NAME);
-			strcpy(device->pnp.device_class, ACPI_BUS_CLASS);
+		if (acpi_is_video_device(handle))
+			acpi_add_id(pnp, ACPI_VIDEO_HID);
+		else if (ACPI_SUCCESS(acpi_bay_match(handle)))
+			acpi_add_id(pnp, ACPI_BAY_HID);
+		else if (ACPI_SUCCESS(acpi_dock_match(handle)))
+			acpi_add_id(pnp, ACPI_DOCK_HID);
+		else if (!acpi_ibm_smbus_match(handle))
+			acpi_add_id(pnp, ACPI_SMBUS_IBM_HID);
+		else if (list_empty(&pnp->ids) && handle == ACPI_ROOT_OBJECT) {
+			acpi_add_id(pnp, ACPI_BUS_HID); /* \_SB, LNXSYBUS */
+			strcpy(pnp->device_name, ACPI_BUS_DEVICE_NAME);
+			strcpy(pnp->device_class, ACPI_BUS_CLASS);
 		}
 
 		break;
 	case ACPI_BUS_TYPE_POWER:
-		acpi_add_id(&device->pnp, ACPI_POWER_HID);
+		acpi_add_id(pnp, ACPI_POWER_HID);
 		break;
 	case ACPI_BUS_TYPE_PROCESSOR:
-		acpi_add_id(&device->pnp, ACPI_PROCESSOR_OBJECT_HID);
+		acpi_add_id(pnp, ACPI_PROCESSOR_OBJECT_HID);
 		break;
 	case ACPI_BUS_TYPE_THERMAL:
-		acpi_add_id(&device->pnp, ACPI_THERMAL_HID);
+		acpi_add_id(pnp, ACPI_THERMAL_HID);
 		break;
 	case ACPI_BUS_TYPE_POWER_BUTTON:
-		acpi_add_id(&device->pnp, ACPI_BUTTON_HID_POWERF);
+		acpi_add_id(pnp, ACPI_BUTTON_HID_POWERF);
 		break;
 	case ACPI_BUS_TYPE_SLEEP_BUTTON:
-		acpi_add_id(&device->pnp, ACPI_BUTTON_HID_SLEEPF);
+		acpi_add_id(pnp, ACPI_BUTTON_HID_SLEEPF);
 		break;
 	}
 }
 
+void acpi_free_pnp_ids(struct acpi_device_pnp *pnp)
+{
+	struct acpi_hardware_id *id, *tmp;
+
+	list_for_each_entry_safe(id, tmp, &pnp->ids, list) {
+		kfree(id->id);
+		kfree(id);
+	}
+	kfree(pnp->unique_id);
+}
+
 void acpi_init_device_object(struct acpi_device *device, acpi_handle handle,
 			     int type, unsigned long long sta)
 {
@@ -1597,7 +1598,7 @@ void acpi_init_device_object(struct acpi_device *device, acpi_handle handle,
 	device->parent = acpi_bus_get_parent(handle);
 	STRUCT_TO_INT(device->status) = sta;
 	acpi_device_get_busid(device);
-	acpi_device_set_id(device);
+	acpi_set_pnp_ids(handle, &device->pnp, type);
 	acpi_bus_get_flags(device);
 	device->flags.match_driver = false;
 	device_initialize(&device->dev);

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/3] ACPI: Update PNPID match handling for notify
  2013-03-04 21:30 [PATCH 0/3] ACPI: Provide consistent PNPID match handling Toshi Kani
  2013-03-04 21:30 ` [PATCH 1/3] ACPI: Remove acpi_device dependency in acpi_device_set_id() Toshi Kani
  2013-03-04 21:30 ` [PATCH 2/3] ACPI: Update PNPID set/free interfaces Toshi Kani
@ 2013-03-04 21:30 ` Toshi Kani
  2013-03-26 13:11 ` [PATCH 0/3] ACPI: Provide consistent PNPID match handling Rafael J. Wysocki
  3 siblings, 0 replies; 6+ messages in thread
From: Toshi Kani @ 2013-03-04 21:30 UTC (permalink / raw)
  To: rjw
  Cc: linux-acpi, linux-kernel, yinghai, jiang.liu, isimatu.yasuaki,
	Toshi Kani

When installing/removing a notify handler to/from an ACPI device
object, ACPI core tries to match its associated scan handler to
see if it supports hotplug.  However, the matching logic of the
notify handler is different from the matching logic of attaching
a scan handler to an ACPI device object.  This patch updates the
matching logic of the notify handlers to be consistent with the
attach handling.

Signed-off-by: Toshi Kani <toshi.kani@hp.com>
---
 drivers/acpi/scan.c |   85 +++++++++++++++++++++++++++++++--------------------
 1 file changed, 52 insertions(+), 33 deletions(-)

diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index e9a71ed..3f6ec0d 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -1703,24 +1703,47 @@ static bool acpi_scan_handler_matching(struct acpi_scan_handler *handler,
 	return false;
 }
 
+static struct acpi_scan_handler *acpi_scan_match_handler(char *idstr,
+					const struct acpi_device_id **matchid)
+{
+	struct acpi_scan_handler *handler;
+
+	list_for_each_entry(handler, &acpi_scan_handlers_list, list_node)
+		if (acpi_scan_handler_matching(handler, idstr, matchid))
+			return handler;
+
+	return NULL;
+}
+
 static acpi_status acpi_scan_hotplug_modify(acpi_handle handle,
 					    u32 lvl_not_used, void *data,
 					    void **ret_not_used)
 {
-	struct acpi_scan_handler *handler = data;
-	struct acpi_device_info *info;
+	struct acpi_device_pnp pnp = {};
+	struct acpi_scan_handler *tgt_handler = data, *handler;
+	struct acpi_hardware_id *hwid;
+	unsigned long long sta_not_used;
+	int type;
 	bool match = false;
 
-	if (ACPI_FAILURE(acpi_get_object_info(handle, &info)))
+	if (acpi_bus_type_and_status(handle, &type, &sta_not_used))
+		return AE_OK;
+
+	INIT_LIST_HEAD(&pnp.ids);
+	acpi_set_pnp_ids(handle, &pnp, type);
+
+	if (!pnp.type.hardware_id)
 		return AE_OK;
 
-	if (info->valid & ACPI_VALID_HID) {
-		char *idstr = info->hardware_id.string;
-		match = acpi_scan_handler_matching(handler, idstr, NULL);
+	list_for_each_entry(hwid, &pnp.ids, list) {
+		handler = acpi_scan_match_handler(hwid->id, NULL);
+		if (handler && handler == tgt_handler) {
+			match = true;
+			break;
+		}
 	}
-	kfree(info);
 	if (!match)
-		return AE_OK;
+		goto out;
 
 	if (handler->hotplug.enabled)
 		acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY,
@@ -1729,6 +1752,8 @@ static acpi_status acpi_scan_hotplug_modify(acpi_handle handle,
 		acpi_remove_notify_handler(handle, ACPI_SYSTEM_NOTIFY,
 					   acpi_hotplug_notify_cb);
 
+out:
+	acpi_free_pnp_ids(&pnp);
 	return AE_OK;
 }
 
@@ -1749,40 +1774,34 @@ void acpi_scan_hotplug_enabled(struct acpi_hotplug_profile *hotplug, bool val)
 	mutex_unlock(&acpi_scan_lock);
 }
 
-static struct acpi_scan_handler *acpi_scan_match_handler(char *idstr,
-					const struct acpi_device_id **matchid)
-{
-	struct acpi_scan_handler *handler;
-
-	list_for_each_entry(handler, &acpi_scan_handlers_list, list_node)
-		if (acpi_scan_handler_matching(handler, idstr, matchid))
-			return handler;
-
-	return NULL;
-}
-
-static void acpi_scan_init_hotplug(acpi_handle handle)
+static void acpi_scan_init_hotplug(acpi_handle handle, int type)
 {
-	struct acpi_device_info *info;
+	struct acpi_device_pnp pnp = {};
+	struct acpi_hardware_id *hwid;
 	struct acpi_scan_handler *handler;
 
-	if (ACPI_FAILURE(acpi_get_object_info(handle, &info)))
-		return;
+	INIT_LIST_HEAD(&pnp.ids);
+	acpi_set_pnp_ids(handle, &pnp, type);
 
-	if (!(info->valid & ACPI_VALID_HID)) {
-		kfree(info);
+	if (!pnp.type.hardware_id)
 		return;
-	}
 
 	/*
 	 * This relies on the fact that acpi_install_notify_handler() will not
 	 * install the same notify handler routine twice for the same handle.
 	 */
-	handler = acpi_scan_match_handler(info->hardware_id.string, NULL);
-	kfree(info);
-	if (handler && handler->hotplug.enabled)
-		acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY,
-					    acpi_hotplug_notify_cb, NULL);
+	list_for_each_entry(hwid, &pnp.ids, list) {
+		handler = acpi_scan_match_handler(hwid->id, NULL);
+		if (handler) {
+			if (handler->hotplug.enabled)
+				acpi_install_notify_handler(handle,
+					ACPI_SYSTEM_NOTIFY,
+					acpi_hotplug_notify_cb, NULL);
+			break;
+		}
+	}
+
+	acpi_free_pnp_ids(&pnp);
 }
 
 static acpi_status acpi_bus_check_add(acpi_handle handle, u32 lvl_not_used,
@@ -1807,7 +1826,7 @@ static acpi_status acpi_bus_check_add(acpi_handle handle, u32 lvl_not_used,
 		return AE_OK;
 	}
 
-	acpi_scan_init_hotplug(handle);
+	acpi_scan_init_hotplug(handle, type);
 
 	if (!(sta & ACPI_STA_DEVICE_PRESENT) &&
 	    !(sta & ACPI_STA_DEVICE_FUNCTIONING)) {

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 0/3] ACPI: Provide consistent PNPID match handling
  2013-03-04 21:30 [PATCH 0/3] ACPI: Provide consistent PNPID match handling Toshi Kani
                   ` (2 preceding siblings ...)
  2013-03-04 21:30 ` [PATCH 3/3] ACPI: Update PNPID match handling for notify Toshi Kani
@ 2013-03-26 13:11 ` Rafael J. Wysocki
  2013-03-26 14:42   ` Toshi Kani
  3 siblings, 1 reply; 6+ messages in thread
From: Rafael J. Wysocki @ 2013-03-26 13:11 UTC (permalink / raw)
  To: Toshi Kani; +Cc: linux-acpi, linux-kernel, yinghai, jiang.liu, isimatu.yasuaki

On Monday, March 04, 2013 02:30:40 PM Toshi Kani wrote:
> When installing/removing a notify handler to/from an ACPI device
> object, ACPI core tries to match its associated scan handler to
> see if it supports hotplug.  However, the matching logic of the
> notify handler is different from the matching logic of attaching
> a scan handler to an ACPI device object.  This inconsistency can
> lead a mismatch and prevents ACPI scan handlers from supporting
> non-HID devices, such as processor objects.
> 
> This patchset first updates PNPID setup interfaces to be independent
> from acpi_device, and then updates the matching logic of the notify
> handlers to be consistent with the attach handling.
> 
> This patchset is based on linux-pm.git/bleeding-edge.

All patches in the series applied to linux-pm.git/linux-next.

Thanks,
Rafael


> ---
> Toshi Kani (3):
>   ACPI: Remove acpi_device dependency in acpi_device_set_id()
>   ACPI: Update PNPID set/free interfaces
>   ACPI: Update PNPID match handling for notify
> 
> ---
>  drivers/acpi/internal.h               |   2 +-
>  drivers/acpi/power.c                  |   2 +-
>  drivers/acpi/scan.c                   | 203 +++++++++++++++++++---------------
>  drivers/acpi/video_detect.c           |  25 ++---
>  drivers/gpu/drm/i915/intel_opregion.c |   4 +-
>  include/acpi/acpi_bus.h               |  14 ++-
>  include/linux/acpi.h                  |   4 +-
>  7 files changed, 138 insertions(+), 116 deletions(-)
> --
> To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 0/3] ACPI: Provide consistent PNPID match handling
  2013-03-26 13:11 ` [PATCH 0/3] ACPI: Provide consistent PNPID match handling Rafael J. Wysocki
@ 2013-03-26 14:42   ` Toshi Kani
  0 siblings, 0 replies; 6+ messages in thread
From: Toshi Kani @ 2013-03-26 14:42 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: linux-acpi, linux-kernel, yinghai, jiang.liu, isimatu.yasuaki

On Tue, 2013-03-26 at 14:11 +0100, Rafael J. Wysocki wrote:
> On Monday, March 04, 2013 02:30:40 PM Toshi Kani wrote:
> > When installing/removing a notify handler to/from an ACPI device
> > object, ACPI core tries to match its associated scan handler to
> > see if it supports hotplug.  However, the matching logic of the
> > notify handler is different from the matching logic of attaching
> > a scan handler to an ACPI device object.  This inconsistency can
> > lead a mismatch and prevents ACPI scan handlers from supporting
> > non-HID devices, such as processor objects.
> > 
> > This patchset first updates PNPID setup interfaces to be independent
> > from acpi_device, and then updates the matching logic of the notify
> > handlers to be consistent with the attach handling.
> > 
> > This patchset is based on linux-pm.git/bleeding-edge.
> 
> All patches in the series applied to linux-pm.git/linux-next.

Great!  Thanks Rafael!
-Toshi


> 
> Thanks,
> Rafael
> 
> 
> > ---
> > Toshi Kani (3):
> >   ACPI: Remove acpi_device dependency in acpi_device_set_id()
> >   ACPI: Update PNPID set/free interfaces
> >   ACPI: Update PNPID match handling for notify
> > 
> > ---
> >  drivers/acpi/internal.h               |   2 +-
> >  drivers/acpi/power.c                  |   2 +-
> >  drivers/acpi/scan.c                   | 203 +++++++++++++++++++---------------
> >  drivers/acpi/video_detect.c           |  25 ++---
> >  drivers/gpu/drm/i915/intel_opregion.c |   4 +-
> >  include/acpi/acpi_bus.h               |  14 ++-
> >  include/linux/acpi.h                  |   4 +-
> >  7 files changed, 138 insertions(+), 116 deletions(-)
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2013-03-26 14:42 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-04 21:30 [PATCH 0/3] ACPI: Provide consistent PNPID match handling Toshi Kani
2013-03-04 21:30 ` [PATCH 1/3] ACPI: Remove acpi_device dependency in acpi_device_set_id() Toshi Kani
2013-03-04 21:30 ` [PATCH 2/3] ACPI: Update PNPID set/free interfaces Toshi Kani
2013-03-04 21:30 ` [PATCH 3/3] ACPI: Update PNPID match handling for notify Toshi Kani
2013-03-26 13:11 ` [PATCH 0/3] ACPI: Provide consistent PNPID match handling Rafael J. Wysocki
2013-03-26 14:42   ` Toshi Kani

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.