/*************** primitives for use in any context *********************/ static inline uint8_t hp_sdc_status_in8 (void) { uint8_t status; unsigned long flags; write_lock_irqsave(&hp_sdc.ibf_lock, flags); status = sdc_readb(hp_sdc.status_io); if (!(status & HP_SDC_STATUS_IBF)) hp_sdc.ibf = 0; write_unlock_irqrestore(&hp_sdc.ibf_lock, flags); return status; }
/* Care must be taken to only invoke hp_sdc_spin_ibf when * absolutely needed, or in rarely invoked subroutines. * Not only does it waste CPU cycles, it also wastes bus cycles. */ static inline void hp_sdc_spin_ibf(void) { unsigned long flags; rwlock_t *lock; lock = &hp_sdc.ibf_lock; read_lock_irqsave(lock, flags); if (!hp_sdc.ibf) { read_unlock_irqrestore(lock, flags); return; } read_unlock(lock); write_lock(lock); while (sdc_readb(hp_sdc.status_io) & HP_SDC_STATUS_IBF) {}; hp_sdc.ibf = 0; write_unlock_irqrestore(lock, flags); }
static inline uint8_t hp_sdc_data_in8(void) { return sdc_readb(hp_sdc.data_io); }