]> rtime.felk.cvut.cz Git - lincan.git/blobdiff - lincan/src/devcommon.c
CAN driver infrastructure redesign to LinCAN-0.2 version
[lincan.git] / lincan / src / devcommon.c
diff --git a/lincan/src/devcommon.c b/lincan/src/devcommon.c
new file mode 100644 (file)
index 0000000..9cd29d0
--- /dev/null
@@ -0,0 +1,66 @@
+/* devcommon.c - common device code
+ * Linux CAN-bus device driver.
+ * New CAN queues by Pavel Pisa - OCERA team member
+ * email:pisa@cmp.felk.cvut.cz
+ * This software is released under the GPL-License.
+ * Version lincan-0.2  9 Jul 2003
+ */
+
+#define __NO_VERSION__
+#include <linux/module.h>
+#include <linux/version.h>
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0))
+#include <linux/malloc.h>
+#else
+#include <linux/slab.h>
+#endif
+#include <linux/wait.h>
+#include "../include/can.h"
+#include "../include/can_queue.h"
+#include "../include/main.h"
+#include "../include/devcommon.h"
+
+void canqueue_notify_chip(struct canque_ends_t *qends, struct canque_edge_t *qedge, int what)
+{
+       struct chip_t *chip=qends->endinfo.chipinfo.chip;
+       struct msgobj_t *obj=qends->endinfo.chipinfo.msgobj;
+
+       DEBUGMSG("canqueue_notify_chip for edge %d and event %d\n",qedge->edge_num,what);
+       switch(what){
+               /*case CANQUEUE_NOTIFY_EMPTY:*/
+               /*case CANQUEUE_NOTIFY_SPACE:*/
+               /*case CANQUEUE_NOTIFY_NOUSR:
+                       wake_up_interruptible(&qends->endinfo.chipinfo.daemonq);
+                       break;*/
+               case CANQUEUE_NOTIFY_PROC:
+                       /*wake_up_interruptible(&qends->endinfo.chipinfo.daemonq);*/
+                       chip->chipspecops->wakeup_tx(chip, obj);
+                       break;
+               case CANQUEUE_NOTIFY_DEAD:
+                       if(atomic_read(&qedge->edge_used)>0)
+                               atomic_dec(&qedge->edge_used);
+                       break;
+               case CANQUEUE_NOTIFY_ATACH:
+                       atomic_inc(&qedge->edge_used);
+                       break;
+       }
+}
+
+
+int canqueue_ends_init_chip(struct canque_ends_t *qends, struct chip_t *chip, struct msgobj_t *obj)
+{
+       int ret;
+       ret=canqueue_ends_init_gen(qends);
+       if(ret<0) return ret;
+       
+       qends->context=NULL;
+       init_waitqueue_head(&qends->endinfo.chipinfo.daemonq);
+       qends->endinfo.chipinfo.chip=chip;
+       qends->endinfo.chipinfo.msgobj=obj;
+       qends->notify=canqueue_notify_chip;
+
+       DEBUGMSG("canqueue_ends_init_chip\n");
+       return 0;
+}
+
+