summaryrefslogtreecommitdiff
path: root/drivers/staging/nvec/nvec.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/staging/nvec/nvec.c')
-rw-r--r--drivers/staging/nvec/nvec.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/drivers/staging/nvec/nvec.c b/drivers/staging/nvec/nvec.c
index 43a83a953d4..fb0f51a2b0b 100644
--- a/drivers/staging/nvec/nvec.c
+++ b/drivers/staging/nvec/nvec.c
@@ -17,6 +17,7 @@
#include <asm/irq.h>
+#include <linux/atomic.h>
#include <linux/completion.h>
#include <linux/interrupt.h>
#include <linux/io.h>
@@ -91,6 +92,28 @@ static int nvec_status_notifier(struct notifier_block *nb,
return NOTIFY_OK;
}
+static struct nvec_msg *nvec_msg_alloc(struct nvec_chip *nvec)
+{
+ int i;
+
+ for (i = 0; i < NVEC_POOL_SIZE; i++) {
+ if (atomic_xchg(&nvec->msg_pool[i].used, 1) == 0) {
+ dev_vdbg(nvec->dev, "INFO: Allocate %i\n", i);
+ return &nvec->msg_pool[i];
+ }
+ }
+
+ dev_err(nvec->dev, "could not allocate buffer\n");
+
+ return NULL;
+}
+
+static void nvec_msg_free(struct nvec_chip *nvec, struct nvec_msg *msg)
+{
+ dev_vdbg(nvec->dev, "INFO: Free %ti\n", msg - nvec->msg_pool);
+ atomic_set(&msg->used, 0);
+}
+
void nvec_write_async(struct nvec_chip *nvec, const unsigned char *data,
short size)
{