public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Matthew Garrett <mjg59@srcf.ucam.org>
To: linux-kernel@vger.kernel.org
Subject: [PATCH] Make DMI code store chassis type
Date: Mon, 6 Feb 2006 19:15:06 +0000	[thread overview]
Message-ID: <20060206191506.GA17395@srcf.ucam.org> (raw)

The previous patch had a typo, so here's a fixed one. This patch stores 
the chassis type of the hardware, making it easier to determine whether 
a piece of hardware from a manufacturer is a laptop. This information is 
not 100% reliable - some vendors insert bogus values, but most of the 
big ones are fairly accurate.

Signed-Off-By: Matthew Garrett <mjg59@srcf.ucam.org>

diff --git a/arch/i386/kernel/dmi_scan.c b/arch/i386/kernel/dmi_scan.c
index 58516e2..e555588 100644
--- a/arch/i386/kernel/dmi_scan.c
+++ b/arch/i386/kernel/dmi_scan.c
@@ -30,6 +30,50 @@ static char * __init dmi_string(struct d
 	return str;
 }
 
+static char * __init dmi_chassis_type(struct dmi_header *dm, u8 s)
+{
+	char *str = "";
+	static const char *type[]={
+                "Other", /* 0x01 */
+                "Unknown",
+                "Desktop",
+                "Low Profile Desktop",
+                "Pizza Box",
+                "Mini Tower",
+                "Tower",
+                "Portable",
+                "Laptop",
+                "Notebook",
+                "Hand Held",
+                "Docking Station",
+                "All In One",
+                "Sub Notebook",
+                "Space-saving",
+                "Lunch Box",
+                "Main Server Chassis", /* master.mif says System */
+                "Expansion Chassis",
+                "Sub Chassis",
+                "Bus Expansion Chassis",
+                "Peripheral Chassis",
+                "RAID Chassis",
+                "Rack Mount Chassis",
+                "Sealed-case PC",
+                "Multi-system" /* 0x19 */
+        };
+
+        if(s>=0x01 && s<=0x19) {
+		str = alloc_bootmem(strlen(type[code-0x01]));
+		if (str != NULL)
+			strcpy(str, type[code-0x01]);
+		else
+			printk(KERN_ERR "dmi_chassis_type: out of memory.\n");
+
+                return str;
+	}
+
+	return NULL;
+}
+
 /*
  *	We have to be cautious here. We have seen BIOSes with DMI pointers
  *	pointing to completely the wrong place for example
@@ -93,7 +137,11 @@ static void __init dmi_save_ident(struct
 	if (dmi_ident[slot])
 		return;
 
-	p = dmi_string(dm, d[string]);
+	if (slot == DMI_CHASSIS_TYPE)
+		p = dmi_chassis_type(string & 0x7f);
+	else
+		p = dmi_string(dm, d[string]);
+
 	if (p == NULL)
 		return;
 
@@ -176,6 +224,11 @@ static void __init dmi_decode(struct dmi
 		dmi_save_ident(dm, DMI_BOARD_NAME, 5);
 		dmi_save_ident(dm, DMI_BOARD_VERSION, 6);
 		break;
+	case 3:         /* Chassis Information */
+		dmi_save_ident(dm, DMI_CHASSIS_VENDOR, 4);
+		dmi_save_ident(dm, DMI_CHASSIS_TYPE, 5);
+		break;
+		
 	case 10:	/* Onboard Devices Information */
 		dmi_save_devices(dm);
 		break;
diff --git a/include/linux/dmi.h b/include/linux/dmi.h
index 05f4132..5f425a7 100644
--- a/include/linux/dmi.h
+++ b/include/linux/dmi.h
@@ -15,6 +15,8 @@ enum dmi_field {
 	DMI_BOARD_VENDOR,
 	DMI_BOARD_NAME,
 	DMI_BOARD_VERSION,
+	DMI_CHASSIS_VENDOR,
+	DMI_CHASSIS_TYPE,
 	DMI_STRING_MAX,
 };
 

-- 
Matthew Garrett | mjg59@srcf.ucam.org

             reply	other threads:[~2006-02-06 19:15 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-02-06 19:15 Matthew Garrett [this message]
2006-02-06 19:18 ` [PATCH] Add HP laptop backlight brightness display Matthew Garrett
2006-02-06 19:19   ` [PATCH] Add Dell " Matthew Garrett
2006-02-07  0:37     ` [PATCH] [RESEND] " Matthew Garrett
2006-02-07  3:37       ` Dmitry Torokhov
2006-02-07 12:32         ` Matthew Garrett
2006-02-07 13:06           ` Richard Purdie
2006-02-07 13:23             ` Matthew Garrett
2006-02-07 13:37               ` Richard Purdie
2006-02-07 13:55                 ` Matthew Garrett
2006-02-07 14:54                   ` Richard Purdie
2006-02-08  9:06                   ` Pavel Machek
2006-02-06 20:04   ` [PATCH] Add HP " Jan-Benedict Glaw

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060206191506.GA17395@srcf.ucam.org \
    --to=mjg59@srcf.ucam.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox