wait_queue_head_t rt_queue;
wait_queue_head_t lx_queue;
atomic_t in_open;
+ struct mutex mutex;
} channel_wqs[RTLX_CHANNELS];
static struct irqaction irq;
lx = &rtlx->channel[index];
+ mutex_lock(&channel_wqs[index].mutex);
smp_rmb();
lx_write = lx->lx_write;
smp_wmb();
lx->lx_read = (lx->lx_read + count) % lx->buffer_size;
smp_wmb();
+ mutex_unlock(&channel_wqs[index].mutex);
return count;
}
rt = &rtlx->channel[index];
+ mutex_lock(&channel_wqs[index].mutex);
smp_rmb();
rt_read = rt->rt_read;
smp_wmb();
rt->rt_write = (rt->rt_write + count) % rt->buffer_size;
smp_wmb();
+ mutex_unlock(&channel_wqs[index].mutex);
return count;
}
init_waitqueue_head(&channel_wqs[i].rt_queue);
init_waitqueue_head(&channel_wqs[i].lx_queue);
atomic_set(&channel_wqs[i].in_open, 0);
+ mutex_init(&channel_wqs[i].mutex);
dev = device_create(mt_class, NULL, MKDEV(major, i),
"%s%d", module_name, i);