aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/misc
diff options
context:
space:
mode:
authorLennart Poettering <mzxreary@0pointer.de>2007-05-08 16:07:02 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2007-07-11 19:09:00 -0400
commit4f5c791a850e5305a5b1b48d0e4b4de248dc96f9 (patch)
tree3059bba718b9f8d5c07081221b1ab23845638935 /drivers/misc
parentcfc94cdf8e0f14e692a5a40ef3cc10f464b2511b (diff)
DMI-based module autoloading
The patch below adds DMI/SMBIOS based module autoloading to the Linux kernel. The idea is to load laptop drivers automatically (and other drivers which cannot be autoloaded otherwise), based on the DMI system identification information of the BIOS. Right now most distros manually try to load all available laptop drivers on bootup in the hope that at least one of them loads successfully. This patch does away with all that, and uses udev to automatically load matching drivers on the right machines. Basically the patch just exports the DMI information that has been parsed by the kernel anyway to userspace via a sysfs device /sys/class/dmi/id and makes sure that proper modalias attributes are available. Besides adding the "modalias" attribute it also adds attributes for a few other DMI fields which might be useful for writing udev rules. This patch is not an attempt to export the entire DMI/SMBIOS data to userspace. We already have "dmidecode" which parses the complete DMI info from userspace. The purpose of this patch is machine model identification and good udev integration. To take advantage of DMI based module autoloading, a driver should export one or more MODULE_ALIAS fields similar to these: MODULE_ALIAS("dmi:*:svnMICRO-STARINT'LCO.,LTD:pnMS-1013:pvr0131*:cvnMICRO-STARINT'LCO.,LTD:ct10:*"); MODULE_ALIAS("dmi:*:svnMicro-StarInternational:pnMS-1058:pvr0581:rvnMSI:rnMS-1058:*:ct10:*"); MODULE_ALIAS("dmi:*:svnMicro-StarInternational:pnMS-1412:*:rvnMSI:rnMS-1412:*:cvnMICRO-STARINT'LCO.,LTD:ct10:*"); MODULE_ALIAS("dmi:*:svnNOTEBOOK:pnSAM2000:pvr0131*:cvnMICRO-STARINT'LCO.,LTD:ct10:*"); These lines are specific to my msi-laptop.c driver. They are basically just a concatenation of a few carefully selected DMI fields with all potentially bad characters stripped. Besides laptop drivers, modules like "hdaps", the i2c modules and the hwmon modules are good candidates for "dmi:" MODULE_ALIAS lines. Besides merely exporting the DMI data via sysfs the patch adds support for a few more DMI fields. Especially the CHASSIS fields are very useful to identify different laptop modules. The patch also adds working MODULE_ALIAS lines to my msi-laptop.c driver. I'd like to thank Kay Sievers for helping me to clean up this patch for posting it on lkml. Patch is against Linus' current GIT HEAD. Should probably apply to older kernels as well without modification. Signed-off-by: Lennart Poettering <mzxreary@0pointer.de> Signed-off-by: Kay Sievers <kay.sievers@vrfy.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/misc')
-rw-r--r--drivers/misc/msi-laptop.c44
1 files changed, 41 insertions, 3 deletions
diff --git a/drivers/misc/msi-laptop.c b/drivers/misc/msi-laptop.c
index 41e901f53e7c..932a415197b3 100644
--- a/drivers/misc/msi-laptop.c
+++ b/drivers/misc/msi-laptop.c
@@ -23,6 +23,8 @@
23 * msi-laptop.c - MSI S270 laptop support. This laptop is sold under 23 * msi-laptop.c - MSI S270 laptop support. This laptop is sold under
24 * various brands, including "Cytron/TCM/Medion/Tchibo MD96100". 24 * various brands, including "Cytron/TCM/Medion/Tchibo MD96100".
25 * 25 *
26 * Driver also supports S271, S420 models.
27 *
26 * This driver exports a few files in /sys/devices/platform/msi-laptop-pf/: 28 * This driver exports a few files in /sys/devices/platform/msi-laptop-pf/:
27 * 29 *
28 * lcd_level - Screen brightness: contains a single integer in the 30 * lcd_level - Screen brightness: contains a single integer in the
@@ -281,25 +283,56 @@ static struct platform_device *msipf_device;
281 283
282/* Initialization */ 284/* Initialization */
283 285
286static int dmi_check_cb(struct dmi_system_id *id)
287{
288 printk("msi-laptop: Identified laptop model '%s'.\n", id->ident);
289 return 0;
290}
291
284static struct dmi_system_id __initdata msi_dmi_table[] = { 292static struct dmi_system_id __initdata msi_dmi_table[] = {
285 { 293 {
286 .ident = "MSI S270", 294 .ident = "MSI S270",
287 .matches = { 295 .matches = {
288 DMI_MATCH(DMI_SYS_VENDOR, "MICRO-STAR INT'L CO.,LTD"), 296 DMI_MATCH(DMI_SYS_VENDOR, "MICRO-STAR INT'L CO.,LTD"),
289 DMI_MATCH(DMI_PRODUCT_NAME, "MS-1013"), 297 DMI_MATCH(DMI_PRODUCT_NAME, "MS-1013"),
290 } 298 DMI_MATCH(DMI_PRODUCT_VERSION, "0131"),
299 DMI_MATCH(DMI_CHASSIS_VENDOR, "MICRO-STAR INT'L CO.,LTD")
300 },
301 .callback = dmi_check_cb
302 },
303 {
304 .ident = "MSI S271",
305 .matches = {
306 DMI_MATCH(DMI_SYS_VENDOR, "Micro-Star International"),
307 DMI_MATCH(DMI_PRODUCT_NAME, "MS-1058"),
308 DMI_MATCH(DMI_PRODUCT_VERSION, "0581"),
309 DMI_MATCH(DMI_BOARD_NAME, "MS-1058")
310 },
311 .callback = dmi_check_cb
312 },
313 {
314 .ident = "MSI S420",
315 .matches = {
316 DMI_MATCH(DMI_SYS_VENDOR, "Micro-Star International"),
317 DMI_MATCH(DMI_PRODUCT_NAME, "MS-1412"),
318 DMI_MATCH(DMI_BOARD_VENDOR, "MSI"),
319 DMI_MATCH(DMI_BOARD_NAME, "MS-1412")
320 },
321 .callback = dmi_check_cb
291 }, 322 },
292 { 323 {
293 .ident = "Medion MD96100", 324 .ident = "Medion MD96100",
294 .matches = { 325 .matches = {
295 DMI_MATCH(DMI_SYS_VENDOR, "NOTEBOOK"), 326 DMI_MATCH(DMI_SYS_VENDOR, "NOTEBOOK"),
296 DMI_MATCH(DMI_PRODUCT_NAME, "SAM2000"), 327 DMI_MATCH(DMI_PRODUCT_NAME, "SAM2000"),
297 } 328 DMI_MATCH(DMI_PRODUCT_VERSION, "0131"),
329 DMI_MATCH(DMI_CHASSIS_VENDOR, "MICRO-STAR INT'L CO.,LTD")
330 },
331 .callback = dmi_check_cb
298 }, 332 },
299 { } 333 { }
300}; 334};
301 335
302
303static int __init msi_init(void) 336static int __init msi_init(void)
304{ 337{
305 int ret; 338 int ret;
@@ -394,3 +427,8 @@ MODULE_AUTHOR("Lennart Poettering");
394MODULE_DESCRIPTION("MSI Laptop Support"); 427MODULE_DESCRIPTION("MSI Laptop Support");
395MODULE_VERSION(MSI_DRIVER_VERSION); 428MODULE_VERSION(MSI_DRIVER_VERSION);
396MODULE_LICENSE("GPL"); 429MODULE_LICENSE("GPL");
430
431MODULE_ALIAS("dmi:*:svnMICRO-STARINT'LCO.,LTD:pnMS-1013:pvr0131*:cvnMICRO-STARINT'LCO.,LTD:ct10:*");
432MODULE_ALIAS("dmi:*:svnMicro-StarInternational:pnMS-1058:pvr0581:rvnMSI:rnMS-1058:*:ct10:*");
433MODULE_ALIAS("dmi:*:svnMicro-StarInternational:pnMS-1412:*:rvnMSI:rnMS-1412:*:cvnMICRO-STARINT'LCO.,LTD:ct10:*");
434MODULE_ALIAS("dmi:*:svnNOTEBOOK:pnSAM2000:pvr0131*:cvnMICRO-STARINT'LCO.,LTD:ct10:*");