aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2014-03-02 18:40:38 -0500
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2014-03-04 19:26:35 -0500
commit1e3bcb596c6b1cf6db93f8f506e2de260e771bad (patch)
tree376eec12f3237da51dcb199f21aacbb06a6afaae
parent8cc2568124ad599a60024d5b410ba812a0b0917a (diff)
ACPI / hotplug: Rework deferred execution of acpi_device_hotplug()
Since the only function executed by acpi_hotplug_execute() is acpi_device_hotplug() and it only is called by the ACPI core, simplify its definition so that it only takes two arguments, the ACPI device object pointer and event code, rename it to acpi_hotplug_schedule() and move its header from acpi_bus.h to the ACPI core's internal header file internal.h. Modify the definition of acpi_device_hotplug() so that its first argument is an ACPI device object pointer and modify the definition of struct acpi_hp_work accordingly. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Acked-by: Toshi Kani <toshi.kani@hp.com>
-rw-r--r--drivers/acpi/bus.c2
-rw-r--r--drivers/acpi/internal.h3
-rw-r--r--drivers/acpi/osl.c14
-rw-r--r--drivers/acpi/scan.c6
-rw-r--r--include/acpi/acpi_bus.h4
5 files changed, 11 insertions, 18 deletions
diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
index e61e7b8a2eaf..afe6f9a919c1 100644
--- a/drivers/acpi/bus.c
+++ b/drivers/acpi/bus.c
@@ -400,7 +400,7 @@ static void acpi_bus_notify(acpi_handle handle, u32 type, void *data)
400 case ACPI_NOTIFY_BUS_CHECK: 400 case ACPI_NOTIFY_BUS_CHECK:
401 case ACPI_NOTIFY_DEVICE_CHECK: 401 case ACPI_NOTIFY_DEVICE_CHECK:
402 case ACPI_NOTIFY_EJECT_REQUEST: 402 case ACPI_NOTIFY_EJECT_REQUEST:
403 status = acpi_hotplug_execute(acpi_device_hotplug, adev, type); 403 status = acpi_hotplug_schedule(adev, type);
404 if (ACPI_SUCCESS(status)) 404 if (ACPI_SUCCESS(status))
405 return; 405 return;
406 default: 406 default:
diff --git a/drivers/acpi/internal.h b/drivers/acpi/internal.h
index 4d081fc1aa24..957391306cbf 100644
--- a/drivers/acpi/internal.h
+++ b/drivers/acpi/internal.h
@@ -78,8 +78,9 @@ void acpi_lpss_init(void);
78static inline void acpi_lpss_init(void) {} 78static inline void acpi_lpss_init(void) {}
79#endif 79#endif
80 80
81acpi_status acpi_hotplug_schedule(struct acpi_device *adev, u32 src);
81bool acpi_queue_hotplug_work(struct work_struct *work); 82bool acpi_queue_hotplug_work(struct work_struct *work);
82void acpi_device_hotplug(void *data, u32 src); 83void acpi_device_hotplug(struct acpi_device *adev, u32 src);
83bool acpi_scan_is_offline(struct acpi_device *adev, bool uevent); 84bool acpi_scan_is_offline(struct acpi_device *adev, bool uevent);
84 85
85/* -------------------------------------------------------------------------- 86/* --------------------------------------------------------------------------
diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
index fc1aa7909690..afb4be566940 100644
--- a/drivers/acpi/osl.c
+++ b/drivers/acpi/osl.c
@@ -1168,8 +1168,7 @@ void acpi_os_wait_events_complete(void)
1168 1168
1169struct acpi_hp_work { 1169struct acpi_hp_work {
1170 struct work_struct work; 1170 struct work_struct work;
1171 acpi_hp_callback func; 1171 struct acpi_device *adev;
1172 void *data;
1173 u32 src; 1172 u32 src;
1174}; 1173};
1175 1174
@@ -1178,25 +1177,24 @@ static void acpi_hotplug_work_fn(struct work_struct *work)
1178 struct acpi_hp_work *hpw = container_of(work, struct acpi_hp_work, work); 1177 struct acpi_hp_work *hpw = container_of(work, struct acpi_hp_work, work);
1179 1178
1180 acpi_os_wait_events_complete(); 1179 acpi_os_wait_events_complete();
1181 hpw->func(hpw->data, hpw->src); 1180 acpi_device_hotplug(hpw->adev, hpw->src);
1182 kfree(hpw); 1181 kfree(hpw);
1183} 1182}
1184 1183
1185acpi_status acpi_hotplug_execute(acpi_hp_callback func, void *data, u32 src) 1184acpi_status acpi_hotplug_schedule(struct acpi_device *adev, u32 src)
1186{ 1185{
1187 struct acpi_hp_work *hpw; 1186 struct acpi_hp_work *hpw;
1188 1187
1189 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, 1188 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
1190 "Scheduling function [%p(%p, %u)] for deferred execution.\n", 1189 "Scheduling hotplug event (%p, %u) for deferred execution.\n",
1191 func, data, src)); 1190 adev, src));
1192 1191
1193 hpw = kmalloc(sizeof(*hpw), GFP_KERNEL); 1192 hpw = kmalloc(sizeof(*hpw), GFP_KERNEL);
1194 if (!hpw) 1193 if (!hpw)
1195 return AE_NO_MEMORY; 1194 return AE_NO_MEMORY;
1196 1195
1197 INIT_WORK(&hpw->work, acpi_hotplug_work_fn); 1196 INIT_WORK(&hpw->work, acpi_hotplug_work_fn);
1198 hpw->func = func; 1197 hpw->adev = adev;
1199 hpw->data = data;
1200 hpw->src = src; 1198 hpw->src = src;
1201 /* 1199 /*
1202 * We can't run hotplug code in kacpid_wq/kacpid_notify_wq etc., because 1200 * We can't run hotplug code in kacpid_wq/kacpid_notify_wq etc., because
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index f6bcc24f73dc..eb7a1ff224e7 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -481,10 +481,9 @@ static int acpi_generic_hotplug_event(struct acpi_device *adev, u32 type)
481 return -EINVAL; 481 return -EINVAL;
482} 482}
483 483
484void acpi_device_hotplug(void *data, u32 src) 484void acpi_device_hotplug(struct acpi_device *adev, u32 src)
485{ 485{
486 u32 ost_code = ACPI_OST_SC_NON_SPECIFIC_FAILURE; 486 u32 ost_code = ACPI_OST_SC_NON_SPECIFIC_FAILURE;
487 struct acpi_device *adev = data;
488 int error = -ENODEV; 487 int error = -ENODEV;
489 488
490 lock_device_hotplug(); 489 lock_device_hotplug();
@@ -579,8 +578,7 @@ acpi_eject_store(struct device *d, struct device_attribute *attr,
579 return -ENODEV; 578 return -ENODEV;
580 579
581 get_device(&acpi_device->dev); 580 get_device(&acpi_device->dev);
582 status = acpi_hotplug_execute(acpi_device_hotplug, acpi_device, 581 status = acpi_hotplug_schedule(acpi_device, ACPI_OST_EC_OSPM_EJECT);
583 ACPI_OST_EC_OSPM_EJECT);
584 if (ACPI_SUCCESS(status)) 582 if (ACPI_SUCCESS(status))
585 return count; 583 return count;
586 584
diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
index fb23a7b6c919..660f5056a37f 100644
--- a/include/acpi/acpi_bus.h
+++ b/include/acpi/acpi_bus.h
@@ -455,10 +455,6 @@ static inline bool acpi_device_enumerated(struct acpi_device *adev)
455 return adev && adev->flags.initialized && adev->flags.visited; 455 return adev && adev->flags.initialized && adev->flags.visited;
456} 456}
457 457
458typedef void (*acpi_hp_callback)(void *data, u32 src);
459
460acpi_status acpi_hotplug_execute(acpi_hp_callback func, void *data, u32 src);
461
462/** 458/**
463 * module_acpi_driver(acpi_driver) - Helper macro for registering an ACPI driver 459 * module_acpi_driver(acpi_driver) - Helper macro for registering an ACPI driver
464 * @__acpi_driver: acpi_driver struct 460 * @__acpi_driver: acpi_driver struct