struct canque_slot_t **tail; /* points to NULL pointer for chaining */
struct canque_slot_t *flist; /* points the first entry in the free list */
struct canque_slot_t *entry; /* points to first allocated entry */
- spinlock_t fifo_lock; /* spin_lock_irqsave / spin_lock_irqrestore */
+ can_spinlock_t fifo_lock; /* can_spin_lock_irqsave / can_spin_unlock_irqrestore */
};
#define CAN_FIFOF_DESTROY_b 15
static inline
int canque_fifo_get_inslot(struct canque_fifo_t *fifo, struct canque_slot_t **slotp, int cmd)
{
- unsigned long flags;
+ can_spin_irqflags_t flags;
struct canque_slot_t *slot;
- spin_lock_irqsave(&fifo->fifo_lock, flags);
+ can_spin_lock_irqsave(&fifo->fifo_lock, flags);
/* get the first free slot slot from flist */
if(!(slot=fifo->flist)) {
canque_fifo_set_fl(fifo,OVERRUN);
canque_fifo_set_fl(fifo,FULL);
- spin_unlock_irqrestore(&fifo->fifo_lock, flags);
+ can_spin_unlock_irqrestore(&fifo->fifo_lock, flags);
*slotp=NULL;
return -1;
}
/* adjust free slot list */
if(!(fifo->flist=slot->next))
canque_fifo_set_fl(fifo,FULL);
- spin_unlock_irqrestore(&fifo->fifo_lock, flags);
+ can_spin_unlock_irqrestore(&fifo->fifo_lock, flags);
*slotp=slot;
slot->slot_flags=cmd&CAN_SLOTF_CMD;
return 1;
int canque_fifo_put_inslot(struct canque_fifo_t *fifo, struct canque_slot_t *slot)
{
int ret;
- unsigned long flags;
+ can_spin_irqflags_t flags;
slot->next=NULL;
- spin_lock_irqsave(&fifo->fifo_lock, flags);
+ can_spin_lock_irqsave(&fifo->fifo_lock, flags);
if(*fifo->tail) printk(KERN_CRIT "canque_fifo_put_inslot: fifo->tail != NULL\n");
*fifo->tail=slot;
fifo->tail=&slot->next;
ret=CAN_FIFOF_EMPTY; /* Fifo has been empty before put */
if(canque_fifo_test_and_clear_fl(fifo,INACTIVE))
ret=CAN_FIFOF_INACTIVE; /* Fifo has been empty before put */
- spin_unlock_irqrestore(&fifo->fifo_lock, flags);
+ can_spin_unlock_irqrestore(&fifo->fifo_lock, flags);
return ret;
}
int canque_fifo_abort_inslot(struct canque_fifo_t *fifo, struct canque_slot_t *slot)
{
int ret=0;
- unsigned long flags;
- spin_lock_irqsave(&fifo->fifo_lock, flags);
+ can_spin_irqflags_t flags;
+ can_spin_lock_irqsave(&fifo->fifo_lock, flags);
slot->next=fifo->flist;
fifo->flist=slot;
if(canque_fifo_test_and_clear_fl(fifo,FULL))
ret=CAN_FIFOF_FULL;
- spin_unlock_irqrestore(&fifo->fifo_lock, flags);
+ can_spin_unlock_irqrestore(&fifo->fifo_lock, flags);
return ret;
}
static inline
int canque_fifo_test_outslot(struct canque_fifo_t *fifo, struct canque_slot_t **slotp)
{
- unsigned long flags;
+ can_spin_irqflags_t flags;
int cmd;
struct canque_slot_t *slot;
- spin_lock_irqsave(&fifo->fifo_lock, flags);
+ can_spin_lock_irqsave(&fifo->fifo_lock, flags);
if(!(slot=fifo->head)){;
canque_fifo_set_fl(fifo,EMPTY);
- spin_unlock_irqrestore(&fifo->fifo_lock, flags);
+ can_spin_unlock_irqrestore(&fifo->fifo_lock, flags);
*slotp=NULL;
return -1;
}
if(!(fifo->head=slot->next))
fifo->tail=&fifo->head;
- spin_unlock_irqrestore(&fifo->fifo_lock, flags);
+ can_spin_unlock_irqrestore(&fifo->fifo_lock, flags);
*slotp=slot;
cmd=slot->slot_flags;
int canque_fifo_free_outslot(struct canque_fifo_t *fifo, struct canque_slot_t *slot)
{
int ret=0;
- unsigned long flags;
- spin_lock_irqsave(&fifo->fifo_lock, flags);
+ can_spin_irqflags_t flags;
+ can_spin_lock_irqsave(&fifo->fifo_lock, flags);
slot->next=fifo->flist;
fifo->flist=slot;
if(canque_fifo_test_and_clear_fl(fifo,FULL))
canque_fifo_set_fl(fifo,EMPTY);
ret|=CAN_FIFOF_EMPTY;
}
- spin_unlock_irqrestore(&fifo->fifo_lock, flags);
+ can_spin_unlock_irqrestore(&fifo->fifo_lock, flags);
return ret;
}
static inline
int canque_fifo_again_outslot(struct canque_fifo_t *fifo, struct canque_slot_t *slot)
{
- unsigned long flags;
- spin_lock_irqsave(&fifo->fifo_lock, flags);
+ can_spin_irqflags_t flags;
+ can_spin_lock_irqsave(&fifo->fifo_lock, flags);
if(!(slot->next=fifo->head))
fifo->tail=&slot->next;
fifo->head=slot;
- spin_unlock_irqrestore(&fifo->fifo_lock, flags);
+ can_spin_unlock_irqrestore(&fifo->fifo_lock, flags);
return 1;
}
struct list_head idle;
struct list_head inlist;
struct list_head outlist;
- spinlock_t ends_lock; /* spin_lock_irqsave / spin_lock_irqrestore */
+ can_spinlock_t ends_lock; /* can_spin_lock_irqsave / can_spin_unlock_irqrestore */
void (*notify)(struct canque_ends_t *qends, struct canque_edge_t *qedge, int what);
void *context;
union {
wait_queue_head_t readq;
wait_queue_head_t writeq;
wait_queue_head_t emptyq;
+ #ifdef CAN_ENABLE_KERN_FASYNC
+ struct fasync_struct *fasync;
+ #endif /*CAN_ENABLE_KERN_FASYNC*/
} fileinfo;
struct {
wait_queue_head_t daemonq;
static inline
void canque_activate_edge(struct canque_ends_t *inends, struct canque_edge_t *qedge)
{
- unsigned long flags;
+ can_spin_irqflags_t flags;
struct canque_ends_t *outends;
if(qedge->edge_prio>=CANQUEUE_PRIO_NR)
qedge->edge_prio=CANQUEUE_PRIO_NR-1;
- spin_lock_irqsave(&inends->ends_lock, flags);
+ can_spin_lock_irqsave(&inends->ends_lock, flags);
if((outends=qedge->outends)){
- spin_lock(&outends->ends_lock);
- spin_lock(&qedge->fifo.fifo_lock);
+ can_spin_lock(&outends->ends_lock);
+ can_spin_lock(&qedge->fifo.fifo_lock);
if(!canque_fifo_test_fl(&qedge->fifo,EMPTY)){
list_del(&qedge->activepeers);
list_add_tail(&qedge->activepeers,&outends->active[qedge->edge_prio]);
}
- spin_unlock(&qedge->fifo.fifo_lock);
- spin_unlock(&outends->ends_lock);
+ can_spin_unlock(&qedge->fifo.fifo_lock);
+ can_spin_unlock(&outends->ends_lock);
}
- spin_unlock_irqrestore(&inends->ends_lock, flags);
+ can_spin_unlock_irqrestore(&inends->ends_lock, flags);
}
/**
void canqueue_block_outlist(struct canque_ends_t *qends);
+int canqueue_ends_kill_inlist(struct canque_ends_t *qends, int send_rest);
+
+int canqueue_ends_kill_outlist(struct canque_ends_t *qends);
+
/* edge reference and traversal functions */
void canque_edge_do_dead(struct canque_edge_t *edge, int dead_fl);
static inline
void canque_edge_decref(struct canque_edge_t *edge)
{
- unsigned long flags;
+ can_spin_irqflags_t flags;
struct canque_ends_t *inends=edge->inends;
struct canque_ends_t *outends=edge->outends;
int dead_fl;
- spin_lock_irqsave(&inends->ends_lock, flags);
- spin_lock(&outends->ends_lock);
+ can_spin_lock_irqsave(&inends->ends_lock, flags);
+ can_spin_lock(&outends->ends_lock);
if(atomic_dec_and_test(&edge->edge_used)) {
dead_fl=canque_fifo_test_and_set_fl(&edge->fifo,DEAD);
/*This should not be there, but it cannot be outside of the lock :-(*/
canque_notify_bothends(edge,CANQUEUE_NOTIFY_NOUSR);
- spin_unlock(&outends->ends_lock);
- spin_unlock_irqrestore(&inends->ends_lock, flags);
+ can_spin_unlock(&outends->ends_lock);
+ can_spin_unlock_irqrestore(&inends->ends_lock, flags);
canque_edge_do_dead(edge, dead_fl);
} else {
- spin_unlock(&outends->ends_lock);
- spin_unlock_irqrestore(&inends->ends_lock, flags);
+ can_spin_unlock(&outends->ends_lock);
+ can_spin_unlock_irqrestore(&inends->ends_lock, flags);
}
}
static inline
struct canque_edge_t *canque_first_inedge(struct canque_ends_t *qends)
{
- unsigned long flags;
+ can_spin_irqflags_t flags;
struct list_head *entry;
struct canque_edge_t *edge;
- spin_lock_irqsave(&qends->ends_lock, flags);
+ can_spin_lock_irqsave(&qends->ends_lock, flags);
entry=qends->inlist.next;
skip_dead:
if(entry != &qends->inlist) {
} else {
edge=NULL;
}
- spin_unlock_irqrestore(&qends->ends_lock, flags);
+ can_spin_unlock_irqrestore(&qends->ends_lock, flags);
return edge;
}
static inline
struct canque_edge_t *canque_next_inedge(struct canque_ends_t *qends, struct canque_edge_t *edge)
{
- unsigned long flags;
+ can_spin_irqflags_t flags;
struct list_head *entry;
struct canque_edge_t *next;
- spin_lock_irqsave(&qends->ends_lock, flags);
+ can_spin_lock_irqsave(&qends->ends_lock, flags);
entry=edge->inpeers.next;
skip_dead:
if(entry != &qends->inlist) {
} else {
next=NULL;
}
- spin_unlock_irqrestore(&qends->ends_lock, flags);
+ can_spin_unlock_irqrestore(&qends->ends_lock, flags);
canque_edge_decref(edge);
return next;
}
static inline
struct canque_edge_t *canque_first_outedge(struct canque_ends_t *qends)
{
- unsigned long flags;
+ can_spin_irqflags_t flags;
struct list_head *entry;
struct canque_edge_t *edge;
- spin_lock_irqsave(&qends->ends_lock, flags);
+ can_spin_lock_irqsave(&qends->ends_lock, flags);
entry=qends->outlist.next;
skip_dead:
if(entry != &qends->outlist) {
} else {
edge=NULL;
}
- spin_unlock_irqrestore(&qends->ends_lock, flags);
+ can_spin_unlock_irqrestore(&qends->ends_lock, flags);
return edge;
}
static inline
struct canque_edge_t *canque_next_outedge(struct canque_ends_t *qends, struct canque_edge_t *edge)
{
- unsigned long flags;
+ can_spin_irqflags_t flags;
struct list_head *entry;
struct canque_edge_t *next;
- spin_lock_irqsave(&qends->ends_lock, flags);
+ can_spin_lock_irqsave(&qends->ends_lock, flags);
entry=edge->outpeers.next;
skip_dead:
if(entry != &qends->outlist) {
} else {
next=NULL;
}
- spin_unlock_irqrestore(&qends->ends_lock, flags);
+ can_spin_unlock_irqrestore(&qends->ends_lock, flags);
canque_edge_decref(edge);
return next;
}