aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Torokhov <dmitry.torokhov@gmail.com>2010-03-14 03:49:18 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2010-05-21 12:37:30 -0400
commitbcb9bd18e397eabe14b45f4dc4283359ab148d79 (patch)
tree0fbb55b4e90a02824f8dc7aaffc3c26a2f0ebfa3
parent673fae90d5ee4ae2b6403f9d45af7ff640f06a60 (diff)
firmware loader: split out builtin firmware handling
Split builtin firmware handling into separate functions to clean up the main body of code. Signed-off-by: Dmitry Torokhov <dtor@mail.ru> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r--drivers/base/firmware_class.c76
1 files changed, 50 insertions, 26 deletions
diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
index d351e773f439..c378a355bed4 100644
--- a/drivers/base/firmware_class.c
+++ b/drivers/base/firmware_class.c
@@ -27,6 +27,52 @@ MODULE_AUTHOR("Manuel Estrada Sainz");
27MODULE_DESCRIPTION("Multi purpose firmware loading support"); 27MODULE_DESCRIPTION("Multi purpose firmware loading support");
28MODULE_LICENSE("GPL"); 28MODULE_LICENSE("GPL");
29 29
30/* Builtin firmware support */
31
32#ifdef CONFIG_FW_LOADER
33
34extern struct builtin_fw __start_builtin_fw[];
35extern struct builtin_fw __end_builtin_fw[];
36
37static 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
52static 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
65static inline bool fw_get_builtin_firmware(struct firmware *fw, const char *name)
66{
67 return false;
68}
69
70static inline bool fw_is_builtin_firmware(const struct firmware *fw)
71{
72 return false;
73}
74#endif
75
30enum { 76enum {
31 FW_STATUS_LOADING, 77 FW_STATUS_LOADING,
32 FW_STATUS_DONE, 78 FW_STATUS_DONE,
@@ -53,14 +99,6 @@ struct firmware_priv {
53 bool nowait; 99 bool nowait;
54}; 100};
55 101
56#ifdef CONFIG_FW_LOADER
57extern struct builtin_fw __start_builtin_fw[];
58extern struct builtin_fw __end_builtin_fw[];
59#else /* Module case. Avoid ifdefs later; it'll all optimise out */
60static struct builtin_fw *__start_builtin_fw;
61static struct builtin_fw *__end_builtin_fw;
62#endif
63
64static void 102static void
65fw_load_abort(struct firmware_priv *fw_priv) 103fw_load_abort(struct firmware_priv *fw_priv)
66{ 104{
@@ -497,7 +535,6 @@ _request_firmware(const struct firmware **firmware_p, const char *name,
497 struct device *f_dev; 535 struct device *f_dev;
498 struct firmware_priv *fw_priv; 536 struct firmware_priv *fw_priv;
499 struct firmware *firmware; 537 struct firmware *firmware;
500 struct builtin_fw *builtin;
501 int retval; 538 int retval;
502 539
503 if (!firmware_p) 540 if (!firmware_p)
@@ -511,13 +548,8 @@ _request_firmware(const struct firmware **firmware_p, const char *name,
511 goto out; 548 goto out;
512 } 549 }
513 550
514 for (builtin = __start_builtin_fw; builtin != __end_builtin_fw; 551 if (fw_get_builtin_firmware(firmware, name)) {
515 builtin++) {
516 if (strcmp(name, builtin->name))
517 continue;
518 dev_dbg(device, "firmware: using built-in firmware %s\n", name); 552 dev_dbg(device, "firmware: using built-in firmware %s\n", name);
519 firmware->size = builtin->size;
520 firmware->data = builtin->data;
521 return 0; 553 return 0;
522 } 554 }
523 555
@@ -589,19 +621,11 @@ request_firmware(const struct firmware **firmware_p, const char *name,
589 * release_firmware: - release the resource associated with a firmware image 621 * release_firmware: - release the resource associated with a firmware image
590 * @fw: firmware resource to release 622 * @fw: firmware resource to release
591 **/ 623 **/
592void 624void release_firmware(const struct firmware *fw)
593release_firmware(const struct firmware *fw)
594{ 625{
595 struct builtin_fw *builtin;
596
597 if (fw) { 626 if (fw) {
598 for (builtin = __start_builtin_fw; builtin != __end_builtin_fw; 627 if (!fw_is_builtin_firmware(fw))
599 builtin++) { 628 firmware_free_data(fw);
600 if (fw->data == builtin->data)
601 goto free_fw;
602 }
603 firmware_free_data(fw);
604 free_fw:
605 kfree(fw); 629 kfree(fw);
606 } 630 }
607} 631}