aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/firmware/dmi_scan.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/firmware/dmi_scan.c')
-rw-r--r--drivers/firmware/dmi_scan.c73
1 files changed, 29 insertions, 44 deletions
diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
index 232fa8fce26a..fa0affb699b4 100644
--- a/drivers/firmware/dmi_scan.c
+++ b/drivers/firmware/dmi_scan.c
@@ -14,7 +14,7 @@
14 * of and an antecedent to, SMBIOS, which stands for System 14 * of and an antecedent to, SMBIOS, which stands for System
15 * Management BIOS. See further: http://www.dmtf.org/standards 15 * Management BIOS. See further: http://www.dmtf.org/standards
16 */ 16 */
17static char dmi_empty_string[] = " "; 17static const char dmi_empty_string[] = " ";
18 18
19static u16 __initdata dmi_ver; 19static u16 __initdata dmi_ver;
20/* 20/*
@@ -49,7 +49,7 @@ static const char * __init dmi_string_nosave(const struct dmi_header *dm, u8 s)
49 return ""; 49 return "";
50} 50}
51 51
52static char * __init dmi_string(const struct dmi_header *dm, u8 s) 52static const char * __init dmi_string(const struct dmi_header *dm, u8 s)
53{ 53{
54 const char *bp = dmi_string_nosave(dm, s); 54 const char *bp = dmi_string_nosave(dm, s);
55 char *str; 55 char *str;
@@ -62,8 +62,6 @@ static char * __init dmi_string(const struct dmi_header *dm, u8 s)
62 str = dmi_alloc(len); 62 str = dmi_alloc(len);
63 if (str != NULL) 63 if (str != NULL)
64 strcpy(str, bp); 64 strcpy(str, bp);
65 else
66 printk(KERN_ERR "dmi_string: cannot allocate %Zu bytes.\n", len);
67 65
68 return str; 66 return str;
69} 67}
@@ -133,17 +131,18 @@ static int __init dmi_checksum(const u8 *buf, u8 len)
133 return sum == 0; 131 return sum == 0;
134} 132}
135 133
136static char *dmi_ident[DMI_STRING_MAX]; 134static const char *dmi_ident[DMI_STRING_MAX];
137static LIST_HEAD(dmi_devices); 135static LIST_HEAD(dmi_devices);
138int dmi_available; 136int dmi_available;
139 137
140/* 138/*
141 * Save a DMI string 139 * Save a DMI string
142 */ 140 */
143static void __init dmi_save_ident(const struct dmi_header *dm, int slot, int string) 141static void __init dmi_save_ident(const struct dmi_header *dm, int slot,
142 int string)
144{ 143{
145 const char *d = (const char*) dm; 144 const char *d = (const char *) dm;
146 char *p; 145 const char *p;
147 146
148 if (dmi_ident[slot]) 147 if (dmi_ident[slot])
149 return; 148 return;
@@ -155,9 +154,10 @@ static void __init dmi_save_ident(const struct dmi_header *dm, int slot, int str
155 dmi_ident[slot] = p; 154 dmi_ident[slot] = p;
156} 155}
157 156
158static void __init dmi_save_uuid(const struct dmi_header *dm, int slot, int index) 157static void __init dmi_save_uuid(const struct dmi_header *dm, int slot,
158 int index)
159{ 159{
160 const u8 *d = (u8*) dm + index; 160 const u8 *d = (u8 *) dm + index;
161 char *s; 161 char *s;
162 int is_ff = 1, is_00 = 1, i; 162 int is_ff = 1, is_00 = 1, i;
163 163
@@ -188,12 +188,13 @@ static void __init dmi_save_uuid(const struct dmi_header *dm, int slot, int inde
188 else 188 else
189 sprintf(s, "%pUB", d); 189 sprintf(s, "%pUB", d);
190 190
191 dmi_ident[slot] = s; 191 dmi_ident[slot] = s;
192} 192}
193 193
194static void __init dmi_save_type(const struct dmi_header *dm, int slot, int index) 194static void __init dmi_save_type(const struct dmi_header *dm, int slot,
195 int index)
195{ 196{
196 const u8 *d = (u8*) dm + index; 197 const u8 *d = (u8 *) dm + index;
197 char *s; 198 char *s;
198 199
199 if (dmi_ident[slot]) 200 if (dmi_ident[slot])
@@ -216,10 +217,8 @@ static void __init dmi_save_one_device(int type, const char *name)
216 return; 217 return;
217 218
218 dev = dmi_alloc(sizeof(*dev) + strlen(name) + 1); 219 dev = dmi_alloc(sizeof(*dev) + strlen(name) + 1);
219 if (!dev) { 220 if (!dev)
220 printk(KERN_ERR "dmi_save_one_device: out of memory.\n");
221 return; 221 return;
222 }
223 222
224 dev->type = type; 223 dev->type = type;
225 strcpy((char *)(dev + 1), name); 224 strcpy((char *)(dev + 1), name);
@@ -249,17 +248,14 @@ static void __init dmi_save_oem_strings_devices(const struct dmi_header *dm)
249 struct dmi_device *dev; 248 struct dmi_device *dev;
250 249
251 for (i = 1; i <= count; i++) { 250 for (i = 1; i <= count; i++) {
252 char *devname = dmi_string(dm, i); 251 const char *devname = dmi_string(dm, i);
253 252
254 if (devname == dmi_empty_string) 253 if (devname == dmi_empty_string)
255 continue; 254 continue;
256 255
257 dev = dmi_alloc(sizeof(*dev)); 256 dev = dmi_alloc(sizeof(*dev));
258 if (!dev) { 257 if (!dev)
259 printk(KERN_ERR
260 "dmi_save_oem_strings_devices: out of memory.\n");
261 break; 258 break;
262 }
263 259
264 dev->type = DMI_DEV_TYPE_OEM_STRING; 260 dev->type = DMI_DEV_TYPE_OEM_STRING;
265 dev->name = devname; 261 dev->name = devname;
@@ -272,21 +268,17 @@ static void __init dmi_save_oem_strings_devices(const struct dmi_header *dm)
272static void __init dmi_save_ipmi_device(const struct dmi_header *dm) 268static void __init dmi_save_ipmi_device(const struct dmi_header *dm)
273{ 269{
274 struct dmi_device *dev; 270 struct dmi_device *dev;
275 void * data; 271 void *data;
276 272
277 data = dmi_alloc(dm->length); 273 data = dmi_alloc(dm->length);
278 if (data == NULL) { 274 if (data == NULL)
279 printk(KERN_ERR "dmi_save_ipmi_device: out of memory.\n");
280 return; 275 return;
281 }
282 276
283 memcpy(data, dm, dm->length); 277 memcpy(data, dm, dm->length);
284 278
285 dev = dmi_alloc(sizeof(*dev)); 279 dev = dmi_alloc(sizeof(*dev));
286 if (!dev) { 280 if (!dev)
287 printk(KERN_ERR "dmi_save_ipmi_device: out of memory.\n");
288 return; 281 return;
289 }
290 282
291 dev->type = DMI_DEV_TYPE_IPMI; 283 dev->type = DMI_DEV_TYPE_IPMI;
292 dev->name = "IPMI controller"; 284 dev->name = "IPMI controller";
@@ -301,10 +293,9 @@ static void __init dmi_save_dev_onboard(int instance, int segment, int bus,
301 struct dmi_dev_onboard *onboard_dev; 293 struct dmi_dev_onboard *onboard_dev;
302 294
303 onboard_dev = dmi_alloc(sizeof(*onboard_dev) + strlen(name) + 1); 295 onboard_dev = dmi_alloc(sizeof(*onboard_dev) + strlen(name) + 1);
304 if (!onboard_dev) { 296 if (!onboard_dev)
305 printk(KERN_ERR "dmi_save_dev_onboard: out of memory.\n");
306 return; 297 return;
307 } 298
308 onboard_dev->instance = instance; 299 onboard_dev->instance = instance;
309 onboard_dev->segment = segment; 300 onboard_dev->segment = segment;
310 onboard_dev->bus = bus; 301 onboard_dev->bus = bus;
@@ -320,7 +311,7 @@ static void __init dmi_save_dev_onboard(int instance, int segment, int bus,
320 311
321static void __init dmi_save_extended_devices(const struct dmi_header *dm) 312static void __init dmi_save_extended_devices(const struct dmi_header *dm)
322{ 313{
323 const u8 *d = (u8*) dm + 5; 314 const u8 *d = (u8 *) dm + 5;
324 315
325 /* Skip disabled device */ 316 /* Skip disabled device */
326 if ((*d & 0x80) == 0) 317 if ((*d & 0x80) == 0)
@@ -338,7 +329,7 @@ static void __init dmi_save_extended_devices(const struct dmi_header *dm)
338 */ 329 */
339static void __init dmi_decode(const struct dmi_header *dm, void *dummy) 330static void __init dmi_decode(const struct dmi_header *dm, void *dummy)
340{ 331{
341 switch(dm->type) { 332 switch (dm->type) {
342 case 0: /* BIOS Information */ 333 case 0: /* BIOS Information */
343 dmi_save_ident(dm, DMI_BIOS_VENDOR, 4); 334 dmi_save_ident(dm, DMI_BIOS_VENDOR, 4);
344 dmi_save_ident(dm, DMI_BIOS_VERSION, 5); 335 dmi_save_ident(dm, DMI_BIOS_VERSION, 5);
@@ -502,13 +493,7 @@ void __init dmi_scan_machine(void)
502 dmi_available = 1; 493 dmi_available = 1;
503 goto out; 494 goto out;
504 } 495 }
505 } 496 } else {
506 else {
507 /*
508 * no iounmap() for that ioremap(); it would be a no-op, but
509 * it's so early in setup that sucker gets confused into doing
510 * what it shouldn't if we actually call it.
511 */
512 p = dmi_ioremap(0xF0000, 0x10000); 497 p = dmi_ioremap(0xF0000, 0x10000);
513 if (p == NULL) 498 if (p == NULL)
514 goto error; 499 goto error;
@@ -533,7 +518,7 @@ void __init dmi_scan_machine(void)
533 dmi_iounmap(p, 0x10000); 518 dmi_iounmap(p, 0x10000);
534 } 519 }
535 error: 520 error:
536 printk(KERN_INFO "DMI not present or invalid.\n"); 521 pr_info("DMI not present or invalid.\n");
537 out: 522 out:
538 dmi_initialized = 1; 523 dmi_initialized = 1;
539} 524}
@@ -669,7 +654,7 @@ int dmi_name_in_serial(const char *str)
669 654
670/** 655/**
671 * dmi_name_in_vendors - Check if string is in the DMI system or board vendor name 656 * dmi_name_in_vendors - Check if string is in the DMI system or board vendor name
672 * @str: Case sensitive Name 657 * @str: Case sensitive Name
673 */ 658 */
674int dmi_name_in_vendors(const char *str) 659int dmi_name_in_vendors(const char *str)
675{ 660{
@@ -696,13 +681,13 @@ EXPORT_SYMBOL(dmi_name_in_vendors);
696 * A new search is initiated by passing %NULL as the @from argument. 681 * A new search is initiated by passing %NULL as the @from argument.
697 * If @from is not %NULL, searches continue from next device. 682 * If @from is not %NULL, searches continue from next device.
698 */ 683 */
699const struct dmi_device * dmi_find_device(int type, const char *name, 684const struct dmi_device *dmi_find_device(int type, const char *name,
700 const struct dmi_device *from) 685 const struct dmi_device *from)
701{ 686{
702 const struct list_head *head = from ? &from->list : &dmi_devices; 687 const struct list_head *head = from ? &from->list : &dmi_devices;
703 struct list_head *d; 688 struct list_head *d;
704 689
705 for(d = head->next; d != &dmi_devices; d = d->next) { 690 for (d = head->next; d != &dmi_devices; d = d->next) {
706 const struct dmi_device *dev = 691 const struct dmi_device *dev =
707 list_entry(d, struct dmi_device, list); 692 list_entry(d, struct dmi_device, list);
708 693