/* special treatment of command port - on newer macbooks, it seems necessary to resend the command byte before polling the status again. Callers must hold applesmc_lock.  */
static int send_command(u8 cmd)
/* special treatment of command port - on newer macbooks, it seems necessary to resend the command byte before polling the status again. Callers must hold applesmc_lock.  */
static int send_command(u8 cmd)
{
	int us;
	for (us = APPLESMC_MIN_WAIT; us < APPLESMC_MAX_WAIT; us <<= 1) {
		outb(cmd, APPLESMC_CMD_PORT);
		udelay(us);
		if ((inb(APPLESMC_CMD_PORT) & APPLESMC_STATUS_MASK) == 0x0c)
			return 0;
	}
	printk(KERN_WARNING "applesmc: command failed: %x -> %x\n",
		cmd, inb(APPLESMC_CMD_PORT));
	return -EIO;
}