#include <asm/irq.h>
+#include <linux/atomic.h>
#include <linux/completion.h>
#include <linux/interrupt.h>
#include <linux/io.h>
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)
{
#ifndef __LINUX_MFD_NVEC
#define __LINUX_MFD_NVEC
+#include <linux/atomic.h>
#include <linux/notifier.h>
#include <linux/semaphore.h>
+/* NVEC_POOL_SIZE - Size of the pool in &struct nvec_msg */
+#define NVEC_POOL_SIZE 64
+
typedef enum {
NVEC_2BYTES,
NVEC_3BYTES,
unsigned short size;
unsigned short pos;
struct list_head node;
+ atomic_t used;
};
struct nvec_subdev {
struct notifier_block nvec_status_notifier;
struct work_struct rx_work, tx_work;
struct nvec_msg *rx, *tx;
+ struct nvec_msg msg_pool[NVEC_POOL_SIZE];
/* sync write stuff */
struct semaphore sync_write_mutex;