Skip to content

Commit

Permalink
PCI/ACPI: acpiphp: Rename alloc_acpiphp_hp_work() to alloc_acpi_hp_wo…
Browse files Browse the repository at this point in the history
…rk()

Will need to use it for PCI root bridge hotplug support, so rename
*acpiphp* to *acpi* and move to osc.c.  Also make kacpi_hotplug_wq static
after that.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
CC: Len Brown <lenb@kernel.org>
CC: linux-acpi@vger.kernel.org
  • Loading branch information
Yinghai Lu authored and Bjorn Helgaas committed Jan 25, 2013
1 parent e723f0b commit 92d8aff
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 40 deletions.
24 changes: 22 additions & 2 deletions drivers/acpi/osl.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,7 @@ static acpi_osd_handler acpi_irq_handler;
static void *acpi_irq_context;
static struct workqueue_struct *kacpid_wq;
static struct workqueue_struct *kacpi_notify_wq;
struct workqueue_struct *kacpi_hotplug_wq;
EXPORT_SYMBOL(kacpi_hotplug_wq);
static struct workqueue_struct *kacpi_hotplug_wq;

/*
* This list of permanent mappings is for memory that may be accessed from
Expand Down Expand Up @@ -1778,3 +1777,24 @@ void acpi_os_set_prepare_sleep(int (*func)(u8 sleep_state,
{
__acpi_os_prepare_sleep = func;
}

void alloc_acpi_hp_work(acpi_handle handle, u32 type, void *context,
void (*func)(struct work_struct *work))
{
struct acpi_hp_work *hp_work;
int ret;

hp_work = kmalloc(sizeof(*hp_work), GFP_KERNEL);
if (!hp_work)
return;

hp_work->handle = handle;
hp_work->type = type;
hp_work->context = context;

INIT_WORK(&hp_work->work, func);
ret = queue_work(kacpi_hotplug_wq, &hp_work->work);
if (!ret)
kfree(hp_work);
}
EXPORT_SYMBOL_GPL(alloc_acpi_hp_work);
42 changes: 6 additions & 36 deletions drivers/pci/hotplug/acpiphp_glue.c
Original file line number Diff line number Diff line change
Expand Up @@ -1203,34 +1203,6 @@ check_sub_bridges(acpi_handle handle, u32 lvl, void *context, void **rv)
return AE_OK ;
}

struct acpiphp_hp_work {
struct work_struct work;
acpi_handle handle;
u32 type;
void *context;
};

static void alloc_acpiphp_hp_work(acpi_handle handle, u32 type,
void *context,
void (*func)(struct work_struct *work))
{
struct acpiphp_hp_work *hp_work;
int ret;

hp_work = kmalloc(sizeof(*hp_work), GFP_KERNEL);
if (!hp_work)
return;

hp_work->handle = handle;
hp_work->type = type;
hp_work->context = context;

INIT_WORK(&hp_work->work, func);
ret = queue_work(kacpi_hotplug_wq, &hp_work->work);
if (!ret)
kfree(hp_work);
}

static void _handle_hotplug_event_bridge(struct work_struct *work)
{
struct acpiphp_bridge *bridge;
Expand All @@ -1239,11 +1211,11 @@ static void _handle_hotplug_event_bridge(struct work_struct *work)
.pointer = objname };
struct acpi_device *device;
int num_sub_bridges = 0;
struct acpiphp_hp_work *hp_work;
struct acpi_hp_work *hp_work;
acpi_handle handle;
u32 type;

hp_work = container_of(work, struct acpiphp_hp_work, work);
hp_work = container_of(work, struct acpi_hp_work, work);
handle = hp_work->handle;
type = hp_work->type;

Expand Down Expand Up @@ -1346,8 +1318,7 @@ static void handle_hotplug_event_bridge(acpi_handle handle, u32 type,
* For now just re-add this work to the kacpi_hotplug_wq so we
* don't deadlock on hotplug actions.
*/
alloc_acpiphp_hp_work(handle, type, context,
_handle_hotplug_event_bridge);
alloc_acpi_hp_work(handle, type, context, _handle_hotplug_event_bridge);
}

static void _handle_hotplug_event_func(struct work_struct *work)
Expand All @@ -1356,12 +1327,12 @@ static void _handle_hotplug_event_func(struct work_struct *work)
char objname[64];
struct acpi_buffer buffer = { .length = sizeof(objname),
.pointer = objname };
struct acpiphp_hp_work *hp_work;
struct acpi_hp_work *hp_work;
acpi_handle handle;
u32 type;
void *context;

hp_work = container_of(work, struct acpiphp_hp_work, work);
hp_work = container_of(work, struct acpi_hp_work, work);
handle = hp_work->handle;
type = hp_work->type;
context = hp_work->context;
Expand Down Expand Up @@ -1422,8 +1393,7 @@ static void handle_hotplug_event_func(acpi_handle handle, u32 type,
* For now just re-add this work to the kacpi_hotplug_wq so we
* don't deadlock on hotplug actions.
*/
alloc_acpiphp_hp_work(handle, type, context,
_handle_hotplug_event_func);
alloc_acpi_hp_work(handle, type, context, _handle_hotplug_event_func);
}

static acpi_status
Expand Down
9 changes: 9 additions & 0 deletions include/acpi/acpi_bus.h
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,15 @@ struct acpi_eject_event {
u32 event;
};

struct acpi_hp_work {
struct work_struct work;
acpi_handle handle;
u32 type;
void *context;
};
void alloc_acpi_hp_work(acpi_handle handle, u32 type, void *context,
void (*func)(struct work_struct *work));

extern struct kobject *acpi_kobj;
extern int acpi_bus_generate_netlink_event(const char*, const char*, u8, int);
void acpi_bus_private_data_handler(acpi_handle, void *);
Expand Down
2 changes: 0 additions & 2 deletions include/acpi/acpiosxf.h
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,6 @@ void acpi_os_fixed_event_count(u32 fixed_event_number);
/*
* Threads and Scheduling
*/
extern struct workqueue_struct *kacpi_hotplug_wq;

acpi_thread_id acpi_os_get_thread_id(void);

acpi_status
Expand Down

0 comments on commit 92d8aff

Please sign in to comment.