include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit...
[safe/jmp/linux-2.6] / drivers / isdn / hysdn / hysdn_proclog.c
index 8ef2b7c..e83f6fd 100644 (file)
  */
 
 #include <linux/module.h>
-#include <linux/version.h>
 #include <linux/poll.h>
 #include <linux/proc_fs.h>
-#include <linux/pci.h>
+#include <linux/sched.h>
+#include <linux/slab.h>
 #include <linux/smp_lock.h>
 
 #include "hysdn_defs.h"
 /* the proc subdir for the interface is defined in the procconf module */
 extern struct proc_dir_entry *hysdn_proc_entry;
 
+static void put_log_buffer(hysdn_card * card, char *cp);
+
 /*************************************************/
 /* structure keeping ascii log for device output */
 /*************************************************/
 struct log_data {
        struct log_data *next;
-       ulong usage_cnt;        /* number of files still to work */
+       unsigned long usage_cnt;/* number of files still to work */
        void *proc_ctrl;        /* pointer to own control procdata structure */
        char log_start[2];      /* log string start (final len aligned by size) */
 };
@@ -41,7 +43,7 @@ struct procdata {
        struct log_data *log_head, *log_tail;   /* head and tail for queue */
        int if_used;            /* open count for interface */
        int volatile del_lock;  /* lock for delete operations */
-       uchar logtmp[LOG_MAX_LINELEN];
+       unsigned char logtmp[LOG_MAX_LINELEN];
        wait_queue_head_t rd_queue;
 };
 
@@ -93,7 +95,7 @@ hysdn_addlog(hysdn_card * card, char *fmt,...)
 /* opened for read got the contents.        */
 /* Flushes buffers not longer in use.       */
 /********************************************/
-void
+static void
 put_log_buffer(hysdn_card * card, char *cp)
 {
        struct log_data *ib;
@@ -110,13 +112,12 @@ put_log_buffer(hysdn_card * card, char *cp)
        if (pd->if_used <= 0)
                return;         /* no open file for read */
 
-       if (!(ib = (struct log_data *) kmalloc(sizeof(struct log_data) + strlen(cp), GFP_ATOMIC)))
+       if (!(ib = kmalloc(sizeof(struct log_data) + strlen(cp), GFP_ATOMIC)))
                 return;        /* no memory */
        strcpy(ib->log_start, cp);      /* set output string */
        ib->next = NULL;
        ib->proc_ctrl = pd;     /* point to own control structure */
-       save_flags(flags);
-       cli();
+       spin_lock_irqsave(&card->hysdn_lock, flags);
        ib->usage_cnt = pd->if_used;
        if (!pd->log_head)
                pd->log_head = ib;      /* new head */
@@ -124,7 +125,7 @@ put_log_buffer(hysdn_card * card, char *cp)
                pd->log_tail->next = ib;        /* follows existing messages */
        pd->log_tail = ib;      /* new tail */
        i = pd->del_lock++;     /* get lock state */
-       restore_flags(flags);
+       spin_unlock_irqrestore(&card->hysdn_lock, flags);
 
        /* delete old entrys */
        if (!i)
@@ -152,9 +153,9 @@ put_log_buffer(hysdn_card * card, char *cp)
 static ssize_t
 hysdn_log_write(struct file *file, const char __user *buf, size_t count, loff_t * off)
 {
-       ulong u = 0;
+       unsigned long u = 0;
        int found = 0;
-       uchar *cp, valbuf[128];
+       unsigned char *cp, valbuf[128];
        long base = 10;
        hysdn_card *card = (hysdn_card *) file->private_data;
 
@@ -204,7 +205,7 @@ hysdn_log_read(struct file *file, char __user *buf, size_t count, loff_t * off)
 {
        struct log_data *inf;
        int len;
-       struct proc_dir_entry *pde = PDE(file->f_dentry->d_inode);
+       struct proc_dir_entry *pde = PDE(file->f_path.dentry->d_inode);
        struct procdata *pd = NULL;
        hysdn_card *card;
 
@@ -248,7 +249,7 @@ hysdn_log_open(struct inode *ino, struct file *filep)
 {
        hysdn_card *card;
        struct procdata *pd = NULL;
-       ulong flags;
+       unsigned long flags;
 
        lock_kernel();
        card = card_root;
@@ -269,14 +270,13 @@ hysdn_log_open(struct inode *ino, struct file *filep)
        } else if ((filep->f_mode & (FMODE_READ | FMODE_WRITE)) == FMODE_READ) {
 
                /* read access -> log/debug read */
-               save_flags(flags);
-               cli();
+               spin_lock_irqsave(&card->hysdn_lock, flags);
                pd->if_used++;
                if (pd->log_head)
                        filep->private_data = &pd->log_tail->next;
                else
                        filep->private_data = &pd->log_head;
-               restore_flags(flags);
+               spin_unlock_irqrestore(&card->hysdn_lock, flags);
        } else {                /* simultaneous read/write access forbidden ! */
                unlock_kernel();
                return (-EPERM);        /* no permission this time */
@@ -299,8 +299,6 @@ hysdn_log_close(struct inode *ino, struct file *filep)
        struct procdata *pd;
        hysdn_card *card;
        int retval = 0;
-       unsigned long flags;
-
 
        lock_kernel();
        if ((filep->f_mode & (FMODE_READ | FMODE_WRITE)) == FMODE_WRITE) {
@@ -310,8 +308,6 @@ hysdn_log_close(struct inode *ino, struct file *filep)
                /* read access -> log/debug read, mark one further file as closed */
 
                pd = NULL;
-               save_flags(flags);
-               cli();
                inf = *((struct log_data **) filep->private_data);      /* get first log entry */
                if (inf)
                        pd = (struct procdata *) inf->proc_ctrl;        /* still entries there */
@@ -334,7 +330,6 @@ hysdn_log_close(struct inode *ino, struct file *filep)
                        inf->usage_cnt--;       /* decrement usage count for buffers */
                        inf = inf->next;
                }
-               restore_flags(flags);
 
                if (pd)
                        if (pd->if_used <= 0)   /* delete buffers if last file closed */
@@ -356,7 +351,7 @@ static unsigned int
 hysdn_log_poll(struct file *file, poll_table * wait)
 {
        unsigned int mask = 0;
-       struct proc_dir_entry *pde = PDE(file->f_dentry->d_inode);
+       struct proc_dir_entry *pde = PDE(file->f_path.dentry->d_inode);
        hysdn_card *card;
        struct procdata *pd = NULL;
 
@@ -385,8 +380,9 @@ hysdn_log_poll(struct file *file, poll_table * wait)
 /**************************************************/
 /* table for log filesystem functions defined above. */
 /**************************************************/
-static struct file_operations log_fops =
+static const struct file_operations log_fops =
 {
+       .owner          = THIS_MODULE,
        .llseek         = no_llseek,
        .read           = hysdn_log_read,
        .write          = hysdn_log_write,
@@ -407,13 +403,11 @@ hysdn_proclog_init(hysdn_card * card)
 
        /* create a cardlog proc entry */
 
-       if ((pd = (struct procdata *) kmalloc(sizeof(struct procdata), GFP_KERNEL)) != NULL) {
-               memset(pd, 0, sizeof(struct procdata));
+       if ((pd = kzalloc(sizeof(struct procdata), GFP_KERNEL)) != NULL) {
                sprintf(pd->log_name, "%s%d", PROC_LOG_BASENAME, card->myid);
-               if ((pd->log = create_proc_entry(pd->log_name, S_IFREG | S_IRUGO | S_IWUSR, hysdn_proc_entry)) != NULL) {
-                       pd->log->proc_fops = &log_fops; 
-                       pd->log->owner = THIS_MODULE;
-               }
+               pd->log = proc_create(pd->log_name,
+                               S_IFREG | S_IRUGO | S_IWUSR, hysdn_proc_entry,
+                               &log_fops);
 
                init_waitqueue_head(&(pd->rd_queue));