diff options
author | Andrey Panin <pazke@donpac.ru> | 2005-06-25 17:54:47 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-06-25 19:24:28 -0400 |
commit | 1249c5138f573890eae0c01f13d627094edcd55c (patch) | |
tree | 2c116cafdef2de503266d67e4ddbd0fb7a1ff093 /arch/i386/kernel/dmi_scan.c | |
parent | b625883f24d018c989173aeb727f6de954fb154d (diff) |
[PATCH] dmi: spring cleanup
Whitespace and CodingStyle cleanup. No functionality changes.
Signed-off-by: Andrey Panin <pazke@donpac.ru>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'arch/i386/kernel/dmi_scan.c')
-rw-r--r-- | arch/i386/kernel/dmi_scan.c | 163 |
1 files changed, 70 insertions, 93 deletions
diff --git a/arch/i386/kernel/dmi_scan.c b/arch/i386/kernel/dmi_scan.c index ad4b369a5837..a3cdf894302b 100644 --- a/arch/i386/kernel/dmi_scan.c +++ b/arch/i386/kernel/dmi_scan.c | |||
@@ -1,22 +1,15 @@ | |||
1 | #include <linux/types.h> | 1 | #include <linux/types.h> |
2 | #include <linux/kernel.h> | ||
3 | #include <linux/string.h> | 2 | #include <linux/string.h> |
4 | #include <linux/init.h> | 3 | #include <linux/init.h> |
5 | #include <linux/module.h> | 4 | #include <linux/module.h> |
6 | #include <linux/slab.h> | ||
7 | #include <linux/acpi.h> | ||
8 | #include <asm/io.h> | ||
9 | #include <linux/pm.h> | ||
10 | #include <asm/system.h> | ||
11 | #include <linux/dmi.h> | 5 | #include <linux/dmi.h> |
12 | #include <linux/bootmem.h> | 6 | #include <linux/bootmem.h> |
13 | 7 | ||
14 | 8 | ||
15 | struct dmi_header | 9 | struct dmi_header { |
16 | { | 10 | u8 type; |
17 | u8 type; | 11 | u8 length; |
18 | u8 length; | 12 | u16 handle; |
19 | u16 handle; | ||
20 | }; | 13 | }; |
21 | 14 | ||
22 | #undef DMI_DEBUG | 15 | #undef DMI_DEBUG |
@@ -29,15 +22,13 @@ struct dmi_header | |||
29 | 22 | ||
30 | static char * __init dmi_string(struct dmi_header *dm, u8 s) | 23 | static char * __init dmi_string(struct dmi_header *dm, u8 s) |
31 | { | 24 | { |
32 | u8 *bp=(u8 *)dm; | 25 | u8 *bp = ((u8 *) dm) + dm->length; |
33 | bp+=dm->length; | 26 | |
34 | if(!s) | 27 | if (!s) |
35 | return ""; | 28 | return ""; |
36 | s--; | 29 | s--; |
37 | while(s>0 && *bp) | 30 | while (s > 0 && *bp) { |
38 | { | 31 | bp += strlen(bp) + 1; |
39 | bp+=strlen(bp); | ||
40 | bp++; | ||
41 | s--; | 32 | s--; |
42 | } | 33 | } |
43 | return bp; | 34 | return bp; |
@@ -47,16 +38,14 @@ static char * __init dmi_string(struct dmi_header *dm, u8 s) | |||
47 | * We have to be cautious here. We have seen BIOSes with DMI pointers | 38 | * We have to be cautious here. We have seen BIOSes with DMI pointers |
48 | * pointing to completely the wrong place for example | 39 | * pointing to completely the wrong place for example |
49 | */ | 40 | */ |
50 | 41 | static int __init dmi_table(u32 base, int len, int num, | |
51 | static int __init dmi_table(u32 base, int len, int num, void (*decode)(struct dmi_header *)) | 42 | void (*decode)(struct dmi_header *)) |
52 | { | 43 | { |
53 | u8 *buf; | 44 | u8 *buf, *data; |
54 | struct dmi_header *dm; | 45 | int i = 0; |
55 | u8 *data; | ||
56 | int i=0; | ||
57 | 46 | ||
58 | buf = bt_ioremap(base, len); | 47 | buf = bt_ioremap(base, len); |
59 | if(buf==NULL) | 48 | if (buf == NULL) |
60 | return -1; | 49 | return -1; |
61 | 50 | ||
62 | data = buf; | 51 | data = buf; |
@@ -65,36 +54,34 @@ static int __init dmi_table(u32 base, int len, int num, void (*decode)(struct dm | |||
65 | * Stop when we see all the items the table claimed to have | 54 | * Stop when we see all the items the table claimed to have |
66 | * OR we run off the end of the table (also happens) | 55 | * OR we run off the end of the table (also happens) |
67 | */ | 56 | */ |
68 | 57 | while ((i < num) && (data - buf + sizeof(struct dmi_header)) <= len) { | |
69 | while(i<num && data-buf+sizeof(struct dmi_header)<=len) | 58 | struct dmi_header *dm = (struct dmi_header *)data; |
70 | { | ||
71 | dm=(struct dmi_header *)data; | ||
72 | /* | 59 | /* |
73 | * We want to know the total length (formated area and strings) | 60 | * We want to know the total length (formated area and strings) |
74 | * before decoding to make sure we won't run off the table in | 61 | * before decoding to make sure we won't run off the table in |
75 | * dmi_decode or dmi_string | 62 | * dmi_decode or dmi_string |
76 | */ | 63 | */ |
77 | data+=dm->length; | 64 | data += dm->length; |
78 | while(data-buf<len-1 && (data[0] || data[1])) | 65 | while ((data - buf < len - 1) && (data[0] || data[1])) |
79 | data++; | 66 | data++; |
80 | if(data-buf<len-1) | 67 | if (data - buf < len - 1) |
81 | decode(dm); | 68 | decode(dm); |
82 | data+=2; | 69 | data += 2; |
83 | i++; | 70 | i++; |
84 | } | 71 | } |
85 | bt_iounmap(buf, len); | 72 | bt_iounmap(buf, len); |
86 | return 0; | 73 | return 0; |
87 | } | 74 | } |
88 | 75 | ||
89 | 76 | static int __init dmi_checksum(u8 *buf) | |
90 | inline static int __init dmi_checksum(u8 *buf) | ||
91 | { | 77 | { |
92 | u8 sum=0; | 78 | u8 sum = 0; |
93 | int a; | 79 | int a; |
94 | 80 | ||
95 | for(a=0; a<15; a++) | 81 | for (a = 0; a < 15; a++) |
96 | sum+=buf[a]; | 82 | sum += buf[a]; |
97 | return (sum==0); | 83 | |
84 | return sum == 0; | ||
98 | } | 85 | } |
99 | 86 | ||
100 | static int __init dmi_iterate(void (*decode)(struct dmi_header *)) | 87 | static int __init dmi_iterate(void (*decode)(struct dmi_header *)) |
@@ -110,28 +97,30 @@ static int __init dmi_iterate(void (*decode)(struct dmi_header *)) | |||
110 | p = ioremap(0xF0000, 0x10000); | 97 | p = ioremap(0xF0000, 0x10000); |
111 | if (p == NULL) | 98 | if (p == NULL) |
112 | return -1; | 99 | return -1; |
100 | |||
113 | for (q = p; q < p + 0x10000; q += 16) { | 101 | for (q = p; q < p + 0x10000; q += 16) { |
114 | memcpy_fromio(buf, q, 15); | 102 | memcpy_fromio(buf, q, 15); |
115 | if(memcmp(buf, "_DMI_", 5)==0 && dmi_checksum(buf)) | 103 | if ((memcmp(buf, "_DMI_", 5) == 0) && dmi_checksum(buf)) { |
116 | { | 104 | u16 num = (buf[13] << 8) | buf[12]; |
117 | u16 num=buf[13]<<8|buf[12]; | 105 | u16 len = (buf[7] << 8) | buf[6]; |
118 | u16 len=buf[7]<<8|buf[6]; | 106 | u32 base = (buf[11] << 24) | (buf[10] << 16) | |
119 | u32 base=buf[11]<<24|buf[10]<<16|buf[9]<<8|buf[8]; | 107 | (buf[9] << 8) | buf[8]; |
120 | 108 | ||
121 | /* | 109 | /* |
122 | * DMI version 0.0 means that the real version is taken from | 110 | * DMI version 0.0 means that the real version is taken from |
123 | * the SMBIOS version, which we don't know at this point. | 111 | * the SMBIOS version, which we don't know at this point. |
124 | */ | 112 | */ |
125 | if(buf[14]!=0) | 113 | if (buf[14] != 0) |
126 | printk(KERN_INFO "DMI %d.%d present.\n", | 114 | printk(KERN_INFO "DMI %d.%d present.\n", |
127 | buf[14]>>4, buf[14]&0x0F); | 115 | buf[14] >> 4, buf[14] & 0xF); |
128 | else | 116 | else |
129 | printk(KERN_INFO "DMI present.\n"); | 117 | printk(KERN_INFO "DMI present.\n"); |
118 | |||
130 | dmi_printk((KERN_INFO "%d structures occupying %d bytes.\n", | 119 | dmi_printk((KERN_INFO "%d structures occupying %d bytes.\n", |
131 | num, len)); | 120 | num, len)); |
132 | dmi_printk((KERN_INFO "DMI table at 0x%08X.\n", | 121 | dmi_printk((KERN_INFO "DMI table at 0x%08X.\n", base)); |
133 | base)); | 122 | |
134 | if(dmi_table(base,len, num, decode)==0) | 123 | if (dmi_table(base,len, num, decode) == 0) |
135 | return 0; | 124 | return 0; |
136 | } | 125 | } |
137 | } | 126 | } |
@@ -143,16 +132,17 @@ static char *dmi_ident[DMI_STRING_MAX]; | |||
143 | /* | 132 | /* |
144 | * Save a DMI string | 133 | * Save a DMI string |
145 | */ | 134 | */ |
146 | |||
147 | static void __init dmi_save_ident(struct dmi_header *dm, int slot, int string) | 135 | static void __init dmi_save_ident(struct dmi_header *dm, int slot, int string) |
148 | { | 136 | { |
149 | char *d = (char*)dm; | 137 | char *d = (char*)dm; |
150 | char *p = dmi_string(dm, d[string]); | 138 | char *p = dmi_string(dm, d[string]); |
151 | if(p==NULL || *p == 0) | 139 | |
140 | if (p == NULL || *p == 0) | ||
152 | return; | 141 | return; |
153 | if (dmi_ident[slot]) | 142 | if (dmi_ident[slot]) |
154 | return; | 143 | return; |
155 | dmi_ident[slot] = alloc_bootmem(strlen(p)+1); | 144 | |
145 | dmi_ident[slot] = alloc_bootmem(strlen(p) + 1); | ||
156 | if(dmi_ident[slot]) | 146 | if(dmi_ident[slot]) |
157 | strcpy(dmi_ident[slot], p); | 147 | strcpy(dmi_ident[slot], p); |
158 | else | 148 | else |
@@ -166,48 +156,35 @@ static void __init dmi_save_ident(struct dmi_header *dm, int slot, int string) | |||
166 | */ | 156 | */ |
167 | static void __init dmi_decode(struct dmi_header *dm) | 157 | static void __init dmi_decode(struct dmi_header *dm) |
168 | { | 158 | { |
169 | #ifdef DMI_DEBUG | 159 | u8 *data __attribute__((__unused__)) = (u8 *)dm; |
170 | u8 *data = (u8 *)dm; | ||
171 | #endif | ||
172 | 160 | ||
173 | switch(dm->type) | 161 | switch(dm->type) { |
174 | { | 162 | case 0: |
175 | case 0: | 163 | dmi_printk(("BIOS Vendor: %s\n", dmi_string(dm, data[4]))); |
176 | dmi_printk(("BIOS Vendor: %s\n", | 164 | dmi_save_ident(dm, DMI_BIOS_VENDOR, 4); |
177 | dmi_string(dm, data[4]))); | 165 | dmi_printk(("BIOS Version: %s\n", dmi_string(dm, data[5]))); |
178 | dmi_save_ident(dm, DMI_BIOS_VENDOR, 4); | 166 | dmi_save_ident(dm, DMI_BIOS_VERSION, 5); |
179 | dmi_printk(("BIOS Version: %s\n", | 167 | dmi_printk(("BIOS Release: %s\n", dmi_string(dm, data[8]))); |
180 | dmi_string(dm, data[5]))); | 168 | dmi_save_ident(dm, DMI_BIOS_DATE, 8); |
181 | dmi_save_ident(dm, DMI_BIOS_VERSION, 5); | 169 | break; |
182 | dmi_printk(("BIOS Release: %s\n", | 170 | case 1: |
183 | dmi_string(dm, data[8]))); | 171 | dmi_printk(("System Vendor: %s\n", dmi_string(dm, data[4]))); |
184 | dmi_save_ident(dm, DMI_BIOS_DATE, 8); | 172 | dmi_save_ident(dm, DMI_SYS_VENDOR, 4); |
185 | break; | 173 | dmi_printk(("Product Name: %s\n", dmi_string(dm, data[5]))); |
186 | case 1: | 174 | dmi_save_ident(dm, DMI_PRODUCT_NAME, 5); |
187 | dmi_printk(("System Vendor: %s\n", | 175 | dmi_printk(("Version: %s\n", dmi_string(dm, data[6]))); |
188 | dmi_string(dm, data[4]))); | 176 | dmi_save_ident(dm, DMI_PRODUCT_VERSION, 6); |
189 | dmi_save_ident(dm, DMI_SYS_VENDOR, 4); | 177 | dmi_printk(("Serial Number: %s\n", dmi_string(dm, data[7]))); |
190 | dmi_printk(("Product Name: %s\n", | 178 | dmi_save_ident(dm, DMI_PRODUCT_SERIAL, 7); |
191 | dmi_string(dm, data[5]))); | 179 | break; |
192 | dmi_save_ident(dm, DMI_PRODUCT_NAME, 5); | 180 | case 2: |
193 | dmi_printk(("Version: %s\n", | 181 | dmi_printk(("Board Vendor: %s\n", dmi_string(dm, data[4]))); |
194 | dmi_string(dm, data[6]))); | 182 | dmi_save_ident(dm, DMI_BOARD_VENDOR, 4); |
195 | dmi_save_ident(dm, DMI_PRODUCT_VERSION, 6); | 183 | dmi_printk(("Board Name: %s\n", dmi_string(dm, data[5]))); |
196 | dmi_printk(("Serial Number: %s\n", | 184 | dmi_save_ident(dm, DMI_BOARD_NAME, 5); |
197 | dmi_string(dm, data[7]))); | 185 | dmi_printk(("Board Version: %s\n", dmi_string(dm, data[6]))); |
198 | dmi_save_ident(dm, DMI_PRODUCT_SERIAL, 7); | 186 | dmi_save_ident(dm, DMI_BOARD_VERSION, 6); |
199 | break; | 187 | break; |
200 | case 2: | ||
201 | dmi_printk(("Board Vendor: %s\n", | ||
202 | dmi_string(dm, data[4]))); | ||
203 | dmi_save_ident(dm, DMI_BOARD_VENDOR, 4); | ||
204 | dmi_printk(("Board Name: %s\n", | ||
205 | dmi_string(dm, data[5]))); | ||
206 | dmi_save_ident(dm, DMI_BOARD_NAME, 5); | ||
207 | dmi_printk(("Board Version: %s\n", | ||
208 | dmi_string(dm, data[6]))); | ||
209 | dmi_save_ident(dm, DMI_BOARD_VERSION, 6); | ||
210 | break; | ||
211 | } | 188 | } |
212 | } | 189 | } |
213 | 190 | ||