parport: change style of NULL comparison
[deliverable/linux.git] / drivers / parport / share.c
index 5ce5ef211bdbdf575752e150edc6e26cc683e82d..ccd7df458ebc5678285619351e9a5978c8250605 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Parallel-port resource manager code.
- * 
+ *
  * Authors: David Campbell <campbell@tirian.che.curtin.edu.au>
  *          Tim Waugh <tim@cyberelk.demon.co.uk>
  *          Jose Renau <renau@acm.org>
@@ -93,7 +93,7 @@ static struct parport_operations dead_ops = {
        .ecp_write_data = dead_write,           /* ecp */
        .ecp_read_data  = dead_read,
        .ecp_write_addr = dead_write,
+
        .compat_write_data      = dead_write,   /* compat */
        .nibble_read_data       = dead_read,    /* nibble */
        .byte_read_data         = dead_read,    /* byte */
@@ -148,7 +148,7 @@ void parport_bus_exit(void)
 /*
  * iterates through all the drivers registered with the bus and sends the port
  * details to the match_port callback of the driver, so that the driver can
- * know about the new port that just regsitered with the bus and decide if it
+ * know about the new port that just registered with the bus and decide if it
  * wants to use this new port.
  */
 static int driver_check(struct device_driver *dev_drv, void *_port)
@@ -207,8 +207,10 @@ static void detach_driver_chain(struct parport *port)
 /* Ask kmod for some lowlevel drivers. */
 static void get_lowlevel_driver (void)
 {
-       /* There is no actual module called this: you should set
-        * up an alias for modutils. */
+       /*
+        * There is no actual module called this: you should set
+        * up an alias for modutils.
+        */
        request_module ("parport_lowlevel");
 }
 
@@ -343,6 +345,7 @@ void parport_unregister_driver (struct parport_driver *drv)
        }
        mutex_unlock(&registration_lock);
 }
+EXPORT_SYMBOL(parport_unregister_driver);
 
 static void free_port(struct device *dev)
 {
@@ -378,6 +381,7 @@ struct parport *parport_get_port (struct parport *port)
 
        return to_parport_dev(dev);
 }
+EXPORT_SYMBOL(parport_get_port);
 
 void parport_del_port(struct parport *port)
 {
@@ -398,6 +402,7 @@ void parport_put_port (struct parport *port)
 {
        put_device(&port->bus_dev);
 }
+EXPORT_SYMBOL(parport_put_port);
 
 /**
  *     parport_register_port - register a parallel port
@@ -439,10 +444,8 @@ struct parport *parport_register_port(unsigned long base, int irq, int dma,
        int ret;
 
        tmp = kzalloc(sizeof(struct parport), GFP_KERNEL);
-       if (!tmp) {
-               printk(KERN_WARNING "parport: memory squeeze\n");
+       if (!tmp)
                return NULL;
-       }
 
        /* Init our structure */
        tmp->base = base;
@@ -450,7 +453,7 @@ struct parport *parport_register_port(unsigned long base, int irq, int dma,
        tmp->dma = dma;
        tmp->muxport = tmp->daisy = tmp->muxsel = -1;
        tmp->modes = 0;
-       INIT_LIST_HEAD(&tmp->list);
+       INIT_LIST_HEAD(&tmp->list);
        tmp->devices = tmp->cad = NULL;
        tmp->flags = 0;
        tmp->ops = ops;
@@ -468,7 +471,6 @@ struct parport *parport_register_port(unsigned long base, int irq, int dma,
 
        name = kmalloc(15, GFP_KERNEL);
        if (!name) {
-               printk(KERN_ERR "parport: memory squeeze\n");
                kfree(tmp);
                return NULL;
        }
@@ -508,6 +510,7 @@ struct parport *parport_register_port(unsigned long base, int irq, int dma,
 
        return tmp;
 }
+EXPORT_SYMBOL(parport_register_port);
 
 /**
  *     parport_announce_port - tell device drivers about a parallel port
@@ -531,9 +534,8 @@ void parport_announce_port (struct parport *port)
 #endif
 
        if (!port->dev)
-               printk(KERN_WARNING "%s: fix this legacy "
-                               "no-device port driver!\n",
-                               port->name);
+               printk(KERN_WARNING "%s: fix this legacy no-device port driver!\n",
+                      port->name);
 
        parport_proc_register(port);
        mutex_lock(&registration_lock);
@@ -555,6 +557,7 @@ void parport_announce_port (struct parport *port)
        }
        mutex_unlock(&registration_lock);
 }
+EXPORT_SYMBOL(parport_announce_port);
 
 /**
  *     parport_remove_port - deregister a parallel port
@@ -616,6 +619,7 @@ void parport_remove_port(struct parport *port)
                        parport_put_port(slave);
        }
 }
+EXPORT_SYMBOL(parport_remove_port);
 
 /**
  *     parport_register_device - register a device on a parallel port
@@ -689,7 +693,7 @@ void parport_remove_port(struct parport *port)
 struct pardevice *
 parport_register_device(struct parport *port, const char *name,
                        int (*pf)(void *), void (*kf)(void *),
-                       void (*irq_func)(void *), 
+                       void (*irq_func)(void *),
                        int flags, void *handle)
 {
        struct pardevice *tmp;
@@ -722,28 +726,24 @@ parport_register_device(struct parport *port, const char *name,
                }
        }
 
-       /* We up our own module reference count, and that of the port
-           on which a device is to be registered, to ensure that
-           neither of us gets unloaded while we sleep in (e.g.)
-           kmalloc.
-         */
-       if (!try_module_get(port->ops->owner)) {
+       /*
+        * We up our own module reference count, and that of the port
+        * on which a device is to be registered, to ensure that
+        * neither of us gets unloaded while we sleep in (e.g.)
+        * kmalloc.
+        */
+       if (!try_module_get(port->ops->owner))
                return NULL;
-       }
-               
+
        parport_get_port (port);
 
        tmp = kmalloc(sizeof(struct pardevice), GFP_KERNEL);
-       if (tmp == NULL) {
-               printk(KERN_WARNING "%s: memory squeeze, couldn't register %s.\n", port->name, name);
+       if (!tmp)
                goto out;
-       }
 
        tmp->state = kmalloc(sizeof(struct parport_state), GFP_KERNEL);
-       if (tmp->state == NULL) {
-               printk(KERN_WARNING "%s: memory squeeze, couldn't register %s.\n", port->name, name);
+       if (!tmp->state)
                goto out_free_pardevice;
-       }
 
        tmp->name = name;
        tmp->port = port;
@@ -769,17 +769,19 @@ parport_register_device(struct parport *port, const char *name,
                if (port->physport->devices) {
                        spin_unlock (&port->physport->pardevice_lock);
                        printk (KERN_DEBUG
-                               "%s: cannot grant exclusive access for "
-                               "device %s\n", port->name, name);
+                               "%s: cannot grant exclusive access for device %s\n",
+                               port->name, name);
                        goto out_free_all;
                }
                port->flags |= PARPORT_FLAG_EXCL;
        }
 
        tmp->next = port->physport->devices;
-       wmb(); /* Make sure that tmp->next is written before it's
-                  added to the list; see comments marked 'no locking
-                  required' */
+       wmb(); /*
+               * Make sure that tmp->next is written before it's
+               * added to the list; see comments marked 'no locking
+               * required'
+               */
        if (port->physport->devices)
                port->physport->devices->prev = tmp;
        port->physport->devices = tmp;
@@ -810,6 +812,7 @@ parport_register_device(struct parport *port, const char *name,
 
        return NULL;
 }
+EXPORT_SYMBOL(parport_register_device);
 
 static void free_pardevice(struct device *dev)
 {
@@ -968,7 +971,7 @@ void parport_unregister_device(struct pardevice *dev)
        struct parport *port;
 
 #ifdef PARPORT_PARANOID
-       if (dev == NULL) {
+       if (!dev) {
                printk(KERN_ERR "parport_unregister_device: passed NULL\n");
                return;
        }
@@ -1001,8 +1004,10 @@ void parport_unregister_device(struct pardevice *dev)
 
        spin_unlock(&port->pardevice_lock);
 
-       /* Make sure we haven't left any pointers around in the wait
-        * list. */
+       /*
+        * Make sure we haven't left any pointers around in the wait
+        * list.
+        */
        spin_lock_irq(&port->waitlist_lock);
        if (dev->waitprev || dev->waitnext || port->waithead == dev) {
                if (dev->waitprev)
@@ -1025,6 +1030,7 @@ void parport_unregister_device(struct pardevice *dev)
        module_put(port->ops->owner);
        parport_put_port (port);
 }
+EXPORT_SYMBOL(parport_unregister_device);
 
 /**
  *     parport_find_number - find a parallel port by number
@@ -1055,6 +1061,7 @@ struct parport *parport_find_number (int number)
        spin_unlock (&parportlist_lock);
        return result;
 }
+EXPORT_SYMBOL(parport_find_number);
 
 /**
  *     parport_find_base - find a parallel port by base address
@@ -1085,6 +1092,7 @@ struct parport *parport_find_base (unsigned long base)
        spin_unlock (&parportlist_lock);
        return result;
 }
+EXPORT_SYMBOL(parport_find_base);
 
 /**
  *     parport_claim - claim access to a parallel port device
@@ -1121,8 +1129,10 @@ int parport_claim(struct pardevice *dev)
                        goto blocked;
 
                if (port->cad != oldcad) {
-                       /* I think we'll actually deadlock rather than
-                           get here, but just in case.. */
+                       /*
+                        * I think we'll actually deadlock rather than
+                        * get here, but just in case..
+                        */
                        printk(KERN_WARNING
                               "%s: %s released port when preempted!\n",
                               port->name, oldcad->name);
@@ -1175,9 +1185,11 @@ int parport_claim(struct pardevice *dev)
        return 0;
 
 blocked:
-       /* If this is the first time we tried to claim the port, register an
-          interest.  This is only allowed for devices sleeping in
-          parport_claim_or_block(), or those with a wakeup function.  */
+       /*
+        * If this is the first time we tried to claim the port, register an
+        * interest.  This is only allowed for devices sleeping in
+        * parport_claim_or_block(), or those with a wakeup function.
+        */
 
        /* The cad_lock is still held for writing here */
        if (dev->waiting & 2 || dev->wakeup) {
@@ -1197,6 +1209,7 @@ blocked:
        write_unlock_irqrestore (&port->cad_lock, flags);
        return -EAGAIN;
 }
+EXPORT_SYMBOL(parport_claim);
 
 /**
  *     parport_claim_or_block - claim access to a parallel port device
@@ -1212,8 +1225,10 @@ int parport_claim_or_block(struct pardevice *dev)
 {
        int r;
 
-       /* Signal to parport_claim() that we can wait even without a
-          wakeup function.  */
+       /*
+        * Signal to parport_claim() that we can wait even without a
+        * wakeup function.
+        */
        dev->waiting = 2;
 
        /* Try to claim the port.  If this fails, we need to sleep.  */
@@ -1231,14 +1246,15 @@ int parport_claim_or_block(struct pardevice *dev)
                 * See also parport_release()
                 */
 
-               /* If dev->waiting is clear now, an interrupt
-                  gave us the port and we would deadlock if we slept.  */
+               /*
+                * If dev->waiting is clear now, an interrupt
+                * gave us the port and we would deadlock if we slept.
+                */
                if (dev->waiting) {
                        wait_event_interruptible(dev->wait_q,
                                                 !dev->waiting);
-                       if (signal_pending (current)) {
+                       if (signal_pending (current))
                                return -EINTR;
-                       }
                        r = 1;
                } else {
                        r = 0;
@@ -1250,15 +1266,15 @@ int parport_claim_or_block(struct pardevice *dev)
 
 #ifdef PARPORT_DEBUG_SHARING
                if (dev->port->physport->cad != dev)
-                       printk(KERN_DEBUG "%s: exiting parport_claim_or_block "
-                              "but %s owns port!\n", dev->name,
-                              dev->port->physport->cad ?
+                       printk(KERN_DEBUG "%s: exiting parport_claim_or_block but %s owns port!\n",
+                              dev->name, dev->port->physport->cad ?
                               dev->port->physport->cad->name:"nobody");
 #endif
        }
        dev->waiting = 0;
        return r;
 }
+EXPORT_SYMBOL(parport_claim_or_block);
 
 /**
  *     parport_release - give up access to a parallel port device
@@ -1279,8 +1295,8 @@ void parport_release(struct pardevice *dev)
        write_lock_irqsave(&port->cad_lock, flags);
        if (port->cad != dev) {
                write_unlock_irqrestore (&port->cad_lock, flags);
-               printk(KERN_WARNING "%s: %s tried to release parport "
-                      "when not owner\n", port->name, dev->name);
+               printk(KERN_WARNING "%s: %s tried to release parport when not owner\n",
+                      port->name, dev->name);
                return;
        }
 
@@ -1304,8 +1320,10 @@ void parport_release(struct pardevice *dev)
        /* Save control registers */
        port->ops->save_state(port, dev->state);
 
-       /* If anybody is waiting, find out who's been there longest and
-          then wake them up. (Note: no locking required) */
+       /*
+        * If anybody is waiting, find out who's been there longest and
+        * then wake them up. (Note: no locking required)
+        */
        /* !!! LOCKING IS NEEDED HERE */
        for (pd = port->waithead; pd; pd = pd->waitnext) {
                if (pd->waiting & 2) { /* sleeping in claim_or_block */
@@ -1322,14 +1340,17 @@ void parport_release(struct pardevice *dev)
                }
        }
 
-       /* Nobody was waiting, so walk the list to see if anyone is
-          interested in being woken up. (Note: no locking required) */
+       /*
+        * Nobody was waiting, so walk the list to see if anyone is
+        * interested in being woken up. (Note: no locking required)
+        */
        /* !!! LOCKING IS NEEDED HERE */
-       for (pd = port->devices; (port->cad == NULL) && pd; pd = pd->next) {
+       for (pd = port->devices; !port->cad && pd; pd = pd->next) {
                if (pd->wakeup && pd != dev)
                        pd->wakeup(pd->private);
        }
 }
+EXPORT_SYMBOL(parport_release);
 
 irqreturn_t parport_irq_handler(int irq, void *dev_id)
 {
@@ -1339,22 +1360,6 @@ irqreturn_t parport_irq_handler(int irq, void *dev_id)
 
        return IRQ_HANDLED;
 }
-
-/* Exported symbols for modules. */
-
-EXPORT_SYMBOL(parport_claim);
-EXPORT_SYMBOL(parport_claim_or_block);
-EXPORT_SYMBOL(parport_release);
-EXPORT_SYMBOL(parport_register_port);
-EXPORT_SYMBOL(parport_announce_port);
-EXPORT_SYMBOL(parport_remove_port);
-EXPORT_SYMBOL(parport_unregister_driver);
-EXPORT_SYMBOL(parport_register_device);
-EXPORT_SYMBOL(parport_unregister_device);
-EXPORT_SYMBOL(parport_get_port);
-EXPORT_SYMBOL(parport_put_port);
-EXPORT_SYMBOL(parport_find_number);
-EXPORT_SYMBOL(parport_find_base);
 EXPORT_SYMBOL(parport_irq_handler);
 
 MODULE_LICENSE("GPL");
This page took 0.034683 seconds and 5 git commands to generate.