2 * firmware_class.c - Multi purpose firmware loading support
4 * Copyright (c) 2003 Manuel Estrada Sainz
6 * Please see Documentation/firmware_class/ for more information.
10 #include <linux/capability.h>
11 #include <linux/device.h>
12 #include <linux/module.h>
13 #include <linux/init.h>
14 #include <linux/timer.h>
15 #include <linux/vmalloc.h>
16 #include <linux/interrupt.h>
17 #include <linux/bitops.h>
18 #include <linux/mutex.h>
19 #include <linux/workqueue.h>
20 #include <linux/highmem.h>
21 #include <linux/firmware.h>
22 #include <linux/slab.h>
23 #include <linux/sched.h>
24 #include <linux/list.h>
26 MODULE_AUTHOR("Manuel Estrada Sainz");
27 MODULE_DESCRIPTION("Multi purpose firmware loading support");
28 MODULE_LICENSE("GPL");
30 /* Builtin firmware support */
32 #ifdef CONFIG_FW_LOADER
34 extern struct builtin_fw __start_builtin_fw[];
35 extern struct builtin_fw __end_builtin_fw[];
37 static bool fw_get_builtin_firmware(struct firmware *fw, const char *name)
39 struct builtin_fw *b_fw;
41 for (b_fw = __start_builtin_fw; b_fw != __end_builtin_fw; b_fw++) {
42 if (strcmp(name, b_fw->name) == 0) {
43 fw->size = b_fw->size;
44 fw->data = b_fw->data;
52 static bool fw_is_builtin_firmware(const struct firmware *fw)
54 struct builtin_fw *b_fw;
56 for (b_fw = __start_builtin_fw; b_fw != __end_builtin_fw; b_fw++)
57 if (fw->data == b_fw->data)
63 #else /* Module case - no builtin firmware support */
65 static inline bool fw_get_builtin_firmware(struct firmware *fw, const char *name)
70 static inline bool fw_is_builtin_firmware(const struct firmware *fw)
82 static int loading_timeout = 60; /* In seconds */
84 static inline long firmware_loading_timeout(void)
86 return loading_timeout > 0 ? loading_timeout * HZ : MAX_SCHEDULE_TIMEOUT;
89 struct firmware_cache {
90 /* firmware_buf instance will be added into the below list */
92 struct list_head head;
97 struct list_head list;
98 struct completion completion;
99 struct firmware_cache *fwc;
100 unsigned long status;
109 struct firmware_priv {
110 struct timer_list timeout;
113 struct firmware_buf *buf;
117 struct fw_name_devm {
122 #define to_fwbuf(d) container_of(d, struct firmware_buf, ref)
124 /* fw_lock could be moved to 'struct firmware_priv' but since it is just
125 * guarding for corner cases a global lock should be OK */
126 static DEFINE_MUTEX(fw_lock);
128 static struct firmware_cache fw_cache;
130 static struct firmware_buf *__allocate_fw_buf(const char *fw_name,
131 struct firmware_cache *fwc)
133 struct firmware_buf *buf;
135 buf = kzalloc(sizeof(*buf) + strlen(fw_name) + 1 , GFP_ATOMIC);
140 kref_init(&buf->ref);
141 strcpy(buf->fw_id, fw_name);
143 init_completion(&buf->completion);
145 pr_debug("%s: fw-%s buf=%p\n", __func__, fw_name, buf);
150 static struct firmware_buf *__fw_lookup_buf(const char *fw_name)
152 struct firmware_buf *tmp;
153 struct firmware_cache *fwc = &fw_cache;
155 list_for_each_entry(tmp, &fwc->head, list)
156 if (!strcmp(tmp->fw_id, fw_name))
161 static int fw_lookup_and_allocate_buf(const char *fw_name,
162 struct firmware_cache *fwc,
163 struct firmware_buf **buf)
165 struct firmware_buf *tmp;
167 spin_lock(&fwc->lock);
168 tmp = __fw_lookup_buf(fw_name);
171 spin_unlock(&fwc->lock);
175 tmp = __allocate_fw_buf(fw_name, fwc);
177 list_add(&tmp->list, &fwc->head);
178 spin_unlock(&fwc->lock);
182 return tmp ? 0 : -ENOMEM;
185 static struct firmware_buf *fw_lookup_buf(const char *fw_name)
187 struct firmware_buf *tmp;
188 struct firmware_cache *fwc = &fw_cache;
190 spin_lock(&fwc->lock);
191 tmp = __fw_lookup_buf(fw_name);
192 spin_unlock(&fwc->lock);
197 static void __fw_free_buf(struct kref *ref)
199 struct firmware_buf *buf = to_fwbuf(ref);
200 struct firmware_cache *fwc = buf->fwc;
203 pr_debug("%s: fw-%s buf=%p data=%p size=%u\n",
204 __func__, buf->fw_id, buf, buf->data,
205 (unsigned int)buf->size);
207 spin_lock(&fwc->lock);
208 list_del(&buf->list);
209 spin_unlock(&fwc->lock);
212 for (i = 0; i < buf->nr_pages; i++)
213 __free_page(buf->pages[i]);
218 static void fw_free_buf(struct firmware_buf *buf)
220 kref_put(&buf->ref, __fw_free_buf);
223 static void __init fw_cache_init(void)
225 spin_lock_init(&fw_cache.lock);
226 INIT_LIST_HEAD(&fw_cache.head);
229 static struct firmware_priv *to_firmware_priv(struct device *dev)
231 return container_of(dev, struct firmware_priv, dev);
234 static void fw_load_abort(struct firmware_priv *fw_priv)
236 struct firmware_buf *buf = fw_priv->buf;
238 set_bit(FW_STATUS_ABORT, &buf->status);
239 complete_all(&buf->completion);
242 static ssize_t firmware_timeout_show(struct class *class,
243 struct class_attribute *attr,
246 return sprintf(buf, "%d\n", loading_timeout);
250 * firmware_timeout_store - set number of seconds to wait for firmware
251 * @class: device class pointer
252 * @attr: device attribute pointer
253 * @buf: buffer to scan for timeout value
254 * @count: number of bytes in @buf
256 * Sets the number of seconds to wait for the firmware. Once
257 * this expires an error will be returned to the driver and no
258 * firmware will be provided.
260 * Note: zero means 'wait forever'.
262 static ssize_t firmware_timeout_store(struct class *class,
263 struct class_attribute *attr,
264 const char *buf, size_t count)
266 loading_timeout = simple_strtol(buf, NULL, 10);
267 if (loading_timeout < 0)
273 static struct class_attribute firmware_class_attrs[] = {
274 __ATTR(timeout, S_IWUSR | S_IRUGO,
275 firmware_timeout_show, firmware_timeout_store),
279 static void fw_dev_release(struct device *dev)
281 struct firmware_priv *fw_priv = to_firmware_priv(dev);
285 module_put(THIS_MODULE);
288 static int firmware_uevent(struct device *dev, struct kobj_uevent_env *env)
290 struct firmware_priv *fw_priv = to_firmware_priv(dev);
292 if (add_uevent_var(env, "FIRMWARE=%s", fw_priv->buf->fw_id))
294 if (add_uevent_var(env, "TIMEOUT=%i", loading_timeout))
296 if (add_uevent_var(env, "ASYNC=%d", fw_priv->nowait))
302 static struct class firmware_class = {
304 .class_attrs = firmware_class_attrs,
305 .dev_uevent = firmware_uevent,
306 .dev_release = fw_dev_release,
309 static ssize_t firmware_loading_show(struct device *dev,
310 struct device_attribute *attr, char *buf)
312 struct firmware_priv *fw_priv = to_firmware_priv(dev);
313 int loading = test_bit(FW_STATUS_LOADING, &fw_priv->buf->status);
315 return sprintf(buf, "%d\n", loading);
318 /* firmware holds the ownership of pages */
319 static void firmware_free_data(const struct firmware *fw)
322 fw_free_buf(fw->priv);
325 /* Some architectures don't have PAGE_KERNEL_RO */
326 #ifndef PAGE_KERNEL_RO
327 #define PAGE_KERNEL_RO PAGE_KERNEL
330 * firmware_loading_store - set value in the 'loading' control file
331 * @dev: device pointer
332 * @attr: device attribute pointer
333 * @buf: buffer to scan for loading control value
334 * @count: number of bytes in @buf
336 * The relevant values are:
338 * 1: Start a load, discarding any previous partial load.
339 * 0: Conclude the load and hand the data to the driver code.
340 * -1: Conclude the load with an error and discard any written data.
342 static ssize_t firmware_loading_store(struct device *dev,
343 struct device_attribute *attr,
344 const char *buf, size_t count)
346 struct firmware_priv *fw_priv = to_firmware_priv(dev);
347 struct firmware_buf *fw_buf = fw_priv->buf;
348 int loading = simple_strtol(buf, NULL, 10);
351 mutex_lock(&fw_lock);
358 /* discarding any previous partial load */
359 if (!test_bit(FW_STATUS_DONE, &fw_buf->status)) {
360 for (i = 0; i < fw_buf->nr_pages; i++)
361 __free_page(fw_buf->pages[i]);
362 kfree(fw_buf->pages);
363 fw_buf->pages = NULL;
364 fw_buf->page_array_size = 0;
365 fw_buf->nr_pages = 0;
366 set_bit(FW_STATUS_LOADING, &fw_buf->status);
370 if (test_bit(FW_STATUS_LOADING, &fw_buf->status)) {
371 set_bit(FW_STATUS_DONE, &fw_buf->status);
372 clear_bit(FW_STATUS_LOADING, &fw_buf->status);
373 complete_all(&fw_buf->completion);
378 dev_err(dev, "%s: unexpected value (%d)\n", __func__, loading);
381 fw_load_abort(fw_priv);
385 mutex_unlock(&fw_lock);
389 static DEVICE_ATTR(loading, 0644, firmware_loading_show, firmware_loading_store);
391 static ssize_t firmware_data_read(struct file *filp, struct kobject *kobj,
392 struct bin_attribute *bin_attr,
393 char *buffer, loff_t offset, size_t count)
395 struct device *dev = kobj_to_dev(kobj);
396 struct firmware_priv *fw_priv = to_firmware_priv(dev);
397 struct firmware_buf *buf;
400 mutex_lock(&fw_lock);
402 if (!buf || test_bit(FW_STATUS_DONE, &buf->status)) {
406 if (offset > buf->size) {
410 if (count > buf->size - offset)
411 count = buf->size - offset;
417 int page_nr = offset >> PAGE_SHIFT;
418 int page_ofs = offset & (PAGE_SIZE-1);
419 int page_cnt = min_t(size_t, PAGE_SIZE - page_ofs, count);
421 page_data = kmap(buf->pages[page_nr]);
423 memcpy(buffer, page_data + page_ofs, page_cnt);
425 kunmap(buf->pages[page_nr]);
431 mutex_unlock(&fw_lock);
435 static int fw_realloc_buffer(struct firmware_priv *fw_priv, int min_size)
437 struct firmware_buf *buf = fw_priv->buf;
438 int pages_needed = ALIGN(min_size, PAGE_SIZE) >> PAGE_SHIFT;
440 /* If the array of pages is too small, grow it... */
441 if (buf->page_array_size < pages_needed) {
442 int new_array_size = max(pages_needed,
443 buf->page_array_size * 2);
444 struct page **new_pages;
446 new_pages = kmalloc(new_array_size * sizeof(void *),
449 fw_load_abort(fw_priv);
452 memcpy(new_pages, buf->pages,
453 buf->page_array_size * sizeof(void *));
454 memset(&new_pages[buf->page_array_size], 0, sizeof(void *) *
455 (new_array_size - buf->page_array_size));
457 buf->pages = new_pages;
458 buf->page_array_size = new_array_size;
461 while (buf->nr_pages < pages_needed) {
462 buf->pages[buf->nr_pages] =
463 alloc_page(GFP_KERNEL | __GFP_HIGHMEM);
465 if (!buf->pages[buf->nr_pages]) {
466 fw_load_abort(fw_priv);
475 * firmware_data_write - write method for firmware
476 * @filp: open sysfs file
477 * @kobj: kobject for the device
478 * @bin_attr: bin_attr structure
479 * @buffer: buffer being written
480 * @offset: buffer offset for write in total data store area
481 * @count: buffer size
483 * Data written to the 'data' attribute will be later handed to
484 * the driver as a firmware image.
486 static ssize_t firmware_data_write(struct file *filp, struct kobject *kobj,
487 struct bin_attribute *bin_attr,
488 char *buffer, loff_t offset, size_t count)
490 struct device *dev = kobj_to_dev(kobj);
491 struct firmware_priv *fw_priv = to_firmware_priv(dev);
492 struct firmware_buf *buf;
495 if (!capable(CAP_SYS_RAWIO))
498 mutex_lock(&fw_lock);
500 if (!buf || test_bit(FW_STATUS_DONE, &buf->status)) {
505 retval = fw_realloc_buffer(fw_priv, offset + count);
513 int page_nr = offset >> PAGE_SHIFT;
514 int page_ofs = offset & (PAGE_SIZE - 1);
515 int page_cnt = min_t(size_t, PAGE_SIZE - page_ofs, count);
517 page_data = kmap(buf->pages[page_nr]);
519 memcpy(page_data + page_ofs, buffer, page_cnt);
521 kunmap(buf->pages[page_nr]);
527 buf->size = max_t(size_t, offset, buf->size);
529 mutex_unlock(&fw_lock);
533 static struct bin_attribute firmware_attr_data = {
534 .attr = { .name = "data", .mode = 0644 },
536 .read = firmware_data_read,
537 .write = firmware_data_write,
540 static void firmware_class_timeout(u_long data)
542 struct firmware_priv *fw_priv = (struct firmware_priv *) data;
544 fw_load_abort(fw_priv);
547 static struct firmware_priv *
548 fw_create_instance(struct firmware *firmware, const char *fw_name,
549 struct device *device, bool uevent, bool nowait)
551 struct firmware_priv *fw_priv;
552 struct device *f_dev;
554 fw_priv = kzalloc(sizeof(*fw_priv), GFP_KERNEL);
556 dev_err(device, "%s: kmalloc failed\n", __func__);
557 fw_priv = ERR_PTR(-ENOMEM);
561 fw_priv->nowait = nowait;
562 fw_priv->fw = firmware;
563 setup_timer(&fw_priv->timeout,
564 firmware_class_timeout, (u_long) fw_priv);
566 f_dev = &fw_priv->dev;
568 device_initialize(f_dev);
569 dev_set_name(f_dev, "%s", fw_name);
570 f_dev->parent = device;
571 f_dev->class = &firmware_class;
576 /* one pages buffer is mapped/unmapped only once */
577 static int fw_map_pages_buf(struct firmware_buf *buf)
579 buf->data = vmap(buf->pages, buf->nr_pages, 0, PAGE_KERNEL_RO);
585 /* store the pages buffer info firmware from buf */
586 static void fw_set_page_data(struct firmware_buf *buf, struct firmware *fw)
589 fw->pages = buf->pages;
590 fw->size = buf->size;
591 fw->data = buf->data;
593 pr_debug("%s: fw-%s buf=%p data=%p size=%u\n",
594 __func__, buf->fw_id, buf, buf->data,
595 (unsigned int)buf->size);
598 static void fw_name_devm_release(struct device *dev, void *res)
600 struct fw_name_devm *fwn = res;
602 if (fwn->magic == (unsigned long)&fw_cache)
603 pr_debug("%s: fw_name-%s devm-%p released\n",
604 __func__, fwn->name, res);
607 static int fw_devm_match(struct device *dev, void *res,
610 struct fw_name_devm *fwn = res;
612 return (fwn->magic == (unsigned long)&fw_cache) &&
613 !strcmp(fwn->name, match_data);
616 static struct fw_name_devm *fw_find_devm_name(struct device *dev,
619 struct fw_name_devm *fwn;
621 fwn = devres_find(dev, fw_name_devm_release,
622 fw_devm_match, (void *)name);
626 /* add firmware name into devres list */
627 static int fw_add_devm_name(struct device *dev, const char *name)
629 struct fw_name_devm *fwn;
631 fwn = fw_find_devm_name(dev, name);
635 fwn = devres_alloc(fw_name_devm_release, sizeof(struct fw_name_devm) +
636 strlen(name) + 1, GFP_KERNEL);
640 fwn->magic = (unsigned long)&fw_cache;
641 strcpy(fwn->name, name);
642 devres_add(dev, fwn);
647 static void _request_firmware_cleanup(const struct firmware **firmware_p)
649 release_firmware(*firmware_p);
653 static struct firmware_priv *
654 _request_firmware_prepare(const struct firmware **firmware_p, const char *name,
655 struct device *device, bool uevent, bool nowait)
657 struct firmware *firmware;
658 struct firmware_priv *fw_priv = NULL;
659 struct firmware_buf *buf;
663 return ERR_PTR(-EINVAL);
665 *firmware_p = firmware = kzalloc(sizeof(*firmware), GFP_KERNEL);
667 dev_err(device, "%s: kmalloc(struct firmware) failed\n",
669 return ERR_PTR(-ENOMEM);
672 if (fw_get_builtin_firmware(firmware, name)) {
673 dev_dbg(device, "firmware: using built-in firmware %s\n", name);
677 ret = fw_lookup_and_allocate_buf(name, &fw_cache, &buf);
679 fw_priv = fw_create_instance(firmware, name, device,
682 if (IS_ERR(fw_priv) || ret < 0) {
685 return ERR_PTR(-ENOMEM);
686 } else if (fw_priv) {
690 * bind with 'buf' now to avoid warning in failure path
691 * of requesting firmware.
693 firmware->priv = buf;
697 /* share the cached buf, which is inprogessing or completed */
699 mutex_lock(&fw_lock);
700 if (test_bit(FW_STATUS_ABORT, &buf->status)) {
701 fw_priv = ERR_PTR(-ENOENT);
702 _request_firmware_cleanup(firmware_p);
704 } else if (test_bit(FW_STATUS_DONE, &buf->status)) {
706 fw_set_page_data(buf, firmware);
709 mutex_unlock(&fw_lock);
710 wait_for_completion(&buf->completion);
714 mutex_unlock(&fw_lock);
718 static int _request_firmware_load(struct firmware_priv *fw_priv, bool uevent,
722 struct device *f_dev = &fw_priv->dev;
723 struct firmware_buf *buf = fw_priv->buf;
725 dev_set_uevent_suppress(f_dev, true);
727 /* Need to pin this module until class device is destroyed */
728 __module_get(THIS_MODULE);
730 retval = device_add(f_dev);
732 dev_err(f_dev, "%s: device_register failed\n", __func__);
736 retval = device_create_bin_file(f_dev, &firmware_attr_data);
738 dev_err(f_dev, "%s: sysfs_create_bin_file failed\n", __func__);
742 retval = device_create_file(f_dev, &dev_attr_loading);
744 dev_err(f_dev, "%s: device_create_file failed\n", __func__);
745 goto err_del_bin_attr;
749 dev_set_uevent_suppress(f_dev, false);
750 dev_dbg(f_dev, "firmware: requesting %s\n", buf->fw_id);
751 if (timeout != MAX_SCHEDULE_TIMEOUT)
752 mod_timer(&fw_priv->timeout,
753 round_jiffies_up(jiffies + timeout));
755 kobject_uevent(&fw_priv->dev.kobj, KOBJ_ADD);
758 wait_for_completion(&buf->completion);
760 del_timer_sync(&fw_priv->timeout);
762 mutex_lock(&fw_lock);
763 if (!buf->size || test_bit(FW_STATUS_ABORT, &buf->status))
767 * add firmware name into devres list so that we can auto cache
768 * and uncache firmware for device.
770 * f_dev->parent may has been deleted already, but the problem
771 * should be fixed in devres or driver core.
773 if (!retval && f_dev->parent)
774 fw_add_devm_name(f_dev->parent, buf->fw_id);
777 retval = fw_map_pages_buf(buf);
779 /* pass the pages buffer to driver at the last minute */
780 fw_set_page_data(buf, fw_priv->fw);
783 mutex_unlock(&fw_lock);
785 device_remove_file(f_dev, &dev_attr_loading);
787 device_remove_bin_file(f_dev, &firmware_attr_data);
796 * request_firmware: - send firmware request and wait for it
797 * @firmware_p: pointer to firmware image
798 * @name: name of firmware file
799 * @device: device for which firmware is being loaded
801 * @firmware_p will be used to return a firmware image by the name
802 * of @name for device @device.
804 * Should be called from user context where sleeping is allowed.
806 * @name will be used as $FIRMWARE in the uevent environment and
807 * should be distinctive enough not to be confused with any other
808 * firmware image for this or any other device.
810 * Caller must hold the reference count of @device.
813 request_firmware(const struct firmware **firmware_p, const char *name,
814 struct device *device)
816 struct firmware_priv *fw_priv;
819 fw_priv = _request_firmware_prepare(firmware_p, name, device, true,
821 if (IS_ERR_OR_NULL(fw_priv))
822 return PTR_RET(fw_priv);
824 ret = usermodehelper_read_trylock();
826 dev_err(device, "firmware: %s will not be loaded\n", name);
828 ret = _request_firmware_load(fw_priv, true,
829 firmware_loading_timeout());
830 usermodehelper_read_unlock();
833 _request_firmware_cleanup(firmware_p);
839 * release_firmware: - release the resource associated with a firmware image
840 * @fw: firmware resource to release
842 void release_firmware(const struct firmware *fw)
845 if (!fw_is_builtin_firmware(fw))
846 firmware_free_data(fw);
852 struct firmware_work {
853 struct work_struct work;
854 struct module *module;
856 struct device *device;
858 void (*cont)(const struct firmware *fw, void *context);
862 static void request_firmware_work_func(struct work_struct *work)
864 struct firmware_work *fw_work;
865 const struct firmware *fw;
866 struct firmware_priv *fw_priv;
870 fw_work = container_of(work, struct firmware_work, work);
871 fw_priv = _request_firmware_prepare(&fw, fw_work->name, fw_work->device,
872 fw_work->uevent, true);
873 if (IS_ERR_OR_NULL(fw_priv)) {
874 ret = PTR_RET(fw_priv);
878 timeout = usermodehelper_read_lock_wait(firmware_loading_timeout());
880 ret = _request_firmware_load(fw_priv, fw_work->uevent, timeout);
881 usermodehelper_read_unlock();
883 dev_dbg(fw_work->device, "firmware: %s loading timed out\n",
888 _request_firmware_cleanup(&fw);
891 fw_work->cont(fw, fw_work->context);
892 put_device(fw_work->device);
894 module_put(fw_work->module);
899 * request_firmware_nowait - asynchronous version of request_firmware
900 * @module: module requesting the firmware
901 * @uevent: sends uevent to copy the firmware image if this flag
902 * is non-zero else the firmware copy must be done manually.
903 * @name: name of firmware file
904 * @device: device for which firmware is being loaded
905 * @gfp: allocation flags
906 * @context: will be passed over to @cont, and
907 * @fw may be %NULL if firmware request fails.
908 * @cont: function will be called asynchronously when the firmware
911 * Caller must hold the reference count of @device.
913 * Asynchronous variant of request_firmware() for user contexts:
914 * - sleep for as small periods as possible since it may
915 * increase kernel boot time of built-in device drivers
916 * requesting firmware in their ->probe() methods, if
917 * @gfp is GFP_KERNEL.
919 * - can't sleep at all if @gfp is GFP_ATOMIC.
922 request_firmware_nowait(
923 struct module *module, bool uevent,
924 const char *name, struct device *device, gfp_t gfp, void *context,
925 void (*cont)(const struct firmware *fw, void *context))
927 struct firmware_work *fw_work;
929 fw_work = kzalloc(sizeof (struct firmware_work), gfp);
933 fw_work->module = module;
934 fw_work->name = name;
935 fw_work->device = device;
936 fw_work->context = context;
937 fw_work->cont = cont;
938 fw_work->uevent = uevent;
940 if (!try_module_get(module)) {
945 get_device(fw_work->device);
946 INIT_WORK(&fw_work->work, request_firmware_work_func);
947 schedule_work(&fw_work->work);
952 * cache_firmware - cache one firmware image in kernel memory space
953 * @fw_name: the firmware image name
955 * Cache firmware in kernel memory so that drivers can use it when
956 * system isn't ready for them to request firmware image from userspace.
957 * Once it returns successfully, driver can use request_firmware or its
958 * nowait version to get the cached firmware without any interacting
961 * Return 0 if the firmware image has been cached successfully
962 * Return !0 otherwise
965 int cache_firmware(const char *fw_name)
968 const struct firmware *fw;
970 pr_debug("%s: %s\n", __func__, fw_name);
972 ret = request_firmware(&fw, fw_name, NULL);
976 pr_debug("%s: %s ret=%d\n", __func__, fw_name, ret);
982 * uncache_firmware - remove one cached firmware image
983 * @fw_name: the firmware image name
985 * Uncache one firmware image which has been cached successfully
988 * Return 0 if the firmware cache has been removed successfully
989 * Return !0 otherwise
992 int uncache_firmware(const char *fw_name)
994 struct firmware_buf *buf;
997 pr_debug("%s: %s\n", __func__, fw_name);
999 if (fw_get_builtin_firmware(&fw, fw_name))
1002 buf = fw_lookup_buf(fw_name);
1011 static int __init firmware_class_init(void)
1014 return class_register(&firmware_class);
1017 static void __exit firmware_class_exit(void)
1019 class_unregister(&firmware_class);
1022 fs_initcall(firmware_class_init);
1023 module_exit(firmware_class_exit);
1025 EXPORT_SYMBOL(release_firmware);
1026 EXPORT_SYMBOL(request_firmware);
1027 EXPORT_SYMBOL(request_firmware_nowait);
1028 EXPORT_SYMBOL_GPL(cache_firmware);
1029 EXPORT_SYMBOL_GPL(uncache_firmware);