diff options
author | Alan Cox <alan@redhat.com> | 2009-01-02 08:45:19 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-01-02 13:19:38 -0500 |
commit | 5d951fb458f847e5485b5251597fbf326000bb3b (patch) | |
tree | f668a015282f657f258995a1e5a85e145ca8251a /drivers/char | |
parent | d0c9873addc1f18e7becb50094dad07df8cc4694 (diff) |
tty: Pull the dtr raise into tty port
This moves another per device special out of what should be shared open
wait paths into private methods
Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/char')
-rw-r--r-- | drivers/char/isicom.c | 13 | ||||
-rw-r--r-- | drivers/char/mxser.c | 17 | ||||
-rw-r--r-- | drivers/char/rocket.c | 14 | ||||
-rw-r--r-- | drivers/char/synclink.c | 21 | ||||
-rw-r--r-- | drivers/char/synclink_gt.c | 21 | ||||
-rw-r--r-- | drivers/char/tty_port.c | 16 |
6 files changed, 77 insertions, 25 deletions
diff --git a/drivers/char/isicom.c b/drivers/char/isicom.c index b3da4858fd4a..a449449e301c 100644 --- a/drivers/char/isicom.c +++ b/drivers/char/isicom.c | |||
@@ -328,11 +328,13 @@ static inline void drop_rts(struct isi_port *port) | |||
328 | } | 328 | } |
329 | 329 | ||
330 | /* card->lock MUST NOT be held */ | 330 | /* card->lock MUST NOT be held */ |
331 | static inline void raise_dtr_rts(struct isi_port *port) | 331 | |
332 | static void isicom_raise_dtr_rts(struct tty_port *port) | ||
332 | { | 333 | { |
333 | struct isi_board *card = port->card; | 334 | struct isi_port *ip = container_of(port, struct isi_port, port); |
335 | struct isi_board *card = ip->card; | ||
334 | unsigned long base = card->base; | 336 | unsigned long base = card->base; |
335 | u16 channel = port->channel; | 337 | u16 channel = ip->channel; |
336 | 338 | ||
337 | if (!lock_card(card)) | 339 | if (!lock_card(card)) |
338 | return; | 340 | return; |
@@ -340,7 +342,7 @@ static inline void raise_dtr_rts(struct isi_port *port) | |||
340 | outw(0x8000 | (channel << card->shift_count) | 0x02, base); | 342 | outw(0x8000 | (channel << card->shift_count) | 0x02, base); |
341 | outw(0x0f04, base); | 343 | outw(0x0f04, base); |
342 | InterruptTheCard(base); | 344 | InterruptTheCard(base); |
343 | port->status |= (ISI_DTR | ISI_RTS); | 345 | ip->status |= (ISI_DTR | ISI_RTS); |
344 | unlock_card(card); | 346 | unlock_card(card); |
345 | } | 347 | } |
346 | 348 | ||
@@ -881,7 +883,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp, | |||
881 | spin_unlock_irqrestore(&card->card_lock, flags); | 883 | spin_unlock_irqrestore(&card->card_lock, flags); |
882 | 884 | ||
883 | while (1) { | 885 | while (1) { |
884 | raise_dtr_rts(ip); | 886 | tty_port_raise_dtr_rts(port); |
885 | 887 | ||
886 | set_current_state(TASK_INTERRUPTIBLE); | 888 | set_current_state(TASK_INTERRUPTIBLE); |
887 | if (tty_hung_up_p(filp) || !(port->flags & ASYNC_INITIALIZED)) { | 889 | if (tty_hung_up_p(filp) || !(port->flags & ASYNC_INITIALIZED)) { |
@@ -1462,6 +1464,7 @@ static const struct tty_operations isicom_ops = { | |||
1462 | 1464 | ||
1463 | static const struct tty_port_operations isicom_port_ops = { | 1465 | static const struct tty_port_operations isicom_port_ops = { |
1464 | .carrier_raised = isicom_carrier_raised, | 1466 | .carrier_raised = isicom_carrier_raised, |
1467 | .raise_dtr_rts = isicom_raise_dtr_rts, | ||
1465 | }; | 1468 | }; |
1466 | 1469 | ||
1467 | static int __devinit reset_card(struct pci_dev *pdev, | 1470 | static int __devinit reset_card(struct pci_dev *pdev, |
diff --git a/drivers/char/mxser.c b/drivers/char/mxser.c index eafbbcf355e7..ff5ff6188809 100644 --- a/drivers/char/mxser.c +++ b/drivers/char/mxser.c | |||
@@ -547,6 +547,17 @@ static int mxser_carrier_raised(struct tty_port *port) | |||
547 | return (inb(mp->ioaddr + UART_MSR) & UART_MSR_DCD)?1:0; | 547 | return (inb(mp->ioaddr + UART_MSR) & UART_MSR_DCD)?1:0; |
548 | } | 548 | } |
549 | 549 | ||
550 | static void mxser_raise_dtr_rts(struct tty_port *port) | ||
551 | { | ||
552 | struct mxser_port *mp = container_of(port, struct mxser_port, port); | ||
553 | unsigned long flags; | ||
554 | |||
555 | spin_lock_irqsave(&mp->slock, flags); | ||
556 | outb(inb(mp->ioaddr + UART_MCR) | | ||
557 | UART_MCR_DTR | UART_MCR_RTS, mp->ioaddr + UART_MCR); | ||
558 | spin_unlock_irqrestore(&mp->slock, flags); | ||
559 | } | ||
560 | |||
550 | static int mxser_block_til_ready(struct tty_struct *tty, struct file *filp, | 561 | static int mxser_block_til_ready(struct tty_struct *tty, struct file *filp, |
551 | struct mxser_port *mp) | 562 | struct mxser_port *mp) |
552 | { | 563 | { |
@@ -586,10 +597,7 @@ static int mxser_block_til_ready(struct tty_struct *tty, struct file *filp, | |||
586 | spin_unlock_irqrestore(&mp->slock, flags); | 597 | spin_unlock_irqrestore(&mp->slock, flags); |
587 | port->blocked_open++; | 598 | port->blocked_open++; |
588 | while (1) { | 599 | while (1) { |
589 | spin_lock_irqsave(&mp->slock, flags); | 600 | tty_port_raise_dtr_rts(port); |
590 | outb(inb(mp->ioaddr + UART_MCR) | | ||
591 | UART_MCR_DTR | UART_MCR_RTS, mp->ioaddr + UART_MCR); | ||
592 | spin_unlock_irqrestore(&mp->slock, flags); | ||
593 | set_current_state(TASK_INTERRUPTIBLE); | 601 | set_current_state(TASK_INTERRUPTIBLE); |
594 | if (tty_hung_up_p(filp) || !(port->flags & ASYNC_INITIALIZED)) { | 602 | if (tty_hung_up_p(filp) || !(port->flags & ASYNC_INITIALIZED)) { |
595 | if (port->flags & ASYNC_HUP_NOTIFY) | 603 | if (port->flags & ASYNC_HUP_NOTIFY) |
@@ -2458,6 +2466,7 @@ static const struct tty_operations mxser_ops = { | |||
2458 | 2466 | ||
2459 | struct tty_port_operations mxser_port_ops = { | 2467 | struct tty_port_operations mxser_port_ops = { |
2460 | .carrier_raised = mxser_carrier_raised, | 2468 | .carrier_raised = mxser_carrier_raised, |
2469 | .raise_dtr_rts = mxser_raise_dtr_rts, | ||
2461 | }; | 2470 | }; |
2462 | 2471 | ||
2463 | /* | 2472 | /* |
diff --git a/drivers/char/rocket.c b/drivers/char/rocket.c index 4a4110e703a5..f4d9c3993488 100644 --- a/drivers/char/rocket.c +++ b/drivers/char/rocket.c | |||
@@ -870,6 +870,13 @@ static int carrier_raised(struct tty_port *port) | |||
870 | return (sGetChanStatusLo(&info->channel) & CD_ACT) ? 1 : 0; | 870 | return (sGetChanStatusLo(&info->channel) & CD_ACT) ? 1 : 0; |
871 | } | 871 | } |
872 | 872 | ||
873 | static void raise_dtr_rts(struct tty_port *port) | ||
874 | { | ||
875 | struct r_port *info = container_of(port, struct r_port, port); | ||
876 | sSetDTR(&info->channel); | ||
877 | sSetRTS(&info->channel); | ||
878 | } | ||
879 | |||
873 | /* info->port.count is considered critical, protected by spinlocks. */ | 880 | /* info->port.count is considered critical, protected by spinlocks. */ |
874 | static int block_til_ready(struct tty_struct *tty, struct file *filp, | 881 | static int block_til_ready(struct tty_struct *tty, struct file *filp, |
875 | struct r_port *info) | 882 | struct r_port *info) |
@@ -928,10 +935,8 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp, | |||
928 | spin_unlock_irqrestore(&info->slock, flags); | 935 | spin_unlock_irqrestore(&info->slock, flags); |
929 | 936 | ||
930 | while (1) { | 937 | while (1) { |
931 | if (tty->termios->c_cflag & CBAUD) { | 938 | if (tty->termios->c_cflag & CBAUD) |
932 | sSetDTR(&info->channel); | 939 | tty_port_raise_dtr_rts(port); |
933 | sSetRTS(&info->channel); | ||
934 | } | ||
935 | set_current_state(TASK_INTERRUPTIBLE); | 940 | set_current_state(TASK_INTERRUPTIBLE); |
936 | if (tty_hung_up_p(filp) || !(info->flags & ROCKET_INITIALIZED)) { | 941 | if (tty_hung_up_p(filp) || !(info->flags & ROCKET_INITIALIZED)) { |
937 | if (info->flags & ROCKET_HUP_NOTIFY) | 942 | if (info->flags & ROCKET_HUP_NOTIFY) |
@@ -2381,6 +2386,7 @@ static const struct tty_operations rocket_ops = { | |||
2381 | 2386 | ||
2382 | static const struct tty_port_operations rocket_port_ops = { | 2387 | static const struct tty_port_operations rocket_port_ops = { |
2383 | .carrier_raised = carrier_raised, | 2388 | .carrier_raised = carrier_raised, |
2389 | .raise_dtr_rts = raise_dtr_rts, | ||
2384 | }; | 2390 | }; |
2385 | 2391 | ||
2386 | /* | 2392 | /* |
diff --git a/drivers/char/synclink.c b/drivers/char/synclink.c index fb2e6b5e0ef1..ac9f21e18c3f 100644 --- a/drivers/char/synclink.c +++ b/drivers/char/synclink.c | |||
@@ -3298,6 +3298,18 @@ static int carrier_raised(struct tty_port *port) | |||
3298 | return (info->serial_signals & SerialSignal_DCD) ? 1 : 0; | 3298 | return (info->serial_signals & SerialSignal_DCD) ? 1 : 0; |
3299 | } | 3299 | } |
3300 | 3300 | ||
3301 | static void raise_dtr_rts(struct tty_port *port) | ||
3302 | { | ||
3303 | struct mgsl_struct *info = container_of(port, struct mgsl_struct, port); | ||
3304 | unsigned long flags; | ||
3305 | |||
3306 | spin_lock_irqsave(&info->irq_spinlock,flags); | ||
3307 | info->serial_signals |= SerialSignal_RTS + SerialSignal_DTR; | ||
3308 | usc_set_serial_signals(info); | ||
3309 | spin_unlock_irqrestore(&info->irq_spinlock,flags); | ||
3310 | } | ||
3311 | |||
3312 | |||
3301 | /* block_til_ready() | 3313 | /* block_til_ready() |
3302 | * | 3314 | * |
3303 | * Block the current process until the specified port | 3315 | * Block the current process until the specified port |
@@ -3358,12 +3370,8 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp, | |||
3358 | port->blocked_open++; | 3370 | port->blocked_open++; |
3359 | 3371 | ||
3360 | while (1) { | 3372 | while (1) { |
3361 | if (tty->termios->c_cflag & CBAUD) { | 3373 | if (tty->termios->c_cflag & CBAUD) |
3362 | spin_lock_irqsave(&info->irq_spinlock,flags); | 3374 | tty_port_raise_dtr_rts(port); |
3363 | info->serial_signals |= SerialSignal_RTS + SerialSignal_DTR; | ||
3364 | usc_set_serial_signals(info); | ||
3365 | spin_unlock_irqrestore(&info->irq_spinlock,flags); | ||
3366 | } | ||
3367 | 3375 | ||
3368 | set_current_state(TASK_INTERRUPTIBLE); | 3376 | set_current_state(TASK_INTERRUPTIBLE); |
3369 | 3377 | ||
@@ -4321,6 +4329,7 @@ static void mgsl_add_device( struct mgsl_struct *info ) | |||
4321 | 4329 | ||
4322 | static const struct tty_port_operations mgsl_port_ops = { | 4330 | static const struct tty_port_operations mgsl_port_ops = { |
4323 | .carrier_raised = carrier_raised, | 4331 | .carrier_raised = carrier_raised, |
4332 | .raise_dtr_rts = raise_dtr_rts, | ||
4324 | }; | 4333 | }; |
4325 | 4334 | ||
4326 | 4335 | ||
diff --git a/drivers/char/synclink_gt.c b/drivers/char/synclink_gt.c index 39ccaba8ca37..625c9bde3be8 100644 --- a/drivers/char/synclink_gt.c +++ b/drivers/char/synclink_gt.c | |||
@@ -3143,6 +3143,18 @@ static int carrier_raised(struct tty_port *port) | |||
3143 | return (info->signals & SerialSignal_DCD) ? 1 : 0; | 3143 | return (info->signals & SerialSignal_DCD) ? 1 : 0; |
3144 | } | 3144 | } |
3145 | 3145 | ||
3146 | static void raise_dtr_rts(struct tty_port *port) | ||
3147 | { | ||
3148 | unsigned long flags; | ||
3149 | struct slgt_info *info = container_of(port, struct slgt_info, port); | ||
3150 | |||
3151 | spin_lock_irqsave(&info->lock,flags); | ||
3152 | info->signals |= SerialSignal_RTS + SerialSignal_DTR; | ||
3153 | set_signals(info); | ||
3154 | spin_unlock_irqrestore(&info->lock,flags); | ||
3155 | } | ||
3156 | |||
3157 | |||
3146 | /* | 3158 | /* |
3147 | * block current process until the device is ready to open | 3159 | * block current process until the device is ready to open |
3148 | */ | 3160 | */ |
@@ -3187,12 +3199,8 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp, | |||
3187 | port->blocked_open++; | 3199 | port->blocked_open++; |
3188 | 3200 | ||
3189 | while (1) { | 3201 | while (1) { |
3190 | if ((tty->termios->c_cflag & CBAUD)) { | 3202 | if ((tty->termios->c_cflag & CBAUD)) |
3191 | spin_lock_irqsave(&info->lock,flags); | 3203 | tty_port_raise_dtr_rts(port); |
3192 | info->signals |= SerialSignal_RTS + SerialSignal_DTR; | ||
3193 | set_signals(info); | ||
3194 | spin_unlock_irqrestore(&info->lock,flags); | ||
3195 | } | ||
3196 | 3204 | ||
3197 | set_current_state(TASK_INTERRUPTIBLE); | 3205 | set_current_state(TASK_INTERRUPTIBLE); |
3198 | 3206 | ||
@@ -3455,6 +3463,7 @@ static void add_device(struct slgt_info *info) | |||
3455 | 3463 | ||
3456 | static const struct tty_port_operations slgt_port_ops = { | 3464 | static const struct tty_port_operations slgt_port_ops = { |
3457 | .carrier_raised = carrier_raised, | 3465 | .carrier_raised = carrier_raised, |
3466 | .raise_dtr_rts = raise_dtr_rts, | ||
3458 | }; | 3467 | }; |
3459 | 3468 | ||
3460 | /* | 3469 | /* |
diff --git a/drivers/char/tty_port.c b/drivers/char/tty_port.c index f54e40cbf023..0557b6384747 100644 --- a/drivers/char/tty_port.c +++ b/drivers/char/tty_port.c | |||
@@ -111,3 +111,19 @@ int tty_port_carrier_raised(struct tty_port *port) | |||
111 | return port->ops->carrier_raised(port); | 111 | return port->ops->carrier_raised(port); |
112 | } | 112 | } |
113 | EXPORT_SYMBOL(tty_port_carrier_raised); | 113 | EXPORT_SYMBOL(tty_port_carrier_raised); |
114 | |||
115 | /** | ||
116 | * tty_port_raise_dtr_rts - Riase DTR/RTS | ||
117 | * @port: tty port | ||
118 | * | ||
119 | * Wrapper for the DTR/RTS raise logic. For the moment this is used | ||
120 | * to hide some internal details. This will eventually become entirely | ||
121 | * internal to the tty port. | ||
122 | */ | ||
123 | |||
124 | void tty_port_raise_dtr_rts(struct tty_port *port) | ||
125 | { | ||
126 | if (port->ops->raise_dtr_rts) | ||
127 | port->ops->raise_dtr_rts(port); | ||
128 | } | ||
129 | EXPORT_SYMBOL(tty_port_raise_dtr_rts); | ||