aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/cyclades.c
diff options
context:
space:
mode:
authorJiri Slaby <jirislaby@gmail.com>2007-05-08 03:36:57 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-05-08 14:15:25 -0400
commit9fa1b3b185a802fa0b3f764ad468efd64e1b582e (patch)
treead69042a5fdd7f406f51b01548d559e210c2a4f1 /drivers/char/cyclades.c
parent6a0aa67b177a3d84f789f7f19c523d8c5e8bb5f8 (diff)
Char: cyclades, remove locking macros
and use locally stored card structure if possible Signed-off-by: Jiri Slaby <jirislaby@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/char/cyclades.c')
-rw-r--r--drivers/char/cyclades.c245
1 files changed, 118 insertions, 127 deletions
diff --git a/drivers/char/cyclades.c b/drivers/char/cyclades.c
index ab9ad66ceefa..6e5fca9c393a 100644
--- a/drivers/char/cyclades.c
+++ b/drivers/char/cyclades.c
@@ -653,16 +653,6 @@
653#include <asm/irq.h> 653#include <asm/irq.h>
654#include <asm/uaccess.h> 654#include <asm/uaccess.h>
655 655
656#define CY_LOCK(info,flags) \
657 do { \
658 spin_lock_irqsave(&info->card->card_lock, flags); \
659 } while (0)
660
661#define CY_UNLOCK(info,flags) \
662 do { \
663 spin_unlock_irqrestore(&info->card->card_lock, flags); \
664 } while (0)
665
666#include <linux/kernel.h> 656#include <linux/kernel.h>
667#include <linux/pci.h> 657#include <linux/pci.h>
668 658
@@ -1863,13 +1853,13 @@ static void cyz_rx_restart(unsigned long arg)
1863 __u32 channel = info->line - card->first_line; 1853 __u32 channel = info->line - card->first_line;
1864 unsigned long flags; 1854 unsigned long flags;
1865 1855
1866 CY_LOCK(info, flags); 1856 spin_lock_irqsave(&card->card_lock, flags);
1867 retval = cyz_issue_cmd(card, channel, C_CM_INTBACK2, 0L); 1857 retval = cyz_issue_cmd(card, channel, C_CM_INTBACK2, 0L);
1868 if (retval != 0) { 1858 if (retval != 0) {
1869 printk(KERN_ERR "cyc:cyz_rx_restart retval on ttyC%d was %x\n", 1859 printk(KERN_ERR "cyc:cyz_rx_restart retval on ttyC%d was %x\n",
1870 info->line, retval); 1860 info->line, retval);
1871 } 1861 }
1872 CY_UNLOCK(info, flags); 1862 spin_unlock_irqrestore(&card->card_lock, flags);
1873} 1863}
1874 1864
1875#else /* CONFIG_CYZ_INTR */ 1865#else /* CONFIG_CYZ_INTR */
@@ -1949,7 +1939,7 @@ static int startup(struct cyclades_port *info)
1949 if (!page) 1939 if (!page)
1950 return -ENOMEM; 1940 return -ENOMEM;
1951 1941
1952 CY_LOCK(info, flags); 1942 spin_lock_irqsave(&card->card_lock, flags);
1953 1943
1954 if (info->flags & ASYNC_INITIALIZED) { 1944 if (info->flags & ASYNC_INITIALIZED) {
1955 free_page(page); 1945 free_page(page);
@@ -1969,7 +1959,7 @@ static int startup(struct cyclades_port *info)
1969 else 1959 else
1970 info->xmit_buf = (unsigned char *)page; 1960 info->xmit_buf = (unsigned char *)page;
1971 1961
1972 CY_UNLOCK(info, flags); 1962 spin_unlock_irqrestore(&card->card_lock, flags);
1973 1963
1974 set_line_char(info); 1964 set_line_char(info);
1975 1965
@@ -1984,7 +1974,7 @@ static int startup(struct cyclades_port *info)
1984 "base_addr %p\n", 1974 "base_addr %p\n",
1985 card, chip, channel, base_addr); 1975 card, chip, channel, base_addr);
1986#endif 1976#endif
1987 CY_LOCK(info, flags); 1977 spin_lock_irqsave(&card->card_lock, flags);
1988 1978
1989 cy_writeb(base_addr + (CyCAR << index), (u_char) channel); 1979 cy_writeb(base_addr + (CyCAR << index), (u_char) channel);
1990 1980
@@ -2020,7 +2010,7 @@ static int startup(struct cyclades_port *info)
2020 info->idle_stats.recv_idle = 2010 info->idle_stats.recv_idle =
2021 info->idle_stats.xmit_idle = jiffies; 2011 info->idle_stats.xmit_idle = jiffies;
2022 2012
2023 CY_UNLOCK(info, flags); 2013 spin_unlock_irqrestore(&card->card_lock, flags);
2024 2014
2025 } else { 2015 } else {
2026 struct FIRM_ID __iomem *firm_id; 2016 struct FIRM_ID __iomem *firm_id;
@@ -2045,7 +2035,7 @@ static int startup(struct cyclades_port *info)
2045 printk(KERN_DEBUG "cyc startup Z card %d, channel %d, " 2035 printk(KERN_DEBUG "cyc startup Z card %d, channel %d, "
2046 "base_addr %p\n", card, channel, base_addr); 2036 "base_addr %p\n", card, channel, base_addr);
2047#endif 2037#endif
2048 CY_LOCK(info, flags); 2038 spin_lock_irqsave(&card->card_lock, flags);
2049 2039
2050 cy_writel(&ch_ctrl[channel].op_mode, C_CH_ENABLE); 2040 cy_writel(&ch_ctrl[channel].op_mode, C_CH_ENABLE);
2051#ifdef Z_WAKE 2041#ifdef Z_WAKE
@@ -2085,8 +2075,7 @@ static int startup(struct cyclades_port *info)
2085 cy_writel(&ch_ctrl[channel].rs_control, 2075 cy_writel(&ch_ctrl[channel].rs_control,
2086 readl(&ch_ctrl[channel].rs_control) | C_RS_RTS | 2076 readl(&ch_ctrl[channel].rs_control) | C_RS_RTS |
2087 C_RS_DTR); 2077 C_RS_DTR);
2088 retval = cyz_issue_cmd(info->card, channel, 2078 retval = cyz_issue_cmd(card, channel, C_CM_IOCTLM, 0L);
2089 C_CM_IOCTLM, 0L);
2090 if (retval != 0) { 2079 if (retval != 0) {
2091 printk(KERN_ERR "cyc:startup(3) retval on ttyC%d was " 2080 printk(KERN_ERR "cyc:startup(3) retval on ttyC%d was "
2092 "%x\n", info->line, retval); 2081 "%x\n", info->line, retval);
@@ -2108,7 +2097,7 @@ static int startup(struct cyclades_port *info)
2108 info->idle_stats.recv_idle = 2097 info->idle_stats.recv_idle =
2109 info->idle_stats.xmit_idle = jiffies; 2098 info->idle_stats.xmit_idle = jiffies;
2110 2099
2111 CY_UNLOCK(info, flags); 2100 spin_unlock_irqrestore(&card->card_lock, flags);
2112 } 2101 }
2113 2102
2114#ifdef CY_DEBUG_OPEN 2103#ifdef CY_DEBUG_OPEN
@@ -2117,7 +2106,7 @@ static int startup(struct cyclades_port *info)
2117 return 0; 2106 return 0;
2118 2107
2119errout: 2108errout:
2120 CY_UNLOCK(info, flags); 2109 spin_unlock_irqrestore(&card->card_lock, flags);
2121 return retval; 2110 return retval;
2122} /* startup */ 2111} /* startup */
2123 2112
@@ -2136,22 +2125,22 @@ static void start_xmit(struct cyclades_port *info)
2136 index = card->bus_index; 2125 index = card->bus_index;
2137 base_addr = card->base_addr + (cy_chip_offset[chip] << index); 2126 base_addr = card->base_addr + (cy_chip_offset[chip] << index);
2138 2127
2139 CY_LOCK(info, flags); 2128 spin_lock_irqsave(&card->card_lock, flags);
2140 cy_writeb(base_addr + (CyCAR << index), channel); 2129 cy_writeb(base_addr + (CyCAR << index), channel);
2141 cy_writeb(base_addr + (CySRER << index), 2130 cy_writeb(base_addr + (CySRER << index),
2142 readb(base_addr + (CySRER << index)) | CyTxRdy); 2131 readb(base_addr + (CySRER << index)) | CyTxRdy);
2143 CY_UNLOCK(info, flags); 2132 spin_unlock_irqrestore(&card->card_lock, flags);
2144 } else { 2133 } else {
2145#ifdef CONFIG_CYZ_INTR 2134#ifdef CONFIG_CYZ_INTR
2146 int retval; 2135 int retval;
2147 2136
2148 CY_LOCK(info, flags); 2137 spin_lock_irqsave(&card->card_lock, flags);
2149 retval = cyz_issue_cmd(card, channel, C_CM_INTBACK, 0L); 2138 retval = cyz_issue_cmd(card, channel, C_CM_INTBACK, 0L);
2150 if (retval != 0) { 2139 if (retval != 0) {
2151 printk(KERN_ERR "cyc:start_xmit retval on ttyC%d was " 2140 printk(KERN_ERR "cyc:start_xmit retval on ttyC%d was "
2152 "%x\n", info->line, retval); 2141 "%x\n", info->line, retval);
2153 } 2142 }
2154 CY_UNLOCK(info, flags); 2143 spin_unlock_irqrestore(&card->card_lock, flags);
2155#else /* CONFIG_CYZ_INTR */ 2144#else /* CONFIG_CYZ_INTR */
2156 /* Don't have to do anything at this time */ 2145 /* Don't have to do anything at this time */
2157#endif /* CONFIG_CYZ_INTR */ 2146#endif /* CONFIG_CYZ_INTR */
@@ -2187,7 +2176,7 @@ static void shutdown(struct cyclades_port *info)
2187 card, chip, channel, base_addr); 2176 card, chip, channel, base_addr);
2188#endif 2177#endif
2189 2178
2190 CY_LOCK(info, flags); 2179 spin_lock_irqsave(&card->card_lock, flags);
2191 2180
2192 /* Clear delta_msr_wait queue to avoid mem leaks. */ 2181 /* Clear delta_msr_wait queue to avoid mem leaks. */
2193 wake_up_interruptible(&info->delta_msr_wait); 2182 wake_up_interruptible(&info->delta_msr_wait);
@@ -2217,7 +2206,7 @@ static void shutdown(struct cyclades_port *info)
2217 set_bit(TTY_IO_ERROR, &info->tty->flags); 2206 set_bit(TTY_IO_ERROR, &info->tty->flags);
2218 } 2207 }
2219 info->flags &= ~ASYNC_INITIALIZED; 2208 info->flags &= ~ASYNC_INITIALIZED;
2220 CY_UNLOCK(info, flags); 2209 spin_unlock_irqrestore(&card->card_lock, flags);
2221 } else { 2210 } else {
2222 struct FIRM_ID __iomem *firm_id; 2211 struct FIRM_ID __iomem *firm_id;
2223 struct ZFW_CTRL __iomem *zfw_ctrl; 2212 struct ZFW_CTRL __iomem *zfw_ctrl;
@@ -2241,7 +2230,7 @@ static void shutdown(struct cyclades_port *info)
2241 board_ctrl = &zfw_ctrl->board_ctrl; 2230 board_ctrl = &zfw_ctrl->board_ctrl;
2242 ch_ctrl = zfw_ctrl->ch_ctrl; 2231 ch_ctrl = zfw_ctrl->ch_ctrl;
2243 2232
2244 CY_LOCK(info, flags); 2233 spin_lock_irqsave(&card->card_lock, flags);
2245 2234
2246 if (info->xmit_buf) { 2235 if (info->xmit_buf) {
2247 unsigned char *temp; 2236 unsigned char *temp;
@@ -2270,7 +2259,7 @@ static void shutdown(struct cyclades_port *info)
2270 } 2259 }
2271 info->flags &= ~ASYNC_INITIALIZED; 2260 info->flags &= ~ASYNC_INITIALIZED;
2272 2261
2273 CY_UNLOCK(info, flags); 2262 spin_unlock_irqrestore(&card->card_lock, flags);
2274 } 2263 }
2275 2264
2276#ifdef CY_DEBUG_OPEN 2265#ifdef CY_DEBUG_OPEN
@@ -2330,10 +2319,10 @@ block_til_ready(struct tty_struct *tty, struct file *filp,
2330 printk(KERN_DEBUG "cyc block_til_ready before block: ttyC%d, " 2319 printk(KERN_DEBUG "cyc block_til_ready before block: ttyC%d, "
2331 "count = %d\n", info->line, info->count); 2320 "count = %d\n", info->line, info->count);
2332#endif 2321#endif
2333 CY_LOCK(info, flags); 2322 spin_lock_irqsave(&cinfo->card_lock, flags);
2334 if (!tty_hung_up_p(filp)) 2323 if (!tty_hung_up_p(filp))
2335 info->count--; 2324 info->count--;
2336 CY_UNLOCK(info, flags); 2325 spin_unlock_irqrestore(&cinfo->card_lock, flags);
2337#ifdef CY_DEBUG_COUNT 2326#ifdef CY_DEBUG_COUNT
2338 printk(KERN_DEBUG "cyc block_til_ready: (%d): decrementing count to " 2327 printk(KERN_DEBUG "cyc block_til_ready: (%d): decrementing count to "
2339 "%d\n", current->pid, info->count); 2328 "%d\n", current->pid, info->count);
@@ -2347,7 +2336,7 @@ block_til_ready(struct tty_struct *tty, struct file *filp,
2347 base_addr = cinfo->base_addr + (cy_chip_offset[chip] << index); 2336 base_addr = cinfo->base_addr + (cy_chip_offset[chip] << index);
2348 2337
2349 while (1) { 2338 while (1) {
2350 CY_LOCK(info, flags); 2339 spin_lock_irqsave(&cinfo->card_lock, flags);
2351 if ((tty->termios->c_cflag & CBAUD)) { 2340 if ((tty->termios->c_cflag & CBAUD)) {
2352 cy_writeb(base_addr + (CyCAR << index), 2341 cy_writeb(base_addr + (CyCAR << index),
2353 (u_char) channel); 2342 (u_char) channel);
@@ -2363,7 +2352,7 @@ block_til_ready(struct tty_struct *tty, struct file *filp,
2363 readb(base_addr + (CyMSVR2 << index))); 2352 readb(base_addr + (CyMSVR2 << index)));
2364#endif 2353#endif
2365 } 2354 }
2366 CY_UNLOCK(info, flags); 2355 spin_unlock_irqrestore(&cinfo->card_lock, flags);
2367 2356
2368 set_current_state(TASK_INTERRUPTIBLE); 2357 set_current_state(TASK_INTERRUPTIBLE);
2369 if (tty_hung_up_p(filp) || 2358 if (tty_hung_up_p(filp) ||
@@ -2373,16 +2362,16 @@ block_til_ready(struct tty_struct *tty, struct file *filp,
2373 break; 2362 break;
2374 } 2363 }
2375 2364
2376 CY_LOCK(info, flags); 2365 spin_lock_irqsave(&cinfo->card_lock, flags);
2377 cy_writeb(base_addr + (CyCAR << index), 2366 cy_writeb(base_addr + (CyCAR << index),
2378 (u_char) channel); 2367 (u_char) channel);
2379 if (!(info->flags & ASYNC_CLOSING) && (C_CLOCAL(tty) || 2368 if (!(info->flags & ASYNC_CLOSING) && (C_CLOCAL(tty) ||
2380 (readb(base_addr + 2369 (readb(base_addr +
2381 (CyMSVR1 << index)) & CyDCD))) { 2370 (CyMSVR1 << index)) & CyDCD))) {
2382 CY_UNLOCK(info, flags); 2371 spin_unlock_irqrestore(&cinfo->card_lock, flags);
2383 break; 2372 break;
2384 } 2373 }
2385 CY_UNLOCK(info, flags); 2374 spin_unlock_irqrestore(&cinfo->card_lock, flags);
2386 2375
2387 if (signal_pending(current)) { 2376 if (signal_pending(current)) {
2388 retval = -ERESTARTSYS; 2377 retval = -ERESTARTSYS;
@@ -2419,7 +2408,7 @@ block_til_ready(struct tty_struct *tty, struct file *filp,
2419 cy_writel(&ch_ctrl[channel].rs_control, 2408 cy_writel(&ch_ctrl[channel].rs_control,
2420 readl(&ch_ctrl[channel].rs_control) | 2409 readl(&ch_ctrl[channel].rs_control) |
2421 C_RS_RTS | C_RS_DTR); 2410 C_RS_RTS | C_RS_DTR);
2422 retval = cyz_issue_cmd(info->card, 2411 retval = cyz_issue_cmd(cinfo,
2423 channel, C_CM_IOCTLM, 0L); 2412 channel, C_CM_IOCTLM, 0L);
2424 if (retval != 0) { 2413 if (retval != 0) {
2425 printk(KERN_ERR "cyc:block_til_ready " 2414 printk(KERN_ERR "cyc:block_til_ready "
@@ -2688,6 +2677,7 @@ static void cy_wait_until_sent(struct tty_struct *tty, int timeout)
2688static void cy_close(struct tty_struct *tty, struct file *filp) 2677static void cy_close(struct tty_struct *tty, struct file *filp)
2689{ 2678{
2690 struct cyclades_port *info = tty->driver_data; 2679 struct cyclades_port *info = tty->driver_data;
2680 struct cyclades_card *card;
2691 unsigned long flags; 2681 unsigned long flags;
2692 2682
2693#ifdef CY_DEBUG_OTHER 2683#ifdef CY_DEBUG_OTHER
@@ -2698,10 +2688,12 @@ static void cy_close(struct tty_struct *tty, struct file *filp)
2698 return; 2688 return;
2699 } 2689 }
2700 2690
2701 CY_LOCK(info, flags); 2691 card = info->card;
2692
2693 spin_lock_irqsave(&card->card_lock, flags);
2702 /* If the TTY is being hung up, nothing to do */ 2694 /* If the TTY is being hung up, nothing to do */
2703 if (tty_hung_up_p(filp)) { 2695 if (tty_hung_up_p(filp)) {
2704 CY_UNLOCK(info, flags); 2696 spin_unlock_irqrestore(&card->card_lock, flags);
2705 return; 2697 return;
2706 } 2698 }
2707#ifdef CY_DEBUG_OPEN 2699#ifdef CY_DEBUG_OPEN
@@ -2731,7 +2723,7 @@ static void cy_close(struct tty_struct *tty, struct file *filp)
2731 info->count = 0; 2723 info->count = 0;
2732 } 2724 }
2733 if (info->count) { 2725 if (info->count) {
2734 CY_UNLOCK(info, flags); 2726 spin_unlock_irqrestore(&card->card_lock, flags);
2735 return; 2727 return;
2736 } 2728 }
2737 info->flags |= ASYNC_CLOSING; 2729 info->flags |= ASYNC_CLOSING;
@@ -2741,16 +2733,16 @@ static void cy_close(struct tty_struct *tty, struct file *filp)
2741 * the line discipline to only process XON/XOFF characters. 2733 * the line discipline to only process XON/XOFF characters.
2742 */ 2734 */
2743 tty->closing = 1; 2735 tty->closing = 1;
2744 CY_UNLOCK(info, flags); 2736 spin_unlock_irqrestore(&card->card_lock, flags);
2745 if (info->closing_wait != CY_CLOSING_WAIT_NONE) { 2737 if (info->closing_wait != CY_CLOSING_WAIT_NONE) {
2746 tty_wait_until_sent(tty, info->closing_wait); 2738 tty_wait_until_sent(tty, info->closing_wait);
2747 } 2739 }
2748 CY_LOCK(info, flags); 2740 spin_lock_irqsave(&card->card_lock, flags);
2749 2741
2750 if (!IS_CYC_Z(*info->card)) { 2742 if (!IS_CYC_Z(*card)) {
2751 int channel = info->line - info->card->first_line; 2743 int channel = info->line - card->first_line;
2752 int index = info->card->bus_index; 2744 int index = card->bus_index;
2753 void __iomem *base_addr = info->card->base_addr + 2745 void __iomem *base_addr = card->base_addr +
2754 (cy_chip_offset[channel >> 2] << index); 2746 (cy_chip_offset[channel >> 2] << index);
2755 /* Stop accepting input */ 2747 /* Stop accepting input */
2756 channel &= 0x03; 2748 channel &= 0x03;
@@ -2760,53 +2752,52 @@ static void cy_close(struct tty_struct *tty, struct file *filp)
2760 if (info->flags & ASYNC_INITIALIZED) { 2752 if (info->flags & ASYNC_INITIALIZED) {
2761 /* Waiting for on-board buffers to be empty before closing 2753 /* Waiting for on-board buffers to be empty before closing
2762 the port */ 2754 the port */
2763 CY_UNLOCK(info, flags); 2755 spin_unlock_irqrestore(&card->card_lock, flags);
2764 cy_wait_until_sent(tty, info->timeout); 2756 cy_wait_until_sent(tty, info->timeout);
2765 CY_LOCK(info, flags); 2757 spin_lock_irqsave(&card->card_lock, flags);
2766 } 2758 }
2767 } else { 2759 } else {
2768#ifdef Z_WAKE 2760#ifdef Z_WAKE
2769 /* Waiting for on-board buffers to be empty before closing the port */ 2761 /* Waiting for on-board buffers to be empty before closing the port */
2770 void __iomem *base_addr = info->card->base_addr; 2762 void __iomem *base_addr = card->base_addr;
2771 struct FIRM_ID __iomem *firm_id = base_addr + ID_ADDRESS; 2763 struct FIRM_ID __iomem *firm_id = base_addr + ID_ADDRESS;
2772 struct ZFW_CTRL __iomem *zfw_ctrl = 2764 struct ZFW_CTRL __iomem *zfw_ctrl =
2773 base_addr + (readl(&firm_id->zfwctrl_addr) & 0xfffff); 2765 base_addr + (readl(&firm_id->zfwctrl_addr) & 0xfffff);
2774 struct CH_CTRL __iomem *ch_ctrl = zfw_ctrl->ch_ctrl; 2766 struct CH_CTRL __iomem *ch_ctrl = zfw_ctrl->ch_ctrl;
2775 int channel = info->line - info->card->first_line; 2767 int channel = info->line - card->first_line;
2776 int retval; 2768 int retval;
2777 2769
2778 if (readl(&ch_ctrl[channel].flow_status) != C_FS_TXIDLE) { 2770 if (readl(&ch_ctrl[channel].flow_status) != C_FS_TXIDLE) {
2779 retval = cyz_issue_cmd(info->card, channel, 2771 retval = cyz_issue_cmd(card, channel, C_CM_IOCTLW, 0L);
2780 C_CM_IOCTLW, 0L);
2781 if (retval != 0) { 2772 if (retval != 0) {
2782 printk(KERN_DEBUG "cyc:cy_close retval on " 2773 printk(KERN_DEBUG "cyc:cy_close retval on "
2783 "ttyC%d was %x\n", info->line, retval); 2774 "ttyC%d was %x\n", info->line, retval);
2784 } 2775 }
2785 CY_UNLOCK(info, flags); 2776 spin_unlock_irqrestore(&card->card_lock, flags);
2786 wait_for_completion_interruptible(&info->shutdown_wait); 2777 wait_for_completion_interruptible(&info->shutdown_wait);
2787 CY_LOCK(info, flags); 2778 spin_lock_irqsave(&card->card_lock, flags);
2788 } 2779 }
2789#endif 2780#endif
2790 } 2781 }
2791 2782
2792 CY_UNLOCK(info, flags); 2783 spin_unlock_irqrestore(&card->card_lock, flags);
2793 shutdown(info); 2784 shutdown(info);
2794 if (tty->driver->flush_buffer) 2785 if (tty->driver->flush_buffer)
2795 tty->driver->flush_buffer(tty); 2786 tty->driver->flush_buffer(tty);
2796 tty_ldisc_flush(tty); 2787 tty_ldisc_flush(tty);
2797 CY_LOCK(info, flags); 2788 spin_lock_irqsave(&card->card_lock, flags);
2798 2789
2799 tty->closing = 0; 2790 tty->closing = 0;
2800 info->event = 0; 2791 info->event = 0;
2801 info->tty = NULL; 2792 info->tty = NULL;
2802 if (info->blocked_open) { 2793 if (info->blocked_open) {
2803 CY_UNLOCK(info, flags); 2794 spin_unlock_irqrestore(&card->card_lock, flags);
2804 if (info->close_delay) { 2795 if (info->close_delay) {
2805 msleep_interruptible(jiffies_to_msecs 2796 msleep_interruptible(jiffies_to_msecs
2806 (info->close_delay)); 2797 (info->close_delay));
2807 } 2798 }
2808 wake_up_interruptible(&info->open_wait); 2799 wake_up_interruptible(&info->open_wait);
2809 CY_LOCK(info, flags); 2800 spin_lock_irqsave(&card->card_lock, flags);
2810 } 2801 }
2811 info->flags &= ~(ASYNC_NORMAL_ACTIVE | ASYNC_CLOSING); 2802 info->flags &= ~(ASYNC_NORMAL_ACTIVE | ASYNC_CLOSING);
2812 wake_up_interruptible(&info->close_wait); 2803 wake_up_interruptible(&info->close_wait);
@@ -2815,7 +2806,7 @@ static void cy_close(struct tty_struct *tty, struct file *filp)
2815 printk(KERN_DEBUG "cyc:cy_close done\n"); 2806 printk(KERN_DEBUG "cyc:cy_close done\n");
2816#endif 2807#endif
2817 2808
2818 CY_UNLOCK(info, flags); 2809 spin_unlock_irqrestore(&card->card_lock, flags);
2819} /* cy_close */ 2810} /* cy_close */
2820 2811
2821/* This routine gets called when tty_write has put something into 2812/* This routine gets called when tty_write has put something into
@@ -2848,7 +2839,7 @@ static int cy_write(struct tty_struct *tty, const unsigned char *buf, int count)
2848 if (!info->xmit_buf) 2839 if (!info->xmit_buf)
2849 return 0; 2840 return 0;
2850 2841
2851 CY_LOCK(info, flags); 2842 spin_lock_irqsave(&info->card->card_lock, flags);
2852 while (1) { 2843 while (1) {
2853 c = min(count, min((int)(SERIAL_XMIT_SIZE - info->xmit_cnt - 1), 2844 c = min(count, min((int)(SERIAL_XMIT_SIZE - info->xmit_cnt - 1),
2854 (int)(SERIAL_XMIT_SIZE - info->xmit_head))); 2845 (int)(SERIAL_XMIT_SIZE - info->xmit_head)));
@@ -2864,7 +2855,7 @@ static int cy_write(struct tty_struct *tty, const unsigned char *buf, int count)
2864 count -= c; 2855 count -= c;
2865 ret += c; 2856 ret += c;
2866 } 2857 }
2867 CY_UNLOCK(info, flags); 2858 spin_unlock_irqrestore(&info->card->card_lock, flags);
2868 2859
2869 info->idle_stats.xmit_bytes += ret; 2860 info->idle_stats.xmit_bytes += ret;
2870 info->idle_stats.xmit_idle = jiffies; 2861 info->idle_stats.xmit_idle = jiffies;
@@ -2897,9 +2888,9 @@ static void cy_put_char(struct tty_struct *tty, unsigned char ch)
2897 if (!info->xmit_buf) 2888 if (!info->xmit_buf)
2898 return; 2889 return;
2899 2890
2900 CY_LOCK(info, flags); 2891 spin_lock_irqsave(&info->card->card_lock, flags);
2901 if (info->xmit_cnt >= (int)(SERIAL_XMIT_SIZE - 1)) { 2892 if (info->xmit_cnt >= (int)(SERIAL_XMIT_SIZE - 1)) {
2902 CY_UNLOCK(info, flags); 2893 spin_unlock_irqrestore(&info->card->card_lock, flags);
2903 return; 2894 return;
2904 } 2895 }
2905 2896
@@ -2908,7 +2899,7 @@ static void cy_put_char(struct tty_struct *tty, unsigned char ch)
2908 info->xmit_cnt++; 2899 info->xmit_cnt++;
2909 info->idle_stats.xmit_bytes++; 2900 info->idle_stats.xmit_bytes++;
2910 info->idle_stats.xmit_idle = jiffies; 2901 info->idle_stats.xmit_idle = jiffies;
2911 CY_UNLOCK(info, flags); 2902 spin_unlock_irqrestore(&info->card->card_lock, flags);
2912} /* cy_put_char */ 2903} /* cy_put_char */
2913 2904
2914/* 2905/*
@@ -3202,7 +3193,7 @@ static void set_line_char(struct cyclades_port *info)
3202 channel &= 0x03; 3193 channel &= 0x03;
3203 base_addr = card->base_addr + (cy_chip_offset[chip] << index); 3194 base_addr = card->base_addr + (cy_chip_offset[chip] << index);
3204 3195
3205 CY_LOCK(info, flags); 3196 spin_lock_irqsave(&card->card_lock, flags);
3206 cy_writeb(base_addr + (CyCAR << index), (u_char) channel); 3197 cy_writeb(base_addr + (CyCAR << index), (u_char) channel);
3207 3198
3208 /* tx and rx baud rate */ 3199 /* tx and rx baud rate */
@@ -3297,7 +3288,7 @@ static void set_line_char(struct cyclades_port *info)
3297 if (info->tty) { 3288 if (info->tty) {
3298 clear_bit(TTY_IO_ERROR, &info->tty->flags); 3289 clear_bit(TTY_IO_ERROR, &info->tty->flags);
3299 } 3290 }
3300 CY_UNLOCK(info, flags); 3291 spin_unlock_irqrestore(&card->card_lock, flags);
3301 3292
3302 } else { 3293 } else {
3303 struct FIRM_ID __iomem *firm_id; 3294 struct FIRM_ID __iomem *firm_id;
@@ -3537,10 +3528,10 @@ static int get_lsr_info(struct cyclades_port *info, unsigned int __user * value)
3537 index = card->bus_index; 3528 index = card->bus_index;
3538 base_addr = card->base_addr + (cy_chip_offset[chip] << index); 3529 base_addr = card->base_addr + (cy_chip_offset[chip] << index);
3539 3530
3540 CY_LOCK(info, flags); 3531 spin_lock_irqsave(&card->card_lock, flags);
3541 status = readb(base_addr + (CySRER << index)) & 3532 status = readb(base_addr + (CySRER << index)) &
3542 (CyTxRdy | CyTxMpty); 3533 (CyTxRdy | CyTxMpty);
3543 CY_UNLOCK(info, flags); 3534 spin_unlock_irqrestore(&card->card_lock, flags);
3544 result = (status ? 0 : TIOCSER_TEMT); 3535 result = (status ? 0 : TIOCSER_TEMT);
3545 } else { 3536 } else {
3546 /* Not supported yet */ 3537 /* Not supported yet */
@@ -3575,11 +3566,11 @@ static int cy_tiocmget(struct tty_struct *tty, struct file *file)
3575 index = card->bus_index; 3566 index = card->bus_index;
3576 base_addr = card->base_addr + (cy_chip_offset[chip] << index); 3567 base_addr = card->base_addr + (cy_chip_offset[chip] << index);
3577 3568
3578 CY_LOCK(info, flags); 3569 spin_lock_irqsave(&card->card_lock, flags);
3579 cy_writeb(base_addr + (CyCAR << index), (u_char) channel); 3570 cy_writeb(base_addr + (CyCAR << index), (u_char) channel);
3580 status = readb(base_addr + (CyMSVR1 << index)); 3571 status = readb(base_addr + (CyMSVR1 << index));
3581 status |= readb(base_addr + (CyMSVR2 << index)); 3572 status |= readb(base_addr + (CyMSVR2 << index));
3582 CY_UNLOCK(info, flags); 3573 spin_unlock_irqrestore(&card->card_lock, flags);
3583 3574
3584 if (info->rtsdtr_inv) { 3575 if (info->rtsdtr_inv) {
3585 result = ((status & CyRTS) ? TIOCM_DTR : 0) | 3576 result = ((status & CyRTS) ? TIOCM_DTR : 0) |
@@ -3643,7 +3634,7 @@ cy_tiocmset(struct tty_struct *tty, struct file *file,
3643 base_addr = card->base_addr + (cy_chip_offset[chip] << index); 3634 base_addr = card->base_addr + (cy_chip_offset[chip] << index);
3644 3635
3645 if (set & TIOCM_RTS) { 3636 if (set & TIOCM_RTS) {
3646 CY_LOCK(info, flags); 3637 spin_lock_irqsave(&card->card_lock, flags);
3647 cy_writeb(base_addr + (CyCAR << index), 3638 cy_writeb(base_addr + (CyCAR << index),
3648 (u_char) channel); 3639 (u_char) channel);
3649 if (info->rtsdtr_inv) { 3640 if (info->rtsdtr_inv) {
@@ -3653,10 +3644,10 @@ cy_tiocmset(struct tty_struct *tty, struct file *file,
3653 cy_writeb(base_addr + (CyMSVR1 << index), 3644 cy_writeb(base_addr + (CyMSVR1 << index),
3654 CyRTS); 3645 CyRTS);
3655 } 3646 }
3656 CY_UNLOCK(info, flags); 3647 spin_unlock_irqrestore(&card->card_lock, flags);
3657 } 3648 }
3658 if (clear & TIOCM_RTS) { 3649 if (clear & TIOCM_RTS) {
3659 CY_LOCK(info, flags); 3650 spin_lock_irqsave(&card->card_lock, flags);
3660 cy_writeb(base_addr + (CyCAR << index), 3651 cy_writeb(base_addr + (CyCAR << index),
3661 (u_char) channel); 3652 (u_char) channel);
3662 if (info->rtsdtr_inv) { 3653 if (info->rtsdtr_inv) {
@@ -3666,10 +3657,10 @@ cy_tiocmset(struct tty_struct *tty, struct file *file,
3666 cy_writeb(base_addr + (CyMSVR1 << index), 3657 cy_writeb(base_addr + (CyMSVR1 << index),
3667 ~CyRTS); 3658 ~CyRTS);
3668 } 3659 }
3669 CY_UNLOCK(info, flags); 3660 spin_unlock_irqrestore(&card->card_lock, flags);
3670 } 3661 }
3671 if (set & TIOCM_DTR) { 3662 if (set & TIOCM_DTR) {
3672 CY_LOCK(info, flags); 3663 spin_lock_irqsave(&card->card_lock, flags);
3673 cy_writeb(base_addr + (CyCAR << index), 3664 cy_writeb(base_addr + (CyCAR << index),
3674 (u_char) channel); 3665 (u_char) channel);
3675 if (info->rtsdtr_inv) { 3666 if (info->rtsdtr_inv) {
@@ -3685,10 +3676,10 @@ cy_tiocmset(struct tty_struct *tty, struct file *file,
3685 readb(base_addr + (CyMSVR1 << index)), 3676 readb(base_addr + (CyMSVR1 << index)),
3686 readb(base_addr + (CyMSVR2 << index))); 3677 readb(base_addr + (CyMSVR2 << index)));
3687#endif 3678#endif
3688 CY_UNLOCK(info, flags); 3679 spin_unlock_irqrestore(&card->card_lock, flags);
3689 } 3680 }
3690 if (clear & TIOCM_DTR) { 3681 if (clear & TIOCM_DTR) {
3691 CY_LOCK(info, flags); 3682 spin_lock_irqsave(&card->card_lock, flags);
3692 cy_writeb(base_addr + (CyCAR << index), 3683 cy_writeb(base_addr + (CyCAR << index),
3693 (u_char) channel); 3684 (u_char) channel);
3694 if (info->rtsdtr_inv) { 3685 if (info->rtsdtr_inv) {
@@ -3705,7 +3696,7 @@ cy_tiocmset(struct tty_struct *tty, struct file *file,
3705 readb(base_addr + (CyMSVR1 << index)), 3696 readb(base_addr + (CyMSVR1 << index)),
3706 readb(base_addr + (CyMSVR2 << index))); 3697 readb(base_addr + (CyMSVR2 << index)));
3707#endif 3698#endif
3708 CY_UNLOCK(info, flags); 3699 spin_unlock_irqrestore(&card->card_lock, flags);
3709 } 3700 }
3710 } else { 3701 } else {
3711 base_addr = card->base_addr; 3702 base_addr = card->base_addr;
@@ -3718,21 +3709,21 @@ cy_tiocmset(struct tty_struct *tty, struct file *file,
3718 ch_ctrl = zfw_ctrl->ch_ctrl; 3709 ch_ctrl = zfw_ctrl->ch_ctrl;
3719 3710
3720 if (set & TIOCM_RTS) { 3711 if (set & TIOCM_RTS) {
3721 CY_LOCK(info, flags); 3712 spin_lock_irqsave(&card->card_lock, flags);
3722 cy_writel(&ch_ctrl[channel].rs_control, 3713 cy_writel(&ch_ctrl[channel].rs_control,
3723 readl(&ch_ctrl[channel].rs_control) | 3714 readl(&ch_ctrl[channel].rs_control) |
3724 C_RS_RTS); 3715 C_RS_RTS);
3725 CY_UNLOCK(info, flags); 3716 spin_unlock_irqrestore(&card->card_lock, flags);
3726 } 3717 }
3727 if (clear & TIOCM_RTS) { 3718 if (clear & TIOCM_RTS) {
3728 CY_LOCK(info, flags); 3719 spin_lock_irqsave(&card->card_lock, flags);
3729 cy_writel(&ch_ctrl[channel].rs_control, 3720 cy_writel(&ch_ctrl[channel].rs_control,
3730 readl(&ch_ctrl[channel].rs_control) & 3721 readl(&ch_ctrl[channel].rs_control) &
3731 ~C_RS_RTS); 3722 ~C_RS_RTS);
3732 CY_UNLOCK(info, flags); 3723 spin_unlock_irqrestore(&card->card_lock, flags);
3733 } 3724 }
3734 if (set & TIOCM_DTR) { 3725 if (set & TIOCM_DTR) {
3735 CY_LOCK(info, flags); 3726 spin_lock_irqsave(&card->card_lock, flags);
3736 cy_writel(&ch_ctrl[channel].rs_control, 3727 cy_writel(&ch_ctrl[channel].rs_control,
3737 readl(&ch_ctrl[channel].rs_control) | 3728 readl(&ch_ctrl[channel].rs_control) |
3738 C_RS_DTR); 3729 C_RS_DTR);
@@ -3740,10 +3731,10 @@ cy_tiocmset(struct tty_struct *tty, struct file *file,
3740 printk(KERN_DEBUG "cyc:set_modem_info raising " 3731 printk(KERN_DEBUG "cyc:set_modem_info raising "
3741 "Z DTR\n"); 3732 "Z DTR\n");
3742#endif 3733#endif
3743 CY_UNLOCK(info, flags); 3734 spin_unlock_irqrestore(&card->card_lock, flags);
3744 } 3735 }
3745 if (clear & TIOCM_DTR) { 3736 if (clear & TIOCM_DTR) {
3746 CY_LOCK(info, flags); 3737 spin_lock_irqsave(&card->card_lock, flags);
3747 cy_writel(&ch_ctrl[channel].rs_control, 3738 cy_writel(&ch_ctrl[channel].rs_control,
3748 readl(&ch_ctrl[channel].rs_control) & 3739 readl(&ch_ctrl[channel].rs_control) &
3749 ~C_RS_DTR); 3740 ~C_RS_DTR);
@@ -3751,19 +3742,18 @@ cy_tiocmset(struct tty_struct *tty, struct file *file,
3751 printk(KERN_DEBUG "cyc:set_modem_info clearing " 3742 printk(KERN_DEBUG "cyc:set_modem_info clearing "
3752 "Z DTR\n"); 3743 "Z DTR\n");
3753#endif 3744#endif
3754 CY_UNLOCK(info, flags); 3745 spin_unlock_irqrestore(&card->card_lock, flags);
3755 } 3746 }
3756 } else { 3747 } else {
3757 return -ENODEV; 3748 return -ENODEV;
3758 } 3749 }
3759 CY_LOCK(info, flags); 3750 spin_lock_irqsave(&card->card_lock, flags);
3760 retval = cyz_issue_cmd(info->card, 3751 retval = cyz_issue_cmd(card, channel, C_CM_IOCTLM, 0L);
3761 channel, C_CM_IOCTLM, 0L);
3762 if (retval != 0) { 3752 if (retval != 0) {
3763 printk(KERN_ERR "cyc:set_modem_info retval on ttyC%d " 3753 printk(KERN_ERR "cyc:set_modem_info retval on ttyC%d "
3764 "was %x\n", info->line, retval); 3754 "was %x\n", info->line, retval);
3765 } 3755 }
3766 CY_UNLOCK(info, flags); 3756 spin_unlock_irqrestore(&card->card_lock, flags);
3767 } 3757 }
3768 return 0; 3758 return 0;
3769} /* cy_tiocmset */ 3759} /* cy_tiocmset */
@@ -3774,13 +3764,16 @@ cy_tiocmset(struct tty_struct *tty, struct file *file,
3774static void cy_break(struct tty_struct *tty, int break_state) 3764static void cy_break(struct tty_struct *tty, int break_state)
3775{ 3765{
3776 struct cyclades_port *info = tty->driver_data; 3766 struct cyclades_port *info = tty->driver_data;
3767 struct cyclades_card *card;
3777 unsigned long flags; 3768 unsigned long flags;
3778 3769
3779 if (serial_paranoia_check(info, tty->name, "cy_break")) 3770 if (serial_paranoia_check(info, tty->name, "cy_break"))
3780 return; 3771 return;
3781 3772
3782 CY_LOCK(info, flags); 3773 card = info->card;
3783 if (!IS_CYC_Z(*info->card)) { 3774
3775 spin_lock_irqsave(&card->card_lock, flags);
3776 if (!IS_CYC_Z(*card)) {
3784 /* Let the transmit ISR take care of this (since it 3777 /* Let the transmit ISR take care of this (since it
3785 requires stuffing characters into the output stream). 3778 requires stuffing characters into the output stream).
3786 */ 3779 */
@@ -3788,18 +3781,18 @@ static void cy_break(struct tty_struct *tty, int break_state)
3788 if (!info->breakon) { 3781 if (!info->breakon) {
3789 info->breakon = 1; 3782 info->breakon = 1;
3790 if (!info->xmit_cnt) { 3783 if (!info->xmit_cnt) {
3791 CY_UNLOCK(info, flags); 3784 spin_unlock_irqrestore(&card->card_lock, flags);
3792 start_xmit(info); 3785 start_xmit(info);
3793 CY_LOCK(info, flags); 3786 spin_lock_irqsave(&card->card_lock, flags);
3794 } 3787 }
3795 } 3788 }
3796 } else { 3789 } else {
3797 if (!info->breakoff) { 3790 if (!info->breakoff) {
3798 info->breakoff = 1; 3791 info->breakoff = 1;
3799 if (!info->xmit_cnt) { 3792 if (!info->xmit_cnt) {
3800 CY_UNLOCK(info, flags); 3793 spin_unlock_irqrestore(&card->card_lock, flags);
3801 start_xmit(info); 3794 start_xmit(info);
3802 CY_LOCK(info, flags); 3795 spin_lock_irqsave(&card->card_lock, flags);
3803 } 3796 }
3804 } 3797 }
3805 } 3798 }
@@ -3807,16 +3800,16 @@ static void cy_break(struct tty_struct *tty, int break_state)
3807 int retval; 3800 int retval;
3808 3801
3809 if (break_state == -1) { 3802 if (break_state == -1) {
3810 retval = cyz_issue_cmd(info->card, 3803 retval = cyz_issue_cmd(card,
3811 info->line - info->card->first_line, 3804 info->line - card->first_line,
3812 C_CM_SET_BREAK, 0L); 3805 C_CM_SET_BREAK, 0L);
3813 if (retval != 0) { 3806 if (retval != 0) {
3814 printk(KERN_ERR "cyc:cy_break (set) retval on " 3807 printk(KERN_ERR "cyc:cy_break (set) retval on "
3815 "ttyC%d was %x\n", info->line, retval); 3808 "ttyC%d was %x\n", info->line, retval);
3816 } 3809 }
3817 } else { 3810 } else {
3818 retval = cyz_issue_cmd(info->card, 3811 retval = cyz_issue_cmd(card,
3819 info->line - info->card->first_line, 3812 info->line - card->first_line,
3820 C_CM_CLR_BREAK, 0L); 3813 C_CM_CLR_BREAK, 0L);
3821 if (retval != 0) { 3814 if (retval != 0) {
3822 printk(KERN_DEBUG "cyc:cy_break (clr) retval " 3815 printk(KERN_DEBUG "cyc:cy_break (clr) retval "
@@ -3825,7 +3818,7 @@ static void cy_break(struct tty_struct *tty, int break_state)
3825 } 3818 }
3826 } 3819 }
3827 } 3820 }
3828 CY_UNLOCK(info, flags); 3821 spin_unlock_irqrestore(&card->card_lock, flags);
3829} /* cy_break */ 3822} /* cy_break */
3830 3823
3831static int 3824static int
@@ -3860,10 +3853,10 @@ static int set_threshold(struct cyclades_port *info, unsigned long value)
3860 info->cor3 &= ~CyREC_FIFO; 3853 info->cor3 &= ~CyREC_FIFO;
3861 info->cor3 |= value & CyREC_FIFO; 3854 info->cor3 |= value & CyREC_FIFO;
3862 3855
3863 CY_LOCK(info, flags); 3856 spin_lock_irqsave(&card->card_lock, flags);
3864 cy_writeb(base_addr + (CyCOR3 << index), info->cor3); 3857 cy_writeb(base_addr + (CyCOR3 << index), info->cor3);
3865 cyy_issue_cmd(base_addr, CyCOR_CHANGE | CyCOR3ch, index); 3858 cyy_issue_cmd(base_addr, CyCOR_CHANGE | CyCOR3ch, index);
3866 CY_UNLOCK(info, flags); 3859 spin_unlock_irqrestore(&card->card_lock, flags);
3867 } else { 3860 } else {
3868 /* Nothing to do! */ 3861 /* Nothing to do! */
3869 } 3862 }
@@ -3922,9 +3915,9 @@ static int set_timeout(struct cyclades_port *info, unsigned long value)
3922 index = card->bus_index; 3915 index = card->bus_index;
3923 base_addr = card->base_addr + (cy_chip_offset[chip] << index); 3916 base_addr = card->base_addr + (cy_chip_offset[chip] << index);
3924 3917
3925 CY_LOCK(info, flags); 3918 spin_lock_irqsave(&card->card_lock, flags);
3926 cy_writeb(base_addr + (CyRTPR << index), value & 0xff); 3919 cy_writeb(base_addr + (CyRTPR << index), value & 0xff);
3927 CY_UNLOCK(info, flags); 3920 spin_unlock_irqrestore(&card->card_lock, flags);
3928 } else { 3921 } else {
3929 /* Nothing to do! */ 3922 /* Nothing to do! */
3930 } 3923 }
@@ -4067,15 +4060,15 @@ cy_ioctl(struct tty_struct *tty, struct file *file,
4067 * Caller should use TIOCGICOUNT to see which one it was 4060 * Caller should use TIOCGICOUNT to see which one it was
4068 */ 4061 */
4069 case TIOCMIWAIT: 4062 case TIOCMIWAIT:
4070 CY_LOCK(info, flags); 4063 spin_lock_irqsave(&info->card->card_lock, flags);
4071 /* note the counters on entry */ 4064 /* note the counters on entry */
4072 cnow = info->icount; 4065 cnow = info->icount;
4073 CY_UNLOCK(info, flags); 4066 spin_unlock_irqrestore(&info->card->card_lock, flags);
4074 ret_val = wait_event_interruptible(info->delta_msr_wait, ({ 4067 ret_val = wait_event_interruptible(info->delta_msr_wait, ({
4075 cprev = cnow; 4068 cprev = cnow;
4076 CY_LOCK(info, flags); 4069 spin_lock_irqsave(&info->card->card_lock, flags);
4077 cnow = info->icount; /* atomic copy */ 4070 cnow = info->icount; /* atomic copy */
4078 CY_UNLOCK(info, flags); 4071 spin_unlock_irqrestore(&info->card->card_lock, flags);
4079 4072
4080 ((arg & TIOCM_RNG) && (cnow.rng != cprev.rng)) || 4073 ((arg & TIOCM_RNG) && (cnow.rng != cprev.rng)) ||
4081 ((arg & TIOCM_DSR) && (cnow.dsr != cprev.dsr)) || 4074 ((arg & TIOCM_DSR) && (cnow.dsr != cprev.dsr)) ||
@@ -4091,9 +4084,9 @@ cy_ioctl(struct tty_struct *tty, struct file *file,
4091 * RI where only 0->1 is counted. 4084 * RI where only 0->1 is counted.
4092 */ 4085 */
4093 case TIOCGICOUNT: 4086 case TIOCGICOUNT:
4094 CY_LOCK(info, flags); 4087 spin_lock_irqsave(&info->card->card_lock, flags);
4095 cnow = info->icount; 4088 cnow = info->icount;
4096 CY_UNLOCK(info, flags); 4089 spin_unlock_irqrestore(&info->card->card_lock, flags);
4097 p_cuser = argp; 4090 p_cuser = argp;
4098 ret_val = put_user(cnow.cts, &p_cuser->cts); 4091 ret_val = put_user(cnow.cts, &p_cuser->cts);
4099 if (ret_val) 4092 if (ret_val)
@@ -4248,7 +4241,7 @@ static void cy_throttle(struct tty_struct *tty)
4248 base_addr = card->base_addr + 4241 base_addr = card->base_addr +
4249 (cy_chip_offset[chip] << index); 4242 (cy_chip_offset[chip] << index);
4250 4243
4251 CY_LOCK(info, flags); 4244 spin_lock_irqsave(&card->card_lock, flags);
4252 cy_writeb(base_addr + (CyCAR << index), 4245 cy_writeb(base_addr + (CyCAR << index),
4253 (u_char) channel); 4246 (u_char) channel);
4254 if (info->rtsdtr_inv) { 4247 if (info->rtsdtr_inv) {
@@ -4258,7 +4251,7 @@ static void cy_throttle(struct tty_struct *tty)
4258 cy_writeb(base_addr + (CyMSVR1 << index), 4251 cy_writeb(base_addr + (CyMSVR1 << index),
4259 ~CyRTS); 4252 ~CyRTS);
4260 } 4253 }
4261 CY_UNLOCK(info, flags); 4254 spin_unlock_irqrestore(&card->card_lock, flags);
4262 } else { 4255 } else {
4263 info->throttle = 1; 4256 info->throttle = 1;
4264 } 4257 }
@@ -4306,7 +4299,7 @@ static void cy_unthrottle(struct tty_struct *tty)
4306 base_addr = card->base_addr + 4299 base_addr = card->base_addr +
4307 (cy_chip_offset[chip] << index); 4300 (cy_chip_offset[chip] << index);
4308 4301
4309 CY_LOCK(info, flags); 4302 spin_lock_irqsave(&card->card_lock, flags);
4310 cy_writeb(base_addr + (CyCAR << index), 4303 cy_writeb(base_addr + (CyCAR << index),
4311 (u_char) channel); 4304 (u_char) channel);
4312 if (info->rtsdtr_inv) { 4305 if (info->rtsdtr_inv) {
@@ -4316,7 +4309,7 @@ static void cy_unthrottle(struct tty_struct *tty)
4316 cy_writeb(base_addr + (CyMSVR1 << index), 4309 cy_writeb(base_addr + (CyMSVR1 << index),
4317 CyRTS); 4310 CyRTS);
4318 } 4311 }
4319 CY_UNLOCK(info, flags); 4312 spin_unlock_irqrestore(&card->card_lock, flags);
4320 } else { 4313 } else {
4321 info->throttle = 0; 4314 info->throttle = 0;
4322 } 4315 }
@@ -4347,15 +4340,14 @@ static void cy_stop(struct tty_struct *tty)
4347 index = cinfo->bus_index; 4340 index = cinfo->bus_index;
4348 chip = channel >> 2; 4341 chip = channel >> 2;
4349 channel &= 0x03; 4342 channel &= 0x03;
4350 base_addr = info->card->base_addr + 4343 base_addr = cinfo->base_addr + (cy_chip_offset[chip] << index);
4351 (cy_chip_offset[chip] << index);
4352 4344
4353 CY_LOCK(info, flags); 4345 spin_lock_irqsave(&cinfo->card_lock, flags);
4354 cy_writeb(base_addr + (CyCAR << index), 4346 cy_writeb(base_addr + (CyCAR << index),
4355 (u_char)(channel & 0x0003)); /* index channel */ 4347 (u_char)(channel & 0x0003)); /* index channel */
4356 cy_writeb(base_addr + (CySRER << index), 4348 cy_writeb(base_addr + (CySRER << index),
4357 readb(base_addr + (CySRER << index)) & ~CyTxRdy); 4349 readb(base_addr + (CySRER << index)) & ~CyTxRdy);
4358 CY_UNLOCK(info, flags); 4350 spin_unlock_irqrestore(&cinfo->card_lock, flags);
4359 } else { 4351 } else {
4360 /* Nothing to do! */ 4352 /* Nothing to do! */
4361 } 4353 }
@@ -4382,14 +4374,13 @@ static void cy_start(struct tty_struct *tty)
4382 if (!IS_CYC_Z(*cinfo)) { 4374 if (!IS_CYC_Z(*cinfo)) {
4383 chip = channel >> 2; 4375 chip = channel >> 2;
4384 channel &= 0x03; 4376 channel &= 0x03;
4385 base_addr = info->card->base_addr + 4377 base_addr = cinfo->base_addr + (cy_chip_offset[chip] << index);
4386 (cy_chip_offset[chip] << index);
4387 4378
4388 CY_LOCK(info, flags); 4379 spin_lock_irqsave(&cinfo->card_lock, flags);
4389 cy_writeb(base_addr + (CyCAR << index), (u_char) (channel & 0x0003)); /* index channel */ 4380 cy_writeb(base_addr + (CyCAR << index), (u_char) (channel & 0x0003)); /* index channel */
4390 cy_writeb(base_addr + (CySRER << index), 4381 cy_writeb(base_addr + (CySRER << index),
4391 readb(base_addr + (CySRER << index)) | CyTxRdy); 4382 readb(base_addr + (CySRER << index)) | CyTxRdy);
4392 CY_UNLOCK(info, flags); 4383 spin_unlock_irqrestore(&cinfo->card_lock, flags);
4393 } else { 4384 } else {
4394 /* Nothing to do! */ 4385 /* Nothing to do! */
4395 } 4386 }
@@ -4412,19 +4403,19 @@ static void cy_flush_buffer(struct tty_struct *tty)
4412 card = info->card; 4403 card = info->card;
4413 channel = info->line - card->first_line; 4404 channel = info->line - card->first_line;
4414 4405
4415 CY_LOCK(info, flags); 4406 spin_lock_irqsave(&card->card_lock, flags);
4416 info->xmit_cnt = info->xmit_head = info->xmit_tail = 0; 4407 info->xmit_cnt = info->xmit_head = info->xmit_tail = 0;
4417 CY_UNLOCK(info, flags); 4408 spin_unlock_irqrestore(&card->card_lock, flags);
4418 4409
4419 if (IS_CYC_Z(*card)) { /* If it is a Z card, flush the on-board 4410 if (IS_CYC_Z(*card)) { /* If it is a Z card, flush the on-board
4420 buffers as well */ 4411 buffers as well */
4421 CY_LOCK(info, flags); 4412 spin_lock_irqsave(&card->card_lock, flags);
4422 retval = cyz_issue_cmd(card, channel, C_CM_FLUSH_TX, 0L); 4413 retval = cyz_issue_cmd(card, channel, C_CM_FLUSH_TX, 0L);
4423 if (retval != 0) { 4414 if (retval != 0) {
4424 printk(KERN_ERR "cyc: flush_buffer retval on ttyC%d " 4415 printk(KERN_ERR "cyc: flush_buffer retval on ttyC%d "
4425 "was %x\n", info->line, retval); 4416 "was %x\n", info->line, retval);
4426 } 4417 }
4427 CY_UNLOCK(info, flags); 4418 spin_unlock_irqrestore(&card->card_lock, flags);
4428 } 4419 }
4429 tty_wakeup(tty); 4420 tty_wakeup(tty);
4430} /* cy_flush_buffer */ 4421} /* cy_flush_buffer */