diff options
| author | Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> | 2010-09-26 21:43:53 +0000 | 
|---|---|---|
| committer | Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> | 2010-09-26 21:43:53 +0000 | 
| commit | cb3eb051729118b3ac5acd67064ba519bb0cd88e (patch) | |
| tree | a22c76b7635edc25401fd321434ccdc994c6d298 | |
| parent | ed7a964786fc50b13410dbd074e9404514e8700f (diff) | |
| download | flashrom-cb3eb051729118b3ac5acd67064ba519bb0cd88e.tar.gz flashrom-cb3eb051729118b3ac5acd67064ba519bb0cd88e.tar.bz2 flashrom-cb3eb051729118b3ac5acd67064ba519bb0cd88e.zip  | |
Add list with DMI chassis types
Half a dozen hardcoded strcmp() don't make sense if we need a
chassis-type list anyway once we merge the internal DMI decoder. Provide
and array of the most interesting chassis types and annotate them with
laptop/non-laptop status. Match the dmidecode chassis type against the
strings in the array.
Corresponding to flashrom svn r1182.
Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Sean Nelson <audiohacked@gmail.com>
| -rw-r--r-- | dmi.c | 33 | 
1 files changed, 29 insertions, 4 deletions
@@ -54,6 +54,26 @@ static const char *dmidecode_names[] = {  	"baseboard-version",  }; +/* A full list of chassis types can be found in the System Management BIOS + * (SMBIOS) Reference Specification 2.7.0 section 7.4.1 "Chassis Types" at + * http://www.dmtf.org/sites/default/files/standards/documents/DSP0134_2.7.0.pdf + * The types below are the most common ones. + */ +static const struct { +	unsigned char type; +	unsigned char is_laptop; +	const char *name; +} dmi_chassis_types[] = { +	{0x01, 0, "Other"}, +	{0x02, 0, "Unknown"}, +	{0x03, 0, "Desktop",}, +	{0x08, 1, "Portable"}, +	{0x09, 1, "Laptop"}, +	{0x0a, 1, "Notebook"}, +	{0x0b, 1, "Hand Held"}, +	{0x0e, 1, "Sub Notebook"}, +}; +  #define DMI_COMMAND_LEN_MAX 260  static const char *dmidecode_command = "dmidecode"; @@ -132,10 +152,15 @@ void dmi_init(void)  	}  	chassis_type = get_dmi_string("chassis-type"); -	if (chassis_type && (!strcmp(chassis_type, "Notebook") || -			     !strcmp(chassis_type, "Portable"))) { -		msg_pdbg("Laptop detected via DMI\n"); -		is_laptop = 1; +	if (chassis_type) { +		for (i = 0; i < ARRAY_SIZE(dmi_chassis_types); i++) { +			if (!strcasecmp(chassis_type, +					dmi_chassis_types[i].name) && +			    dmi_chassis_types[i].is_laptop) { +				msg_pdbg("Laptop detected via DMI\n"); +				is_laptop = 1; +			} +		}  	}  	free(chassis_type);  }  | 
