diff options
author | Matthias Kaehlcke <matthias.kaehlcke@gmail.com> | 2007-05-08 03:32:00 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-05-08 14:15:15 -0400 |
commit | 69f545ea6aa9cf0a1b2e31b287e17f4cd9eb6d93 (patch) | |
tree | 14ffae34a61890a9cb652e316a3735074515049b | |
parent | 6bdb6b620e335d38ced8d5981e8f44778225c1d8 (diff) |
use mutex instead of semaphore in RocketPort driver
The RocketPort driver uses a semaphore as mutex. Use the mutex API instead of
the (binary) semaphore.
Signed-off-by: Matthias Kaehlcke <matthias.kaehlcke@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | drivers/char/rocket.c | 19 | ||||
-rw-r--r-- | drivers/char/rocket_int.h | 4 |
2 files changed, 14 insertions, 9 deletions
diff --git a/drivers/char/rocket.c b/drivers/char/rocket.c index e249d8cfcd06..61a63da420c2 100644 --- a/drivers/char/rocket.c +++ b/drivers/char/rocket.c | |||
@@ -81,6 +81,7 @@ | |||
81 | #include <linux/string.h> | 81 | #include <linux/string.h> |
82 | #include <linux/fcntl.h> | 82 | #include <linux/fcntl.h> |
83 | #include <linux/ptrace.h> | 83 | #include <linux/ptrace.h> |
84 | #include <linux/mutex.h> | ||
84 | #include <linux/ioport.h> | 85 | #include <linux/ioport.h> |
85 | #include <linux/delay.h> | 86 | #include <linux/delay.h> |
86 | #include <linux/wait.h> | 87 | #include <linux/wait.h> |
@@ -89,7 +90,6 @@ | |||
89 | #include <asm/atomic.h> | 90 | #include <asm/atomic.h> |
90 | #include <linux/bitops.h> | 91 | #include <linux/bitops.h> |
91 | #include <linux/spinlock.h> | 92 | #include <linux/spinlock.h> |
92 | #include <asm/semaphore.h> | ||
93 | #include <linux/init.h> | 93 | #include <linux/init.h> |
94 | 94 | ||
95 | /****** RocketPort includes ******/ | 95 | /****** RocketPort includes ******/ |
@@ -698,7 +698,7 @@ static void init_r_port(int board, int aiop, int chan, struct pci_dev *pci_dev) | |||
698 | } | 698 | } |
699 | } | 699 | } |
700 | spin_lock_init(&info->slock); | 700 | spin_lock_init(&info->slock); |
701 | sema_init(&info->write_sem, 1); | 701 | mutex_init(&info->write_mtx); |
702 | rp_table[line] = info; | 702 | rp_table[line] = info; |
703 | if (pci_dev) | 703 | if (pci_dev) |
704 | tty_register_device(rocket_driver, line, &pci_dev->dev); | 704 | tty_register_device(rocket_driver, line, &pci_dev->dev); |
@@ -1657,8 +1657,11 @@ static void rp_put_char(struct tty_struct *tty, unsigned char ch) | |||
1657 | if (rocket_paranoia_check(info, "rp_put_char")) | 1657 | if (rocket_paranoia_check(info, "rp_put_char")) |
1658 | return; | 1658 | return; |
1659 | 1659 | ||
1660 | /* Grab the port write semaphore, locking out other processes that try to write to this port */ | 1660 | /* |
1661 | down(&info->write_sem); | 1661 | * Grab the port write mutex, locking out other processes that try to |
1662 | * write to this port | ||
1663 | */ | ||
1664 | mutex_lock(&info->write_mtx); | ||
1662 | 1665 | ||
1663 | #ifdef ROCKET_DEBUG_WRITE | 1666 | #ifdef ROCKET_DEBUG_WRITE |
1664 | printk(KERN_INFO "rp_put_char %c...", ch); | 1667 | printk(KERN_INFO "rp_put_char %c...", ch); |
@@ -1680,12 +1683,12 @@ static void rp_put_char(struct tty_struct *tty, unsigned char ch) | |||
1680 | info->xmit_fifo_room--; | 1683 | info->xmit_fifo_room--; |
1681 | } | 1684 | } |
1682 | spin_unlock_irqrestore(&info->slock, flags); | 1685 | spin_unlock_irqrestore(&info->slock, flags); |
1683 | up(&info->write_sem); | 1686 | mutex_unlock(&info->write_mtx); |
1684 | } | 1687 | } |
1685 | 1688 | ||
1686 | /* | 1689 | /* |
1687 | * Exception handler - write routine, called when user app writes to the device. | 1690 | * Exception handler - write routine, called when user app writes to the device. |
1688 | * A per port write semaphore is used to protect from another process writing to | 1691 | * A per port write mutex is used to protect from another process writing to |
1689 | * this port at the same time. This other process could be running on the other CPU | 1692 | * this port at the same time. This other process could be running on the other CPU |
1690 | * or get control of the CPU if the copy_from_user() blocks due to a page fault (swapped out). | 1693 | * or get control of the CPU if the copy_from_user() blocks due to a page fault (swapped out). |
1691 | * Spinlocks protect the info xmit members. | 1694 | * Spinlocks protect the info xmit members. |
@@ -1702,7 +1705,7 @@ static int rp_write(struct tty_struct *tty, | |||
1702 | if (count <= 0 || rocket_paranoia_check(info, "rp_write")) | 1705 | if (count <= 0 || rocket_paranoia_check(info, "rp_write")) |
1703 | return 0; | 1706 | return 0; |
1704 | 1707 | ||
1705 | down_interruptible(&info->write_sem); | 1708 | mutex_lock_interruptible(&info->write_mtx); |
1706 | 1709 | ||
1707 | #ifdef ROCKET_DEBUG_WRITE | 1710 | #ifdef ROCKET_DEBUG_WRITE |
1708 | printk(KERN_INFO "rp_write %d chars...", count); | 1711 | printk(KERN_INFO "rp_write %d chars...", count); |
@@ -1773,7 +1776,7 @@ end: | |||
1773 | wake_up_interruptible(&tty->poll_wait); | 1776 | wake_up_interruptible(&tty->poll_wait); |
1774 | #endif | 1777 | #endif |
1775 | } | 1778 | } |
1776 | up(&info->write_sem); | 1779 | mutex_unlock(&info->write_mtx); |
1777 | return retval; | 1780 | return retval; |
1778 | } | 1781 | } |
1779 | 1782 | ||
diff --git a/drivers/char/rocket_int.h b/drivers/char/rocket_int.h index 3a8bcc85bc14..89b4d7b10d12 100644 --- a/drivers/char/rocket_int.h +++ b/drivers/char/rocket_int.h | |||
@@ -15,6 +15,8 @@ | |||
15 | #define ROCKET_TYPE_MODEMIII 3 | 15 | #define ROCKET_TYPE_MODEMIII 3 |
16 | #define ROCKET_TYPE_PC104 4 | 16 | #define ROCKET_TYPE_PC104 4 |
17 | 17 | ||
18 | #include <linux/mutex.h> | ||
19 | |||
18 | #include <asm/io.h> | 20 | #include <asm/io.h> |
19 | #include <asm/byteorder.h> | 21 | #include <asm/byteorder.h> |
20 | 22 | ||
@@ -1171,7 +1173,7 @@ struct r_port { | |||
1171 | struct wait_queue *close_wait; | 1173 | struct wait_queue *close_wait; |
1172 | #endif | 1174 | #endif |
1173 | spinlock_t slock; | 1175 | spinlock_t slock; |
1174 | struct semaphore write_sem; | 1176 | struct mutex write_mtx; |
1175 | }; | 1177 | }; |
1176 | 1178 | ||
1177 | #define RPORT_MAGIC 0x525001 | 1179 | #define RPORT_MAGIC 0x525001 |