diff options
author | Uwe Kleine-König <Uwe.Kleine-Koenig@digi.com> | 2008-02-21 09:04:40 -0500 |
---|---|---|
committer | Uwe Kleine-König <Uwe.Kleine-Koenig@digi.com> | 2008-05-30 04:33:49 -0400 |
commit | f7b0b939d54b457ba172e088f477af2012aef9b3 (patch) | |
tree | 297ab46adf231fe05766e4030e80d17234f467a1 | |
parent | 8ff7f2a46bd8831e1f1f2a694ec13921720180b7 (diff) |
clean up atags exporting code
This gets rid of two static variables (one of them being __initdata)
and a static function.
Signed-off-by: Uwe Kleine-König <Uwe.Kleine-Koenig@digi.com>
Acked-by: Uli Luckas <u.luckas@road.de>
-rw-r--r-- | arch/arm/kernel/atags.c | 80 |
1 files changed, 39 insertions, 41 deletions
diff --git a/arch/arm/kernel/atags.c b/arch/arm/kernel/atags.c index 56fef9a05504..42a1a1415fa6 100644 --- a/arch/arm/kernel/atags.c +++ b/arch/arm/kernel/atags.c | |||
@@ -6,9 +6,8 @@ | |||
6 | 6 | ||
7 | struct buffer { | 7 | struct buffer { |
8 | size_t size; | 8 | size_t size; |
9 | char *data; | 9 | char data[]; |
10 | }; | 10 | }; |
11 | static struct buffer tags_buffer; | ||
12 | 11 | ||
13 | static int | 12 | static int |
14 | read_buffer(char* page, char** start, off_t off, int count, | 13 | read_buffer(char* page, char** start, off_t off, int count, |
@@ -28,58 +27,57 @@ read_buffer(char* page, char** start, off_t off, int count, | |||
28 | return count; | 27 | return count; |
29 | } | 28 | } |
30 | 29 | ||
31 | |||
32 | static int | ||
33 | create_proc_entries(void) | ||
34 | { | ||
35 | struct proc_dir_entry* tags_entry; | ||
36 | |||
37 | tags_entry = create_proc_read_entry("atags", 0400, NULL, read_buffer, &tags_buffer); | ||
38 | if (!tags_entry) | ||
39 | return -ENOMEM; | ||
40 | |||
41 | return 0; | ||
42 | } | ||
43 | |||
44 | #define BOOT_PARAMS_SIZE 1536 | 30 | #define BOOT_PARAMS_SIZE 1536 |
45 | static char __initdata atags_copy_buf[BOOT_PARAMS_SIZE]; | 31 | static char __initdata atags_copy[BOOT_PARAMS_SIZE]; |
46 | static char __initdata *atags_copy; | ||
47 | 32 | ||
48 | void __init save_atags(const struct tag *tags) | 33 | void __init save_atags(const struct tag *tags) |
49 | { | 34 | { |
50 | atags_copy = atags_copy_buf; | 35 | memcpy(atags_copy, tags, sizeof(atags_copy)); |
51 | memcpy(atags_copy, tags, sizeof(atags_copy_buf)); | ||
52 | } | 36 | } |
53 | 37 | ||
54 | |||
55 | static int __init init_atags_procfs(void) | 38 | static int __init init_atags_procfs(void) |
56 | { | 39 | { |
57 | struct tag *tag; | 40 | /* |
58 | int error; | 41 | * This cannot go into save_atags() because kmalloc and proc don't work |
42 | * yet when it is called. | ||
43 | */ | ||
44 | struct proc_dir_entry *tags_entry; | ||
45 | struct tag *tag = (struct tag *)atags_copy; | ||
46 | struct buffer *b; | ||
47 | size_t size; | ||
59 | 48 | ||
60 | if (!atags_copy) { | 49 | if (tag->hdr.tag != ATAG_CORE) { |
61 | printk(KERN_WARNING "Exporting ATAGs: No saved tags found\n"); | 50 | printk(KERN_INFO "No ATAGs?"); |
62 | return -EIO; | 51 | return -EINVAL; |
63 | } | 52 | } |
64 | 53 | ||
65 | for (tag = (struct tag *) atags_copy; tag->hdr.size; tag = tag_next(tag)) | 54 | for (; tag->hdr.size; tag = tag_next(tag)) |
66 | ; | 55 | ; |
67 | 56 | ||
68 | tags_buffer.size = ((char *) tag - atags_copy) + sizeof(tag->hdr); | 57 | /* include the terminating ATAG_NONE */ |
69 | tags_buffer.data = kmalloc(tags_buffer.size, GFP_KERNEL); | 58 | size = (char *)tag - atags_copy + sizeof(struct tag_header); |
70 | if (tags_buffer.data == NULL) | ||
71 | return -ENOMEM; | ||
72 | memcpy(tags_buffer.data, atags_copy, tags_buffer.size); | ||
73 | |||
74 | error = create_proc_entries(); | ||
75 | if (error) { | ||
76 | printk(KERN_ERR "Exporting ATAGs: not enough memory\n"); | ||
77 | kfree(tags_buffer.data); | ||
78 | tags_buffer.size = 0; | ||
79 | tags_buffer.data = NULL; | ||
80 | } | ||
81 | 59 | ||
82 | return error; | 60 | WARN_ON(tag->hdr.tag != ATAG_NONE); |
83 | } | 61 | |
62 | b = kmalloc(sizeof(*b) + size, GFP_KERNEL); | ||
63 | if (!b) | ||
64 | goto nomem; | ||
84 | 65 | ||
66 | b->size = size; | ||
67 | memcpy(b->data, atags_copy, size); | ||
68 | |||
69 | tags_entry = create_proc_read_entry("atags", 0400, | ||
70 | NULL, read_buffer, b); | ||
71 | |||
72 | if (!tags_entry) | ||
73 | goto nomem; | ||
74 | |||
75 | return 0; | ||
76 | |||
77 | nomem: | ||
78 | kfree(b); | ||
79 | printk(KERN_ERR "Exporting ATAGs: not enough memory\n"); | ||
80 | |||
81 | return -ENOMEM; | ||
82 | } | ||
85 | arch_initcall(init_atags_procfs); | 83 | arch_initcall(init_atags_procfs); |