diff options
author | Ingo Molnar <mingo@elte.hu> | 2008-10-28 11:26:12 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-10-28 11:26:12 -0400 |
commit | 7a9787e1eba95a166265e6a260cf30af04ef0a99 (patch) | |
tree | e730a4565e0318140d2fbd2f0415d18a339d7336 /drivers/firmware | |
parent | 41b9eb264c8407655db57b60b4457fe1b2ec9977 (diff) | |
parent | 0173a3265b228da319ceb9c1ec6a5682fd1b2d92 (diff) |
Merge commit 'v2.6.28-rc2' into x86/pci-ioapic-boot-irq-quirks
Diffstat (limited to 'drivers/firmware')
-rw-r--r-- | drivers/firmware/dcdbas.c | 13 | ||||
-rw-r--r-- | drivers/firmware/dell_rbu.c | 28 | ||||
-rw-r--r-- | drivers/firmware/dmi_scan.c | 22 | ||||
-rw-r--r-- | drivers/firmware/iscsi_ibft.c | 22 | ||||
-rw-r--r-- | drivers/firmware/iscsi_ibft_find.c | 1 | ||||
-rw-r--r-- | drivers/firmware/memmap.c | 67 |
6 files changed, 78 insertions, 75 deletions
diff --git a/drivers/firmware/dcdbas.c b/drivers/firmware/dcdbas.c index 25918f7dfd0f..50a071f1c945 100644 --- a/drivers/firmware/dcdbas.c +++ b/drivers/firmware/dcdbas.c | |||
@@ -152,20 +152,11 @@ static ssize_t smi_data_read(struct kobject *kobj, | |||
152 | struct bin_attribute *bin_attr, | 152 | struct bin_attribute *bin_attr, |
153 | char *buf, loff_t pos, size_t count) | 153 | char *buf, loff_t pos, size_t count) |
154 | { | 154 | { |
155 | size_t max_read; | ||
156 | ssize_t ret; | 155 | ssize_t ret; |
157 | 156 | ||
158 | mutex_lock(&smi_data_lock); | 157 | mutex_lock(&smi_data_lock); |
159 | 158 | ret = memory_read_from_buffer(buf, count, &pos, smi_data_buf, | |
160 | if (pos >= smi_data_buf_size) { | 159 | smi_data_buf_size); |
161 | ret = 0; | ||
162 | goto out; | ||
163 | } | ||
164 | |||
165 | max_read = smi_data_buf_size - pos; | ||
166 | ret = min(max_read, count); | ||
167 | memcpy(buf, smi_data_buf + pos, ret); | ||
168 | out: | ||
169 | mutex_unlock(&smi_data_lock); | 160 | mutex_unlock(&smi_data_lock); |
170 | return ret; | 161 | return ret; |
171 | } | 162 | } |
diff --git a/drivers/firmware/dell_rbu.c b/drivers/firmware/dell_rbu.c index 7430e218cda6..13946ebd77d6 100644 --- a/drivers/firmware/dell_rbu.c +++ b/drivers/firmware/dell_rbu.c | |||
@@ -507,11 +507,6 @@ static ssize_t read_packet_data(char *buffer, loff_t pos, size_t count) | |||
507 | 507 | ||
508 | static ssize_t read_rbu_mono_data(char *buffer, loff_t pos, size_t count) | 508 | static ssize_t read_rbu_mono_data(char *buffer, loff_t pos, size_t count) |
509 | { | 509 | { |
510 | unsigned char *ptemp = NULL; | ||
511 | size_t bytes_left = 0; | ||
512 | size_t data_length = 0; | ||
513 | ssize_t ret_count = 0; | ||
514 | |||
515 | /* check to see if we have something to return */ | 510 | /* check to see if we have something to return */ |
516 | if ((rbu_data.image_update_buffer == NULL) || | 511 | if ((rbu_data.image_update_buffer == NULL) || |
517 | (rbu_data.bios_image_size == 0)) { | 512 | (rbu_data.bios_image_size == 0)) { |
@@ -519,28 +514,11 @@ static ssize_t read_rbu_mono_data(char *buffer, loff_t pos, size_t count) | |||
519 | "bios_image_size %lu\n", | 514 | "bios_image_size %lu\n", |
520 | rbu_data.image_update_buffer, | 515 | rbu_data.image_update_buffer, |
521 | rbu_data.bios_image_size); | 516 | rbu_data.bios_image_size); |
522 | ret_count = -ENOMEM; | 517 | return -ENOMEM; |
523 | goto read_rbu_data_exit; | ||
524 | } | ||
525 | |||
526 | if (pos > rbu_data.bios_image_size) { | ||
527 | ret_count = 0; | ||
528 | goto read_rbu_data_exit; | ||
529 | } | 518 | } |
530 | 519 | ||
531 | bytes_left = rbu_data.bios_image_size - pos; | 520 | return memory_read_from_buffer(buffer, count, &pos, |
532 | data_length = min(bytes_left, count); | 521 | rbu_data.image_update_buffer, rbu_data.bios_image_size); |
533 | |||
534 | ptemp = rbu_data.image_update_buffer; | ||
535 | memcpy(buffer, (ptemp + pos), data_length); | ||
536 | |||
537 | if ((pos + count) > rbu_data.bios_image_size) | ||
538 | /* this was the last copy */ | ||
539 | ret_count = bytes_left; | ||
540 | else | ||
541 | ret_count = count; | ||
542 | read_rbu_data_exit: | ||
543 | return ret_count; | ||
544 | } | 522 | } |
545 | 523 | ||
546 | static ssize_t read_rbu_data(struct kobject *kobj, | 524 | static ssize_t read_rbu_data(struct kobject *kobj, |
diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c index 455575be3560..3e526b6d00cb 100644 --- a/drivers/firmware/dmi_scan.c +++ b/drivers/firmware/dmi_scan.c | |||
@@ -15,6 +15,11 @@ | |||
15 | */ | 15 | */ |
16 | static char dmi_empty_string[] = " "; | 16 | static char dmi_empty_string[] = " "; |
17 | 17 | ||
18 | /* | ||
19 | * Catch too early calls to dmi_check_system(): | ||
20 | */ | ||
21 | static int dmi_initialized; | ||
22 | |||
18 | static const char * __init dmi_string_nosave(const struct dmi_header *dm, u8 s) | 23 | static const char * __init dmi_string_nosave(const struct dmi_header *dm, u8 s) |
19 | { | 24 | { |
20 | const u8 *bp = ((u8 *) dm) + dm->length; | 25 | const u8 *bp = ((u8 *) dm) + dm->length; |
@@ -366,7 +371,7 @@ void __init dmi_scan_machine(void) | |||
366 | 371 | ||
367 | if (efi_enabled) { | 372 | if (efi_enabled) { |
368 | if (efi.smbios == EFI_INVALID_TABLE_ADDR) | 373 | if (efi.smbios == EFI_INVALID_TABLE_ADDR) |
369 | goto out; | 374 | goto error; |
370 | 375 | ||
371 | /* This is called as a core_initcall() because it isn't | 376 | /* This is called as a core_initcall() because it isn't |
372 | * needed during early boot. This also means we can | 377 | * needed during early boot. This also means we can |
@@ -374,13 +379,13 @@ void __init dmi_scan_machine(void) | |||
374 | */ | 379 | */ |
375 | p = dmi_ioremap(efi.smbios, 32); | 380 | p = dmi_ioremap(efi.smbios, 32); |
376 | if (p == NULL) | 381 | if (p == NULL) |
377 | goto out; | 382 | goto error; |
378 | 383 | ||
379 | rc = dmi_present(p + 0x10); /* offset of _DMI_ string */ | 384 | rc = dmi_present(p + 0x10); /* offset of _DMI_ string */ |
380 | dmi_iounmap(p, 32); | 385 | dmi_iounmap(p, 32); |
381 | if (!rc) { | 386 | if (!rc) { |
382 | dmi_available = 1; | 387 | dmi_available = 1; |
383 | return; | 388 | goto out; |
384 | } | 389 | } |
385 | } | 390 | } |
386 | else { | 391 | else { |
@@ -391,19 +396,22 @@ void __init dmi_scan_machine(void) | |||
391 | */ | 396 | */ |
392 | p = dmi_ioremap(0xF0000, 0x10000); | 397 | p = dmi_ioremap(0xF0000, 0x10000); |
393 | if (p == NULL) | 398 | if (p == NULL) |
394 | goto out; | 399 | goto error; |
395 | 400 | ||
396 | for (q = p; q < p + 0x10000; q += 16) { | 401 | for (q = p; q < p + 0x10000; q += 16) { |
397 | rc = dmi_present(q); | 402 | rc = dmi_present(q); |
398 | if (!rc) { | 403 | if (!rc) { |
399 | dmi_available = 1; | 404 | dmi_available = 1; |
400 | dmi_iounmap(p, 0x10000); | 405 | dmi_iounmap(p, 0x10000); |
401 | return; | 406 | goto out; |
402 | } | 407 | } |
403 | } | 408 | } |
404 | dmi_iounmap(p, 0x10000); | 409 | dmi_iounmap(p, 0x10000); |
405 | } | 410 | } |
406 | out: printk(KERN_INFO "DMI not present or invalid.\n"); | 411 | error: |
412 | printk(KERN_INFO "DMI not present or invalid.\n"); | ||
413 | out: | ||
414 | dmi_initialized = 1; | ||
407 | } | 415 | } |
408 | 416 | ||
409 | /** | 417 | /** |
@@ -424,6 +432,8 @@ int dmi_check_system(const struct dmi_system_id *list) | |||
424 | int i, count = 0; | 432 | int i, count = 0; |
425 | const struct dmi_system_id *d = list; | 433 | const struct dmi_system_id *d = list; |
426 | 434 | ||
435 | WARN(!dmi_initialized, KERN_ERR "dmi check: not initialized yet.\n"); | ||
436 | |||
427 | while (d->ident) { | 437 | while (d->ident) { |
428 | for (i = 0; i < ARRAY_SIZE(d->matches); i++) { | 438 | for (i = 0; i < ARRAY_SIZE(d->matches); i++) { |
429 | int s = d->matches[i].slot; | 439 | int s = d->matches[i].slot; |
diff --git a/drivers/firmware/iscsi_ibft.c b/drivers/firmware/iscsi_ibft.c index 8024e3bfd877..4353414a0b77 100644 --- a/drivers/firmware/iscsi_ibft.c +++ b/drivers/firmware/iscsi_ibft.c | |||
@@ -334,9 +334,9 @@ static void ibft_release(struct kobject *kobj) | |||
334 | /* | 334 | /* |
335 | * Routines for parsing the iBFT data to be human readable. | 335 | * Routines for parsing the iBFT data to be human readable. |
336 | */ | 336 | */ |
337 | ssize_t ibft_attr_show_initiator(struct ibft_kobject *entry, | 337 | static ssize_t ibft_attr_show_initiator(struct ibft_kobject *entry, |
338 | struct ibft_attribute *attr, | 338 | struct ibft_attribute *attr, |
339 | char *buf) | 339 | char *buf) |
340 | { | 340 | { |
341 | struct ibft_initiator *initiator = entry->initiator; | 341 | struct ibft_initiator *initiator = entry->initiator; |
342 | void *ibft_loc = entry->header; | 342 | void *ibft_loc = entry->header; |
@@ -376,9 +376,9 @@ ssize_t ibft_attr_show_initiator(struct ibft_kobject *entry, | |||
376 | return str - buf; | 376 | return str - buf; |
377 | } | 377 | } |
378 | 378 | ||
379 | ssize_t ibft_attr_show_nic(struct ibft_kobject *entry, | 379 | static ssize_t ibft_attr_show_nic(struct ibft_kobject *entry, |
380 | struct ibft_attribute *attr, | 380 | struct ibft_attribute *attr, |
381 | char *buf) | 381 | char *buf) |
382 | { | 382 | { |
383 | struct ibft_nic *nic = entry->nic; | 383 | struct ibft_nic *nic = entry->nic; |
384 | void *ibft_loc = entry->header; | 384 | void *ibft_loc = entry->header; |
@@ -440,9 +440,9 @@ ssize_t ibft_attr_show_nic(struct ibft_kobject *entry, | |||
440 | return str - buf; | 440 | return str - buf; |
441 | }; | 441 | }; |
442 | 442 | ||
443 | ssize_t ibft_attr_show_target(struct ibft_kobject *entry, | 443 | static ssize_t ibft_attr_show_target(struct ibft_kobject *entry, |
444 | struct ibft_attribute *attr, | 444 | struct ibft_attribute *attr, |
445 | char *buf) | 445 | char *buf) |
446 | { | 446 | { |
447 | struct ibft_tgt *tgt = entry->tgt; | 447 | struct ibft_tgt *tgt = entry->tgt; |
448 | void *ibft_loc = entry->header; | 448 | void *ibft_loc = entry->header; |
@@ -669,8 +669,7 @@ static int __init ibft_register_kobjects(struct ibft_table_header *header, | |||
669 | 669 | ||
670 | control = (void *)header + sizeof(*header); | 670 | control = (void *)header + sizeof(*header); |
671 | end = (void *)control + control->hdr.length; | 671 | end = (void *)control + control->hdr.length; |
672 | eot_offset = (void *)header + header->length - | 672 | eot_offset = (void *)header + header->length - (void *)control; |
673 | (void *)control - sizeof(*header); | ||
674 | rc = ibft_verify_hdr("control", (struct ibft_hdr *)control, id_control, | 673 | rc = ibft_verify_hdr("control", (struct ibft_hdr *)control, id_control, |
675 | sizeof(*control)); | 674 | sizeof(*control)); |
676 | 675 | ||
@@ -733,7 +732,6 @@ static int __init ibft_create_attribute(struct ibft_kobject *kobj_data, | |||
733 | 732 | ||
734 | attr->attr.name = name; | 733 | attr->attr.name = name; |
735 | attr->attr.mode = S_IRUSR; | 734 | attr->attr.mode = S_IRUSR; |
736 | attr->attr.owner = THIS_MODULE; | ||
737 | 735 | ||
738 | attr->hdr = hdr; | 736 | attr->hdr = hdr; |
739 | attr->show = show; | 737 | attr->show = show; |
diff --git a/drivers/firmware/iscsi_ibft_find.c b/drivers/firmware/iscsi_ibft_find.c index 11f17440fea6..d53fbbfefa3e 100644 --- a/drivers/firmware/iscsi_ibft_find.c +++ b/drivers/firmware/iscsi_ibft_find.c | |||
@@ -81,4 +81,3 @@ void __init reserve_ibft_region(void) | |||
81 | if (ibft_addr) | 81 | if (ibft_addr) |
82 | reserve_bootmem(pos, PAGE_ALIGN(len), BOOTMEM_DEFAULT); | 82 | reserve_bootmem(pos, PAGE_ALIGN(len), BOOTMEM_DEFAULT); |
83 | } | 83 | } |
84 | EXPORT_SYMBOL_GPL(reserve_ibft_region); | ||
diff --git a/drivers/firmware/memmap.c b/drivers/firmware/memmap.c index e23399c7f773..3bf8ee120d42 100644 --- a/drivers/firmware/memmap.c +++ b/drivers/firmware/memmap.c | |||
@@ -84,20 +84,23 @@ static struct kobj_type memmap_ktype = { | |||
84 | */ | 84 | */ |
85 | 85 | ||
86 | /* | 86 | /* |
87 | * Firmware memory map entries | 87 | * Firmware memory map entries. No locking is needed because the |
88 | * firmware_map_add() and firmware_map_add_early() functions are called | ||
89 | * in firmware initialisation code in one single thread of execution. | ||
88 | */ | 90 | */ |
89 | static LIST_HEAD(map_entries); | 91 | static LIST_HEAD(map_entries); |
90 | 92 | ||
91 | /** | 93 | /** |
92 | * Common implementation of firmware_map_add() and firmware_map_add_early() | 94 | * firmware_map_add_entry() - Does the real work to add a firmware memmap entry. |
93 | * which expects a pre-allocated struct firmware_map_entry. | ||
94 | * | ||
95 | * @start: Start of the memory range. | 95 | * @start: Start of the memory range. |
96 | * @end: End of the memory range (inclusive). | 96 | * @end: End of the memory range (inclusive). |
97 | * @type: Type of the memory range. | 97 | * @type: Type of the memory range. |
98 | * @entry: Pre-allocated (either kmalloc() or bootmem allocator), uninitialised | 98 | * @entry: Pre-allocated (either kmalloc() or bootmem allocator), uninitialised |
99 | * entry. | 99 | * entry. |
100 | */ | 100 | * |
101 | * Common implementation of firmware_map_add() and firmware_map_add_early() | ||
102 | * which expects a pre-allocated struct firmware_map_entry. | ||
103 | **/ | ||
101 | static int firmware_map_add_entry(resource_size_t start, resource_size_t end, | 104 | static int firmware_map_add_entry(resource_size_t start, resource_size_t end, |
102 | const char *type, | 105 | const char *type, |
103 | struct firmware_map_entry *entry) | 106 | struct firmware_map_entry *entry) |
@@ -115,33 +118,52 @@ static int firmware_map_add_entry(resource_size_t start, resource_size_t end, | |||
115 | return 0; | 118 | return 0; |
116 | } | 119 | } |
117 | 120 | ||
118 | /* | 121 | /** |
119 | * See <linux/firmware-map.h> for documentation. | 122 | * firmware_map_add() - Adds a firmware mapping entry. |
120 | */ | 123 | * @start: Start of the memory range. |
124 | * @end: End of the memory range (inclusive). | ||
125 | * @type: Type of the memory range. | ||
126 | * | ||
127 | * This function uses kmalloc() for memory | ||
128 | * allocation. Use firmware_map_add_early() if you want to use the bootmem | ||
129 | * allocator. | ||
130 | * | ||
131 | * That function must be called before late_initcall. | ||
132 | * | ||
133 | * Returns 0 on success, or -ENOMEM if no memory could be allocated. | ||
134 | **/ | ||
121 | int firmware_map_add(resource_size_t start, resource_size_t end, | 135 | int firmware_map_add(resource_size_t start, resource_size_t end, |
122 | const char *type) | 136 | const char *type) |
123 | { | 137 | { |
124 | struct firmware_map_entry *entry; | 138 | struct firmware_map_entry *entry; |
125 | 139 | ||
126 | entry = kmalloc(sizeof(struct firmware_map_entry), GFP_ATOMIC); | 140 | entry = kmalloc(sizeof(struct firmware_map_entry), GFP_ATOMIC); |
127 | WARN_ON(!entry); | ||
128 | if (!entry) | 141 | if (!entry) |
129 | return -ENOMEM; | 142 | return -ENOMEM; |
130 | 143 | ||
131 | return firmware_map_add_entry(start, end, type, entry); | 144 | return firmware_map_add_entry(start, end, type, entry); |
132 | } | 145 | } |
133 | 146 | ||
134 | /* | 147 | /** |
135 | * See <linux/firmware-map.h> for documentation. | 148 | * firmware_map_add_early() - Adds a firmware mapping entry. |
136 | */ | 149 | * @start: Start of the memory range. |
150 | * @end: End of the memory range (inclusive). | ||
151 | * @type: Type of the memory range. | ||
152 | * | ||
153 | * Adds a firmware mapping entry. This function uses the bootmem allocator | ||
154 | * for memory allocation. Use firmware_map_add() if you want to use kmalloc(). | ||
155 | * | ||
156 | * That function must be called before late_initcall. | ||
157 | * | ||
158 | * Returns 0 on success, or -ENOMEM if no memory could be allocated. | ||
159 | **/ | ||
137 | int __init firmware_map_add_early(resource_size_t start, resource_size_t end, | 160 | int __init firmware_map_add_early(resource_size_t start, resource_size_t end, |
138 | const char *type) | 161 | const char *type) |
139 | { | 162 | { |
140 | struct firmware_map_entry *entry; | 163 | struct firmware_map_entry *entry; |
141 | 164 | ||
142 | entry = alloc_bootmem_low(sizeof(struct firmware_map_entry)); | 165 | entry = alloc_bootmem_low(sizeof(struct firmware_map_entry)); |
143 | WARN_ON(!entry); | 166 | if (WARN_ON(!entry)) |
144 | if (!entry) | ||
145 | return -ENOMEM; | 167 | return -ENOMEM; |
146 | 168 | ||
147 | return firmware_map_add_entry(start, end, type, entry); | 169 | return firmware_map_add_entry(start, end, type, entry); |
@@ -153,12 +175,14 @@ int __init firmware_map_add_early(resource_size_t start, resource_size_t end, | |||
153 | 175 | ||
154 | static ssize_t start_show(struct firmware_map_entry *entry, char *buf) | 176 | static ssize_t start_show(struct firmware_map_entry *entry, char *buf) |
155 | { | 177 | { |
156 | return snprintf(buf, PAGE_SIZE, "0x%llx\n", entry->start); | 178 | return snprintf(buf, PAGE_SIZE, "0x%llx\n", |
179 | (unsigned long long)entry->start); | ||
157 | } | 180 | } |
158 | 181 | ||
159 | static ssize_t end_show(struct firmware_map_entry *entry, char *buf) | 182 | static ssize_t end_show(struct firmware_map_entry *entry, char *buf) |
160 | { | 183 | { |
161 | return snprintf(buf, PAGE_SIZE, "0x%llx\n", entry->end); | 184 | return snprintf(buf, PAGE_SIZE, "0x%llx\n", |
185 | (unsigned long long)entry->end); | ||
162 | } | 186 | } |
163 | 187 | ||
164 | static ssize_t type_show(struct firmware_map_entry *entry, char *buf) | 188 | static ssize_t type_show(struct firmware_map_entry *entry, char *buf) |
@@ -181,7 +205,10 @@ static ssize_t memmap_attr_show(struct kobject *kobj, | |||
181 | /* | 205 | /* |
182 | * Initialises stuff and adds the entries in the map_entries list to | 206 | * Initialises stuff and adds the entries in the map_entries list to |
183 | * sysfs. Important is that firmware_map_add() and firmware_map_add_early() | 207 | * sysfs. Important is that firmware_map_add() and firmware_map_add_early() |
184 | * must be called before late_initcall. | 208 | * must be called before late_initcall. That's just because that function |
209 | * is called as late_initcall() function, which means that if you call | ||
210 | * firmware_map_add() or firmware_map_add_early() afterwards, the entries | ||
211 | * are not added to sysfs. | ||
185 | */ | 212 | */ |
186 | static int __init memmap_init(void) | 213 | static int __init memmap_init(void) |
187 | { | 214 | { |
@@ -190,13 +217,13 @@ static int __init memmap_init(void) | |||
190 | struct kset *memmap_kset; | 217 | struct kset *memmap_kset; |
191 | 218 | ||
192 | memmap_kset = kset_create_and_add("memmap", NULL, firmware_kobj); | 219 | memmap_kset = kset_create_and_add("memmap", NULL, firmware_kobj); |
193 | WARN_ON(!memmap_kset); | 220 | if (WARN_ON(!memmap_kset)) |
194 | if (!memmap_kset) | ||
195 | return -ENOMEM; | 221 | return -ENOMEM; |
196 | 222 | ||
197 | list_for_each_entry(entry, &map_entries, list) { | 223 | list_for_each_entry(entry, &map_entries, list) { |
198 | entry->kobj.kset = memmap_kset; | 224 | entry->kobj.kset = memmap_kset; |
199 | kobject_add(&entry->kobj, NULL, "%d", i++); | 225 | if (kobject_add(&entry->kobj, NULL, "%d", i++)) |
226 | kobject_put(&entry->kobj); | ||
200 | } | 227 | } |
201 | 228 | ||
202 | return 0; | 229 | return 0; |