aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/misc
diff options
context:
space:
mode:
authormatthias@kaehlcke.net <matthias@kaehlcke.net>2008-02-18 14:45:36 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2008-04-25 00:16:38 -0400
commitfadec78bd93ede132c34ab94dce0e65a5ae56054 (patch)
tree797130934738cc90786f5e67039e11ddb6f92b8e /drivers/usb/misc
parent8a0f46b92fcab6652b8e62c006d015d562302d08 (diff)
USB: auerswald: Convert ccp->mutex in a mutex
The semaphore ccp->mutex is used as mutex, convert it to the mutex API Signed-off-by: Matthias Kaehlcke <matthias@kaehlcke.net> Cc: Wolfgang Mües <wolfgang@iksw-muees.de> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/misc')
-rw-r--r--drivers/usb/misc/auerswald.c52
1 files changed, 26 insertions, 26 deletions
diff --git a/drivers/usb/misc/auerswald.c b/drivers/usb/misc/auerswald.c
index 46dfbac0f6f0..81d051ca2291 100644
--- a/drivers/usb/misc/auerswald.c
+++ b/drivers/usb/misc/auerswald.c
@@ -254,7 +254,7 @@ typedef struct
254/* character device context */ 254/* character device context */
255typedef struct 255typedef struct
256{ 256{
257 struct semaphore mutex; /* protection in user context */ 257 struct mutex mutex; /* protection in user context */
258 pauerswald_t auerdev; /* context pointer of assigned device */ 258 pauerswald_t auerdev; /* context pointer of assigned device */
259 auerbufctl_t bufctl; /* controls the buffer chain */ 259 auerbufctl_t bufctl; /* controls the buffer chain */
260 auerscon_t scontext; /* service context */ 260 auerscon_t scontext; /* service context */
@@ -1390,7 +1390,7 @@ static int auerchar_open (struct inode *inode, struct file *file)
1390 } 1390 }
1391 1391
1392 /* Initialize device descriptor */ 1392 /* Initialize device descriptor */
1393 init_MUTEX( &ccp->mutex); 1393 mutex_init(&ccp->mutex);
1394 mutex_init(&ccp->readmutex); 1394 mutex_init(&ccp->readmutex);
1395 auerbuf_init (&ccp->bufctl); 1395 auerbuf_init (&ccp->bufctl);
1396 ccp->scontext.id = AUH_UNASSIGNED; 1396 ccp->scontext.id = AUH_UNASSIGNED;
@@ -1433,23 +1433,23 @@ static int auerchar_ioctl (struct inode *inode, struct file *file, unsigned int
1433 dbg ("ioctl"); 1433 dbg ("ioctl");
1434 1434
1435 /* get the mutexes */ 1435 /* get the mutexes */
1436 if (down_interruptible (&ccp->mutex)) { 1436 if (mutex_lock_interruptible(&ccp->mutex)) {
1437 return -ERESTARTSYS; 1437 return -ERESTARTSYS;
1438 } 1438 }
1439 cp = ccp->auerdev; 1439 cp = ccp->auerdev;
1440 if (!cp) { 1440 if (!cp) {
1441 up (&ccp->mutex); 1441 mutex_unlock(&ccp->mutex);
1442 return -ENODEV; 1442 return -ENODEV;
1443 } 1443 }
1444 if (mutex_lock_interruptible(&cp->mutex)) { 1444 if (mutex_lock_interruptible(&cp->mutex)) {
1445 up(&ccp->mutex); 1445 mutex_unlock(&ccp->mutex);
1446 return -ERESTARTSYS; 1446 return -ERESTARTSYS;
1447 } 1447 }
1448 1448
1449 /* Check for removal */ 1449 /* Check for removal */
1450 if (!cp->usbdev) { 1450 if (!cp->usbdev) {
1451 mutex_unlock(&cp->mutex); 1451 mutex_unlock(&cp->mutex);
1452 up(&ccp->mutex); 1452 mutex_unlock(&ccp->mutex);
1453 return -ENODEV; 1453 return -ENODEV;
1454 } 1454 }
1455 1455
@@ -1552,7 +1552,7 @@ static int auerchar_ioctl (struct inode *inode, struct file *file, unsigned int
1552 } 1552 }
1553 /* release the mutexes */ 1553 /* release the mutexes */
1554 mutex_unlock(&cp->mutex); 1554 mutex_unlock(&cp->mutex);
1555 up(&ccp->mutex); 1555 mutex_unlock(&ccp->mutex);
1556 return ret; 1556 return ret;
1557} 1557}
1558 1558
@@ -1575,18 +1575,18 @@ static ssize_t auerchar_read (struct file *file, char __user *buf, size_t count,
1575 return 0; 1575 return 0;
1576 1576
1577 /* get the mutex */ 1577 /* get the mutex */
1578 if (down_interruptible (&ccp->mutex)) 1578 if (mutex_lock_interruptible(&ccp->mutex))
1579 return -ERESTARTSYS; 1579 return -ERESTARTSYS;
1580 1580
1581 /* Can we expect to read something? */ 1581 /* Can we expect to read something? */
1582 if (ccp->scontext.id == AUH_UNASSIGNED) { 1582 if (ccp->scontext.id == AUH_UNASSIGNED) {
1583 up (&ccp->mutex); 1583 mutex_unlock(&ccp->mutex);
1584 return -EIO; 1584 return -EIO;
1585 } 1585 }
1586 1586
1587 /* only one reader per device allowed */ 1587 /* only one reader per device allowed */
1588 if (mutex_lock_interruptible(&ccp->readmutex)) { 1588 if (mutex_lock_interruptible(&ccp->readmutex)) {
1589 up (&ccp->mutex); 1589 mutex_unlock(&ccp->mutex);
1590 return -ERESTARTSYS; 1590 return -ERESTARTSYS;
1591 } 1591 }
1592 1592
@@ -1604,7 +1604,7 @@ doreadbuf:
1604 if (copy_to_user (buf, bp->bufp+ccp->readoffset, count)) { 1604 if (copy_to_user (buf, bp->bufp+ccp->readoffset, count)) {
1605 dbg ("auerswald_read: copy_to_user failed"); 1605 dbg ("auerswald_read: copy_to_user failed");
1606 mutex_unlock(&ccp->readmutex); 1606 mutex_unlock(&ccp->readmutex);
1607 up (&ccp->mutex); 1607 mutex_unlock(&ccp->mutex);
1608 return -EFAULT; 1608 return -EFAULT;
1609 } 1609 }
1610 } 1610 }
@@ -1619,7 +1619,7 @@ doreadbuf:
1619 /* return with number of bytes read */ 1619 /* return with number of bytes read */
1620 if (count) { 1620 if (count) {
1621 mutex_unlock(&ccp->readmutex); 1621 mutex_unlock(&ccp->readmutex);
1622 up (&ccp->mutex); 1622 mutex_unlock(&ccp->mutex);
1623 return count; 1623 return count;
1624 } 1624 }
1625 } 1625 }
@@ -1656,12 +1656,12 @@ doreadlist:
1656 set_current_state (TASK_RUNNING); 1656 set_current_state (TASK_RUNNING);
1657 remove_wait_queue (&ccp->readwait, &wait); 1657 remove_wait_queue (&ccp->readwait, &wait);
1658 mutex_unlock(&ccp->readmutex); 1658 mutex_unlock(&ccp->readmutex);
1659 up (&ccp->mutex); 1659 mutex_unlock(&ccp->mutex);
1660 return -EAGAIN; /* nonblocking, no data available */ 1660 return -EAGAIN; /* nonblocking, no data available */
1661 } 1661 }
1662 1662
1663 /* yes, we should wait! */ 1663 /* yes, we should wait! */
1664 up (&ccp->mutex); /* allow other operations while we wait */ 1664 mutex_unlock(&ccp->mutex); /* allow other operations while we wait */
1665 schedule(); 1665 schedule();
1666 remove_wait_queue (&ccp->readwait, &wait); 1666 remove_wait_queue (&ccp->readwait, &wait);
1667 if (signal_pending (current)) { 1667 if (signal_pending (current)) {
@@ -1676,7 +1676,7 @@ doreadlist:
1676 return -EIO; 1676 return -EIO;
1677 } 1677 }
1678 1678
1679 if (down_interruptible (&ccp->mutex)) { 1679 if (mutex_lock_interruptible(&ccp->mutex)) {
1680 mutex_unlock(&ccp->readmutex); 1680 mutex_unlock(&ccp->readmutex);
1681 return -ERESTARTSYS; 1681 return -ERESTARTSYS;
1682 } 1682 }
@@ -1708,27 +1708,27 @@ static ssize_t auerchar_write (struct file *file, const char __user *buf, size_t
1708 1708
1709write_again: 1709write_again:
1710 /* get the mutex */ 1710 /* get the mutex */
1711 if (down_interruptible (&ccp->mutex)) 1711 if (mutex_lock_interruptible(&ccp->mutex))
1712 return -ERESTARTSYS; 1712 return -ERESTARTSYS;
1713 1713
1714 /* Can we expect to write something? */ 1714 /* Can we expect to write something? */
1715 if (ccp->scontext.id == AUH_UNASSIGNED) { 1715 if (ccp->scontext.id == AUH_UNASSIGNED) {
1716 up (&ccp->mutex); 1716 mutex_unlock(&ccp->mutex);
1717 return -EIO; 1717 return -EIO;
1718 } 1718 }
1719 1719
1720 cp = ccp->auerdev; 1720 cp = ccp->auerdev;
1721 if (!cp) { 1721 if (!cp) {
1722 up (&ccp->mutex); 1722 mutex_unlock(&ccp->mutex);
1723 return -ERESTARTSYS; 1723 return -ERESTARTSYS;
1724 } 1724 }
1725 if (mutex_lock_interruptible(&cp->mutex)) { 1725 if (mutex_lock_interruptible(&cp->mutex)) {
1726 up (&ccp->mutex); 1726 mutex_unlock(&ccp->mutex);
1727 return -ERESTARTSYS; 1727 return -ERESTARTSYS;
1728 } 1728 }
1729 if (!cp->usbdev) { 1729 if (!cp->usbdev) {
1730 mutex_unlock(&cp->mutex); 1730 mutex_unlock(&cp->mutex);
1731 up (&ccp->mutex); 1731 mutex_unlock(&ccp->mutex);
1732 return -EIO; 1732 return -EIO;
1733 } 1733 }
1734 /* Prepare for sleep */ 1734 /* Prepare for sleep */
@@ -1752,7 +1752,7 @@ write_again:
1752 /* are there any buffers left? */ 1752 /* are there any buffers left? */
1753 if (!bp) { 1753 if (!bp) {
1754 mutex_unlock(&cp->mutex); 1754 mutex_unlock(&cp->mutex);
1755 up (&ccp->mutex); 1755 mutex_unlock(&ccp->mutex);
1756 1756
1757 /* NONBLOCK: don't wait */ 1757 /* NONBLOCK: don't wait */
1758 if (file->f_flags & O_NONBLOCK) { 1758 if (file->f_flags & O_NONBLOCK) {
@@ -1785,7 +1785,7 @@ write_again:
1785 /* Wake up all processes waiting for a buffer */ 1785 /* Wake up all processes waiting for a buffer */
1786 wake_up (&cp->bufferwait); 1786 wake_up (&cp->bufferwait);
1787 mutex_unlock(&cp->mutex); 1787 mutex_unlock(&cp->mutex);
1788 up (&ccp->mutex); 1788 mutex_unlock(&ccp->mutex);
1789 return -EFAULT; 1789 return -EFAULT;
1790 } 1790 }
1791 1791
@@ -1810,12 +1810,12 @@ write_again:
1810 auerbuf_releasebuf (bp); 1810 auerbuf_releasebuf (bp);
1811 /* Wake up all processes waiting for a buffer */ 1811 /* Wake up all processes waiting for a buffer */
1812 wake_up (&cp->bufferwait); 1812 wake_up (&cp->bufferwait);
1813 up (&ccp->mutex); 1813 mutex_unlock(&ccp->mutex);
1814 return -EIO; 1814 return -EIO;
1815 } 1815 }
1816 else { 1816 else {
1817 dbg ("auerchar_write: Write OK"); 1817 dbg ("auerchar_write: Write OK");
1818 up (&ccp->mutex); 1818 mutex_unlock(&ccp->mutex);
1819 return len; 1819 return len;
1820 } 1820 }
1821} 1821}
@@ -1828,7 +1828,7 @@ static int auerchar_release (struct inode *inode, struct file *file)
1828 pauerswald_t cp; 1828 pauerswald_t cp;
1829 dbg("release"); 1829 dbg("release");
1830 1830
1831 down(&ccp->mutex); 1831 mutex_lock(&ccp->mutex);
1832 cp = ccp->auerdev; 1832 cp = ccp->auerdev;
1833 if (cp) { 1833 if (cp) {
1834 mutex_lock(&cp->mutex); 1834 mutex_lock(&cp->mutex);
@@ -1845,7 +1845,7 @@ static int auerchar_release (struct inode *inode, struct file *file)
1845 cp = NULL; 1845 cp = NULL;
1846 ccp->auerdev = NULL; 1846 ccp->auerdev = NULL;
1847 } 1847 }
1848 up (&ccp->mutex); 1848 mutex_unlock(&ccp->mutex);
1849 auerchar_delete (ccp); 1849 auerchar_delete (ccp);
1850 1850
1851 return 0; 1851 return 0;