diff options
author | Peter Feuerer <peter@piie.net> | 2009-12-21 19:20:06 -0500 |
---|---|---|
committer | Len Brown <len.brown@intel.com> | 2009-12-24 00:17:09 -0500 |
commit | dcbfb8156a2149fd6358a377aa9400e28ef43800 (patch) | |
tree | 6ad406b1c74d29f838b655fbff71f4a2bcf3ade2 /drivers/platform/x86/acerhdf.c | |
parent | 94219d798e65dff1dac5f8f36f03a9bdb3105f91 (diff) |
drivers/platform/x86/acerhdf.c: check BIOS information whether it begins with string of table
BIOS information is now checked whether it begins with the strings stored
in the BIOS table. Previous method did a strcmp, what lead to problems if
BIOS information has appended whitespaces.
Signed-off-by: Peter Feuerer <peter@piie.net>
Cc: Borislav Petkov <petkovbb@gmail.com>
Cc: Andreas Mohr <andi@lisas.de>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/platform/x86/acerhdf.c')
-rw-r--r-- | drivers/platform/x86/acerhdf.c | 46 |
1 files changed, 28 insertions, 18 deletions
diff --git a/drivers/platform/x86/acerhdf.c b/drivers/platform/x86/acerhdf.c index a97fc4a7c600..7b2384d674d0 100644 --- a/drivers/platform/x86/acerhdf.c +++ b/drivers/platform/x86/acerhdf.c | |||
@@ -52,7 +52,7 @@ | |||
52 | */ | 52 | */ |
53 | #undef START_IN_KERNEL_MODE | 53 | #undef START_IN_KERNEL_MODE |
54 | 54 | ||
55 | #define DRV_VER "0.5.21" | 55 | #define DRV_VER "0.5.22" |
56 | 56 | ||
57 | /* | 57 | /* |
58 | * According to the Atom N270 datasheet, | 58 | * According to the Atom N270 datasheet, |
@@ -165,12 +165,9 @@ static const struct bios_settings_t bios_tbl[] = { | |||
165 | /* Gateway */ | 165 | /* Gateway */ |
166 | {"Gateway", "AOA110", "v0.3103", 0x55, 0x58, {0x21, 0x21, 0x00} }, | 166 | {"Gateway", "AOA110", "v0.3103", 0x55, 0x58, {0x21, 0x21, 0x00} }, |
167 | {"Gateway", "AOA150", "v0.3103", 0x55, 0x58, {0x20, 0x20, 0x00} }, | 167 | {"Gateway", "AOA150", "v0.3103", 0x55, 0x58, {0x20, 0x20, 0x00} }, |
168 | {"Gateway ", "LT31 ", "v1.3103 ", 0x55, 0x58, | 168 | {"Gateway", "LT31", "v1.3103", 0x55, 0x58, {0x10, 0x0f, 0x00} }, |
169 | {0x10, 0x0f, 0x00} }, | 169 | {"Gateway", "LT31", "v1.3201", 0x55, 0x58, {0x10, 0x0f, 0x00} }, |
170 | {"Gateway ", "LT31 ", "v1.3201 ", 0x55, 0x58, | 170 | {"Gateway", "LT31", "v1.3302", 0x55, 0x58, {0x10, 0x0f, 0x00} }, |
171 | {0x10, 0x0f, 0x00} }, | ||
172 | {"Gateway ", "LT31 ", "v1.3302 ", 0x55, 0x58, | ||
173 | {0x10, 0x0f, 0x00} }, | ||
174 | /* Packard Bell */ | 171 | /* Packard Bell */ |
175 | {"Packard Bell", "DOA150", "v0.3104", 0x55, 0x58, {0x21, 0x21, 0x00} }, | 172 | {"Packard Bell", "DOA150", "v0.3104", 0x55, 0x58, {0x21, 0x21, 0x00} }, |
176 | {"Packard Bell", "DOA150", "v0.3105", 0x55, 0x58, {0x20, 0x20, 0x00} }, | 173 | {"Packard Bell", "DOA150", "v0.3105", 0x55, 0x58, {0x20, 0x20, 0x00} }, |
@@ -495,13 +492,26 @@ static struct platform_driver acerhdf_driver = { | |||
495 | .remove = acerhdf_remove, | 492 | .remove = acerhdf_remove, |
496 | }; | 493 | }; |
497 | 494 | ||
495 | /* checks if str begins with start */ | ||
496 | static int str_starts_with(const char *str, const char *start) | ||
497 | { | ||
498 | unsigned long str_len = 0, start_len = 0; | ||
499 | |||
500 | str_len = strlen(str); | ||
501 | start_len = strlen(start); | ||
502 | |||
503 | if (str_len >= start_len && | ||
504 | !strncmp(str, start, start_len)) | ||
505 | return 1; | ||
506 | |||
507 | return 0; | ||
508 | } | ||
498 | 509 | ||
499 | /* check hardware */ | 510 | /* check hardware */ |
500 | static int acerhdf_check_hardware(void) | 511 | static int acerhdf_check_hardware(void) |
501 | { | 512 | { |
502 | char const *vendor, *version, *product; | 513 | char const *vendor, *version, *product; |
503 | int i; | 514 | const struct bios_settings_t *bt = NULL; |
504 | unsigned long prod_len = 0; | ||
505 | 515 | ||
506 | /* get BIOS data */ | 516 | /* get BIOS data */ |
507 | vendor = dmi_get_system_info(DMI_SYS_VENDOR); | 517 | vendor = dmi_get_system_info(DMI_SYS_VENDOR); |
@@ -523,20 +533,20 @@ static int acerhdf_check_hardware(void) | |||
523 | kernelmode = 0; | 533 | kernelmode = 0; |
524 | } | 534 | } |
525 | 535 | ||
526 | prod_len = strlen(product); | ||
527 | |||
528 | if (verbose) | 536 | if (verbose) |
529 | pr_info("BIOS info: %s %s, product: %s\n", | 537 | pr_info("BIOS info: %s %s, product: %s\n", |
530 | vendor, version, product); | 538 | vendor, version, product); |
531 | 539 | ||
532 | /* search BIOS version and vendor in BIOS settings table */ | 540 | /* search BIOS version and vendor in BIOS settings table */ |
533 | for (i = 0; bios_tbl[i].version[0]; i++) { | 541 | for (bt = bios_tbl; bt->vendor[0]; bt++) { |
534 | if (strlen(bios_tbl[i].product) >= prod_len && | 542 | /* |
535 | !strncmp(bios_tbl[i].product, product, | 543 | * check if actual hardware BIOS vendor, product and version |
536 | strlen(bios_tbl[i].product)) && | 544 | * IDs start with the strings of BIOS table entry |
537 | !strcmp(bios_tbl[i].vendor, vendor) && | 545 | */ |
538 | !strcmp(bios_tbl[i].version, version)) { | 546 | if (str_starts_with(vendor, bt->vendor) && |
539 | bios_cfg = &bios_tbl[i]; | 547 | str_starts_with(product, bt->product) && |
548 | str_starts_with(version, bt->version)) { | ||
549 | bios_cfg = bt; | ||
540 | break; | 550 | break; |
541 | } | 551 | } |
542 | } | 552 | } |