diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2008-07-14 19:54:07 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-07-14 19:54:07 -0400 |
commit | 5a86102248592e178a9023359ccf7f0e489d8e35 (patch) | |
tree | 9e5fdb9aafca687fa412f7c034f2cfbb834b8567 /include | |
parent | 85082fd7cbe3173198aac0eb5e85ab1edcc6352c (diff) | |
parent | 751851af7aae9b8bd5a60b3897209081fbc18b2b (diff) |
Merge branch 'for-2.6.27' of git://git.infradead.org/users/dwmw2/firmware-2.6
* 'for-2.6.27' of git://git.infradead.org/users/dwmw2/firmware-2.6: (64 commits)
firmware: convert sb16_csp driver to use firmware loader exclusively
dsp56k: use request_firmware
edgeport-ti: use request_firmware()
edgeport: use request_firmware()
vicam: use request_firmware()
dabusb: use request_firmware()
cpia2: use request_firmware()
ip2: use request_firmware()
firmware: convert Ambassador ATM driver to request_firmware()
whiteheat: use request_firmware()
ti_usb_3410_5052: use request_firmware()
emi62: use request_firmware()
emi26: use request_firmware()
keyspan_pda: use request_firmware()
keyspan: use request_firmware()
ttusb-budget: use request_firmware()
kaweth: use request_firmware()
smctr: use request_firmware()
firmware: convert ymfpci driver to use firmware loader exclusively
firmware: convert maestro3 driver to use firmware loader exclusively
...
Fix up trivial conflicts with BKL removal in drivers/char/dsp56k.c and
drivers/char/ip2/ip2main.c manually.
Diffstat (limited to 'include')
-rw-r--r-- | include/asm-generic/vmlinux.lds.h | 7 | ||||
-rw-r--r-- | include/linux/firmware.h | 23 | ||||
-rw-r--r-- | include/linux/ihex.h | 74 |
3 files changed, 103 insertions, 1 deletions
diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h index bf2851f93937..b20409404c7d 100644 --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h | |||
@@ -88,6 +88,13 @@ | |||
88 | VMLINUX_SYMBOL(__end_pci_fixups_resume) = .; \ | 88 | VMLINUX_SYMBOL(__end_pci_fixups_resume) = .; \ |
89 | } \ | 89 | } \ |
90 | \ | 90 | \ |
91 | /* Built-in firmware blobs */ \ | ||
92 | .builtin_fw : AT(ADDR(.builtin_fw) - LOAD_OFFSET) { \ | ||
93 | VMLINUX_SYMBOL(__start_builtin_fw) = .; \ | ||
94 | *(.builtin_fw) \ | ||
95 | VMLINUX_SYMBOL(__end_builtin_fw) = .; \ | ||
96 | } \ | ||
97 | \ | ||
91 | /* RapidIO route ops */ \ | 98 | /* RapidIO route ops */ \ |
92 | .rio_route : AT(ADDR(.rio_route) - LOAD_OFFSET) { \ | 99 | .rio_route : AT(ADDR(.rio_route) - LOAD_OFFSET) { \ |
93 | VMLINUX_SYMBOL(__start_rio_route_ops) = .; \ | 100 | VMLINUX_SYMBOL(__start_rio_route_ops) = .; \ |
diff --git a/include/linux/firmware.h b/include/linux/firmware.h index 6c7eff2ebada..c8ecf5b2a207 100644 --- a/include/linux/firmware.h +++ b/include/linux/firmware.h | |||
@@ -1,18 +1,39 @@ | |||
1 | #ifndef _LINUX_FIRMWARE_H | 1 | #ifndef _LINUX_FIRMWARE_H |
2 | #define _LINUX_FIRMWARE_H | 2 | #define _LINUX_FIRMWARE_H |
3 | |||
3 | #include <linux/module.h> | 4 | #include <linux/module.h> |
4 | #include <linux/types.h> | 5 | #include <linux/types.h> |
6 | #include <linux/compiler.h> | ||
7 | |||
5 | #define FIRMWARE_NAME_MAX 30 | 8 | #define FIRMWARE_NAME_MAX 30 |
6 | #define FW_ACTION_NOHOTPLUG 0 | 9 | #define FW_ACTION_NOHOTPLUG 0 |
7 | #define FW_ACTION_HOTPLUG 1 | 10 | #define FW_ACTION_HOTPLUG 1 |
8 | 11 | ||
9 | struct firmware { | 12 | struct firmware { |
10 | size_t size; | 13 | size_t size; |
11 | u8 *data; | 14 | const u8 *data; |
12 | }; | 15 | }; |
13 | 16 | ||
14 | struct device; | 17 | struct device; |
15 | 18 | ||
19 | struct builtin_fw { | ||
20 | char *name; | ||
21 | void *data; | ||
22 | unsigned long size; | ||
23 | }; | ||
24 | |||
25 | /* We have to play tricks here much like stringify() to get the | ||
26 | __COUNTER__ macro to be expanded as we want it */ | ||
27 | #define __fw_concat1(x, y) x##y | ||
28 | #define __fw_concat(x, y) __fw_concat1(x, y) | ||
29 | |||
30 | #define DECLARE_BUILTIN_FIRMWARE(name, blob) \ | ||
31 | DECLARE_BUILTIN_FIRMWARE_SIZE(name, &(blob), sizeof(blob)) | ||
32 | |||
33 | #define DECLARE_BUILTIN_FIRMWARE_SIZE(name, blob, size) \ | ||
34 | static const struct builtin_fw __fw_concat(__builtin_fw,__COUNTER__) \ | ||
35 | __used __section(.builtin_fw) = { name, blob, size } | ||
36 | |||
16 | #if defined(CONFIG_FW_LOADER) || (defined(CONFIG_FW_LOADER_MODULE) && defined(MODULE)) | 37 | #if defined(CONFIG_FW_LOADER) || (defined(CONFIG_FW_LOADER_MODULE) && defined(MODULE)) |
17 | int request_firmware(const struct firmware **fw, const char *name, | 38 | int request_firmware(const struct firmware **fw, const char *name, |
18 | struct device *device); | 39 | struct device *device); |
diff --git a/include/linux/ihex.h b/include/linux/ihex.h new file mode 100644 index 000000000000..2baace2788a7 --- /dev/null +++ b/include/linux/ihex.h | |||
@@ -0,0 +1,74 @@ | |||
1 | /* | ||
2 | * Compact binary representation of ihex records. Some devices need their | ||
3 | * firmware loaded in strange orders rather than a single big blob, but | ||
4 | * actually parsing ihex-as-text within the kernel seems silly. Thus,... | ||
5 | */ | ||
6 | |||
7 | #ifndef __LINUX_IHEX_H__ | ||
8 | #define __LINUX_IHEX_H__ | ||
9 | |||
10 | #include <linux/types.h> | ||
11 | #include <linux/firmware.h> | ||
12 | #include <linux/device.h> | ||
13 | |||
14 | /* Intel HEX files actually limit the length to 256 bytes, but we have | ||
15 | drivers which would benefit from using separate records which are | ||
16 | longer than that, so we extend to 16 bits of length */ | ||
17 | struct ihex_binrec { | ||
18 | __be32 addr; | ||
19 | __be16 len; | ||
20 | uint8_t data[0]; | ||
21 | } __attribute__((aligned(4))); | ||
22 | |||
23 | /* Find the next record, taking into account the 4-byte alignment */ | ||
24 | static inline const struct ihex_binrec * | ||
25 | ihex_next_binrec(const struct ihex_binrec *rec) | ||
26 | { | ||
27 | int next = ((be16_to_cpu(rec->len) + 5) & ~3) - 2; | ||
28 | rec = (void *)&rec->data[next]; | ||
29 | |||
30 | return be16_to_cpu(rec->len) ? rec : NULL; | ||
31 | } | ||
32 | |||
33 | /* Check that ihex_next_binrec() won't take us off the end of the image... */ | ||
34 | static inline int ihex_validate_fw(const struct firmware *fw) | ||
35 | { | ||
36 | const struct ihex_binrec *rec; | ||
37 | size_t ofs = 0; | ||
38 | |||
39 | while (ofs <= fw->size - sizeof(*rec)) { | ||
40 | rec = (void *)&fw->data[ofs]; | ||
41 | |||
42 | /* Zero length marks end of records */ | ||
43 | if (!be16_to_cpu(rec->len)) | ||
44 | return 0; | ||
45 | |||
46 | /* Point to next record... */ | ||
47 | ofs += (sizeof(*rec) + be16_to_cpu(rec->len) + 3) & ~3; | ||
48 | } | ||
49 | return -EINVAL; | ||
50 | } | ||
51 | |||
52 | /* Request firmware and validate it so that we can trust we won't | ||
53 | * run off the end while reading records... */ | ||
54 | static inline int request_ihex_firmware(const struct firmware **fw, | ||
55 | const char *fw_name, | ||
56 | struct device *dev) | ||
57 | { | ||
58 | const struct firmware *lfw; | ||
59 | int ret; | ||
60 | |||
61 | ret = request_firmware(&lfw, fw_name, dev); | ||
62 | if (ret) | ||
63 | return ret; | ||
64 | ret = ihex_validate_fw(lfw); | ||
65 | if (ret) { | ||
66 | dev_err(dev, "Firmware \"%s\" not valid IHEX records\n", | ||
67 | fw_name); | ||
68 | release_firmware(lfw); | ||
69 | return ret; | ||
70 | } | ||
71 | *fw = lfw; | ||
72 | return 0; | ||
73 | } | ||
74 | #endif /* __LINUX_IHEX_H__ */ | ||