#include <linux/poll.h>
#include <linux/kernel.h>
+#include <linux/bitops.h>
#include <linux/slab.h>
#include <linux/fs.h>
#include <linux/errno.h>
struct kfifo fifo;
/* Associated read_wait queue.*/
wait_queue_head_t read_wait;
+ /* User count */
+ volatile unsigned long lock;
};
/**
SCSC_TAG_INFO(MX_MMAP, "open %p\n", filp);
+ if (test_and_set_bit_lock(0, &mx_dev->lock)) {
+ SCSC_TAG_ERR(MX_MMAP, "already open %p\n", filp);
+ return -EBUSY;
+ }
+
filp->private_data = mx_dev;
mx_dev->filp = filp;
ret = kfifo_alloc(&mx_dev->fifo, GDB_TRANSPORT_BUF_LENGTH, GFP_KERNEL);
return -EIO;
}
+ clear_bit_unlock(0, &mx_dev->lock);
+
filp->private_data = NULL;
mx_dev->filp = NULL;
kfifo_free(&mx_dev->fifo);