Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 115907
b: refs/heads/master
c: 8c9398d
h: refs/heads/master
i:
  115905: bbc8b8a
  115903: 38a8d5f
v: v3
  • Loading branch information
Henrik Rydberg authored and Linus Torvalds committed Oct 20, 2008
1 parent 1f2709d commit a28e1d7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 07e8dbd3ebbdedc71335049dd4b0d542cb038d7d
refs/heads/master: 8c9398d1e9766e3659e277acb2e8ca1c17684139
22 changes: 12 additions & 10 deletions trunk/drivers/hwmon/applesmc.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@

#define APPLESMC_MAX_DATA_LENGTH 32

#define APPLESMC_MIN_WAIT 0x0040
#define APPLESMC_MAX_WAIT 0x8000

#define APPLESMC_STATUS_MASK 0x0f
#define APPLESMC_READ_CMD 0x10
#define APPLESMC_WRITE_CMD 0x11
Expand Down Expand Up @@ -172,25 +175,25 @@ static unsigned int key_at_index;
static struct workqueue_struct *applesmc_led_wq;

/*
* __wait_status - Wait up to 10ms for the status port to get a certain value
* __wait_status - Wait up to 32ms for the status port to get a certain value
* (masked with 0x0f), returning zero if the value is obtained. Callers must
* hold applesmc_lock.
*/
static int __wait_status(u8 val)
{
unsigned int i;
int us;

val = val & APPLESMC_STATUS_MASK;

for (i = 0; i < 1000; i++) {
for (us = APPLESMC_MIN_WAIT; us < APPLESMC_MAX_WAIT; us <<= 1) {
udelay(us);
if ((inb(APPLESMC_CMD_PORT) & APPLESMC_STATUS_MASK) == val) {
if (debug)
printk(KERN_DEBUG
"Waited %d us for status %x\n",
i*10, val);
"Waited %d us for status %x\n",
2 * us - APPLESMC_MIN_WAIT, val);
return 0;
}
udelay(10);
}

printk(KERN_WARNING "applesmc: wait status failed: %x != %x\n",
Expand All @@ -206,13 +209,12 @@ static int __wait_status(u8 val)
*/
static int send_command(u8 cmd)
{
int i;
for (i = 0; i < 1000; i++) {
int us;
for (us = APPLESMC_MIN_WAIT; us < APPLESMC_MAX_WAIT; us <<= 1) {
outb(cmd, APPLESMC_CMD_PORT);
udelay(5);
udelay(us);
if ((inb(APPLESMC_CMD_PORT) & APPLESMC_STATUS_MASK) == 0x0c)
return 0;
udelay(5);
}
printk(KERN_WARNING "applesmc: command failed: %x -> %x\n",
cmd, inb(APPLESMC_CMD_PORT));
Expand Down

0 comments on commit a28e1d7

Please sign in to comment.