summaryrefslogtreecommitdiffstats
path: root/main.h
diff options
context:
space:
mode:
authorKyle K <kylek389@gmail.com>2013-01-24 17:56:32 -0600
committerKyle Kaminski <kyle@kkaminsk.com>2013-01-24 17:56:32 -0600
commit20c1a6d14c9447b87394221fa42a0e85aca1b060 (patch)
tree1356fa87585bc2d4cee97cbb83a40f62c10cdd12 /main.h
parent8fdd43b49af70fd8712116b31010c032301a96b4 (diff)
downloadkernelhello-20c1a6d14c9447b87394221fa42a0e85aca1b060.tar.gz
kernelhello-20c1a6d14c9447b87394221fa42a0e85aca1b060.tar.bz2
kernelhello-20c1a6d14c9447b87394221fa42a0e85aca1b060.zip
use a linked list to hold data, utilize Linux api
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 */