#ifndef _HELLOMAIN_H_
#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)
  #define PRDEBUG(fmt, args...) if (printk_ratelimit()) \
                                    printk( KERN_DEBUG "[hello] " fmt, ##args)
#else
  /* not debugging: nothing */
  #define PDEBUG(fmt, args...)
  #define PRDEBUG(fmt, args...)
#endif

#ifndef HELLO_MAJOR
#define HELLO_MAJOR 0 /* let kernel choose, unless user really defined it */
#endif

/*
 * 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 */
    struct hello_ll *mylist;
    int chunk_sz;
    size_t ll_size;
};

/* function prototypes */
int hello_debugfs(void);

#endif