Skip to contentSkip to conversation

ACPI: remove .start() and .stop() methods

PATCH In review Bjorn Helgaas 3 participants 13 messages Jun 22, 2009 – Jun 29, 2009

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v2 cover ACPI: remove .start() and .stop() methods

From: Bjorn Helgaas <[email protected]>

These patches remove several .start() methods (by folding them into .add() methods) and a .stop() method (by folding it into .remove()). There are no remaining .stop() methods, so I also removed it from the driver_ops structure.

This simplifies the ACPI driver structure and will make it easier to support hotplug in the Linux/ACPI core.

They also remove the KOBJ_ONLINE and KOBJ_OFFLINE events generated by the processor driver for CPU hotplug events. As far as I know, these events are unused.

I don't have a way to test most of these changes, unfortunately, so I'd welcome any feedback or testing reports.

These apply to the acpi-test branch.

---

Bjorn Helgaas (9):
ACPI: processor: remove KOBJ_ONLINE/KOBJ_OFFLINE events
ACPI: processor: clean up in acpi_processor_start() error exits
ACPI: processor: move acpi_processor_start() after acpi_processor_add()
ACPI: processor: remove .start() method
ACPI: memory hotplug: remove .start() method
ACPI: EC: move acpi_ec_start() after acpi_ec_add()
ACPI: EC: remove .start() method
ACPI: EC: remove .stop() method
ACPI: remove unused acpi_device_ops .stop method

 drivers/acpi/acpi_memhotplug.c |   40 +++----
 drivers/acpi/ec.c              |  118 ++++++++--------------
 drivers/acpi/processor_core.c  |  219 +++++++++++++++++-----------------------
 drivers/acpi/scan.c            |    5 -
 include/acpi/acpi_bus.h        |    2 
 5 files changed, 153 insertions(+), 231 deletions(-)
Signature · 1 line
Bjorn
#1 lore raw

PATCH v2 1/9 ACPI: processor: remove KOBJ_ONLINE/KOBJ_OFFLINE events

This patch removes the KOBJ_ONLINE/KOBJ_OFFLINE events the driver used to generate for CPU hotplug. As far as I know, nobody consumes these. The driver core still generates KOBJ_ADD and KOBJ_REMOVE, of course.

CC Venkatesh Pallipadi <[email protected]>
CC Zhao Yakui <[email protected]>
CC Matthew Garrett <[email protected]>
CC Thomas Renninger <[email protected]>
CC Dave Jones <[email protected]>
CC Kay Sievers <[email protected]>
CC Greg Kroah-Hartman <[email protected]>
---
 drivers/acpi/processor_core.c |   16 +---------------
 1 files changed, 1 insertions(+), 15 deletions(-)
drivers/acpi/processor_core.c +1 -15
index e3d15f9..d8e210a 100644
@@ -954,9 +954,6 @@ int acpi_processor_device_add(acpi_handle handle, struct acpi_device **device)
 	if (!pr)
 		return -ENODEV;
 
-	if ((pr->id >= 0) && (pr->id < nr_cpu_ids)) {
-		kobject_uevent(&(*device)->dev.kobj, KOBJ_ONLINE);
-	}
 	return 0;
 }
 
@@ -993,18 +990,10 @@ static void __ref acpi_processor_hotplug_notify(acpi_handle handle,
 			break;
 		}
 
-		if (pr->id >= 0 && (pr->id < nr_cpu_ids)) {
-			kobject_uevent(&device->dev.kobj, KOBJ_OFFLINE);
-			break;
-		}
-
 		result = acpi_processor_start(device);
-		if ((!result) && ((pr->id >= 0) && (pr->id < nr_cpu_ids))) {
-			kobject_uevent(&device->dev.kobj, KOBJ_ONLINE);
-		} else {
+		if (result)
 			printk(KERN_ERR PREFIX "Device [%s] failed to start\n",
 				    acpi_device_bid(device));
-		}
 		break;
 	case ACPI_NOTIFY_EJECT_REQUEST:
 		ACPI_DEBUG_PRINT((ACPI_DB_INFO,
@@ -1021,9 +1010,6 @@ static void __ref acpi_processor_hotplug_notify(acpi_handle handle,
 				    "Driver data is NULL, dropping EJECT\n");
 			return;
 		}
-
-		if ((pr->id < nr_cpu_ids) && (cpu_present(pr->id)))
-			kobject_uevent(&device->dev.kobj, KOBJ_OFFLINE);
 		break;
 	default:
 		ACPI_DEBUG_PRINT((ACPI_DB_INFO,
#2 lore raw

PATCH v2 2/9 ACPI: processor: clean up in acpi_processor_start() error exits

In reply to Bjorn Helgaas

We used to leave crud around if things failed in acpi_processor_start(). This patch cleans up as much as we can before returning.

---
 drivers/acpi/processor_core.c |   29 ++++++++++++++++++++++-------
 1 files changed, 22 insertions(+), 7 deletions(-)
drivers/acpi/processor_core.c +22 -7
index d8e210a..7f082b6 100644
@@ -722,11 +722,13 @@ static int __cpuinit acpi_processor_start(struct acpi_device *device)
 
 	result = acpi_processor_add_fs(device);
 	if (result)
-		goto end;
+		return result;
 
 	sysdev = get_cpu_sysdev(pr->id);
-	if (sysfs_create_link(&device->dev.kobj, &sysdev->kobj, "sysdev"))
-		return -EFAULT;
+	if (sysfs_create_link(&device->dev.kobj, &sysdev->kobj, "sysdev")) {
+		result = -EFAULT;
+		goto err_remove_fs;
+	}
 
 	/* _PDC call should be done before doing anything else (if reqd.). */
 	arch_acpi_processor_init_pdc(pr);
@@ -746,7 +748,7 @@ static int __cpuinit acpi_processor_start(struct acpi_device *device)
 						&processor_cooling_ops);
 	if (IS_ERR(pr->cdev)) {
 		result = PTR_ERR(pr->cdev);
-		goto end;
+		goto err_power_exit;
 	}
 
 	dev_info(&device->dev, "registered as cooling_device%d\n",
@@ -755,13 +757,17 @@ static int __cpuinit acpi_processor_start(struct acpi_device *device)
 	result = sysfs_create_link(&device->dev.kobj,
 				   &pr->cdev->device.kobj,
 				   "thermal_cooling");
-	if (result)
+	if (result) {
 		printk(KERN_ERR PREFIX "Create sysfs link\n");
+		goto err_thermal_unregister;
+	}
 	result = sysfs_create_link(&pr->cdev->device.kobj,
 				   &device->dev.kobj,
 				   "device");
-	if (result)
+	if (result) {
 		printk(KERN_ERR PREFIX "Create sysfs link\n");
+		goto err_remove_sysfs;
+	}
 
 	if (pr->flags.throttling) {
 		printk(KERN_INFO PREFIX "%s [%s] (supports",
@@ -770,7 +776,16 @@ static int __cpuinit acpi_processor_start(struct acpi_device *device)
 		printk(")\n");
 	}
 
-      end:
+	return 0;
+
+err_remove_sysfs:
+	sysfs_remove_link(&device->dev.kobj, "thermal_cooling");
+err_thermal_unregister:
+	thermal_cooling_device_unregister(pr->cdev);
+err_power_exit:
+	acpi_processor_power_exit(pr, device);
+err_remove_fs:
+	acpi_processor_remove_fs(device);
 
 	return result;
 }
#3 lore raw

PATCH v2 3/9 ACPI: processor: move acpi_processor_start() after acpi_processor_add()

In reply to Bjorn Helgaas

Move acpi_processor_start() to just after acpi_processor_add(). A subsequent patch will merge them.

Code movement only; no functional change.

CC Venkatesh Pallipadi <[email protected]>
CC Zhao Yakui <[email protected]>
---
 drivers/acpi/processor_core.c |  168 +++++++++++++++++++++--------------------
 1 files changed, 84 insertions(+), 84 deletions(-)
drivers/acpi/processor_core.c +84 -84
index 7f082b6..393695f 100644
@@ -689,6 +689,90 @@ static int acpi_processor_get_info(struct acpi_device *device)
 
 static DEFINE_PER_CPU(void *, processor_device_array);
 
+static void acpi_processor_notify(struct acpi_device *device, u32 event)
+{
+	struct acpi_processor *pr = acpi_driver_data(device);
+	int saved;
+
+	if (!pr)
+		return;
+
+	switch (event) {
+	case ACPI_PROCESSOR_NOTIFY_PERFORMANCE:
+		saved = pr->performance_platform_limit;
+		acpi_processor_ppc_has_changed(pr);
+		if (saved == pr->performance_platform_limit)
+			break;
+		acpi_bus_generate_proc_event(device, event,
+					pr->performance_platform_limit);
+		acpi_bus_generate_netlink_event(device->pnp.device_class,
+						  dev_name(&device->dev), event,
+						  pr->performance_platform_limit);
+		break;
+	case ACPI_PROCESSOR_NOTIFY_POWER:
+		acpi_processor_cst_has_changed(pr);
+		acpi_bus_generate_proc_event(device, event, 0);
+		acpi_bus_generate_netlink_event(device->pnp.device_class,
+						  dev_name(&device->dev), event, 0);
+		break;
+	case ACPI_PROCESSOR_NOTIFY_THROTTLING:
+		acpi_processor_tstate_has_changed(pr);
+		acpi_bus_generate_proc_event(device, event, 0);
+		acpi_bus_generate_netlink_event(device->pnp.device_class,
+						  dev_name(&device->dev), event, 0);
+	default:
+		ACPI_DEBUG_PRINT((ACPI_DB_INFO,
+				  "Unsupported event [0x%x]\n", event));
+		break;
+	}
+
+	return;
+}
+
+static int acpi_cpu_soft_notify(struct notifier_block *nfb,
+		unsigned long action, void *hcpu)
+{
+	unsigned int cpu = (unsigned long)hcpu;
+	struct acpi_processor *pr = per_cpu(processors, cpu);
+
+	if (action == CPU_ONLINE && pr) {
+		acpi_processor_ppc_has_changed(pr);
+		acpi_processor_cst_has_changed(pr);
+		acpi_processor_tstate_has_changed(pr);
+	}
+	return NOTIFY_OK;
+}
+
+static struct notifier_block acpi_cpu_notifier =
+{
+	    .notifier_call = acpi_cpu_soft_notify,
+};
+
+static int acpi_processor_add(struct acpi_device *device)
+{
+	struct acpi_processor *pr = NULL;
+
+
+	if (!device)
+		return -EINVAL;
+
+	pr = kzalloc(sizeof(struct acpi_processor), GFP_KERNEL);
+	if (!pr)
+		return -ENOMEM;
+
+	if (!zalloc_cpumask_var(&pr->throttling.shared_cpu_map, GFP_KERNEL)) {
+		kfree(pr);
+		return -ENOMEM;
+	}
+
+	pr->handle = device->handle;
+	strcpy(acpi_device_name(device), ACPI_PROCESSOR_DEVICE_NAME);
+	strcpy(acpi_device_class(device), ACPI_PROCESSOR_CLASS);
+	device->driver_data = pr;
+
+	return 0;
+}
+
 static int __cpuinit acpi_processor_start(struct acpi_device *device)
 {
 	int result = 0;
@@ -790,90 +874,6 @@ err_remove_fs:
 	return result;
 }
 
-static void acpi_processor_notify(struct acpi_device *device, u32 event)
-{
-	struct acpi_processor *pr = acpi_driver_data(device);
-	int saved;
-
-	if (!pr)
-		return;
-
-	switch (event) {
-	case ACPI_PROCESSOR_NOTIFY_PERFORMANCE:
-		saved = pr->performance_platform_limit;
-		acpi_processor_ppc_has_changed(pr);
-		if (saved == pr->performance_platform_limit)
-			break;
-		acpi_bus_generate_proc_event(device, event,
-					pr->performance_platform_limit);
-		acpi_bus_generate_netlink_event(device->pnp.device_class,
-						  dev_name(&device->dev), event,
-						  pr->performance_platform_limit);
-		break;
-	case ACPI_PROCESSOR_NOTIFY_POWER:
-		acpi_processor_cst_has_changed(pr);
-		acpi_bus_generate_proc_event(device, event, 0);
-		acpi_bus_generate_netlink_event(device->pnp.device_class,
-						  dev_name(&device->dev), event, 0);
-		break;
-	case ACPI_PROCESSOR_NOTIFY_THROTTLING:
-		acpi_processor_tstate_has_changed(pr);
-		acpi_bus_generate_proc_event(device, event, 0);
-		acpi_bus_generate_netlink_event(device->pnp.device_class,
-						  dev_name(&device->dev), event, 0);
-	default:
-		ACPI_DEBUG_PRINT((ACPI_DB_INFO,
-				  "Unsupported event [0x%x]\n", event));
-		break;
-	}
-
-	return;
-}
-
-static int acpi_cpu_soft_notify(struct notifier_block *nfb,
-		unsigned long action, void *hcpu)
-{
-	unsigned int cpu = (unsigned long)hcpu;
-	struct acpi_processor *pr = per_cpu(processors, cpu);
-
-	if (action == CPU_ONLINE && pr) {
-		acpi_processor_ppc_has_changed(pr);
-		acpi_processor_cst_has_changed(pr);
-		acpi_processor_tstate_has_changed(pr);
-	}
-	return NOTIFY_OK;
-}
-
-static struct notifier_block acpi_cpu_notifier =
-{
-	    .notifier_call = acpi_cpu_soft_notify,
-};
-
-static int acpi_processor_add(struct acpi_device *device)
-{
-	struct acpi_processor *pr = NULL;
-
-
-	if (!device)
-		return -EINVAL;
-
-	pr = kzalloc(sizeof(struct acpi_processor), GFP_KERNEL);
-	if (!pr)
-		return -ENOMEM;
-
-	if (!zalloc_cpumask_var(&pr->throttling.shared_cpu_map, GFP_KERNEL)) {
-		kfree(pr);
-		return -ENOMEM;
-	}
-
-	pr->handle = device->handle;
-	strcpy(acpi_device_name(device), ACPI_PROCESSOR_DEVICE_NAME);
-	strcpy(acpi_device_class(device), ACPI_PROCESSOR_CLASS);
-	device->driver_data = pr;
-
-	return 0;
-}
-
 static int acpi_processor_remove(struct acpi_device *device, int type)
 {
 	struct acpi_processor *pr = NULL;
#4 lore raw

PATCH v2 4/9 ACPI: processor: remove .start() method

In reply to Bjorn Helgaas

This patch folds the .start() method into .add().

acpi_processor_start() is always called immediately after acpi_processor_add(), so there's really no point in having them be separate methods.

---
 drivers/acpi/processor_core.c |   44 +++++++----------------------------------
 1 files changed, 7 insertions(+), 37 deletions(-)
drivers/acpi/processor_core.c +7 -37
index 393695f..af292bf 100644
@@ -79,7 +79,6 @@ MODULE_DESCRIPTION("ACPI Processor Driver");
 MODULE_LICENSE("GPL");
 
 static int acpi_processor_add(struct acpi_device *device);
-static int acpi_processor_start(struct acpi_device *device);
 static int acpi_processor_remove(struct acpi_device *device, int type);
 static int acpi_processor_info_open_fs(struct inode *inode, struct file *file);
 static void acpi_processor_notify(struct acpi_device *device, u32 event);
@@ -101,7 +100,6 @@ static struct acpi_driver acpi_processor_driver = {
 	.ops = {
 		.add = acpi_processor_add,
 		.remove = acpi_processor_remove,
-		.start = acpi_processor_start,
 		.suspend = acpi_processor_suspend,
 		.resume = acpi_processor_resume,
 		.notify = acpi_processor_notify,
@@ -751,10 +749,8 @@ static struct notifier_block acpi_cpu_notifier =
 static int acpi_processor_add(struct acpi_device *device)
 {
 	struct acpi_processor *pr = NULL;
-
-
-	if (!device)
-		return -EINVAL;
+	int result = 0;
+	struct sys_device *sysdev;
 
 	pr = kzalloc(sizeof(struct acpi_processor), GFP_KERNEL);
 	if (!pr)
@@ -770,17 +766,6 @@ static int acpi_processor_add(struct acpi_device *device)
 	strcpy(acpi_device_class(device), ACPI_PROCESSOR_CLASS);
 	device->driver_data = pr;
 
-	return 0;
-}
-
-static int __cpuinit acpi_processor_start(struct acpi_device *device)
-{
-	int result = 0;
-	struct acpi_processor *pr;
-	struct sys_device *sysdev;
-
-	pr = acpi_driver_data(device);
-
 	result = acpi_processor_get_info(device);
 	if (result) {
 		/* Processor is physically not present */
@@ -798,7 +783,8 @@ static int __cpuinit acpi_processor_start(struct acpi_device *device)
 	    per_cpu(processor_device_array, pr->id) != device) {
 		printk(KERN_WARNING "BIOS reported wrong ACPI id "
 			"for the processor\n");
-		return -ENODEV;
+		result = -ENODEV;
+		goto err_free_cpumask;
 	}
 	per_cpu(processor_device_array, pr->id) = device;
 
@@ -806,7 +792,7 @@ static int __cpuinit acpi_processor_start(struct acpi_device *device)
 
 	result = acpi_processor_add_fs(device);
 	if (result)
-		return result;
+		goto err_free_cpumask;
 
 	sysdev = get_cpu_sysdev(pr->id);
 	if (sysfs_create_link(&device->dev.kobj, &sysdev->kobj, "sysdev")) {
@@ -870,6 +856,8 @@ err_power_exit:
 	acpi_processor_power_exit(pr, device);
 err_remove_fs:
 	acpi_processor_remove_fs(device);
+err_free_cpumask:
+	free_cpumask_var(pr->throttling.shared_cpu_map);
 
 	return result;
 }
@@ -948,7 +936,6 @@ int acpi_processor_device_add(acpi_handle handle, struct acpi_device **device)
 {
 	acpi_handle phandle;
 	struct acpi_device *pdev;
-	struct acpi_processor *pr;
 
 
 	if (acpi_get_parent(handle, &phandle)) {
@@ -963,12 +950,6 @@ int acpi_processor_device_add(acpi_handle handle, struct acpi_device **device)
 		return -ENODEV;
 	}
 
-	acpi_bus_start(*device);
-
-	pr = acpi_driver_data(*device);
-	if (!pr)
-		return -ENODEV;
-
 	return 0;
 }
 
@@ -998,17 +979,6 @@ static void __ref acpi_processor_hotplug_notify(acpi_handle handle,
 					    "Unable to add the device\n");
 			break;
 		}
-
-		pr = acpi_driver_data(device);
-		if (!pr) {
-			printk(KERN_ERR PREFIX "Driver data is NULL\n");
-			break;
-		}
-
-		result = acpi_processor_start(device);
-		if (result)
-			printk(KERN_ERR PREFIX "Device [%s] failed to start\n",
-				    acpi_device_bid(device));
 		break;
 	case ACPI_NOTIFY_EJECT_REQUEST:
 		ACPI_DEBUG_PRINT((ACPI_DB_INFO,
#5 lore raw

PATCH v2 5/9 ACPI: memory hotplug: remove .start() method

In reply to Bjorn Helgaas

This patch folds the .start() method into .add().

The .start() method is called in two paths: boot-time device enumeration and run-time node addition, currently via container_device_add(). In both cases, .start() is called immediately after .add(), so there's no reason to make them separate methods.

---
 drivers/acpi/acpi_memhotplug.c |   40 ++++++++++++++--------------------------
 1 files changed, 14 insertions(+), 26 deletions(-)
drivers/acpi/acpi_memhotplug.c +14 -26
index 7a0f4aa..a8d9d8f 100644
@@ -50,7 +50,6 @@ MODULE_LICENSE("GPL");
 
 static int acpi_memory_device_add(struct acpi_device *device);
 static int acpi_memory_device_remove(struct acpi_device *device, int type);
-static int acpi_memory_device_start(struct acpi_device *device);
 
 static const struct acpi_device_id memory_device_ids[] = {
 	{ACPI_MEMORY_DEVICE_HID, 0},
@@ -65,7 +64,6 @@ static struct acpi_driver acpi_memory_device_driver = {
 	.ops = {
 		.add = acpi_memory_device_add,
 		.remove = acpi_memory_device_remove,
-		.start = acpi_memory_device_start,
 		},
 };
 
@@ -415,28 +413,6 @@ static int acpi_memory_device_add(struct acpi_device *device)
 
 	printk(KERN_DEBUG "%s \n", acpi_device_name(device));
 
-	return result;
-}
-
-static int acpi_memory_device_remove(struct acpi_device *device, int type)
-{
-	struct acpi_memory_device *mem_device = NULL;
-
-
-	if (!device || !acpi_driver_data(device))
-		return -EINVAL;
-
-	mem_device = acpi_driver_data(device);
-	kfree(mem_device);
-
-	return 0;
-}
-
-static int acpi_memory_device_start (struct acpi_device *device)
-{
-	struct acpi_memory_device *mem_device;
-	int result = 0;
-
 	/*
 	 * Early boot code has recognized memory area by EFI/E820.
 	 * If DSDT shows these memory devices on boot, hotplug is not necessary
@@ -446,8 +422,6 @@ static int acpi_memory_device_start (struct acpi_device *device)
 	if (!acpi_hotmem_initialized)
 		return 0;
 
-	mem_device = acpi_driver_data(device);
-
 	if (!acpi_memory_check_device(mem_device)) {
 		/* call add_memory func */
 		result = acpi_memory_enable_device(mem_device);
@@ -458,6 +432,20 @@ static int acpi_memory_device_start (struct acpi_device *device)
 	return result;
 }
 
+static int acpi_memory_device_remove(struct acpi_device *device, int type)
+{
+	struct acpi_memory_device *mem_device = NULL;
+
+
+	if (!device || !acpi_driver_data(device))
+		return -EINVAL;
+
+	mem_device = acpi_driver_data(device);
+	kfree(mem_device);
+
+	return 0;
+}
+
 /*
  * Helper function to check for memory device
  */
#6 lore raw

PATCH v2 6/9 ACPI: EC: move acpi_ec_start() after acpi_ec_add()

In reply to Bjorn Helgaas

This patch rearranges ec_install_handlers() and acpi_ec_start() so acpi_ec_start() ends up just after acpi_ec_add(). A subsequent patch will merge them.

Code movement only; no functional change.

CC Alexey Starikovskiy <[email protected]>
---
 drivers/acpi/ec.c |  112 +++++++++++++++++++++++++++--------------------------
 1 files changed, 56 insertions(+), 56 deletions(-)
drivers/acpi/ec.c +56 -56
index 391f331..8b387a4 100644
@@ -788,6 +788,42 @@ ec_parse_device(acpi_handle handle, u32 Level, void *context, void **retval)
 	return AE_CTRL_TERMINATE;
 }
 
+static int ec_install_handlers(struct acpi_ec *ec)
+{
+	acpi_status status;
+	if (test_bit(EC_FLAGS_HANDLERS_INSTALLED, &ec->flags))
+		return 0;
+	status = acpi_install_gpe_handler(NULL, ec->gpe,
+				  ACPI_GPE_EDGE_TRIGGERED,
+				  &acpi_ec_gpe_handler, ec);
+	if (ACPI_FAILURE(status))
+		return -ENODEV;
+	acpi_set_gpe_type(NULL, ec->gpe, ACPI_GPE_TYPE_RUNTIME);
+	acpi_enable_gpe(NULL, ec->gpe);
+	status = acpi_install_address_space_handler(ec->handle,
+						    ACPI_ADR_SPACE_EC,
+						    &acpi_ec_space_handler,
+						    NULL, ec);
+	if (ACPI_FAILURE(status)) {
+		if (status == AE_NOT_FOUND) {
+			/*
+			 * Maybe OS fails in evaluating the _REG object.
+			 * The AE_NOT_FOUND error will be ignored and OS
+			 * continue to initialize EC.
+			 */
+			printk(KERN_ERR "Fail in evaluating the _REG object"
+				" of EC device. Broken bios is suspected.\n");
+		} else {
+			acpi_remove_gpe_handler(NULL, ec->gpe,
+				&acpi_ec_gpe_handler);
+			return -ENODEV;
+		}
+	}
+
+	set_bit(EC_FLAGS_HANDLERS_INSTALLED, &ec->flags);
+	return 0;
+}
+
 static void ec_remove_handlers(struct acpi_ec *ec)
 {
 	if (ACPI_FAILURE(acpi_remove_address_space_handler(ec->handle,
@@ -842,6 +878,26 @@ static int acpi_ec_add(struct acpi_device *device)
 	return 0;
 }
 
+static int acpi_ec_start(struct acpi_device *device)
+{
+	struct acpi_ec *ec;
+	int ret = 0;
+
+	if (!device)
+		return -EINVAL;
+
+	ec = acpi_driver_data(device);
+
+	if (!ec)
+		return -EINVAL;
+
+	ret = ec_install_handlers(ec);
+
+	/* EC is fully operational, allow queries */
+	clear_bit(EC_FLAGS_QUERY_PENDING, &ec->flags);
+	return ret;
+}
+
 static int acpi_ec_remove(struct acpi_device *device, int type)
 {
 	struct acpi_ec *ec;
@@ -888,62 +944,6 @@ ec_parse_io_ports(struct acpi_resource *resource, void *context)
 	return AE_OK;
 }
 
-static int ec_install_handlers(struct acpi_ec *ec)
-{
-	acpi_status status;
-	if (test_bit(EC_FLAGS_HANDLERS_INSTALLED, &ec->flags))
-		return 0;
-	status = acpi_install_gpe_handler(NULL, ec->gpe,
-				  ACPI_GPE_EDGE_TRIGGERED,
-				  &acpi_ec_gpe_handler, ec);
-	if (ACPI_FAILURE(status))
-		return -ENODEV;
-	acpi_set_gpe_type(NULL, ec->gpe, ACPI_GPE_TYPE_RUNTIME);
-	acpi_enable_gpe(NULL, ec->gpe);
-	status = acpi_install_address_space_handler(ec->handle,
-						    ACPI_ADR_SPACE_EC,
-						    &acpi_ec_space_handler,
-						    NULL, ec);
-	if (ACPI_FAILURE(status)) {
-		if (status == AE_NOT_FOUND) {
-			/*
-			 * Maybe OS fails in evaluating the _REG object.
-			 * The AE_NOT_FOUND error will be ignored and OS
-			 * continue to initialize EC.
-			 */
-			printk(KERN_ERR "Fail in evaluating the _REG object"
-				" of EC device. Broken bios is suspected.\n");
-		} else {
-			acpi_remove_gpe_handler(NULL, ec->gpe,
-				&acpi_ec_gpe_handler);
-			return -ENODEV;
-		}
-	}
-
-	set_bit(EC_FLAGS_HANDLERS_INSTALLED, &ec->flags);
-	return 0;
-}
-
-static int acpi_ec_start(struct acpi_device *device)
-{
-	struct acpi_ec *ec;
-	int ret = 0;
-
-	if (!device)
-		return -EINVAL;
-
-	ec = acpi_driver_data(device);
-
-	if (!ec)
-		return -EINVAL;
-
-	ret = ec_install_handlers(ec);
-
-	/* EC is fully operational, allow queries */
-	clear_bit(EC_FLAGS_QUERY_PENDING, &ec->flags);
-	return ret;
-}
-
 static int acpi_ec_stop(struct acpi_device *device, int type)
 {
 	struct acpi_ec *ec;
#7 lore raw

PATCH v2 7/9 ACPI: EC: remove .start() method

In reply to Bjorn Helgaas

This patch folds the .start() method into .add().

acpi_ec_start() is always called immediately after acpi_ec_add(), so there's no need to have it be a separate method.

---
 drivers/acpi/ec.c |   19 +------------------
 1 files changed, 1 insertions(+), 18 deletions(-)
drivers/acpi/ec.c +1 -18
index 8b387a4..1feedce 100644
@@ -838,9 +838,8 @@ static void ec_remove_handlers(struct acpi_ec *ec)
 static int acpi_ec_add(struct acpi_device *device)
 {
 	struct acpi_ec *ec = NULL;
+	int ret;
 
-	if (!device)
-		return -EINVAL;
 	strcpy(acpi_device_name(device), ACPI_EC_DEVICE_NAME);
 	strcpy(acpi_device_class(device), ACPI_EC_CLASS);
 
@@ -875,21 +874,6 @@ static int acpi_ec_add(struct acpi_device *device)
 			  ec->gpe, ec->command_addr, ec->data_addr);
 	pr_info(PREFIX "driver started in %s mode\n",
 		(test_bit(EC_FLAGS_GPE_MODE, &ec->flags))?"interrupt":"poll");
-	return 0;
-}
-
-static int acpi_ec_start(struct acpi_device *device)
-{
-	struct acpi_ec *ec;
-	int ret = 0;
-
-	if (!device)
-		return -EINVAL;
-
-	ec = acpi_driver_data(device);
-
-	if (!ec)
-		return -EINVAL;
 
 	ret = ec_install_handlers(ec);
 
@@ -1077,7 +1061,6 @@ static struct acpi_driver acpi_ec_driver = {
 	.ops = {
 		.add = acpi_ec_add,
 		.remove = acpi_ec_remove,
-		.start = acpi_ec_start,
 		.stop = acpi_ec_stop,
 		.suspend = acpi_ec_suspend,
 		.resume = acpi_ec_resume,
#8 lore raw

PATCH v2 8/9 ACPI: EC: remove .stop() method

In reply to Bjorn Helgaas

This patch folds the .stop() method into .remove().

acpi_ec_stop() is only called via acpi_device_probe() and acpi_device_remove(), and in both cases it is called immediately before acpi_ec_remove(), so there's no need to have it be a separate method.

---
 drivers/acpi/ec.c |   15 +--------------
 1 files changed, 1 insertions(+), 14 deletions(-)
drivers/acpi/ec.c +1 -14
index 1feedce..d6bf057 100644
@@ -891,6 +891,7 @@ static int acpi_ec_remove(struct acpi_device *device, int type)
 		return -EINVAL;
 
 	ec = acpi_driver_data(device);
+	ec_remove_handlers(ec);
 	mutex_lock(&ec->lock);
 	list_for_each_entry_safe(handler, tmp, &ec->list, node) {
 		list_del(&handler->node);
@@ -928,19 +929,6 @@ ec_parse_io_ports(struct acpi_resource *resource, void *context)
 	return AE_OK;
 }
 
-static int acpi_ec_stop(struct acpi_device *device, int type)
-{
-	struct acpi_ec *ec;
-	if (!device)
-		return -EINVAL;
-	ec = acpi_driver_data(device);
-	if (!ec)
-		return -EINVAL;
-	ec_remove_handlers(ec);
-
-	return 0;
-}
-
 int __init acpi_boot_ec_enable(void)
 {
 	if (!boot_ec || test_bit(EC_FLAGS_HANDLERS_INSTALLED, &boot_ec->flags))
@@ -1061,7 +1049,6 @@ static struct acpi_driver acpi_ec_driver = {
 	.ops = {
 		.add = acpi_ec_add,
 		.remove = acpi_ec_remove,
-		.stop = acpi_ec_stop,
 		.suspend = acpi_ec_suspend,
 		.resume = acpi_ec_resume,
 		},
#9 lore raw

PATCH v2 9/9 ACPI: remove unused acpi_device_ops .stop method

In reply to Bjorn Helgaas

No drivers use the .stop method, so remove it.

---
 drivers/acpi/scan.c     |    5 -----
 include/acpi/acpi_bus.h |    2 --
 2 files changed, 0 insertions(+), 7 deletions(-)
drivers/acpi/scan.c +0 -5
index c40515e..538bdbb 100644
@@ -430,9 +430,6 @@ static int acpi_device_probe(struct device * dev)
 		if (acpi_drv->ops.notify) {
 			ret = acpi_device_install_notify_handler(acpi_dev);
 			if (ret) {
-				if (acpi_drv->ops.stop)
-					acpi_drv->ops.stop(acpi_dev,
-						   acpi_dev->removal_type);
 				if (acpi_drv->ops.remove)
 					acpi_drv->ops.remove(acpi_dev,
 						     acpi_dev->removal_type);
@@ -456,8 +453,6 @@ static int acpi_device_remove(struct device * dev)
 	if (acpi_drv) {
 		if (acpi_drv->ops.notify)
 			acpi_device_remove_notify_handler(acpi_dev);
-		if (acpi_drv->ops.stop)
-			acpi_drv->ops.stop(acpi_dev, acpi_dev->removal_type);
 		if (acpi_drv->ops.remove)
 			acpi_drv->ops.remove(acpi_dev, acpi_dev->removal_type);
 	}
include/acpi/acpi_bus.h +0 -2
index c65e4ce..79a6c5e 100644
@@ -89,7 +89,6 @@ struct acpi_device;
 typedef int (*acpi_op_add) (struct acpi_device * device);
 typedef int (*acpi_op_remove) (struct acpi_device * device, int type);
 typedef int (*acpi_op_start) (struct acpi_device * device);
-typedef int (*acpi_op_stop) (struct acpi_device * device, int type);
 typedef int (*acpi_op_suspend) (struct acpi_device * device,
 				pm_message_t state);
 typedef int (*acpi_op_resume) (struct acpi_device * device);
@@ -106,7 +105,6 @@ struct acpi_device_ops {
 	acpi_op_add add;
 	acpi_op_remove remove;
 	acpi_op_start start;
-	acpi_op_stop stop;
 	acpi_op_suspend suspend;
 	acpi_op_resume resume;
 	acpi_op_bind bind;
reviewer
#10 lore raw
In reply to Bjorn Helgaas
Quoted 34 lines · Bjorn Helgaas

From: Bjorn Helgaas <[email protected]>

These patches remove several .start() methods (by folding them into .add() methods) and a .stop() method (by folding it into .remove()). There are no remaining .stop() methods, so I also removed it from the driver_ops structure.

This simplifies the ACPI driver structure and will make it easier to support hotplug in the Linux/ACPI core.

They also remove the KOBJ_ONLINE and KOBJ_OFFLINE events generated by the processor driver for CPU hotplug events. As far as I know,

these events are unused.

I don't have a way to test most of these changes, unfortunately, so I'd welcome any feedback or testing reports.

These apply to the acpi-test branch.

---

Bjorn Helgaas (9):
ACPI: processor: remove KOBJ_ONLINE/KOBJ_OFFLINE events
ACPI: processor: clean up in acpi_processor_start() error exits
ACPI: processor: move acpi_processor_start() after acpi_processor_add()
ACPI: processor: remove .start() method
ACPI: memory hotplug: remove .start() method
ACPI: EC: move acpi_ec_start() after acpi_ec_add()
ACPI: EC: remove .start() method
ACPI: EC: remove .stop() method
ACPI: remove unused acpi_device_ops .stop method

Quoted 6 lines
 drivers/acpi/acpi_memhotplug.c |   40 +++----
 drivers/acpi/ec.c              |  118 ++++++++--------------
 drivers/acpi/processor_core.c  |  219 +++++++++++++++++-----------------------
 drivers/acpi/scan.c            |    5 -
 include/acpi/acpi_bus.h        |    2 
 5 files changed, 153 insertions(+), 231 deletions(-)

WARNING: line over 80 characters
#229: FILE: drivers/acpi/processor_core.c:710:
+
pr->performance_platform_limit);

WARNING: line over 80 characters
#235: FILE: drivers/acpi/processor_core.c:716:
+ dev_name(&device->dev),
event, 0);

WARNING: line over 80 characters
#241: FILE: drivers/acpi/processor_core.c:722:
+ dev_name(&device->dev),
event, 0);

ERROR: that open brace { should be on the previous line #266: FILE: drivers/acpi/processor_core.c:747:
+static struct notifier_block acpi_cpu_notifier =

applied to acpi-test

thanks,
Len Brown, Intel Open Source Technology Center

Tested-by on the v2 series
#11 lore raw
In reply to Bjorn Helgaas
Quoted 10 lines

From: Bjorn Helgaas <[email protected]>

These patches remove several .start() methods (by folding them into .add() methods) and a .stop() method (by folding it into .remove()). There are no remaining .stop() methods, so I also removed it from the driver_ops structure.

This simplifies the ACPI driver structure and will make it easier to support hotplug in the Linux/ACPI core.

Quoted 6 lines

They also remove the KOBJ_ONLINE and KOBJ_OFFLINE events generated by the processor driver for CPU hotplug events. As far as I know, these events are unused.

I don't have a way to test most of these changes, unfortunately, so I'd welcome any feedback or testing reports.

Hi.

I could make a time to test this patch set.
It works well on my box. :-)

Bye.

Quoted 30 lines

These apply to the acpi-test branch.

---

Bjorn Helgaas (9):
ACPI: processor: remove KOBJ_ONLINE/KOBJ_OFFLINE events
ACPI: processor: clean up in acpi_processor_start() error exits
ACPI: processor: move acpi_processor_start() after acpi_processor_add()
ACPI: processor: remove .start() method
ACPI: memory hotplug: remove .start() method
ACPI: EC: move acpi_ec_start() after acpi_ec_add()
ACPI: EC: remove .start() method
ACPI: EC: remove .stop() method
ACPI: remove unused acpi_device_ops .stop method

 drivers/acpi/acpi_memhotplug.c |   40 +++----
 drivers/acpi/ec.c              |  118 ++++++++--------------
 drivers/acpi/processor_core.c  |  219 +++++++++++++++++-----------------------
 drivers/acpi/scan.c            |    5 -
 include/acpi/acpi_bus.h        |    2 
 5 files changed, 153 insertions(+), 231 deletions(-)
Signature · 5 lines
Bjorn
--
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
Signature · 1 line
Yasunori Goto 
#12 lore raw
Quoted 17 lines · Yasunori Goto
Quoted 10 lines

From: Bjorn Helgaas <[email protected]>

These patches remove several .start() methods (by folding them into .add() methods) and a .stop() method (by folding it into .remove()). There are no remaining .stop() methods, so I also removed it from the driver_ops structure.

This simplifies the ACPI driver structure and will make it easier to support hotplug in the Linux/ACPI core.

Quoted 6 lines

They also remove the KOBJ_ONLINE and KOBJ_OFFLINE events generated by the processor driver for CPU hotplug events. As far as I know, these events are unused.

I don't have a way to test most of these changes, unfortunately, so I'd welcome any feedback or testing reports.

Quoted 6 lines

Hi.

I could make a time to test this patch set.
It works well on my box. :-)

Thanks a lot for testing these. I appreciate it!

Bjorn