Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jbarnes...
[cascardo/linux.git] / drivers / usb / misc / auerswald.c
index 46dfbac..0939386 100644 (file)
@@ -254,7 +254,7 @@ typedef struct
 /* character device context */
 typedef struct
 {
-       struct semaphore mutex;         /* protection in user context */
+       struct mutex mutex;             /* protection in user context */
        pauerswald_t auerdev;           /* context pointer of assigned device */
         auerbufctl_t bufctl;            /* controls the buffer chain */
         auerscon_t scontext;            /* service context */
@@ -284,7 +284,7 @@ static void auerchain_complete (struct urb * urb)
         int result;
 
         /* get pointer to element and to chain */
-        pauerchainelement_t acep = (pauerchainelement_t) urb->context;
+       pauerchainelement_t acep = urb->context;
         pauerchain_t         acp = acep->chain;
 
         /* restore original entries in urb */
@@ -594,7 +594,7 @@ ac_fail:/* free the elements */
 /* completion handler for synchronous chained URBs */
 static void auerchain_blocking_completion (struct urb *urb)
 {
-       pauerchain_chs_t pchs = (pauerchain_chs_t)urb->context;
+       pauerchain_chs_t pchs = urb->context;
        pchs->done = 1;
        wmb();
        wake_up (&pchs->wqh);
@@ -847,7 +847,7 @@ static int auerswald_status_retry (int status)
 /* Completion of asynchronous write block */
 static void auerchar_ctrlwrite_complete (struct urb * urb)
 {
-       pauerbuf_t bp = (pauerbuf_t) urb->context;
+       pauerbuf_t bp =  urb->context;
        pauerswald_t cp = ((pauerswald_t)((char *)(bp->list)-(unsigned long)(&((pauerswald_t)0)->bufctl)));
        dbg ("auerchar_ctrlwrite_complete called");
 
@@ -860,7 +860,7 @@ static void auerchar_ctrlwrite_complete (struct urb * urb)
 /* Completion handler for dummy retry packet */
 static void auerswald_ctrlread_wretcomplete (struct urb * urb)
 {
-        pauerbuf_t bp = (pauerbuf_t) urb->context;
+       pauerbuf_t bp = urb->context;
         pauerswald_t cp;
        int ret;
        int status = urb->status;
@@ -904,7 +904,7 @@ static void auerswald_ctrlread_complete (struct urb * urb)
         unsigned int  serviceid;
         pauerswald_t  cp;
         pauerscon_t   scp;
-        pauerbuf_t    bp  = (pauerbuf_t) urb->context;
+       pauerbuf_t bp = urb->context;
        int status = urb->status;
        int ret;
 
@@ -981,9 +981,9 @@ static void auerswald_int_complete (struct urb * urb)
         int ret;
        int status = urb->status;
         pauerbuf_t   bp = NULL;
-        pauerswald_t cp = (pauerswald_t) urb->context;
+       pauerswald_t cp = urb->context;
 
-        dbg ("%s called", __FUNCTION__);
+        dbg ("%s called", __func__);
 
        switch (status) {
        case 0:
@@ -993,10 +993,10 @@ static void auerswald_int_complete (struct urb * urb)
        case -ENOENT:
        case -ESHUTDOWN:
                /* this urb is terminated, clean up */
-               dbg("%s - urb shutting down with status: %d", __FUNCTION__, status);
+               dbg("%s - urb shutting down with status: %d", __func__, status);
                return;
        default:
-               dbg("%s - nonzero urb status received: %d", __FUNCTION__, status);
+               dbg("%s - nonzero urb status received: %d", __func__, status);
                goto exit;
        }
 
@@ -1081,7 +1081,7 @@ exit:
        ret = usb_submit_urb (urb, GFP_ATOMIC);
        if (ret)
                err ("%s - usb_submit_urb failed with result %d",
-                    __FUNCTION__, ret);
+                    __func__, ret);
 }
 
 /* int memory deallocation
@@ -1390,7 +1390,7 @@ static int auerchar_open (struct inode *inode, struct file *file)
        }
 
        /* Initialize device descriptor */
-       init_MUTEX( &ccp->mutex);
+       mutex_init(&ccp->mutex);
        mutex_init(&ccp->readmutex);
         auerbuf_init (&ccp->bufctl);
         ccp->scontext.id = AUH_UNASSIGNED;
@@ -1433,23 +1433,23 @@ static int auerchar_ioctl (struct inode *inode, struct file *file, unsigned int
         dbg ("ioctl");
 
        /* get the mutexes */
-       if (down_interruptible (&ccp->mutex)) {
+       if (mutex_lock_interruptible(&ccp->mutex)) {
                return -ERESTARTSYS;
        }
        cp = ccp->auerdev;
        if (!cp) {
-               up (&ccp->mutex);
+               mutex_unlock(&ccp->mutex);
                 return -ENODEV;
        }
        if (mutex_lock_interruptible(&cp->mutex)) {
-               up(&ccp->mutex);
+               mutex_unlock(&ccp->mutex);
                return -ERESTARTSYS;
        }
 
        /* Check for removal */
        if (!cp->usbdev) {
                mutex_unlock(&cp->mutex);
-               up(&ccp->mutex);
+               mutex_unlock(&ccp->mutex);
                 return -ENODEV;
        }
 
@@ -1552,7 +1552,7 @@ static int auerchar_ioctl (struct inode *inode, struct file *file, unsigned int
         }
        /* release the mutexes */
        mutex_unlock(&cp->mutex);
-       up(&ccp->mutex);
+       mutex_unlock(&ccp->mutex);
        return ret;
 }
 
@@ -1575,18 +1575,18 @@ static ssize_t auerchar_read (struct file *file, char __user *buf, size_t count,
                return 0;
 
        /* get the mutex */
-       if (down_interruptible (&ccp->mutex))
+       if (mutex_lock_interruptible(&ccp->mutex))
                return -ERESTARTSYS;
 
        /* Can we expect to read something? */
        if (ccp->scontext.id == AUH_UNASSIGNED) {
-               up (&ccp->mutex);
+               mutex_unlock(&ccp->mutex);
                 return -EIO;
        }
 
        /* only one reader per device allowed */
        if (mutex_lock_interruptible(&ccp->readmutex)) {
-               up (&ccp->mutex);
+               mutex_unlock(&ccp->mutex);
                return -ERESTARTSYS;
        }
 
@@ -1604,7 +1604,7 @@ doreadbuf:
                        if (copy_to_user (buf, bp->bufp+ccp->readoffset, count)) {
                                dbg ("auerswald_read: copy_to_user failed");
                                mutex_unlock(&ccp->readmutex);
-                               up (&ccp->mutex);
+                               mutex_unlock(&ccp->mutex);
                                return -EFAULT;
                        }
                }
@@ -1619,7 +1619,7 @@ doreadbuf:
                /* return with number of bytes read */
                if (count) {
                        mutex_unlock(&ccp->readmutex);
-                       up (&ccp->mutex);
+                       mutex_unlock(&ccp->mutex);
                        return count;
                }
        }
@@ -1656,12 +1656,12 @@ doreadlist:
                set_current_state (TASK_RUNNING);
                remove_wait_queue (&ccp->readwait, &wait);
                mutex_unlock(&ccp->readmutex);
-               up (&ccp->mutex);
+               mutex_unlock(&ccp->mutex);
                return -EAGAIN;  /* nonblocking, no data available */
         }
 
        /* yes, we should wait! */
-       up (&ccp->mutex); /* allow other operations while we wait */
+       mutex_unlock(&ccp->mutex); /* allow other operations while we wait */
        schedule();
        remove_wait_queue (&ccp->readwait, &wait);
        if (signal_pending (current)) {
@@ -1676,7 +1676,7 @@ doreadlist:
                return -EIO;
        }
 
-       if (down_interruptible (&ccp->mutex)) {
+       if (mutex_lock_interruptible(&ccp->mutex)) {
                mutex_unlock(&ccp->readmutex);
                return -ERESTARTSYS;
        }
@@ -1708,27 +1708,27 @@ static ssize_t auerchar_write (struct file *file, const char __user *buf, size_t
 
 write_again:
        /* get the mutex */
-       if (down_interruptible (&ccp->mutex))
+       if (mutex_lock_interruptible(&ccp->mutex))
                return -ERESTARTSYS;
 
        /* Can we expect to write something? */
        if (ccp->scontext.id == AUH_UNASSIGNED) {
-               up (&ccp->mutex);
+               mutex_unlock(&ccp->mutex);
                 return -EIO;
        }
 
        cp = ccp->auerdev;
        if (!cp) {
-               up (&ccp->mutex);
+               mutex_unlock(&ccp->mutex);
                return -ERESTARTSYS;
        }
        if (mutex_lock_interruptible(&cp->mutex)) {
-               up (&ccp->mutex);
+               mutex_unlock(&ccp->mutex);
                return -ERESTARTSYS;
        }
        if (!cp->usbdev) {
                mutex_unlock(&cp->mutex);
-               up (&ccp->mutex);
+               mutex_unlock(&ccp->mutex);
                return -EIO;
        }
        /* Prepare for sleep */
@@ -1752,7 +1752,7 @@ write_again:
        /* are there any buffers left? */
        if (!bp) {
                mutex_unlock(&cp->mutex);
-               up (&ccp->mutex);
+               mutex_unlock(&ccp->mutex);
 
                /* NONBLOCK: don't wait */
                if (file->f_flags & O_NONBLOCK) {
@@ -1785,7 +1785,7 @@ write_again:
                /* Wake up all processes waiting for a buffer */
                wake_up (&cp->bufferwait);
                mutex_unlock(&cp->mutex);
-               up (&ccp->mutex);
+               mutex_unlock(&ccp->mutex);
                return -EFAULT;
        }
 
@@ -1810,12 +1810,12 @@ write_again:
                auerbuf_releasebuf (bp);
                /* Wake up all processes waiting for a buffer */
                wake_up (&cp->bufferwait);
-               up (&ccp->mutex);
+               mutex_unlock(&ccp->mutex);
                return -EIO;
        }
        else {
                dbg ("auerchar_write: Write OK");
-               up (&ccp->mutex);
+               mutex_unlock(&ccp->mutex);
                return len;
        }
 }
@@ -1828,7 +1828,7 @@ static int auerchar_release (struct inode *inode, struct file *file)
        pauerswald_t cp;
        dbg("release");
 
-       down(&ccp->mutex);
+       mutex_lock(&ccp->mutex);
        cp = ccp->auerdev;
        if (cp) {
                mutex_lock(&cp->mutex);
@@ -1845,7 +1845,7 @@ static int auerchar_release (struct inode *inode, struct file *file)
                cp = NULL;
                ccp->auerdev = NULL;
        }
-       up (&ccp->mutex);
+       mutex_unlock(&ccp->mutex);
        auerchar_delete (ccp);
 
        return 0;