Commit a36cf844 authored by Stephen Boyd's avatar Stephen Boyd Committed by Rafael J. Wysocki

firmware_class: Move request_firmware_nowait() to workqueues

Oddly enough a work_struct was already part of the firmware_work
structure but nobody was using it. Instead of creating a new
kthread for each request_firmware_nowait() call just schedule the
work on the system workqueue. This should avoid some overhead
in forking new threads when they're not strictly necessary.
Signed-off-by: default avatarStephen Boyd <sboyd@codeaurora.org>
Acked-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarRafael J. Wysocki <rjw@sisk.pl>
parent dddb5549
...@@ -16,10 +16,11 @@ ...@@ -16,10 +16,11 @@
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/bitops.h> #include <linux/bitops.h>
#include <linux/mutex.h> #include <linux/mutex.h>
#include <linux/kthread.h> #include <linux/workqueue.h>
#include <linux/highmem.h> #include <linux/highmem.h>
#include <linux/firmware.h> #include <linux/firmware.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/sched.h>
#define to_dev(obj) container_of(obj, struct device, kobj) #define to_dev(obj) container_of(obj, struct device, kobj)
...@@ -630,19 +631,15 @@ struct firmware_work { ...@@ -630,19 +631,15 @@ struct firmware_work {
bool uevent; bool uevent;
}; };
static int request_firmware_work_func(void *arg) static void request_firmware_work_func(struct work_struct *work)
{ {
struct firmware_work *fw_work = arg; struct firmware_work *fw_work;
const struct firmware *fw; const struct firmware *fw;
struct firmware_priv *fw_priv; struct firmware_priv *fw_priv;
long timeout; long timeout;
int ret; int ret;
if (!arg) { fw_work = container_of(work, struct firmware_work, work);
WARN_ON(1);
return 0;
}
fw_priv = _request_firmware_prepare(&fw, fw_work->name, fw_work->device, fw_priv = _request_firmware_prepare(&fw, fw_work->name, fw_work->device,
fw_work->uevent, true); fw_work->uevent, true);
if (IS_ERR_OR_NULL(fw_priv)) { if (IS_ERR_OR_NULL(fw_priv)) {
...@@ -667,8 +664,6 @@ static int request_firmware_work_func(void *arg) ...@@ -667,8 +664,6 @@ static int request_firmware_work_func(void *arg)
module_put(fw_work->module); module_put(fw_work->module);
kfree(fw_work); kfree(fw_work);
return ret;
} }
/** /**
...@@ -694,7 +689,6 @@ request_firmware_nowait( ...@@ -694,7 +689,6 @@ request_firmware_nowait(
const char *name, struct device *device, gfp_t gfp, void *context, const char *name, struct device *device, gfp_t gfp, void *context,
void (*cont)(const struct firmware *fw, void *context)) void (*cont)(const struct firmware *fw, void *context))
{ {
struct task_struct *task;
struct firmware_work *fw_work; struct firmware_work *fw_work;
fw_work = kzalloc(sizeof (struct firmware_work), gfp); fw_work = kzalloc(sizeof (struct firmware_work), gfp);
...@@ -713,15 +707,8 @@ request_firmware_nowait( ...@@ -713,15 +707,8 @@ request_firmware_nowait(
return -EFAULT; return -EFAULT;
} }
task = kthread_run(request_firmware_work_func, fw_work, INIT_WORK(&fw_work->work, request_firmware_work_func);
"firmware/%s", name); schedule_work(&fw_work->work);
if (IS_ERR(task)) {
fw_work->cont(NULL, fw_work->context);
module_put(fw_work->module);
kfree(fw_work);
return PTR_ERR(task);
}
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment