firmware_class: Reorganize fw_create_instance()
[linux-2.6.git] / drivers / base / firmware_class.c
1 /*
2  * firmware_class.c - Multi purpose firmware loading support
3  *
4  * Copyright (c) 2003 Manuel Estrada Sainz
5  *
6  * Please see Documentation/firmware_class/ for more information.
7  *
8  */
9
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/kthread.h>
20 #include <linux/highmem.h>
21 #include <linux/firmware.h>
22 #include <linux/slab.h>
23
24 #define to_dev(obj) container_of(obj, struct device, kobj)
25
26 MODULE_AUTHOR("Manuel Estrada Sainz");
27 MODULE_DESCRIPTION("Multi purpose firmware loading support");
28 MODULE_LICENSE("GPL");
29
30 /* Builtin firmware support */
31
32 #ifdef CONFIG_FW_LOADER
33
34 extern struct builtin_fw __start_builtin_fw[];
35 extern struct builtin_fw __end_builtin_fw[];
36
37 static bool fw_get_builtin_firmware(struct firmware *fw, const char *name)
38 {
39         struct builtin_fw *b_fw;
40
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;
45                         return true;
46                 }
47         }
48
49         return false;
50 }
51
52 static bool fw_is_builtin_firmware(const struct firmware *fw)
53 {
54         struct builtin_fw *b_fw;
55
56         for (b_fw = __start_builtin_fw; b_fw != __end_builtin_fw; b_fw++)
57                 if (fw->data == b_fw->data)
58                         return true;
59
60         return false;
61 }
62
63 #else /* Module case - no builtin firmware support */
64
65 static inline bool fw_get_builtin_firmware(struct firmware *fw, const char *name)
66 {
67         return false;
68 }
69
70 static inline bool fw_is_builtin_firmware(const struct firmware *fw)
71 {
72         return false;
73 }
74 #endif
75
76 enum {
77         FW_STATUS_LOADING,
78         FW_STATUS_DONE,
79         FW_STATUS_ABORT,
80 };
81
82 static int loading_timeout = 60;        /* In seconds */
83
84 static inline long firmware_loading_timeout(void)
85 {
86         return loading_timeout > 0 ? loading_timeout * HZ : MAX_SCHEDULE_TIMEOUT;
87 }
88
89 /* fw_lock could be moved to 'struct firmware_priv' but since it is just
90  * guarding for corner cases a global lock should be OK */
91 static DEFINE_MUTEX(fw_lock);
92
93 struct firmware_priv {
94         struct completion completion;
95         struct firmware *fw;
96         unsigned long status;
97         struct page **pages;
98         int nr_pages;
99         int page_array_size;
100         struct timer_list timeout;
101         struct device dev;
102         bool nowait;
103         char fw_id[];
104 };
105
106 static struct firmware_priv *to_firmware_priv(struct device *dev)
107 {
108         return container_of(dev, struct firmware_priv, dev);
109 }
110
111 static void fw_load_abort(struct firmware_priv *fw_priv)
112 {
113         set_bit(FW_STATUS_ABORT, &fw_priv->status);
114         wmb();
115         complete(&fw_priv->completion);
116 }
117
118 static ssize_t firmware_timeout_show(struct class *class,
119                                      struct class_attribute *attr,
120                                      char *buf)
121 {
122         return sprintf(buf, "%d\n", loading_timeout);
123 }
124
125 /**
126  * firmware_timeout_store - set number of seconds to wait for firmware
127  * @class: device class pointer
128  * @attr: device attribute pointer
129  * @buf: buffer to scan for timeout value
130  * @count: number of bytes in @buf
131  *
132  *      Sets the number of seconds to wait for the firmware.  Once
133  *      this expires an error will be returned to the driver and no
134  *      firmware will be provided.
135  *
136  *      Note: zero means 'wait forever'.
137  **/
138 static ssize_t firmware_timeout_store(struct class *class,
139                                       struct class_attribute *attr,
140                                       const char *buf, size_t count)
141 {
142         loading_timeout = simple_strtol(buf, NULL, 10);
143         if (loading_timeout < 0)
144                 loading_timeout = 0;
145
146         return count;
147 }
148
149 static struct class_attribute firmware_class_attrs[] = {
150         __ATTR(timeout, S_IWUSR | S_IRUGO,
151                 firmware_timeout_show, firmware_timeout_store),
152         __ATTR_NULL
153 };
154
155 static void fw_dev_release(struct device *dev)
156 {
157         struct firmware_priv *fw_priv = to_firmware_priv(dev);
158         int i;
159
160         for (i = 0; i < fw_priv->nr_pages; i++)
161                 __free_page(fw_priv->pages[i]);
162         kfree(fw_priv->pages);
163         kfree(fw_priv);
164
165         module_put(THIS_MODULE);
166 }
167
168 static int firmware_uevent(struct device *dev, struct kobj_uevent_env *env)
169 {
170         struct firmware_priv *fw_priv = to_firmware_priv(dev);
171
172         if (add_uevent_var(env, "FIRMWARE=%s", fw_priv->fw_id))
173                 return -ENOMEM;
174         if (add_uevent_var(env, "TIMEOUT=%i", loading_timeout))
175                 return -ENOMEM;
176         if (add_uevent_var(env, "ASYNC=%d", fw_priv->nowait))
177                 return -ENOMEM;
178
179         return 0;
180 }
181
182 static struct class firmware_class = {
183         .name           = "firmware",
184         .class_attrs    = firmware_class_attrs,
185         .dev_uevent     = firmware_uevent,
186         .dev_release    = fw_dev_release,
187 };
188
189 static ssize_t firmware_loading_show(struct device *dev,
190                                      struct device_attribute *attr, char *buf)
191 {
192         struct firmware_priv *fw_priv = to_firmware_priv(dev);
193         int loading = test_bit(FW_STATUS_LOADING, &fw_priv->status);
194
195         return sprintf(buf, "%d\n", loading);
196 }
197
198 static void firmware_free_data(const struct firmware *fw)
199 {
200         int i;
201         vunmap(fw->data);
202         if (fw->pages) {
203                 for (i = 0; i < PFN_UP(fw->size); i++)
204                         __free_page(fw->pages[i]);
205                 kfree(fw->pages);
206         }
207 }
208
209 /* Some architectures don't have PAGE_KERNEL_RO */
210 #ifndef PAGE_KERNEL_RO
211 #define PAGE_KERNEL_RO PAGE_KERNEL
212 #endif
213 /**
214  * firmware_loading_store - set value in the 'loading' control file
215  * @dev: device pointer
216  * @attr: device attribute pointer
217  * @buf: buffer to scan for loading control value
218  * @count: number of bytes in @buf
219  *
220  *      The relevant values are:
221  *
222  *       1: Start a load, discarding any previous partial load.
223  *       0: Conclude the load and hand the data to the driver code.
224  *      -1: Conclude the load with an error and discard any written data.
225  **/
226 static ssize_t firmware_loading_store(struct device *dev,
227                                       struct device_attribute *attr,
228                                       const char *buf, size_t count)
229 {
230         struct firmware_priv *fw_priv = to_firmware_priv(dev);
231         int loading = simple_strtol(buf, NULL, 10);
232         int i;
233
234         mutex_lock(&fw_lock);
235
236         if (!fw_priv->fw)
237                 goto out;
238
239         switch (loading) {
240         case 1:
241                 firmware_free_data(fw_priv->fw);
242                 memset(fw_priv->fw, 0, sizeof(struct firmware));
243                 /* If the pages are not owned by 'struct firmware' */
244                 for (i = 0; i < fw_priv->nr_pages; i++)
245                         __free_page(fw_priv->pages[i]);
246                 kfree(fw_priv->pages);
247                 fw_priv->pages = NULL;
248                 fw_priv->page_array_size = 0;
249                 fw_priv->nr_pages = 0;
250                 set_bit(FW_STATUS_LOADING, &fw_priv->status);
251                 break;
252         case 0:
253                 if (test_bit(FW_STATUS_LOADING, &fw_priv->status)) {
254                         vunmap(fw_priv->fw->data);
255                         fw_priv->fw->data = vmap(fw_priv->pages,
256                                                  fw_priv->nr_pages,
257                                                  0, PAGE_KERNEL_RO);
258                         if (!fw_priv->fw->data) {
259                                 dev_err(dev, "%s: vmap() failed\n", __func__);
260                                 goto err;
261                         }
262                         /* Pages are now owned by 'struct firmware' */
263                         fw_priv->fw->pages = fw_priv->pages;
264                         fw_priv->pages = NULL;
265
266                         fw_priv->page_array_size = 0;
267                         fw_priv->nr_pages = 0;
268                         complete(&fw_priv->completion);
269                         clear_bit(FW_STATUS_LOADING, &fw_priv->status);
270                         break;
271                 }
272                 /* fallthrough */
273         default:
274                 dev_err(dev, "%s: unexpected value (%d)\n", __func__, loading);
275                 /* fallthrough */
276         case -1:
277         err:
278                 fw_load_abort(fw_priv);
279                 break;
280         }
281 out:
282         mutex_unlock(&fw_lock);
283         return count;
284 }
285
286 static DEVICE_ATTR(loading, 0644, firmware_loading_show, firmware_loading_store);
287
288 static ssize_t firmware_data_read(struct file *filp, struct kobject *kobj,
289                                   struct bin_attribute *bin_attr,
290                                   char *buffer, loff_t offset, size_t count)
291 {
292         struct device *dev = to_dev(kobj);
293         struct firmware_priv *fw_priv = to_firmware_priv(dev);
294         struct firmware *fw;
295         ssize_t ret_count;
296
297         mutex_lock(&fw_lock);
298         fw = fw_priv->fw;
299         if (!fw || test_bit(FW_STATUS_DONE, &fw_priv->status)) {
300                 ret_count = -ENODEV;
301                 goto out;
302         }
303         if (offset > fw->size) {
304                 ret_count = 0;
305                 goto out;
306         }
307         if (count > fw->size - offset)
308                 count = fw->size - offset;
309
310         ret_count = count;
311
312         while (count) {
313                 void *page_data;
314                 int page_nr = offset >> PAGE_SHIFT;
315                 int page_ofs = offset & (PAGE_SIZE-1);
316                 int page_cnt = min_t(size_t, PAGE_SIZE - page_ofs, count);
317
318                 page_data = kmap(fw_priv->pages[page_nr]);
319
320                 memcpy(buffer, page_data + page_ofs, page_cnt);
321
322                 kunmap(fw_priv->pages[page_nr]);
323                 buffer += page_cnt;
324                 offset += page_cnt;
325                 count -= page_cnt;
326         }
327 out:
328         mutex_unlock(&fw_lock);
329         return ret_count;
330 }
331
332 static int fw_realloc_buffer(struct firmware_priv *fw_priv, int min_size)
333 {
334         int pages_needed = ALIGN(min_size, PAGE_SIZE) >> PAGE_SHIFT;
335
336         /* If the array of pages is too small, grow it... */
337         if (fw_priv->page_array_size < pages_needed) {
338                 int new_array_size = max(pages_needed,
339                                          fw_priv->page_array_size * 2);
340                 struct page **new_pages;
341
342                 new_pages = kmalloc(new_array_size * sizeof(void *),
343                                     GFP_KERNEL);
344                 if (!new_pages) {
345                         fw_load_abort(fw_priv);
346                         return -ENOMEM;
347                 }
348                 memcpy(new_pages, fw_priv->pages,
349                        fw_priv->page_array_size * sizeof(void *));
350                 memset(&new_pages[fw_priv->page_array_size], 0, sizeof(void *) *
351                        (new_array_size - fw_priv->page_array_size));
352                 kfree(fw_priv->pages);
353                 fw_priv->pages = new_pages;
354                 fw_priv->page_array_size = new_array_size;
355         }
356
357         while (fw_priv->nr_pages < pages_needed) {
358                 fw_priv->pages[fw_priv->nr_pages] =
359                         alloc_page(GFP_KERNEL | __GFP_HIGHMEM);
360
361                 if (!fw_priv->pages[fw_priv->nr_pages]) {
362                         fw_load_abort(fw_priv);
363                         return -ENOMEM;
364                 }
365                 fw_priv->nr_pages++;
366         }
367         return 0;
368 }
369
370 /**
371  * firmware_data_write - write method for firmware
372  * @filp: open sysfs file
373  * @kobj: kobject for the device
374  * @bin_attr: bin_attr structure
375  * @buffer: buffer being written
376  * @offset: buffer offset for write in total data store area
377  * @count: buffer size
378  *
379  *      Data written to the 'data' attribute will be later handed to
380  *      the driver as a firmware image.
381  **/
382 static ssize_t firmware_data_write(struct file *filp, struct kobject *kobj,
383                                    struct bin_attribute *bin_attr,
384                                    char *buffer, loff_t offset, size_t count)
385 {
386         struct device *dev = to_dev(kobj);
387         struct firmware_priv *fw_priv = to_firmware_priv(dev);
388         struct firmware *fw;
389         ssize_t retval;
390
391         if (!capable(CAP_SYS_RAWIO))
392                 return -EPERM;
393
394         mutex_lock(&fw_lock);
395         fw = fw_priv->fw;
396         if (!fw || test_bit(FW_STATUS_DONE, &fw_priv->status)) {
397                 retval = -ENODEV;
398                 goto out;
399         }
400         retval = fw_realloc_buffer(fw_priv, offset + count);
401         if (retval)
402                 goto out;
403
404         retval = count;
405
406         while (count) {
407                 void *page_data;
408                 int page_nr = offset >> PAGE_SHIFT;
409                 int page_ofs = offset & (PAGE_SIZE - 1);
410                 int page_cnt = min_t(size_t, PAGE_SIZE - page_ofs, count);
411
412                 page_data = kmap(fw_priv->pages[page_nr]);
413
414                 memcpy(page_data + page_ofs, buffer, page_cnt);
415
416                 kunmap(fw_priv->pages[page_nr]);
417                 buffer += page_cnt;
418                 offset += page_cnt;
419                 count -= page_cnt;
420         }
421
422         fw->size = max_t(size_t, offset, fw->size);
423 out:
424         mutex_unlock(&fw_lock);
425         return retval;
426 }
427
428 static struct bin_attribute firmware_attr_data = {
429         .attr = { .name = "data", .mode = 0644 },
430         .size = 0,
431         .read = firmware_data_read,
432         .write = firmware_data_write,
433 };
434
435 static void firmware_class_timeout(u_long data)
436 {
437         struct firmware_priv *fw_priv = (struct firmware_priv *) data;
438
439         fw_load_abort(fw_priv);
440 }
441
442 static struct firmware_priv *
443 fw_create_instance(struct firmware *firmware, const char *fw_name,
444                    struct device *device, bool uevent, bool nowait)
445 {
446         struct firmware_priv *fw_priv;
447         struct device *f_dev;
448
449         fw_priv = kzalloc(sizeof(*fw_priv) + strlen(fw_name) + 1 , GFP_KERNEL);
450         if (!fw_priv) {
451                 dev_err(device, "%s: kmalloc failed\n", __func__);
452                 return ERR_PTR(-ENOMEM);
453         }
454
455         fw_priv->fw = firmware;
456         fw_priv->nowait = nowait;
457         strcpy(fw_priv->fw_id, fw_name);
458         init_completion(&fw_priv->completion);
459         setup_timer(&fw_priv->timeout,
460                     firmware_class_timeout, (u_long) fw_priv);
461
462         f_dev = &fw_priv->dev;
463
464         device_initialize(f_dev);
465         dev_set_name(f_dev, "%s", dev_name(device));
466         f_dev->parent = device;
467         f_dev->class = &firmware_class;
468
469         return fw_priv;
470 }
471
472 static struct firmware_priv *
473 _request_firmware_prepare(const struct firmware **firmware_p, const char *name,
474                           struct device *device, bool uevent, bool nowait)
475 {
476         struct firmware *firmware;
477         struct firmware_priv *fw_priv;
478
479         if (!firmware_p)
480                 return ERR_PTR(-EINVAL);
481
482         *firmware_p = firmware = kzalloc(sizeof(*firmware), GFP_KERNEL);
483         if (!firmware) {
484                 dev_err(device, "%s: kmalloc(struct firmware) failed\n",
485                         __func__);
486                 return ERR_PTR(-ENOMEM);
487         }
488
489         if (fw_get_builtin_firmware(firmware, name)) {
490                 dev_dbg(device, "firmware: using built-in firmware %s\n", name);
491                 return NULL;
492         }
493
494         fw_priv = fw_create_instance(firmware, name, device, uevent, nowait);
495         if (IS_ERR(fw_priv)) {
496                 release_firmware(firmware);
497                 *firmware_p = NULL;
498         }
499         return fw_priv;
500 }
501
502 static void _request_firmware_cleanup(const struct firmware **firmware_p)
503 {
504         release_firmware(*firmware_p);
505         *firmware_p = NULL;
506 }
507
508 static int _request_firmware_load(struct firmware_priv *fw_priv, bool uevent,
509                                   long timeout)
510 {
511         int retval = 0;
512         struct device *f_dev = &fw_priv->dev;
513
514         dev_set_uevent_suppress(f_dev, true);
515
516         /* Need to pin this module until class device is destroyed */
517         __module_get(THIS_MODULE);
518
519         retval = device_add(f_dev);
520         if (retval) {
521                 dev_err(f_dev, "%s: device_register failed\n", __func__);
522                 goto err_put_dev;
523         }
524
525         retval = device_create_bin_file(f_dev, &firmware_attr_data);
526         if (retval) {
527                 dev_err(f_dev, "%s: sysfs_create_bin_file failed\n", __func__);
528                 goto err_del_dev;
529         }
530
531         retval = device_create_file(f_dev, &dev_attr_loading);
532         if (retval) {
533                 dev_err(f_dev, "%s: device_create_file failed\n", __func__);
534                 goto err_del_bin_attr;
535         }
536
537         if (uevent) {
538                 dev_set_uevent_suppress(f_dev, false);
539                 dev_dbg(f_dev, "firmware: requesting %s\n", fw_priv->fw_id);
540                 if (timeout != MAX_SCHEDULE_TIMEOUT)
541                         mod_timer(&fw_priv->timeout,
542                                   round_jiffies_up(jiffies + timeout));
543
544                 kobject_uevent(&fw_priv->dev.kobj, KOBJ_ADD);
545         }
546
547         wait_for_completion(&fw_priv->completion);
548
549         set_bit(FW_STATUS_DONE, &fw_priv->status);
550         del_timer_sync(&fw_priv->timeout);
551
552         mutex_lock(&fw_lock);
553         if (!fw_priv->fw->size || test_bit(FW_STATUS_ABORT, &fw_priv->status))
554                 retval = -ENOENT;
555         fw_priv->fw = NULL;
556         mutex_unlock(&fw_lock);
557
558         device_remove_file(f_dev, &dev_attr_loading);
559 err_del_bin_attr:
560         device_remove_bin_file(f_dev, &firmware_attr_data);
561 err_del_dev:
562         device_del(f_dev);
563 err_put_dev:
564         put_device(f_dev);
565         return retval;
566 }
567
568 /**
569  * request_firmware: - send firmware request and wait for it
570  * @firmware_p: pointer to firmware image
571  * @name: name of firmware file
572  * @device: device for which firmware is being loaded
573  *
574  *      @firmware_p will be used to return a firmware image by the name
575  *      of @name for device @device.
576  *
577  *      Should be called from user context where sleeping is allowed.
578  *
579  *      @name will be used as $FIRMWARE in the uevent environment and
580  *      should be distinctive enough not to be confused with any other
581  *      firmware image for this or any other device.
582  **/
583 int
584 request_firmware(const struct firmware **firmware_p, const char *name,
585                  struct device *device)
586 {
587         struct firmware_priv *fw_priv;
588         int ret;
589
590         fw_priv = _request_firmware_prepare(firmware_p, name, device, true,
591                                             false);
592         if (IS_ERR_OR_NULL(fw_priv))
593                 return PTR_RET(fw_priv);
594
595         ret = usermodehelper_read_trylock();
596         if (WARN_ON(ret)) {
597                 dev_err(device, "firmware: %s will not be loaded\n", name);
598         } else {
599                 ret = _request_firmware_load(fw_priv, true,
600                                         firmware_loading_timeout());
601                 usermodehelper_read_unlock();
602         }
603         if (ret)
604                 _request_firmware_cleanup(firmware_p);
605
606         return ret;
607 }
608
609 /**
610  * release_firmware: - release the resource associated with a firmware image
611  * @fw: firmware resource to release
612  **/
613 void release_firmware(const struct firmware *fw)
614 {
615         if (fw) {
616                 if (!fw_is_builtin_firmware(fw))
617                         firmware_free_data(fw);
618                 kfree(fw);
619         }
620 }
621
622 /* Async support */
623 struct firmware_work {
624         struct work_struct work;
625         struct module *module;
626         const char *name;
627         struct device *device;
628         void *context;
629         void (*cont)(const struct firmware *fw, void *context);
630         bool uevent;
631 };
632
633 static int request_firmware_work_func(void *arg)
634 {
635         struct firmware_work *fw_work = arg;
636         const struct firmware *fw;
637         struct firmware_priv *fw_priv;
638         long timeout;
639         int ret;
640
641         if (!arg) {
642                 WARN_ON(1);
643                 return 0;
644         }
645
646         fw_priv = _request_firmware_prepare(&fw, fw_work->name, fw_work->device,
647                         fw_work->uevent, true);
648         if (IS_ERR_OR_NULL(fw_priv)) {
649                 ret = PTR_RET(fw_priv);
650                 goto out;
651         }
652
653         timeout = usermodehelper_read_lock_wait(firmware_loading_timeout());
654         if (timeout) {
655                 ret = _request_firmware_load(fw_priv, fw_work->uevent, timeout);
656                 usermodehelper_read_unlock();
657         } else {
658                 dev_dbg(fw_work->device, "firmware: %s loading timed out\n",
659                         fw_work->name);
660                 ret = -EAGAIN;
661         }
662         if (ret)
663                 _request_firmware_cleanup(&fw);
664
665  out:
666         fw_work->cont(fw, fw_work->context);
667
668         module_put(fw_work->module);
669         kfree(fw_work);
670
671         return ret;
672 }
673
674 /**
675  * request_firmware_nowait - asynchronous version of request_firmware
676  * @module: module requesting the firmware
677  * @uevent: sends uevent to copy the firmware image if this flag
678  *      is non-zero else the firmware copy must be done manually.
679  * @name: name of firmware file
680  * @device: device for which firmware is being loaded
681  * @gfp: allocation flags
682  * @context: will be passed over to @cont, and
683  *      @fw may be %NULL if firmware request fails.
684  * @cont: function will be called asynchronously when the firmware
685  *      request is over.
686  *
687  *      Asynchronous variant of request_firmware() for user contexts where
688  *      it is not possible to sleep for long time. It can't be called
689  *      in atomic contexts.
690  **/
691 int
692 request_firmware_nowait(
693         struct module *module, bool uevent,
694         const char *name, struct device *device, gfp_t gfp, void *context,
695         void (*cont)(const struct firmware *fw, void *context))
696 {
697         struct task_struct *task;
698         struct firmware_work *fw_work;
699
700         fw_work = kzalloc(sizeof (struct firmware_work), gfp);
701         if (!fw_work)
702                 return -ENOMEM;
703
704         fw_work->module = module;
705         fw_work->name = name;
706         fw_work->device = device;
707         fw_work->context = context;
708         fw_work->cont = cont;
709         fw_work->uevent = uevent;
710
711         if (!try_module_get(module)) {
712                 kfree(fw_work);
713                 return -EFAULT;
714         }
715
716         task = kthread_run(request_firmware_work_func, fw_work,
717                             "firmware/%s", name);
718         if (IS_ERR(task)) {
719                 fw_work->cont(NULL, fw_work->context);
720                 module_put(fw_work->module);
721                 kfree(fw_work);
722                 return PTR_ERR(task);
723         }
724
725         return 0;
726 }
727
728 static int __init firmware_class_init(void)
729 {
730         return class_register(&firmware_class);
731 }
732
733 static void __exit firmware_class_exit(void)
734 {
735         class_unregister(&firmware_class);
736 }
737
738 fs_initcall(firmware_class_init);
739 module_exit(firmware_class_exit);
740
741 EXPORT_SYMBOL(release_firmware);
742 EXPORT_SYMBOL(request_firmware);
743 EXPORT_SYMBOL(request_firmware_nowait);