4545 #include <linux/semaphore.h>
4646#endif
4747
48- #define TP_VERSION "0.39 "
48+ #define TP_VERSION "0.40 "
4949
5050MODULE_AUTHOR ("Shem Multinymous" );
5151MODULE_DESCRIPTION ("ThinkPad embedded controller hardware access" );
@@ -88,9 +88,14 @@ static u64 prefetch_jiffies; /* time of prefetch, or: */
8888#define TPC_PREFETCH_JUNK (INITIAL_JIFFIES+1) /* Ignore prefetch */
8989
9090/* Locking: */
91-
9291static DECLARE_MUTEX (thinkpad_ec_mutex );
9392
93+ /* Kludge in case the ACPI DSDT reserves the ports we need. */
94+ static int force_io ; /* Willing to do IO to ports we couldn't reserve? */
95+ static int reserved_io ; /* Successfully reserved the ports? */
96+ module_param_named (force_io , force_io , bool , 0600 );
97+ MODULE_PARM_DESC (force_io , "Force IO even if region already reserved (0=off, 1=on)" );
98+
9499/**
95100 * thinkpad_ec_lock - get lock on the ThinkPad EC
96101 *
@@ -468,17 +473,24 @@ static int __init thinkpad_ec_init(void)
468473 return - ENODEV ;
469474 }
470475
471- if (!request_region (TPC_BASE_PORT , TPC_NUM_PORTS ,
472- "thinkpad_ec" )) {
473- printk (KERN_ERR "thinkpad_ec: cannot claim io ports %#x-%#x\n" ,
476+ if (request_region (TPC_BASE_PORT , TPC_NUM_PORTS , "thinkpad_ec" )) {
477+ reserved_io = 1 ;
478+ } else {
479+ printk (KERN_ERR "thinkpad_ec: cannot claim IO ports %#x-%#x... " ,
474480 TPC_BASE_PORT ,
475481 TPC_BASE_PORT + TPC_NUM_PORTS - 1 );
476- return - ENXIO ;
482+ if (force_io ) {
483+ printk ("forcing use of unreserved IO ports.\n" );
484+ } else {
485+ printk ("consider using force_io=1.\n" );
486+ return - ENXIO ;
487+ }
477488 }
478489 prefetch_jiffies = TPC_PREFETCH_JUNK ;
479490 if (thinkpad_ec_test ()) {
480491 printk (KERN_ERR "thinkpad_ec: initial ec test failed\n" );
481- release_region (TPC_BASE_PORT , TPC_NUM_PORTS );
492+ if (reserved_io )
493+ release_region (TPC_BASE_PORT , TPC_NUM_PORTS );
482494 return - ENXIO ;
483495 }
484496 printk (KERN_INFO "thinkpad_ec: thinkpad_ec " TP_VERSION " loaded.\n" );
@@ -487,7 +499,8 @@ static int __init thinkpad_ec_init(void)
487499
488500static void __exit thinkpad_ec_exit (void )
489501{
490- release_region (TPC_BASE_PORT , TPC_NUM_PORTS );
502+ if (reserved_io )
503+ release_region (TPC_BASE_PORT , TPC_NUM_PORTS );
491504 printk (KERN_INFO "thinkpad_ec: unloaded.\n" );
492505}
493506
0 commit comments