summaryrefslogtreecommitdiffstats
path: root/main.h
diff options
context:
space:
mode:
Diffstat (limited to 'main.h')
-rw-r--r--main.h30
1 files changed, 27 insertions, 3 deletions
diff --git a/main.h b/main.h
index db38aa8..cb751d0 100644
--- a/main.h
+++ b/main.h
@@ -2,26 +2,50 @@
#define _HELLOMAIN_H_
#include <linux/cdev.h>
+#include <linux/list.h>
+
+/*
+ * Macros to aid with debugging
+ */
+#ifdef HELLO_DEBUG
+ #define PDEBUG(fmt, args...) printk( KERN_DEBUG "[hello] " fmt, ##args)
+#else
+ #define PDEBUG(fmt, args...) /* not debugging: nothing */
+#endif
#ifndef HELLO_MAJOR
#define HELLO_MAJOR 0 /* let kernel choose, unless user really defined it */
#endif
-#define HELLO_KERNEL_BUFF_LEN 1024
+/*
+ * Allow user to define size of node using a #define, or passing -D compiler
+ * flag
+ */
+#ifndef HELLO_NODE_CHUNK_SIZE
+#define HELLO_NODE_CHUNK_SIZE 256
+#endif
extern int hello_major;
extern int hello_minor;
extern char *magicstr;
+/* node to be used with Linux api for circular linked lists */
+struct hello_ll
+{
+ char *chunk;
+ struct list_head list;
+};
+
struct hello_dev {
dev_t devnum;
struct semaphore sem;
struct cdev cdev; /* char device */
/* for r/w operations */
- char hello_buffer[HELLO_KERNEL_BUFF_LEN];
- size_t buff_index;
+ struct hello_ll *mylist;
+ int chunk_sz;
+ size_t ll_size;
};
/* function prototypes */