--- a/thinkpad_ec.c +++ b/thinkpad_ec.c @@ -37,5 +37,5 @@ #include -#define TP_VERSION "0.29" +#define TP_VERSION "0.29-debug1" MODULE_AUTHOR("Shem Multinymous"); @@ -62,5 +62,5 @@ #define TPC_READ_RETRIES 150 #define TPC_READ_NDELAY 500 -#define TPC_REQUEST_RETRIES 100 +#define TPC_REQUEST_RETRIES 1000 #define TPC_REQUEST_NDELAY 10 #define TPC_PREFETCH_TIMEOUT (HZ/10) /* invalidate prefetch after 0.1sec */ @@ -155,4 +155,12 @@ } + /* Ensure status is stable: */ + ndelay(1000); + str3 = inb(TPC_STR3_PORT) & H8S_STR3_MASK; + if (str3 != 0x00) { + printk(KERN_WARNING REQ_FMT("unstable STR3", str3)); + return -EIO; + } + /* Send TWR0MW: */ outb(args->val[0], TPC_TWR0_PORT); @@ -195,5 +203,6 @@ * requested. */ -static int thinkpad_ec_read_data(struct thinkpad_ec_row *data) +static int thinkpad_ec_read_data(const struct thinkpad_ec_row *args, + struct thinkpad_ec_row *data) { int i; @@ -210,5 +219,5 @@ if (str3 != (H8S_STR3_OBF3B|H8S_STR3_SWMF)) { printk(KERN_WARNING - MSG_FMT("bad initial STR3 (0x%02x)", str3)); + REQ_FMT("bad initial STR3", str3)); return -EIO; } @@ -227,5 +236,9 @@ if (str3 & H8S_STR3_OBF3B) printk(KERN_WARNING - MSG_FMT("OBF3B=1 after read (0x%02x)", str3)); + REQ_FMT("OBF3B=1 after read", str3)); + /* If port 0x161F returns 0x80 too often, the EC may lock up: */ + if (data->val[0xF] == 0x80) + printk(KERN_WARNING + REQ_FMT("0x161F reports error", data->val[0xF])); return 0; } @@ -283,5 +296,5 @@ /* Read the row's data */ for (retries=0; retries PAGE_SIZE-TP_CONTROLLER_ROW_LEN*5 ) return -ENOMEM; /* don't overflow sysfs buf */