aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base/firmware_class.c
diff options
context:
space:
mode:
authorAndrea Bastoni <bastoni@cs.unc.edu>2010-05-30 19:16:45 -0400
committerAndrea Bastoni <bastoni@cs.unc.edu>2010-05-30 19:16:45 -0400
commitada47b5fe13d89735805b566185f4885f5a3f750 (patch)
tree644b88f8a71896307d71438e9b3af49126ffb22b /drivers/base/firmware_class.c
parent43e98717ad40a4ae64545b5ba047c7b86aa44f4f (diff)
parent3280f21d43ee541f97f8cda5792150d2dbec20d5 (diff)
Merge branch 'wip-2.6.34' into old-private-masterarchived-private-master
Diffstat (limited to 'drivers/base/firmware_class.c')
-rw-r--r--drivers/base/firmware_class.c28
1 files changed, 16 insertions, 12 deletions
diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
index 7376367bcb80..985da11174e7 100644
--- a/drivers/base/firmware_class.c
+++ b/drivers/base/firmware_class.c
@@ -19,7 +19,7 @@
19#include <linux/kthread.h> 19#include <linux/kthread.h>
20#include <linux/highmem.h> 20#include <linux/highmem.h>
21#include <linux/firmware.h> 21#include <linux/firmware.h>
22#include "base.h" 22#include <linux/slab.h>
23 23
24#define to_dev(obj) container_of(obj, struct device, kobj) 24#define to_dev(obj) container_of(obj, struct device, kobj)
25 25
@@ -69,7 +69,9 @@ fw_load_abort(struct firmware_priv *fw_priv)
69} 69}
70 70
71static ssize_t 71static ssize_t
72firmware_timeout_show(struct class *class, char *buf) 72firmware_timeout_show(struct class *class,
73 struct class_attribute *attr,
74 char *buf)
73{ 75{
74 return sprintf(buf, "%d\n", loading_timeout); 76 return sprintf(buf, "%d\n", loading_timeout);
75} 77}
@@ -77,6 +79,7 @@ firmware_timeout_show(struct class *class, char *buf)
77/** 79/**
78 * firmware_timeout_store - set number of seconds to wait for firmware 80 * firmware_timeout_store - set number of seconds to wait for firmware
79 * @class: device class pointer 81 * @class: device class pointer
82 * @attr: device attribute pointer
80 * @buf: buffer to scan for timeout value 83 * @buf: buffer to scan for timeout value
81 * @count: number of bytes in @buf 84 * @count: number of bytes in @buf
82 * 85 *
@@ -87,7 +90,9 @@ firmware_timeout_show(struct class *class, char *buf)
87 * Note: zero means 'wait forever'. 90 * Note: zero means 'wait forever'.
88 **/ 91 **/
89static ssize_t 92static ssize_t
90firmware_timeout_store(struct class *class, const char *buf, size_t count) 93firmware_timeout_store(struct class *class,
94 struct class_attribute *attr,
95 const char *buf, size_t count)
91{ 96{
92 loading_timeout = simple_strtol(buf, NULL, 10); 97 loading_timeout = simple_strtol(buf, NULL, 10);
93 if (loading_timeout < 0) 98 if (loading_timeout < 0)
@@ -439,6 +444,7 @@ static int fw_setup_device(struct firmware *fw, struct device **dev_p,
439 fw_priv = dev_get_drvdata(f_dev); 444 fw_priv = dev_get_drvdata(f_dev);
440 445
441 fw_priv->fw = fw; 446 fw_priv->fw = fw;
447 sysfs_bin_attr_init(&fw_priv->attr_data);
442 retval = sysfs_create_bin_file(&f_dev->kobj, &fw_priv->attr_data); 448 retval = sysfs_create_bin_file(&f_dev->kobj, &fw_priv->attr_data);
443 if (retval) { 449 if (retval) {
444 dev_err(device, "%s: sysfs_create_bin_file failed\n", __func__); 450 dev_err(device, "%s: sysfs_create_bin_file failed\n", __func__);
@@ -601,24 +607,22 @@ request_firmware_work_func(void *arg)
601 } 607 }
602 ret = _request_firmware(&fw, fw_work->name, fw_work->device, 608 ret = _request_firmware(&fw, fw_work->name, fw_work->device,
603 fw_work->uevent); 609 fw_work->uevent);
604 if (ret < 0) 610
605 fw_work->cont(NULL, fw_work->context); 611 fw_work->cont(fw, fw_work->context);
606 else { 612
607 fw_work->cont(fw, fw_work->context);
608 release_firmware(fw);
609 }
610 module_put(fw_work->module); 613 module_put(fw_work->module);
611 kfree(fw_work); 614 kfree(fw_work);
612 return ret; 615 return ret;
613} 616}
614 617
615/** 618/**
616 * request_firmware_nowait: asynchronous version of request_firmware 619 * request_firmware_nowait - asynchronous version of request_firmware
617 * @module: module requesting the firmware 620 * @module: module requesting the firmware
618 * @uevent: sends uevent to copy the firmware image if this flag 621 * @uevent: sends uevent to copy the firmware image if this flag
619 * is non-zero else the firmware copy must be done manually. 622 * is non-zero else the firmware copy must be done manually.
620 * @name: name of firmware file 623 * @name: name of firmware file
621 * @device: device for which firmware is being loaded 624 * @device: device for which firmware is being loaded
625 * @gfp: allocation flags
622 * @context: will be passed over to @cont, and 626 * @context: will be passed over to @cont, and
623 * @fw may be %NULL if firmware request fails. 627 * @fw may be %NULL if firmware request fails.
624 * @cont: function will be called asynchronously when the firmware 628 * @cont: function will be called asynchronously when the firmware
@@ -631,12 +635,12 @@ request_firmware_work_func(void *arg)
631int 635int
632request_firmware_nowait( 636request_firmware_nowait(
633 struct module *module, int uevent, 637 struct module *module, int uevent,
634 const char *name, struct device *device, void *context, 638 const char *name, struct device *device, gfp_t gfp, void *context,
635 void (*cont)(const struct firmware *fw, void *context)) 639 void (*cont)(const struct firmware *fw, void *context))
636{ 640{
637 struct task_struct *task; 641 struct task_struct *task;
638 struct firmware_work *fw_work = kmalloc(sizeof (struct firmware_work), 642 struct firmware_work *fw_work = kmalloc(sizeof (struct firmware_work),
639 GFP_ATOMIC); 643 gfp);
640 644
641 if (!fw_work) 645 if (!fw_work)
642 return -ENOMEM; 646 return -ENOMEM;