diff options
author | Ben Hutchings <ben@decadent.org.uk> | 2013-07-31 16:53:30 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-07-31 17:41:02 -0400 |
commit | d39de28c95876f8becb559d242eefe718ea1f747 (patch) | |
tree | c08bfae999e12bc54c0d3a577d439d7a27bf11a3 /drivers/firmware | |
parent | 62c610460d73fcfa5637cb497c6923ef1c42b12d (diff) |
dmi_scan: add comments on dmi_present() and the loop in dmi_scan_machine()
My previous refactoring in commit 79bae42d51a5 ("dmi_scan: refactor
dmi_scan_machine(), {smbios,dmi}_present()") resulted in slightly tricky
code (though I think it's more elegant). Explain what it's doing.
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Cc: Zhenzhong Duan <zhenzhong.duan@oracle.com>
Cc: Jean Delvare <jdelvare@suse.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/firmware')
-rw-r--r-- | drivers/firmware/dmi_scan.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c index eb760a218da4..232fa8fce26a 100644 --- a/drivers/firmware/dmi_scan.c +++ b/drivers/firmware/dmi_scan.c | |||
@@ -419,6 +419,13 @@ static void __init dmi_format_ids(char *buf, size_t len) | |||
419 | dmi_get_system_info(DMI_BIOS_DATE)); | 419 | dmi_get_system_info(DMI_BIOS_DATE)); |
420 | } | 420 | } |
421 | 421 | ||
422 | /* | ||
423 | * Check for DMI/SMBIOS headers in the system firmware image. Any | ||
424 | * SMBIOS header must start 16 bytes before the DMI header, so take a | ||
425 | * 32 byte buffer and check for DMI at offset 16 and SMBIOS at offset | ||
426 | * 0. If the DMI header is present, set dmi_ver accordingly (SMBIOS | ||
427 | * takes precedence) and return 0. Otherwise return 1. | ||
428 | */ | ||
422 | static int __init dmi_present(const u8 *buf) | 429 | static int __init dmi_present(const u8 *buf) |
423 | { | 430 | { |
424 | int smbios_ver; | 431 | int smbios_ver; |
@@ -506,6 +513,13 @@ void __init dmi_scan_machine(void) | |||
506 | if (p == NULL) | 513 | if (p == NULL) |
507 | goto error; | 514 | goto error; |
508 | 515 | ||
516 | /* | ||
517 | * Iterate over all possible DMI header addresses q. | ||
518 | * Maintain the 32 bytes around q in buf. On the | ||
519 | * first iteration, substitute zero for the | ||
520 | * out-of-range bytes so there is no chance of falsely | ||
521 | * detecting an SMBIOS header. | ||
522 | */ | ||
509 | memset(buf, 0, 16); | 523 | memset(buf, 0, 16); |
510 | for (q = p; q < p + 0x10000; q += 16) { | 524 | for (q = p; q < p + 0x10000; q += 16) { |
511 | memcpy_fromio(buf + 16, q, 16); | 525 | memcpy_fromio(buf + 16, q, 16); |