aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base
diff options
context:
space:
mode:
authorJohannes Berg <johannes@sipsolutions.net>2009-10-29 07:36:02 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2009-12-11 14:24:52 -0500
commit9ebfbd45f9d4ee9cd72529cf99e5f300eb398e67 (patch)
tree6ad661c4b38d0fad8a88c4a0d28997e9303632f2 /drivers/base
parent03d673e6af6490371aaf64dfe1f84c658c48b71d (diff)
firmware_class: make request_firmware_nowait more useful
Unfortunately, one cannot hold on to the struct firmware that request_firmware_nowait() hands off, which is needed in some cases. Allow this by requiring the callback to free it (via release_firmware). Additionally, give it a gfp_t parameter -- all the current users call it from a GFP_KERNEL context so the GFP_ATOMIC isn't necessary. This also marks an API break which is useful in a sense, although that is obviously not the primary purpose of this change. Signed-off-by: Johannes Berg <johannes@sipsolutions.net> Acked-by: Marcel Holtmann <marcel@holtmann.org> Cc: Ming Lei <tom.leiming@gmail.com> Cc: Catalin Marinas <catalin.marinas@arm.com> Cc: David Woodhouse <David.Woodhouse@intel.com> Cc: Pavel Roskin <proski@gnu.org> Cc: Abhay Salunke <abhay_salunke@dell.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/base')
-rw-r--r--drivers/base/firmware_class.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
index 7376367bcb80..a95024166b66 100644
--- a/drivers/base/firmware_class.c
+++ b/drivers/base/firmware_class.c
@@ -601,12 +601,9 @@ request_firmware_work_func(void *arg)
601 } 601 }
602 ret = _request_firmware(&fw, fw_work->name, fw_work->device, 602 ret = _request_firmware(&fw, fw_work->name, fw_work->device,
603 fw_work->uevent); 603 fw_work->uevent);
604 if (ret < 0) 604
605 fw_work->cont(NULL, fw_work->context); 605 fw_work->cont(fw, fw_work->context);
606 else { 606
607 fw_work->cont(fw, fw_work->context);
608 release_firmware(fw);
609 }
610 module_put(fw_work->module); 607 module_put(fw_work->module);
611 kfree(fw_work); 608 kfree(fw_work);
612 return ret; 609 return ret;
@@ -619,6 +616,7 @@ request_firmware_work_func(void *arg)
619 * is non-zero else the firmware copy must be done manually. 616 * is non-zero else the firmware copy must be done manually.
620 * @name: name of firmware file 617 * @name: name of firmware file
621 * @device: device for which firmware is being loaded 618 * @device: device for which firmware is being loaded
619 * @gfp: allocation flags
622 * @context: will be passed over to @cont, and 620 * @context: will be passed over to @cont, and
623 * @fw may be %NULL if firmware request fails. 621 * @fw may be %NULL if firmware request fails.
624 * @cont: function will be called asynchronously when the firmware 622 * @cont: function will be called asynchronously when the firmware
@@ -631,12 +629,12 @@ request_firmware_work_func(void *arg)
631int 629int
632request_firmware_nowait( 630request_firmware_nowait(
633 struct module *module, int uevent, 631 struct module *module, int uevent,
634 const char *name, struct device *device, void *context, 632 const char *name, struct device *device, gfp_t gfp, void *context,
635 void (*cont)(const struct firmware *fw, void *context)) 633 void (*cont)(const struct firmware *fw, void *context))
636{ 634{
637 struct task_struct *task; 635 struct task_struct *task;
638 struct firmware_work *fw_work = kmalloc(sizeof (struct firmware_work), 636 struct firmware_work *fw_work = kmalloc(sizeof (struct firmware_work),
639 GFP_ATOMIC); 637 gfp);
640 638
641 if (!fw_work) 639 if (!fw_work)
642 return -ENOMEM; 640 return -ENOMEM;