include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit...
[safe/jmp/linux-2.6] / drivers / char / ppdev.c
index 24231d9..fdd3754 100644 (file)
 #include <linux/parport.h>
 #include <linux/ctype.h>
 #include <linux/poll.h>
+#include <linux/slab.h>
 #include <linux/major.h>
 #include <linux/ppdev.h>
 #include <linux/smp_lock.h>
-#include <linux/device.h>
-#include <asm/uaccess.h>
+#include <linux/uaccess.h>
 
 #define PP_VERSION "ppdev: user-space parallel port driver"
 #define CHRDEV "ppdev"
@@ -106,7 +106,7 @@ static inline void pp_enable_irq (struct pp_struct *pp)
 static ssize_t pp_read (struct file * file, char __user * buf, size_t count,
                        loff_t * ppos)
 {
-       unsigned int minor = iminor(file->f_dentry->d_inode);
+       unsigned int minor = iminor(file->f_path.dentry->d_inode);
        struct pp_struct *pp = file->private_data;
        char * kbuffer;
        ssize_t bytes_read = 0;
@@ -115,8 +115,7 @@ static ssize_t pp_read (struct file * file, char __user * buf, size_t count,
 
        if (!(pp->flags & PP_CLAIMED)) {
                /* Don't have the port claimed */
-               printk (KERN_DEBUG CHRDEV "%x: claim the port first\n",
-                       minor);
+               pr_debug(CHRDEV "%x: claim the port first\n", minor);
                return -EINVAL;
        }
 
@@ -189,7 +188,7 @@ static ssize_t pp_read (struct file * file, char __user * buf, size_t count,
 static ssize_t pp_write (struct file * file, const char __user * buf,
                         size_t count, loff_t * ppos)
 {
-       unsigned int minor = iminor(file->f_dentry->d_inode);
+       unsigned int minor = iminor(file->f_path.dentry->d_inode);
        struct pp_struct *pp = file->private_data;
        char * kbuffer;
        ssize_t bytes_written = 0;
@@ -199,8 +198,7 @@ static ssize_t pp_write (struct file * file, const char __user * buf,
 
        if (!(pp->flags & PP_CLAIMED)) {
                /* Don't have the port claimed */
-               printk (KERN_DEBUG CHRDEV "%x: claim the port first\n",
-                       minor);
+               pr_debug(CHRDEV "%x: claim the port first\n", minor);
                return -EINVAL;
        }
 
@@ -269,9 +267,9 @@ static ssize_t pp_write (struct file * file, const char __user * buf,
        return bytes_written;
 }
 
-static void pp_irq (int irq, void * private, struct pt_regs * unused)
+static void pp_irq (void *private)
 {
-       struct pp_struct * pp = (struct pp_struct *) private;
+       struct pp_struct *pp = private;
 
        if (pp->irqresponse) {
                parport_write_control (pp->pdev->port, pp->irqctl);
@@ -314,7 +312,7 @@ static int register_device (int minor, struct pp_struct *pp)
        }
 
        pp->pdev = pdev;
-       printk (KERN_DEBUG "%s: registered pardevice\n", name);
+       pr_debug("%s: registered pardevice\n", name);
        return 0;
 }
 
@@ -329,10 +327,9 @@ static enum ieee1284_phase init_phase (int mode)
        return IEEE1284_PH_FWD_IDLE;
 }
 
-static int pp_ioctl(struct inode *inode, struct file *file,
-                   unsigned int cmd, unsigned long arg)
+static int pp_do_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 {
-       unsigned int minor = iminor(inode);
+       unsigned int minor = iminor(file->f_path.dentry->d_inode);
        struct pp_struct *pp = file->private_data;
        struct parport * port;
        void __user *argp = (void __user *)arg;
@@ -345,8 +342,7 @@ static int pp_ioctl(struct inode *inode, struct file *file,
                int ret;
 
                if (pp->flags & PP_CLAIMED) {
-                       printk (KERN_DEBUG CHRDEV
-                               "%x: you've already got it!\n", minor);
+                       pr_debug(CHRDEV "%x: you've already got it!\n", minor);
                        return -EINVAL;
                }
 
@@ -381,7 +377,7 @@ static int pp_ioctl(struct inode *inode, struct file *file,
            }
        case PPEXCL:
                if (pp->pdev) {
-                       printk (KERN_DEBUG CHRDEV "%x: too late for PPEXCL; "
+                       pr_debug(CHRDEV "%x: too late for PPEXCL; "
                                "already registered\n", minor);
                        if (pp->flags & PP_EXCL)
                                /* But it's not really an error. */
@@ -493,8 +489,7 @@ static int pp_ioctl(struct inode *inode, struct file *file,
        /* Everything else requires the port to be claimed, so check
         * that now. */
        if ((pp->flags & PP_CLAIMED) == 0) {
-               printk (KERN_DEBUG CHRDEV "%x: claim the port first\n",
-                       minor);
+               pr_debug(CHRDEV "%x: claim the port first\n", minor);
                return -EINVAL;
        }
 
@@ -626,8 +621,7 @@ static int pp_ioctl(struct inode *inode, struct file *file,
                return 0;
 
        default:
-               printk (KERN_DEBUG CHRDEV "%x: What? (cmd=0x%x)\n", minor,
-                       cmd);
+               pr_debug(CHRDEV "%x: What? (cmd=0x%x)\n", minor, cmd);
                return -EINVAL;
        }
 
@@ -635,11 +629,21 @@ static int pp_ioctl(struct inode *inode, struct file *file,
        return 0;
 }
 
+static long pp_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
+{
+       long ret;
+       lock_kernel();
+       ret = pp_do_ioctl(file, cmd, arg);
+       unlock_kernel();
+       return ret;
+}
+
 static int pp_open (struct inode * inode, struct file * file)
 {
        unsigned int minor = iminor(inode);
        struct pp_struct *pp;
 
+       cycle_kernel_lock();
        if (minor >= PARPORT_MAX)
                return -ENXIO;
 
@@ -690,9 +694,8 @@ static int pp_release (struct inode * inode, struct file * file)
        }
        if (compat_negot) {
                parport_negotiate (pp->pdev->port, IEEE1284_MODE_COMPAT);
-               printk (KERN_DEBUG CHRDEV
-                       "%x: negotiated back to compatibility mode because "
-                       "user-space forgot\n", minor);
+               pr_debug(CHRDEV "%x: negotiated back to compatibility "
+                       "mode because user-space forgot\n", minor);
        }
 
        if (pp->flags & PP_CLAIMED) {
@@ -705,7 +708,7 @@ static int pp_release (struct inode * inode, struct file * file)
                info->phase = pp->saved_state.phase;
                parport_release (pp->pdev);
                if (compat_negot != 1) {
-                       printk (KERN_DEBUG CHRDEV "%x: released pardevice "
+                       pr_debug(CHRDEV "%x: released pardevice "
                                "because user-space forgot\n", minor);
                }
        }
@@ -715,8 +718,7 @@ static int pp_release (struct inode * inode, struct file * file)
                parport_unregister_device (pp->pdev);
                kfree (name);
                pp->pdev = NULL;
-               printk (KERN_DEBUG CHRDEV "%x: unregistered pardevice\n",
-                       minor);
+               pr_debug(CHRDEV "%x: unregistered pardevice\n", minor);
        }
 
        kfree (pp);
@@ -739,26 +741,26 @@ static unsigned int pp_poll (struct file * file, poll_table * wait)
 
 static struct class *ppdev_class;
 
-static struct file_operations pp_fops = {
+static const struct file_operations pp_fops = {
        .owner          = THIS_MODULE,
        .llseek         = no_llseek,
        .read           = pp_read,
        .write          = pp_write,
        .poll           = pp_poll,
-       .ioctl          = pp_ioctl,
+       .unlocked_ioctl = pp_ioctl,
        .open           = pp_open,
        .release        = pp_release,
 };
 
 static void pp_attach(struct parport *port)
 {
-       class_device_create(ppdev_class, NULL, MKDEV(PP_MAJOR, port->number),
-                       NULL, "parport%d", port->number);
+       device_create(ppdev_class, port->dev, MKDEV(PP_MAJOR, port->number),
+                     NULL, "parport%d", port->number);
 }
 
 static void pp_detach(struct parport *port)
 {
-       class_device_destroy(ppdev_class, MKDEV(PP_MAJOR, port->number));
+       device_destroy(ppdev_class, MKDEV(PP_MAJOR, port->number));
 }
 
 static struct parport_driver pp_driver = {