Skip to content

Commit

Permalink
dmi: morph dmi_dump_ids() into dmi_format_ids() which formats into a …
Browse files Browse the repository at this point in the history
…buffer

We're goning to use DMI identification for other purposes too.  Morph
dmi_dump_ids() which is used to print DMI identification as a debug
message during boot into dmi_format_ids() which formats the same
information sans the leading "DMI:" tag into a string buffer.

dmi_present() is updated to format the information into dmi_ids_string[]
using the new function and print it with "DMI:" prefix.

dmi_ids_string[] will be used for another purpose by a future patch.

Signed-off-by: Tejun Heo <[email protected]>
Cc: Bjorn Helgaas <[email protected]>
Cc: David S. Miller <[email protected]>
Cc: Fengguang Wu <[email protected]>
Cc: Heiko Carstens <[email protected]>
Cc: Jesper Nilsson <[email protected]>
Cc: Martin Schwidefsky <[email protected]>
Cc: Mike Frysinger <[email protected]>
Cc: Vineet Gupta <[email protected]>
Cc: Sam Ravnborg <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
htejun authored and torvalds committed May 1, 2013
1 parent 196779b commit c90fe6b
Showing 1 changed file with 27 additions and 17 deletions.
44 changes: 27 additions & 17 deletions drivers/firmware/dmi_scan.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ static u16 __initdata dmi_ver;
*/
static int dmi_initialized;

/* DMI system identification string used during boot */
static char dmi_ids_string[128] __initdata;

static const char * __init dmi_string_nosave(const struct dmi_header *dm, u8 s)
{
const u8 *bp = ((u8 *) dm) + dm->length;
Expand Down Expand Up @@ -376,38 +379,44 @@ static void __init dmi_decode(const struct dmi_header *dm, void *dummy)
}
}

static void __init print_filtered(const char *info)
static int __init print_filtered(char *buf, size_t len, const char *info)
{
int c = 0;
const char *p;

if (!info)
return;
return c;

for (p = info; *p; p++)
if (isprint(*p))
printk(KERN_CONT "%c", *p);
c += scnprintf(buf + c, len - c, "%c", *p);
else
printk(KERN_CONT "\\x%02x", *p & 0xff);
c += scnprintf(buf + c, len - c, "\\x%02x", *p & 0xff);
return c;
}

static void __init dmi_dump_ids(void)
static void __init dmi_format_ids(char *buf, size_t len)
{
int c = 0;
const char *board; /* Board Name is optional */

printk(KERN_DEBUG "DMI: ");
print_filtered(dmi_get_system_info(DMI_SYS_VENDOR));
printk(KERN_CONT " ");
print_filtered(dmi_get_system_info(DMI_PRODUCT_NAME));
c += print_filtered(buf + c, len - c,
dmi_get_system_info(DMI_SYS_VENDOR));
c += scnprintf(buf + c, len - c, " ");
c += print_filtered(buf + c, len - c,
dmi_get_system_info(DMI_PRODUCT_NAME));

board = dmi_get_system_info(DMI_BOARD_NAME);
if (board) {
printk(KERN_CONT "/");
print_filtered(board);
c += scnprintf(buf + c, len - c, "/");
c += print_filtered(buf + c, len - c, board);
}
printk(KERN_CONT ", BIOS ");
print_filtered(dmi_get_system_info(DMI_BIOS_VERSION));
printk(KERN_CONT " ");
print_filtered(dmi_get_system_info(DMI_BIOS_DATE));
printk(KERN_CONT "\n");
c += scnprintf(buf + c, len - c, ", BIOS ");
c += print_filtered(buf + c, len - c,
dmi_get_system_info(DMI_BIOS_VERSION));
c += scnprintf(buf + c, len - c, " ");
c += print_filtered(buf + c, len - c,
dmi_get_system_info(DMI_BIOS_DATE));
}

static int __init dmi_present(const char __iomem *p)
Expand All @@ -431,7 +440,8 @@ static int __init dmi_present(const char __iomem *p)
pr_info("Legacy DMI %d.%d present.\n",
dmi_ver >> 8, dmi_ver & 0xFF);
}
dmi_dump_ids();
dmi_format_ids(dmi_ids_string, sizeof(dmi_ids_string));
printk(KERN_DEBUG "DMI: %s\n", dmi_ids_string);
return 0;
}
}
Expand Down

0 comments on commit c90fe6b

Please sign in to comment.