]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/char/lp.c
V4L/DVB (7611): em28xx: Move registers to a separate file
[linux-2.6-omap-h63xx.git] / drivers / char / lp.c
index fa626034a6e21c9358f9744306914d2aaf6dd698..60ac642752bea4441604515513efa160d6e8c73f 100644 (file)
 /* if you have more than 8 printers, remember to increase LP_NO */
 #define LP_NO 8
 
-/* ROUND_UP macro from fs/select.c */
-#define ROUND_UP(x,y) (((x)+(y)-1)/(y))
-
 static struct lp_struct lp_table[LP_NO];
 
 static unsigned int lp_count = 0;
 static struct class *lp_class;
 
 #ifdef CONFIG_LP_CONSOLE
-static struct parport *console_registered; // initially NULL
+static struct parport *console_registered;
 #endif /* CONFIG_LP_CONSOLE */
 
 #undef LP_DEBUG
@@ -315,7 +312,7 @@ static ssize_t lp_write(struct file * file, const char __user * buf,
        if (copy_size > LP_BUFFER_SIZE)
                copy_size = LP_BUFFER_SIZE;
 
-       if (down_interruptible (&lp_table[minor].port_mutex))
+       if (mutex_lock_interruptible(&lp_table[minor].port_mutex))
                return -EINTR;
 
        if (copy_from_user (kbuf, buf, copy_size)) {
@@ -402,7 +399,7 @@ static ssize_t lp_write(struct file * file, const char __user * buf,
                lp_release_parport (&lp_table[minor]);
        }
 out_unlock:
-       up (&lp_table[minor].port_mutex);
+       mutex_unlock(&lp_table[minor].port_mutex);
 
        return retv;
 }
@@ -424,7 +421,7 @@ static ssize_t lp_read(struct file * file, char __user * buf,
        if (count > LP_BUFFER_SIZE)
                count = LP_BUFFER_SIZE;
 
-       if (down_interruptible (&lp_table[minor].port_mutex))
+       if (mutex_lock_interruptible(&lp_table[minor].port_mutex))
                return -EINTR;
 
        lp_claim_parport_or_block (&lp_table[minor]);
@@ -482,7 +479,7 @@ static ssize_t lp_read(struct file * file, char __user * buf,
        if (retval > 0 && copy_to_user (buf, kbuf, retval))
                retval = -EFAULT;
 
-       up (&lp_table[minor].port_mutex);
+       mutex_unlock(&lp_table[minor].port_mutex);
 
        return retval;
 }
@@ -651,7 +648,7 @@ static int lp_ioctl(struct inode *inode, struct file *file,
                            (par_timeout.tv_usec < 0)) {
                                return -EINVAL;
                        }
-                       to_jiffies = ROUND_UP(par_timeout.tv_usec, 1000000/HZ);
+                       to_jiffies = DIV_ROUND_UP(par_timeout.tv_usec, 1000000/HZ);
                        to_jiffies += par_timeout.tv_sec * (long) HZ;
                        if (to_jiffies <= 0) {
                                return -EINVAL;
@@ -752,8 +749,8 @@ static struct console lpcons = {
 /* --- initialisation code ------------------------------------- */
 
 static int parport_nr[LP_NO] = { [0 ... LP_NO-1] = LP_PARPORT_UNSPEC };
-static char *parport[LP_NO] = { NULL,  };
-static int reset = 0;
+static char *parport[LP_NO];
+static int reset;
 
 module_param_array(parport, charp, NULL, 0);
 module_param(reset, bool, 0);
@@ -761,10 +758,10 @@ module_param(reset, bool, 0);
 #ifndef MODULE
 static int __init lp_setup (char *str)
 {
-       static int parport_ptr; // initially zero
+       static int parport_ptr;
        int x;
 
-       if (get_option (&str, &x)) {
+       if (get_option(&str, &x)) {
                if (x == 0) {
                        /* disable driver on "lp=" or "lp=0" */
                        parport_nr[0] = LP_PARPORT_OFF;
@@ -802,8 +799,7 @@ static int lp_register(int nr, struct parport *port)
        if (reset)
                lp_reset(nr);
 
-       class_device_create(lp_class, NULL, MKDEV(LP_MAJOR, nr), port->dev,
-                               "lp%d", nr);
+       device_create(lp_class, port->dev, MKDEV(LP_MAJOR, nr), "lp%d", nr);
 
        printk(KERN_INFO "lp%d: using %s (%s).\n", nr, port->name, 
               (port->irq == PARPORT_IRQ_NONE)?"polling":"interrupt-driven");
@@ -811,7 +807,7 @@ static int lp_register(int nr, struct parport *port)
 #ifdef CONFIG_LP_CONSOLE
        if (!nr) {
                if (port->modes & PARPORT_MODE_SAFEININT) {
-                       register_console (&lpcons);
+                       register_console(&lpcons);
                        console_registered = port;
                        printk (KERN_INFO "lp%d: console ready\n", CONSOLE_LP);
                } else
@@ -827,8 +823,7 @@ static void lp_attach (struct parport *port)
 {
        unsigned int i;
 
-       switch (parport_nr[0])
-       {
+       switch (parport_nr[0]) {
        case LP_PARPORT_UNSPEC:
        case LP_PARPORT_AUTO:
                if (parport_nr[0] == LP_PARPORT_AUTO &&
@@ -859,7 +854,7 @@ static void lp_detach (struct parport *port)
        /* Write this some day. */
 #ifdef CONFIG_LP_CONSOLE
        if (console_registered == port) {
-               unregister_console (&lpcons);
+               unregister_console(&lpcons);
                console_registered = NULL;
        }
 #endif /* CONFIG_LP_CONSOLE */
@@ -893,7 +888,7 @@ static int __init lp_init (void)
                lp_table[i].last_error = 0;
                init_waitqueue_head (&lp_table[i].waitq);
                init_waitqueue_head (&lp_table[i].dataq);
-               init_MUTEX (&lp_table[i].port_mutex);
+               mutex_init(&lp_table[i].port_mutex);
                lp_table[i].timeout = 10 * HZ;
        }
 
@@ -974,7 +969,7 @@ static void lp_cleanup_module (void)
                if (lp_table[offset].dev == NULL)
                        continue;
                parport_unregister_device(lp_table[offset].dev);
-               class_device_destroy(lp_class, MKDEV(LP_MAJOR, offset));
+               device_destroy(lp_class, MKDEV(LP_MAJOR, offset));
        }
        class_destroy(lp_class);
 }