Fedora kernel-2.6.17-1.2142_FC4 patched with stable patch-2.6.17.4-vs2.0.2-rc26.diff
[linux-2.6.git] / drivers / parport / share.c
index 94cb193..bbbfd79 100644 (file)
@@ -32,6 +32,7 @@
 #include <linux/kmod.h>
 
 #include <linux/spinlock.h>
+#include <linux/mutex.h>
 #include <asm/irq.h>
 
 #undef PARPORT_PARANOID
@@ -42,15 +43,15 @@ unsigned long parport_default_timeslice = PARPORT_DEFAULT_TIMESLICE;
 int parport_default_spintime =  DEFAULT_SPIN_TIME;
 
 static LIST_HEAD(portlist);
-static spinlock_t parportlist_lock = SPIN_LOCK_UNLOCKED;
+static DEFINE_SPINLOCK(parportlist_lock);
 
 /* list of all allocated ports, sorted by ->number */
 static LIST_HEAD(all_ports);
-static spinlock_t full_list_lock = SPIN_LOCK_UNLOCKED;
+static DEFINE_SPINLOCK(full_list_lock);
 
 static LIST_HEAD(drivers);
 
-static DECLARE_MUTEX(registration_lock);
+static DEFINE_MUTEX(registration_lock);
 
 /* What you can do to a port that's gone away.. */
 static void dead_write_lines (struct parport *p, unsigned char b){}
@@ -158,18 +159,18 @@ int parport_register_driver (struct parport_driver *drv)
        if (list_empty(&portlist))
                get_lowlevel_driver ();
 
-       down(&registration_lock);
+       mutex_lock(&registration_lock);
        list_for_each_entry(port, &portlist, list)
                drv->attach(port);
        list_add(&drv->list, &drivers);
-       up(&registration_lock);
+       mutex_unlock(&registration_lock);
 
        return 0;
 }
 
 /**
  *     parport_unregister_driver - deregister a parallel port device driver
- *     @arg: structure describing the driver that was given to
+ *     @drv: structure describing the driver that was given to
  *           parport_register_driver()
  *
  *     This should be called by a parallel port device driver that
@@ -188,11 +189,11 @@ void parport_unregister_driver (struct parport_driver *drv)
 {
        struct parport *port;
 
-       down(&registration_lock);
+       mutex_lock(&registration_lock);
        list_del_init(&drv->list);
        list_for_each_entry(port, &portlist, list)
                drv->detach(port);
-       up(&registration_lock);
+       mutex_unlock(&registration_lock);
 }
 
 static void free_port (struct parport *port)
@@ -202,16 +203,11 @@ static void free_port (struct parport *port)
        list_del(&port->full_list);
        spin_unlock(&full_list_lock);
        for (d = 0; d < 5; d++) {
-               if (port->probe_info[d].class_name)
-                       kfree (port->probe_info[d].class_name);
-               if (port->probe_info[d].mfr)
-                       kfree (port->probe_info[d].mfr);
-               if (port->probe_info[d].model)
-                       kfree (port->probe_info[d].model);
-               if (port->probe_info[d].cmdset)
-                       kfree (port->probe_info[d].cmdset);
-               if (port->probe_info[d].description)
-                       kfree (port->probe_info[d].description);
+               kfree(port->probe_info[d].class_name);
+               kfree(port->probe_info[d].mfr);
+               kfree(port->probe_info[d].model);
+               kfree(port->probe_info[d].cmdset);
+               kfree(port->probe_info[d].description);
        }
 
        kfree(port->name);
@@ -306,7 +302,7 @@ struct parport *parport_register_port(unsigned long base, int irq, int dma,
        tmp->ops = ops;
        tmp->physport = tmp;
        memset (tmp->probe_info, 0, 5 * sizeof (struct parport_device_info));
-       tmp->cad_lock = RW_LOCK_UNLOCKED;
+       rwlock_init(&tmp->cad_lock);
        spin_lock_init(&tmp->waitlist_lock);
        spin_lock_init(&tmp->pardevice_lock);
        tmp->ieee1284.mode = IEEE1284_MODE_COMPAT;
@@ -371,7 +367,7 @@ void parport_announce_port (struct parport *port)
 #endif
 
        parport_proc_register(port);
-       down(&registration_lock);
+       mutex_lock(&registration_lock);
        spin_lock_irq(&parportlist_lock);
        list_add_tail(&port->list, &portlist);
        for (i = 1; i < 3; i++) {
@@ -388,7 +384,7 @@ void parport_announce_port (struct parport *port)
                if (slave)
                        attach_driver_chain(slave);
        }
-       up(&registration_lock);
+       mutex_unlock(&registration_lock);
 }
 
 /**
@@ -414,7 +410,7 @@ void parport_remove_port(struct parport *port)
 {
        int i;
 
-       down(&registration_lock);
+       mutex_lock(&registration_lock);
 
        /* Spread the word. */
        detach_driver_chain (port);
@@ -441,7 +437,7 @@ void parport_remove_port(struct parport *port)
        }
        spin_unlock(&parportlist_lock);
 
-       up(&registration_lock);
+       mutex_unlock(&registration_lock);
 
        parport_proc_unregister(port);
 
@@ -618,9 +614,9 @@ parport_register_device(struct parport *port, const char *name,
        return tmp;
 
  out_free_all:
-       kfree (tmp->state);
+       kfree(tmp->state);
  out_free_pardevice:
-       kfree (tmp);
+       kfree(tmp);
  out:
        parport_put_port (port);
        module_put(port->ops->owner);