Skip to contentSkip to conversation

ACPI: sysfs eject support for container

PATCH In review Toshi Kani 2 participants 7 messages Feb 6, 2013 – Feb 8, 2013

Subsystems (2)
lore
Share & tools
lore

Toshi Kani

author
#0 lore raw

cover ACPI: sysfs eject support for container

This patchset enables sysfs eject for ACPI scan drivers and registers the ACPI container driver as an ACPI scan driver. This patchset is the one I mentioned in my following reply.

Toshi

Re: [PATCH 2/2] ACPI / scan: Simplify container driver

Quoted 9 lines · Rafael J. Wysocki

From: Rafael J. Wysocki <[email protected]>

The only useful thing that the ACPI container driver does is to install system notify handlers for all container and module device objects it finds in the namespace. The driver structure, acpi_container_driver, and the data structures created by its .add() callback are in fact not used by the driver, so remove them entirely.

Quoted 6 lines

It also makes a little sense to build that driver as a module, so make it non-modular and add its initialization to the namespace scanning code.

In addition to that, make the namespace walk callback used for installing the notify handlers more straightforward.

I think the container driver needs to be registered as an ACPI scan driver so that sysfs eject will continue to work for container devices, such as ACPI0004:XX/eject. Since the container driver does not support ACPI eject notification (and we have been discussing how system device hot-plug should work), this sysfs eject is the only way to eject a container device at this point. I will send an update patchset that applies on top of this patch.

author
#1 lore raw

PATCH 1/2 ACPI: sysfs eject support for ACPI scan handlers

Changed sysfs eject, acpi_eject_store(), to support ACPI scan handlers.

---
 drivers/acpi/scan.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/acpi/scan.c +1 -1
index cfd7a69..3ff632e 100644
@@ -203,7 +203,7 @@ acpi_eject_store(struct device *d, struct device_attribute *attr,
 		return -EINVAL;
 	}
 #ifndef FORCE_EJECT
-	if (acpi_device->driver == NULL) {
+	if (!acpi_device->driver && !acpi_device->handler) {
 		ret = -ENODEV;
 		goto err;
 	}
#2 lore raw

Re: [PATCH 01/02] ACPI: sysfs eject support for ACPI scan handlers

Hi Toshi,

Quoted 12 lines · Toshi Kani

Changed sysfs eject, acpi_eject_store(), to support ACPI scan handlers.

---
  drivers/acpi/scan.c |    2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/acpi/scan.c +0 -0
index cfd7a69..3ff632e 100644

drivers/acpi/scan.c acpi_eject_store(struct device *d, struct device_attribute *attr, · line 207

Quoted 6 lines
drivers/acpi/scan.c +1 -1
@@ -203,7 +203,7 @@ acpi_eject_store(struct device *d, struct device_attribute *attr,
  		return -EINVAL;
  	}
  #ifndef FORCE_EJECT
 
-	if (acpi_device->driver == NULL) {
+	if (!acpi_device->driver && !acpi_device->handler) {

I don't understand the fix.

The if sentence becomes true, when both acpi_device->driver and acpi_device->handler are NULL. It means that acpi_eject_store() runs if either acpi_device->driver or acpi_device->handler has pointer. Is it O.K.?

I think it should be if (!acpi_device->driver || !acpi_device->handler).

Thanks,
Yasuaki Ishimatsu

Quoted 8 lines
drivers/acpi/scan.c +0 -0
  		ret = -ENODEV;
  		goto err;

}
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

author
#3 lore raw

Re: [PATCH 01/02] ACPI: sysfs eject support for ACPI scan handlers

Quoted 19 lines · Yasuaki Ishimatsu

Hi Toshi,

Quoted 15 lines · Toshi Kani

Changed sysfs eject, acpi_eject_store(), to support ACPI scan handlers.

---
  drivers/acpi/scan.c |    2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/acpi/scan.c +0 -0
index cfd7a69..3ff632e 100644
@@ -203,7 +203,7 @@ acpi_eject_store(struct device *d, struct device_attribute *attr,
  		return -EINVAL;
  	}
  #ifndef FORCE_EJECT
Quoted 8 lines

drivers/acpi/scan.c acpi_eject_store(struct device *d, struct device_attribute *attr, · line 206

Quoted 2 lines
drivers/acpi/scan.c +1 -1
-	if (acpi_device->driver == NULL) {
+	if (!acpi_device->driver && !acpi_device->handler) {

I don't understand the fix.

The if sentence becomes true, when both acpi_device->driver and acpi_device->handler are NULL. It means that acpi_eject_store() runs if either acpi_device->driver or acpi_device->handler has pointer. Is it O.K.?

Yes.

Quoted 1 line

I think it should be if (!acpi_device->driver || !acpi_device->handler).

No, the condition has to be "&&" because an acpi_device is _either_ bound to an ACPI driver or an ACPI scan handler.

Thanks,
-Toshi

#4 lore raw

Re: [PATCH 01/02] ACPI: sysfs eject support for ACPI scan handlers

Quoted 29 lines · Toshi Kani
Quoted 19 lines · Yasuaki Ishimatsu

Hi Toshi,

Quoted 15 lines · Toshi Kani

Changed sysfs eject, acpi_eject_store(), to support ACPI scan handlers.

---
   drivers/acpi/scan.c |    2 +-
   1 file changed, 1 insertion(+), 1 deletion(-)
drivers/acpi/scan.c +0 -0
index cfd7a69..3ff632e 100644
@@ -203,7 +203,7 @@ acpi_eject_store(struct device *d, struct device_attribute *attr,
   		return -EINVAL;
   	}
   #ifndef FORCE_EJECT
Quoted 8 lines

drivers/acpi/scan.c acpi_eject_store(struct device *d, struct device_attribute *attr, · line 206

Quoted 2 lines
drivers/acpi/scan.c +1 -1
-	if (acpi_device->driver == NULL) {
+	if (!acpi_device->driver && !acpi_device->handler) {

I don't understand the fix.

The if sentence becomes true, when both acpi_device->driver and acpi_device->handler are NULL. It means that acpi_eject_store() runs if either acpi_device->driver or acpi_device->handler has pointer. Is it O.K.?

Quoted 6 lines

Yes.

Quoted 1 line

I think it should be if (!acpi_device->driver || !acpi_device->handler).

No, the condition has to be "&&" because an acpi_device is _either_ bound to an ACPI driver or an ACPI scan handler.

Thank you for you clarification. I understood it.

Thanks,
Yasuaki Ishimatsu

Quoted 5 lines

Thanks,
-Toshi

author
#5 lore raw

Re: [PATCH 01/02] ACPI: sysfs eject support for ACPI scan handlers

Quoted 32 lines · Yasuaki Ishimatsu
Quoted 31 lines · Toshi Kani
Quoted 19 lines · Yasuaki Ishimatsu

Hi Toshi,

Quoted 15 lines · Toshi Kani

Changed sysfs eject, acpi_eject_store(), to support ACPI scan handlers.

---
   drivers/acpi/scan.c |    2 +-
   1 file changed, 1 insertion(+), 1 deletion(-)
drivers/acpi/scan.c +0 -0
index cfd7a69..3ff632e 100644
@@ -203,7 +203,7 @@ acpi_eject_store(struct device *d, struct device_attribute *attr,
   		return -EINVAL;
   	}
   #ifndef FORCE_EJECT
Quoted 8 lines

drivers/acpi/scan.c acpi_eject_store(struct device *d, struct device_attribute *attr, · line 206

Quoted 2 lines
drivers/acpi/scan.c +1 -1
-	if (acpi_device->driver == NULL) {
+	if (!acpi_device->driver && !acpi_device->handler) {

I don't understand the fix.

The if sentence becomes true, when both acpi_device->driver and acpi_device->handler are NULL. It means that acpi_eject_store() runs if either acpi_device->driver or acpi_device->handler has pointer. Is it O.K.?

Yes.

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

I think it should be if (!acpi_device->driver || !acpi_device->handler).

No, the condition has to be "&&" because an acpi_device is _either_ bound to an ACPI driver or an ACPI scan handler.

Thank you for you clarification. I understood it.

Thanks Yasuaki!
-Toshi

Quoted 11 lines

Thanks,
Yasuaki Ishimatsu

Quoted 5 lines

Thanks,
-Toshi

author
#6 lore raw

PATCH 2/2 ACPI: Register container drv as scan driver

In reply to Toshi Kani

Changed to register the ACPI container driver as an ACPI scan driver so that sysfs eject of container devices works.

Fixed a typo in the acpi_container_init() prototype definition. Removed struct acpi_container, which is no longer used.

---

This patch applies on top of the patch below.
https://lkml.org/lkml/2013/2/3/318

---
 drivers/acpi/container.c |   23 +++++++++++++++++++++++
 drivers/acpi/internal.h  |    2 +-
 include/acpi/container.h |    8 --------
 3 files changed, 24 insertions(+), 9 deletions(-)
drivers/acpi/container.c +23 -0
index bcde1f3..f493180 100644
@@ -41,6 +41,10 @@
 #define _COMPONENT			ACPI_CONTAINER_COMPONENT
 ACPI_MODULE_NAME("container");
 
+static int container_device_attach(struct acpi_device *device,
+				const struct acpi_device_id *not_used);
+static void container_device_detach(struct acpi_device *device);
+
 static const struct acpi_device_id container_device_ids[] = {
 	{"ACPI0004", 0},
 	{"PNP0A05", 0},
@@ -48,6 +52,12 @@ static const struct acpi_device_id container_device_ids[] = {
 	{"", 0},
 };
 
+static struct acpi_scan_handler container_device_handler = {
+	.ids = container_device_ids,
+	.attach = container_device_attach,
+	.detach = container_device_detach,
+};
+
 static int is_device_present(acpi_handle handle)
 {
 	acpi_handle temp;
@@ -66,6 +76,17 @@ static int is_device_present(acpi_handle handle)
 	return ((sta & ACPI_STA_DEVICE_PRESENT) == ACPI_STA_DEVICE_PRESENT);
 }
 
+static int container_device_attach(struct acpi_device *device,
+				const struct acpi_device_id *not_used)
+{
+	return 1;
+}
+
+static void container_device_detach(struct acpi_device *device)
+{
+	return;
+}
+
 static void container_notify_cb(acpi_handle handle, u32 type, void *context)
 {
 	struct acpi_device *device = NULL;
@@ -167,4 +188,6 @@ void __init acpi_container_init(void)
 	acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
 			    acpi_container_register_notify_handler, NULL,
 			    NULL, NULL);
+
+	acpi_scan_add_handler(&container_device_handler);
 }
drivers/acpi/internal.h +1 -1
index 78fbf26..cbc0638 100644
@@ -40,7 +40,7 @@ void acpi_memory_hotplug_init(void);
 #else
 static inline void acpi_memory_hotplug_init(void) {}
 #endif
-#ifdef ACPI_CONTAINER
+#ifdef CONFIG_ACPI_CONTAINER
 void acpi_container_init(void);
 #else
 static inline void acpi_container_init(void) {}
include/acpi/container.h +0 -8
index a703f14..0a464d2 100644
@@ -1,12 +1,4 @@
 #ifndef __ACPI_CONTAINER_H
 #define __ACPI_CONTAINER_H
 
-#include <linux/kernel.h>
-
-struct acpi_container {
-	acpi_handle handle;
-	unsigned long sun;
-	int state;
-};
-
 #endif				/* __ACPI_CONTAINER_H */