aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/firmware
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/firmware')
-rw-r--r--drivers/firmware/dcdbas.c21
-rw-r--r--drivers/firmware/dcdbas.h2
-rw-r--r--drivers/firmware/dell_rbu.c4
-rw-r--r--drivers/firmware/dmi-id.c2
-rw-r--r--drivers/firmware/dmi_scan.c103
-rw-r--r--drivers/firmware/iscsi_ibft.c11
-rw-r--r--drivers/firmware/memmap.c6
7 files changed, 109 insertions, 40 deletions
diff --git a/drivers/firmware/dcdbas.c b/drivers/firmware/dcdbas.c
index 50a071f1c945..3009e0171e54 100644
--- a/drivers/firmware/dcdbas.c
+++ b/drivers/firmware/dcdbas.c
@@ -238,13 +238,13 @@ static ssize_t host_control_on_shutdown_store(struct device *dev,
238} 238}
239 239
240/** 240/**
241 * smi_request: generate SMI request 241 * dcdbas_smi_request: generate SMI request
242 * 242 *
243 * Called with smi_data_lock. 243 * Called with smi_data_lock.
244 */ 244 */
245static int smi_request(struct smi_cmd *smi_cmd) 245int dcdbas_smi_request(struct smi_cmd *smi_cmd)
246{ 246{
247 cpumask_t old_mask; 247 cpumask_var_t old_mask;
248 int ret = 0; 248 int ret = 0;
249 249
250 if (smi_cmd->magic != SMI_CMD_MAGIC) { 250 if (smi_cmd->magic != SMI_CMD_MAGIC) {
@@ -254,8 +254,11 @@ static int smi_request(struct smi_cmd *smi_cmd)
254 } 254 }
255 255
256 /* SMI requires CPU 0 */ 256 /* SMI requires CPU 0 */
257 old_mask = current->cpus_allowed; 257 if (!alloc_cpumask_var(&old_mask, GFP_KERNEL))
258 set_cpus_allowed_ptr(current, &cpumask_of_cpu(0)); 258 return -ENOMEM;
259
260 cpumask_copy(old_mask, &current->cpus_allowed);
261 set_cpus_allowed_ptr(current, cpumask_of(0));
259 if (smp_processor_id() != 0) { 262 if (smp_processor_id() != 0) {
260 dev_dbg(&dcdbas_pdev->dev, "%s: failed to get CPU 0\n", 263 dev_dbg(&dcdbas_pdev->dev, "%s: failed to get CPU 0\n",
261 __func__); 264 __func__);
@@ -275,7 +278,8 @@ static int smi_request(struct smi_cmd *smi_cmd)
275 ); 278 );
276 279
277out: 280out:
278 set_cpus_allowed_ptr(current, &old_mask); 281 set_cpus_allowed_ptr(current, old_mask);
282 free_cpumask_var(old_mask);
279 return ret; 283 return ret;
280} 284}
281 285
@@ -309,14 +313,14 @@ static ssize_t smi_request_store(struct device *dev,
309 switch (val) { 313 switch (val) {
310 case 2: 314 case 2:
311 /* Raw SMI */ 315 /* Raw SMI */
312 ret = smi_request(smi_cmd); 316 ret = dcdbas_smi_request(smi_cmd);
313 if (!ret) 317 if (!ret)
314 ret = count; 318 ret = count;
315 break; 319 break;
316 case 1: 320 case 1:
317 /* Calling Interface SMI */ 321 /* Calling Interface SMI */
318 smi_cmd->ebx = (u32) virt_to_phys(smi_cmd->command_buffer); 322 smi_cmd->ebx = (u32) virt_to_phys(smi_cmd->command_buffer);
319 ret = smi_request(smi_cmd); 323 ret = dcdbas_smi_request(smi_cmd);
320 if (!ret) 324 if (!ret)
321 ret = count; 325 ret = count;
322 break; 326 break;
@@ -333,6 +337,7 @@ out:
333 mutex_unlock(&smi_data_lock); 337 mutex_unlock(&smi_data_lock);
334 return ret; 338 return ret;
335} 339}
340EXPORT_SYMBOL(dcdbas_smi_request);
336 341
337/** 342/**
338 * host_control_smi: generate host control SMI 343 * host_control_smi: generate host control SMI
diff --git a/drivers/firmware/dcdbas.h b/drivers/firmware/dcdbas.h
index 87bc3417de27..ca3cb0a54ab6 100644
--- a/drivers/firmware/dcdbas.h
+++ b/drivers/firmware/dcdbas.h
@@ -101,5 +101,7 @@ struct apm_cmd {
101 } __attribute__ ((packed)) parameters; 101 } __attribute__ ((packed)) parameters;
102} __attribute__ ((packed)); 102} __attribute__ ((packed));
103 103
104int dcdbas_smi_request(struct smi_cmd *smi_cmd);
105
104#endif /* _DCDBAS_H_ */ 106#endif /* _DCDBAS_H_ */
105 107
diff --git a/drivers/firmware/dell_rbu.c b/drivers/firmware/dell_rbu.c
index 13946ebd77d6..b4704e150b28 100644
--- a/drivers/firmware/dell_rbu.c
+++ b/drivers/firmware/dell_rbu.c
@@ -576,7 +576,7 @@ static ssize_t read_rbu_image_type(struct kobject *kobj,
576{ 576{
577 int size = 0; 577 int size = 0;
578 if (!pos) 578 if (!pos)
579 size = sprintf(buffer, "%s\n", image_type); 579 size = scnprintf(buffer, count, "%s\n", image_type);
580 return size; 580 return size;
581} 581}
582 582
@@ -648,7 +648,7 @@ static ssize_t read_rbu_packet_size(struct kobject *kobj,
648 int size = 0; 648 int size = 0;
649 if (!pos) { 649 if (!pos) {
650 spin_lock(&rbu_data.lock); 650 spin_lock(&rbu_data.lock);
651 size = sprintf(buffer, "%lu\n", rbu_data.packetsize); 651 size = scnprintf(buffer, count, "%lu\n", rbu_data.packetsize);
652 spin_unlock(&rbu_data.lock); 652 spin_unlock(&rbu_data.lock);
653 } 653 }
654 return size; 654 return size;
diff --git a/drivers/firmware/dmi-id.c b/drivers/firmware/dmi-id.c
index e880d6c8d896..5a76d056b9d0 100644
--- a/drivers/firmware/dmi-id.c
+++ b/drivers/firmware/dmi-id.c
@@ -223,7 +223,7 @@ static int __init dmi_id_init(void)
223 } 223 }
224 224
225 dmi_dev->class = &dmi_class; 225 dmi_dev->class = &dmi_class;
226 strcpy(dmi_dev->bus_id, "id"); 226 dev_set_name(dmi_dev, "id");
227 dmi_dev->groups = sys_dmi_attribute_groups; 227 dmi_dev->groups = sys_dmi_attribute_groups;
228 228
229 ret = device_register(dmi_dev); 229 ret = device_register(dmi_dev);
diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
index 8daf4793ac32..8f0f7c449305 100644
--- a/drivers/firmware/dmi_scan.c
+++ b/drivers/firmware/dmi_scan.c
@@ -415,6 +415,29 @@ void __init dmi_scan_machine(void)
415} 415}
416 416
417/** 417/**
418 * dmi_matches - check if dmi_system_id structure matches system DMI data
419 * @dmi: pointer to the dmi_system_id structure to check
420 */
421static bool dmi_matches(const struct dmi_system_id *dmi)
422{
423 int i;
424
425 WARN(!dmi_initialized, KERN_ERR "dmi check: not initialized yet.\n");
426
427 for (i = 0; i < ARRAY_SIZE(dmi->matches); i++) {
428 int s = dmi->matches[i].slot;
429 if (s == DMI_NONE)
430 continue;
431 if (dmi_ident[s]
432 && strstr(dmi_ident[s], dmi->matches[i].substr))
433 continue;
434 /* No match */
435 return false;
436 }
437 return true;
438}
439
440/**
418 * dmi_check_system - check system DMI data 441 * dmi_check_system - check system DMI data
419 * @list: array of dmi_system_id structures to match against 442 * @list: array of dmi_system_id structures to match against
420 * All non-null elements of the list must match 443 * All non-null elements of the list must match
@@ -429,32 +452,45 @@ void __init dmi_scan_machine(void)
429 */ 452 */
430int dmi_check_system(const struct dmi_system_id *list) 453int dmi_check_system(const struct dmi_system_id *list)
431{ 454{
432 int i, count = 0; 455 int count = 0;
433 const struct dmi_system_id *d = list; 456 const struct dmi_system_id *d;
434 457
435 WARN(!dmi_initialized, KERN_ERR "dmi check: not initialized yet.\n"); 458 for (d = list; d->ident; d++)
436 459 if (dmi_matches(d)) {
437 while (d->ident) { 460 count++;
438 for (i = 0; i < ARRAY_SIZE(d->matches); i++) { 461 if (d->callback && d->callback(d))
439 int s = d->matches[i].slot; 462 break;
440 if (s == DMI_NONE)
441 continue;
442 if (dmi_ident[s] && strstr(dmi_ident[s], d->matches[i].substr))
443 continue;
444 /* No match */
445 goto fail;
446 } 463 }
447 count++;
448 if (d->callback && d->callback(d))
449 break;
450fail: d++;
451 }
452 464
453 return count; 465 return count;
454} 466}
455EXPORT_SYMBOL(dmi_check_system); 467EXPORT_SYMBOL(dmi_check_system);
456 468
457/** 469/**
470 * dmi_first_match - find dmi_system_id structure matching system DMI data
471 * @list: array of dmi_system_id structures to match against
472 * All non-null elements of the list must match
473 * their slot's (field index's) data (i.e., each
474 * list string must be a substring of the specified
475 * DMI slot's string data) to be considered a
476 * successful match.
477 *
478 * Walk the blacklist table until the first match is found. Return the
479 * pointer to the matching entry or NULL if there's no match.
480 */
481const struct dmi_system_id *dmi_first_match(const struct dmi_system_id *list)
482{
483 const struct dmi_system_id *d;
484
485 for (d = list; d->ident; d++)
486 if (dmi_matches(d))
487 return d;
488
489 return NULL;
490}
491EXPORT_SYMBOL(dmi_first_match);
492
493/**
458 * dmi_get_system_info - return DMI data value 494 * dmi_get_system_info - return DMI data value
459 * @field: data index (see enum dmi_field) 495 * @field: data index (see enum dmi_field)
460 * 496 *
@@ -467,6 +503,17 @@ const char *dmi_get_system_info(int field)
467} 503}
468EXPORT_SYMBOL(dmi_get_system_info); 504EXPORT_SYMBOL(dmi_get_system_info);
469 505
506/**
507 * dmi_name_in_serial - Check if string is in the DMI product serial information
508 * @str: string to check for
509 */
510int dmi_name_in_serial(const char *str)
511{
512 int f = DMI_PRODUCT_SERIAL;
513 if (dmi_ident[f] && strstr(dmi_ident[f], str))
514 return 1;
515 return 0;
516}
470 517
471/** 518/**
472 * dmi_name_in_vendors - Check if string is anywhere in the DMI vendor information. 519 * dmi_name_in_vendors - Check if string is anywhere in the DMI vendor information.
@@ -571,3 +618,21 @@ int dmi_walk(void (*decode)(const struct dmi_header *))
571 return 0; 618 return 0;
572} 619}
573EXPORT_SYMBOL_GPL(dmi_walk); 620EXPORT_SYMBOL_GPL(dmi_walk);
621
622/**
623 * dmi_match - compare a string to the dmi field (if exists)
624 * @f: DMI field identifier
625 * @str: string to compare the DMI field to
626 *
627 * Returns true if the requested field equals to the str (including NULL).
628 */
629bool dmi_match(enum dmi_field f, const char *str)
630{
631 const char *info = dmi_get_system_info(f);
632
633 if (info == NULL || str == NULL)
634 return info == str;
635
636 return !strcmp(info, str);
637}
638EXPORT_SYMBOL_GPL(dmi_match);
diff --git a/drivers/firmware/iscsi_ibft.c b/drivers/firmware/iscsi_ibft.c
index 4353414a0b77..7b7ddc2d51c9 100644
--- a/drivers/firmware/iscsi_ibft.c
+++ b/drivers/firmware/iscsi_ibft.c
@@ -284,15 +284,12 @@ static ssize_t sprintf_ipaddr(char *buf, u8 *ip)
284 /* 284 /*
285 * IPV4 285 * IPV4
286 */ 286 */
287 str += sprintf(buf, NIPQUAD_FMT, ip[12], 287 str += sprintf(buf, "%pI4", ip + 12);
288 ip[13], ip[14], ip[15]);
289 } else { 288 } else {
290 /* 289 /*
291 * IPv6 290 * IPv6
292 */ 291 */
293 str += sprintf(str, NIP6_FMT, ntohs(ip[0]), ntohs(ip[1]), 292 str += sprintf(str, "%pI6", ip);
294 ntohs(ip[2]), ntohs(ip[3]), ntohs(ip[4]),
295 ntohs(ip[5]), ntohs(ip[6]), ntohs(ip[7]));
296 } 293 }
297 str += sprintf(str, "\n"); 294 str += sprintf(str, "\n");
298 return str - buf; 295 return str - buf;
@@ -941,8 +938,8 @@ static int __init ibft_init(void)
941 return -ENOMEM; 938 return -ENOMEM;
942 939
943 if (ibft_addr) { 940 if (ibft_addr) {
944 printk(KERN_INFO "iBFT detected at 0x%lx.\n", 941 printk(KERN_INFO "iBFT detected at 0x%llx.\n",
945 virt_to_phys((void *)ibft_addr)); 942 (u64)virt_to_phys((void *)ibft_addr));
946 943
947 rc = ibft_check_device(); 944 rc = ibft_check_device();
948 if (rc) 945 if (rc)
diff --git a/drivers/firmware/memmap.c b/drivers/firmware/memmap.c
index 3bf8ee120d42..261b9aa3f248 100644
--- a/drivers/firmware/memmap.c
+++ b/drivers/firmware/memmap.c
@@ -56,9 +56,9 @@ struct memmap_attribute {
56 ssize_t (*show)(struct firmware_map_entry *entry, char *buf); 56 ssize_t (*show)(struct firmware_map_entry *entry, char *buf);
57}; 57};
58 58
59struct memmap_attribute memmap_start_attr = __ATTR_RO(start); 59static struct memmap_attribute memmap_start_attr = __ATTR_RO(start);
60struct memmap_attribute memmap_end_attr = __ATTR_RO(end); 60static struct memmap_attribute memmap_end_attr = __ATTR_RO(end);
61struct memmap_attribute memmap_type_attr = __ATTR_RO(type); 61static struct memmap_attribute memmap_type_attr = __ATTR_RO(type);
62 62
63/* 63/*
64 * These are default attributes that are added for every memmap entry. 64 * These are default attributes that are added for every memmap entry.