diff options
Diffstat (limited to 'drivers/firmware/dmi_scan.c')
-rw-r--r-- | drivers/firmware/dmi_scan.c | 57 |
1 files changed, 31 insertions, 26 deletions
diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c index f7318b3b51f2..0cdadea7a40e 100644 --- a/drivers/firmware/dmi_scan.c +++ b/drivers/firmware/dmi_scan.c | |||
@@ -8,9 +8,9 @@ | |||
8 | #include <linux/slab.h> | 8 | #include <linux/slab.h> |
9 | #include <asm/dmi.h> | 9 | #include <asm/dmi.h> |
10 | 10 | ||
11 | static char * __init dmi_string(struct dmi_header *dm, u8 s) | 11 | static char * __init dmi_string(const struct dmi_header *dm, u8 s) |
12 | { | 12 | { |
13 | u8 *bp = ((u8 *) dm) + dm->length; | 13 | const u8 *bp = ((u8 *) dm) + dm->length; |
14 | char *str = ""; | 14 | char *str = ""; |
15 | 15 | ||
16 | if (s) { | 16 | if (s) { |
@@ -37,7 +37,7 @@ static char * __init dmi_string(struct dmi_header *dm, u8 s) | |||
37 | * pointing to completely the wrong place for example | 37 | * pointing to completely the wrong place for example |
38 | */ | 38 | */ |
39 | static int __init dmi_table(u32 base, int len, int num, | 39 | static int __init dmi_table(u32 base, int len, int num, |
40 | void (*decode)(struct dmi_header *)) | 40 | void (*decode)(const struct dmi_header *)) |
41 | { | 41 | { |
42 | u8 *buf, *data; | 42 | u8 *buf, *data; |
43 | int i = 0; | 43 | int i = 0; |
@@ -53,7 +53,8 @@ static int __init dmi_table(u32 base, int len, int num, | |||
53 | * OR we run off the end of the table (also happens) | 53 | * OR we run off the end of the table (also happens) |
54 | */ | 54 | */ |
55 | while ((i < num) && (data - buf + sizeof(struct dmi_header)) <= len) { | 55 | while ((i < num) && (data - buf + sizeof(struct dmi_header)) <= len) { |
56 | struct dmi_header *dm = (struct dmi_header *)data; | 56 | const struct dmi_header *dm = (const struct dmi_header *)data; |
57 | |||
57 | /* | 58 | /* |
58 | * We want to know the total length (formated area and strings) | 59 | * We want to know the total length (formated area and strings) |
59 | * before decoding to make sure we won't run off the table in | 60 | * before decoding to make sure we won't run off the table in |
@@ -71,7 +72,7 @@ static int __init dmi_table(u32 base, int len, int num, | |||
71 | return 0; | 72 | return 0; |
72 | } | 73 | } |
73 | 74 | ||
74 | static int __init dmi_checksum(u8 *buf) | 75 | static int __init dmi_checksum(const u8 *buf) |
75 | { | 76 | { |
76 | u8 sum = 0; | 77 | u8 sum = 0; |
77 | int a; | 78 | int a; |
@@ -89,9 +90,10 @@ int dmi_available; | |||
89 | /* | 90 | /* |
90 | * Save a DMI string | 91 | * Save a DMI string |
91 | */ | 92 | */ |
92 | static void __init dmi_save_ident(struct dmi_header *dm, int slot, int string) | 93 | static void __init dmi_save_ident(const struct dmi_header *dm, int slot, int string) |
93 | { | 94 | { |
94 | char *p, *d = (char*) dm; | 95 | const char *d = (const char*) dm; |
96 | char *p; | ||
95 | 97 | ||
96 | if (dmi_ident[slot]) | 98 | if (dmi_ident[slot]) |
97 | return; | 99 | return; |
@@ -103,9 +105,9 @@ static void __init dmi_save_ident(struct dmi_header *dm, int slot, int string) | |||
103 | dmi_ident[slot] = p; | 105 | dmi_ident[slot] = p; |
104 | } | 106 | } |
105 | 107 | ||
106 | static void __init dmi_save_uuid(struct dmi_header *dm, int slot, int index) | 108 | static void __init dmi_save_uuid(const struct dmi_header *dm, int slot, int index) |
107 | { | 109 | { |
108 | u8 *d = (u8*) dm + index; | 110 | const u8 *d = (u8*) dm + index; |
109 | char *s; | 111 | char *s; |
110 | int is_ff = 1, is_00 = 1, i; | 112 | int is_ff = 1, is_00 = 1, i; |
111 | 113 | ||
@@ -132,9 +134,9 @@ static void __init dmi_save_uuid(struct dmi_header *dm, int slot, int index) | |||
132 | dmi_ident[slot] = s; | 134 | dmi_ident[slot] = s; |
133 | } | 135 | } |
134 | 136 | ||
135 | static void __init dmi_save_type(struct dmi_header *dm, int slot, int index) | 137 | static void __init dmi_save_type(const struct dmi_header *dm, int slot, int index) |
136 | { | 138 | { |
137 | u8 *d = (u8*) dm + index; | 139 | const u8 *d = (u8*) dm + index; |
138 | char *s; | 140 | char *s; |
139 | 141 | ||
140 | if (dmi_ident[slot]) | 142 | if (dmi_ident[slot]) |
@@ -148,13 +150,13 @@ static void __init dmi_save_type(struct dmi_header *dm, int slot, int index) | |||
148 | dmi_ident[slot] = s; | 150 | dmi_ident[slot] = s; |
149 | } | 151 | } |
150 | 152 | ||
151 | static void __init dmi_save_devices(struct dmi_header *dm) | 153 | static void __init dmi_save_devices(const struct dmi_header *dm) |
152 | { | 154 | { |
153 | int i, count = (dm->length - sizeof(struct dmi_header)) / 2; | 155 | int i, count = (dm->length - sizeof(struct dmi_header)) / 2; |
154 | struct dmi_device *dev; | 156 | struct dmi_device *dev; |
155 | 157 | ||
156 | for (i = 0; i < count; i++) { | 158 | for (i = 0; i < count; i++) { |
157 | char *d = (char *)(dm + 1) + (i * 2); | 159 | const char *d = (char *)(dm + 1) + (i * 2); |
158 | 160 | ||
159 | /* Skip disabled device */ | 161 | /* Skip disabled device */ |
160 | if ((*d & 0x80) == 0) | 162 | if ((*d & 0x80) == 0) |
@@ -173,7 +175,7 @@ static void __init dmi_save_devices(struct dmi_header *dm) | |||
173 | } | 175 | } |
174 | } | 176 | } |
175 | 177 | ||
176 | static void __init dmi_save_oem_strings_devices(struct dmi_header *dm) | 178 | static void __init dmi_save_oem_strings_devices(const struct dmi_header *dm) |
177 | { | 179 | { |
178 | int i, count = *(u8 *)(dm + 1); | 180 | int i, count = *(u8 *)(dm + 1); |
179 | struct dmi_device *dev; | 181 | struct dmi_device *dev; |
@@ -194,7 +196,7 @@ static void __init dmi_save_oem_strings_devices(struct dmi_header *dm) | |||
194 | } | 196 | } |
195 | } | 197 | } |
196 | 198 | ||
197 | static void __init dmi_save_ipmi_device(struct dmi_header *dm) | 199 | static void __init dmi_save_ipmi_device(const struct dmi_header *dm) |
198 | { | 200 | { |
199 | struct dmi_device *dev; | 201 | struct dmi_device *dev; |
200 | void * data; | 202 | void * data; |
@@ -225,7 +227,7 @@ static void __init dmi_save_ipmi_device(struct dmi_header *dm) | |||
225 | * and machine entries. For 2.5 we should pull the smbus controller info | 227 | * and machine entries. For 2.5 we should pull the smbus controller info |
226 | * out of here. | 228 | * out of here. |
227 | */ | 229 | */ |
228 | static void __init dmi_decode(struct dmi_header *dm) | 230 | static void __init dmi_decode(const struct dmi_header *dm) |
229 | { | 231 | { |
230 | switch(dm->type) { | 232 | switch(dm->type) { |
231 | case 0: /* BIOS Information */ | 233 | case 0: /* BIOS Information */ |
@@ -265,9 +267,10 @@ static void __init dmi_decode(struct dmi_header *dm) | |||
265 | } | 267 | } |
266 | } | 268 | } |
267 | 269 | ||
268 | static int __init dmi_present(char __iomem *p) | 270 | static int __init dmi_present(const char __iomem *p) |
269 | { | 271 | { |
270 | u8 buf[15]; | 272 | u8 buf[15]; |
273 | |||
271 | memcpy_fromio(buf, p, 15); | 274 | memcpy_fromio(buf, p, 15); |
272 | if ((memcmp(buf, "_DMI_", 5) == 0) && dmi_checksum(buf)) { | 275 | if ((memcmp(buf, "_DMI_", 5) == 0) && dmi_checksum(buf)) { |
273 | u16 num = (buf[13] << 8) | buf[12]; | 276 | u16 num = (buf[13] << 8) | buf[12]; |
@@ -348,10 +351,10 @@ void __init dmi_scan_machine(void) | |||
348 | * returns non zero or we hit the end. Callback function is called for | 351 | * returns non zero or we hit the end. Callback function is called for |
349 | * each successful match. Returns the number of matches. | 352 | * each successful match. Returns the number of matches. |
350 | */ | 353 | */ |
351 | int dmi_check_system(struct dmi_system_id *list) | 354 | int dmi_check_system(const struct dmi_system_id *list) |
352 | { | 355 | { |
353 | int i, count = 0; | 356 | int i, count = 0; |
354 | struct dmi_system_id *d = list; | 357 | const struct dmi_system_id *d = list; |
355 | 358 | ||
356 | while (d->ident) { | 359 | while (d->ident) { |
357 | for (i = 0; i < ARRAY_SIZE(d->matches); i++) { | 360 | for (i = 0; i < ARRAY_SIZE(d->matches); i++) { |
@@ -380,7 +383,7 @@ EXPORT_SYMBOL(dmi_check_system); | |||
380 | * Returns one DMI data value, can be used to perform | 383 | * Returns one DMI data value, can be used to perform |
381 | * complex DMI data checks. | 384 | * complex DMI data checks. |
382 | */ | 385 | */ |
383 | char *dmi_get_system_info(int field) | 386 | const char *dmi_get_system_info(int field) |
384 | { | 387 | { |
385 | return dmi_ident[field]; | 388 | return dmi_ident[field]; |
386 | } | 389 | } |
@@ -391,7 +394,7 @@ EXPORT_SYMBOL(dmi_get_system_info); | |||
391 | * dmi_name_in_vendors - Check if string is anywhere in the DMI vendor information. | 394 | * dmi_name_in_vendors - Check if string is anywhere in the DMI vendor information. |
392 | * @str: Case sensitive Name | 395 | * @str: Case sensitive Name |
393 | */ | 396 | */ |
394 | int dmi_name_in_vendors(char *str) | 397 | int dmi_name_in_vendors(const char *str) |
395 | { | 398 | { |
396 | static int fields[] = { DMI_BIOS_VENDOR, DMI_BIOS_VERSION, DMI_SYS_VENDOR, | 399 | static int fields[] = { DMI_BIOS_VENDOR, DMI_BIOS_VERSION, DMI_SYS_VENDOR, |
397 | DMI_PRODUCT_NAME, DMI_PRODUCT_VERSION, DMI_BOARD_VENDOR, | 400 | DMI_PRODUCT_NAME, DMI_PRODUCT_VERSION, DMI_BOARD_VENDOR, |
@@ -418,13 +421,15 @@ EXPORT_SYMBOL(dmi_name_in_vendors); | |||
418 | * A new search is initiated by passing %NULL as the @from argument. | 421 | * A new search is initiated by passing %NULL as the @from argument. |
419 | * If @from is not %NULL, searches continue from next device. | 422 | * If @from is not %NULL, searches continue from next device. |
420 | */ | 423 | */ |
421 | struct dmi_device * dmi_find_device(int type, const char *name, | 424 | const struct dmi_device * dmi_find_device(int type, const char *name, |
422 | struct dmi_device *from) | 425 | const struct dmi_device *from) |
423 | { | 426 | { |
424 | struct list_head *d, *head = from ? &from->list : &dmi_devices; | 427 | const struct list_head *head = from ? &from->list : &dmi_devices; |
428 | struct list_head *d; | ||
425 | 429 | ||
426 | for(d = head->next; d != &dmi_devices; d = d->next) { | 430 | for(d = head->next; d != &dmi_devices; d = d->next) { |
427 | struct dmi_device *dev = list_entry(d, struct dmi_device, list); | 431 | const struct dmi_device *dev = |
432 | list_entry(d, struct dmi_device, list); | ||
428 | 433 | ||
429 | if (((type == DMI_DEV_TYPE_ANY) || (dev->type == type)) && | 434 | if (((type == DMI_DEV_TYPE_ANY) || (dev->type == type)) && |
430 | ((name == NULL) || (strcmp(dev->name, name) == 0))) | 435 | ((name == NULL) || (strcmp(dev->name, name) == 0))) |
@@ -444,7 +449,7 @@ EXPORT_SYMBOL(dmi_find_device); | |||
444 | int dmi_get_year(int field) | 449 | int dmi_get_year(int field) |
445 | { | 450 | { |
446 | int year; | 451 | int year; |
447 | char *s = dmi_get_system_info(field); | 452 | const char *s = dmi_get_system_info(field); |
448 | 453 | ||
449 | if (!s) | 454 | if (!s) |
450 | return -1; | 455 | return -1; |