Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 268565
b: refs/heads/master
c: 0b1076c
h: refs/heads/master
i:
  268563: b98f78d
v: v3
  • Loading branch information
Julian Andres Klode authored and Greg Kroah-Hartman committed Sep 30, 2011
1 parent cce530a commit e4bc6ca
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: b414e2eb3a487c901c6e0c515753fc0905784eac
refs/heads/master: 0b1076c4b2a06e517fafbb2b4704f23e69b05386
23 changes: 23 additions & 0 deletions trunk/drivers/staging/nvec/nvec.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#include <asm/irq.h>

#include <linux/atomic.h>
#include <linux/completion.h>
#include <linux/interrupt.h>
#include <linux/io.h>
Expand Down Expand Up @@ -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)
{
Expand Down
6 changes: 6 additions & 0 deletions trunk/drivers/staging/nvec/nvec.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,13 @@
#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,
Expand Down Expand Up @@ -52,6 +56,7 @@ struct nvec_msg {
unsigned short size;
unsigned short pos;
struct list_head node;
atomic_t used;
};

struct nvec_subdev {
Expand All @@ -78,6 +83,7 @@ struct nvec_chip {
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;
Expand Down

0 comments on commit e4bc6ca

Please sign in to comment.