/* * Write to the SoundScape's host-mode control registers, but * leave any locking issues to the caller ... */ static inline int host_write_unsafe(unsigned io_base, unsigned char data) { if ((inb(HOST_CTRL_IO(io_base)) & TX_READY) != 0) { outb(data, HOST_DATA_IO(io_base)); return 1; } return 0; }
/* * Read the SoundScape's host-mode control register, but leave * any locking issues to the caller ... */ static inline int host_read_unsafe(unsigned io_base) { int data = -1; if ((inb(HOST_CTRL_IO(io_base)) & RX_READY) != 0) { data = inb(HOST_DATA_IO(io_base)); } return data; }
/* * Wait for the host to return its start-up acknowledgement * sequence. This wait is too long for us to perform * "busy-waiting", and so we must sleep. This in turn means * that we must not be holding any spinlocks when we call * this function. */ static int host_startup_ack(struct soundscape *s, unsigned timeout) { while (timeout != 0) { unsigned long flags; unsigned char x; schedule_timeout_interruptible(1); spin_lock_irqsave(&s->lock, flags); x = inb(HOST_DATA_IO(s->io_base)); spin_unlock_irqrestore(&s->lock, flags); if (x == 0xfe) return 1; --timeout; } /* while */ return 0; }
/* * Wait for the host to return its start-up acknowledgement * sequence. This wait is too long for us to perform * "busy-waiting", and so we must sleep. This in turn means * that we must not be holding any spinlocks when we call * this function. */ static int host_startup_ack(struct soundscape *s, unsigned timeout) { while (timeout != 0) { unsigned long flags; unsigned char x; sleep(1, TASK_INTERRUPTIBLE); spin_lock_irqsave(&s->lock, flags); x = inb(HOST_DATA_IO(s->io_base)); spin_unlock_irqrestore(&s->lock, flags); if (x == 0xfe) return 1; --timeout; } /* while */ return 0; }
/* * Wait for the host to return its start-up acknowledgement * sequence. This wait is too long for us to perform * "busy-waiting", and so we must sleep. This in turn means * that we must not be holding any spinlocks when we call * this function. */ static int host_startup_ack(struct soundscape *s, unsigned timeout) { unsigned long end_time = jiffies + msecs_to_jiffies(timeout); do { unsigned long flags; unsigned char x; spin_lock_irqsave(&s->lock, flags); x = inb(HOST_DATA_IO(s->io_base)); spin_unlock_irqrestore(&s->lock, flags); if (x == 0xfe) return 1; msleep(10); } while (time_before(jiffies, end_time)); return 0; }