tty updates proposed for 2.6.27
Subsystems (13)
cover tty updates proposed for 2.6.27
This patch series introduces the idea of a tty_port - a common structure that eventually all ports will have. Some drivers are migrated to make partial use of the tty port commonality and helpers but only a little.
On the USB side the USB tty API is changed to fix a whole pile of races where tty->port->tty cannot be assumed to be tty (because of hangup/reopen). The USB drivers all get a spring clean and the entire pile have been dragged into CodingStyle near compliance (some cases where the checkpatch whines that make no sense have been ignored).
Greg: At the end of this series there shouldn't be any white space issues although some earlier patches introduce them and later ones take them away
Aim... load... fire...
---
Alan Cox (70):
tty-usb-mos7720: Coding style
whiteheat: remove unused variable
mos7840: remove loads of bogus assignments to status
omninet: Use string flip functions
tty-usb-omninet: Coding style
tty-usb-option: Coding style
tty-usb-oti6858: Coding style
tty-usb-safe-serial: Coding style
tty-usb-ti-usb: Coding style
tty-usb-spcp8x5: Minor coding style
tty-usb-sierra: Coding style - minor
tty-usb-pl2303: Coding style
mct_u232: Use flip buffer functions
tty-usb-mct-u232: Coding style
kobil_sct: Fix ioctls
tty-usb-kobil-sct: Coding style
keyspan_pda: Use string flip functions
tty-usb-kl5kusb105: Coding style
tty-usb-keyspan-pda: Coding style
keyspan: Use string flip functions when possible
tty-usb-keyspan: Coding style
tty-usb-iuu-phoenix: Clean up to coding style
tty-usb-ir-usb: Clean up to coding style
tty-usb-ipw: Coding style
ipaq: Coding style
io_ti: Minor coding style
usb-serial: Coding style
io_edgeport: Fix various bogus returns to the tty layer
tty-usb-io_edgeport: Coding style
tty-usb-visor: Coding style
tty-usb-hp4x: Fix overlong line
tty-usb-generic: Code cleanup
garmin_gps: Coding style
funsoft: Switch to linux/uaccess
ftdi_sio: Coding style
empeg: Coding style
digi_acceleport: coding style
usb-cypress: There is no 0 case to go with CS5/6/7/8 so remove the test
cypress_m8: coding style
cyberjack: Coding style
cp2101: coding style
tty-usb-console: Fix termios
tty-usb-console: tidy the USB console code
usb-serial-bus: tidy coding style
belkin_sa: clean up code
whiteheat: fix bugs found in the tidy and audit
whiteheat: coding style
usb_serial: API all change
tty: add more tty_port fields
termios: Termios defines for other platforms
cyclades: use tty_port
tty: Clean up tiocmset
synclink: use tty_port
stallion: use tty_port
serial: use tty_port
rocket: use tty_port
mxser: use tty_port
moxa: use tty_port
istallion: use tty_port
isicom: use tty_port
riscom8: remove bogus checks
riscom8: use tty_port
gs: use tty_port
esp: use tty_port
epca: use tty_port
tty.h: clean up
tty: Introduce a tty_port common structure
drivers/serial/: remove CVS keywords
drivers/char/rio/: remove VCS tags
tty: Ldisc revamp
drivers/bluetooth/hci_ldisc.c | 6 drivers/char/cyclades.c | 342 +++-- drivers/char/epca.c | 110 +- drivers/char/epca.h | 7 drivers/char/esp.c | 272 ++-- drivers/char/generic_serial.c | 158 +- drivers/char/ip2/i2lib.c | 4 drivers/char/ip2/ip2main.c | 7 drivers/char/isicom.c | 207 +-- drivers/char/istallion.c | 116 +- drivers/char/moxa.c | 93 + drivers/char/mxser.c | 284 ++-- drivers/char/n_hdlc.c | 6 drivers/char/n_r3964.c | 2 drivers/char/n_tty.c | 2 drivers/char/pcmcia/synclink_cs.c | 4 drivers/char/pty.c | 10 drivers/char/rio/cirrus.h | 3 drivers/char/rio/cmdblk.h | 6 drivers/char/rio/cmdpkt.h | 6 drivers/char/rio/daemon.h | 6 drivers/char/rio/errors.h | 6 drivers/char/rio/func.h | 6 drivers/char/rio/map.h | 4 drivers/char/rio/param.h | 5 drivers/char/rio/parmmap.h | 7 drivers/char/rio/pci.h | 4 drivers/char/rio/protsts.h | 7 drivers/char/rio/rio_linux.c | 25 drivers/char/rio/rioboard.h | 6 drivers/char/rio/riocmd.c | 13 drivers/char/rio/rioctrl.c | 4 drivers/char/rio/riodrvr.h | 4 drivers/char/rio/rioinfo.h | 4 drivers/char/rio/rioinit.c | 3 drivers/char/rio/riointr.c | 14 drivers/char/rio/rioparam.c | 6 drivers/char/rio/rioroute.c | 3 drivers/char/rio/riospace.h | 4 drivers/char/rio/riotable.c | 3 drivers/char/rio/riotty.c | 20 drivers/char/rio/route.h | 6 drivers/char/rio/unixrup.h | 4 drivers/char/riscom8.c | 187 +-- drivers/char/riscom8.h | 10 drivers/char/rocket.c | 139 +- drivers/char/rocket.h | 4 drivers/char/rocket_int.h | 11 drivers/char/selection.c | 3 drivers/char/specialix.c | 153 +- drivers/char/specialix_io8.h | 8 drivers/char/stallion.c | 160 +- drivers/char/sx.c | 115 +- drivers/char/synclink.c | 213 ++- drivers/char/synclink_gt.c | 219 ++- drivers/char/synclinkmp.c | 219 ++- drivers/char/tty_io.c | 420 ++++-- drivers/char/tty_ioctl.c | 16 drivers/input/serio/serport.c | 2 drivers/isdn/capi/capi.c | 4 drivers/isdn/gigaset/ser-gigaset.c | 2 drivers/net/hamradio/6pack.c | 2 drivers/net/hamradio/mkiss.c | 2 drivers/net/irda/irtty-sir.c | 2 drivers/net/ppp_async.c | 2 drivers/net/ppp_synctty.c | 2 drivers/net/slip.c | 2 drivers/net/wan/pc300_tty.c | 4 drivers/net/wan/x25_asy.c | 2 drivers/net/wireless/strip.c | 2 drivers/serial/21285.c | 6 drivers/serial/8250.c | 8 drivers/serial/8250.h | 2 drivers/serial/8250_pci.c | 2 drivers/serial/8250_pnp.c | 2 drivers/serial/Kconfig | 2 drivers/serial/Makefile | 2 drivers/serial/amba-pl010.c | 6 drivers/serial/amba-pl011.c | 2 drivers/serial/clps711x.c | 7 drivers/serial/cpm_uart/cpm_uart_core.c | 4 drivers/serial/jsm/jsm_neo.c | 2 drivers/serial/jsm/jsm_tty.c | 8 drivers/serial/m32r_sio.c | 4 drivers/serial/mpsc.c | 4 drivers/serial/pnx8xxx_uart.c | 2 drivers/serial/sa1100.c | 7 drivers/serial/serial_core.c | 80 + drivers/serial/sunsu.c | 2 drivers/usb/serial/Kconfig | 8 drivers/usb/serial/aircable.c | 19 drivers/usb/serial/airprime.c | 16 drivers/usb/serial/ark3116.c | 32 drivers/usb/serial/belkin_sa.c | 201 ++- drivers/usb/serial/belkin_sa.h | 15 drivers/usb/serial/bus.c | 20 drivers/usb/serial/ch341.c | 10 drivers/usb/serial/console.c | 136 +- drivers/usb/serial/cp2101.c | 381 +++--- drivers/usb/serial/cyberjack.c | 176 +-- drivers/usb/serial/cypress_m8.c | 703 +++++----- drivers/usb/serial/cypress_m8.h | 2 drivers/usb/serial/digi_acceleport.c | 804 ++++++------ drivers/usb/serial/empeg.c | 257 ++-- drivers/usb/serial/ezusb.c | 22 drivers/usb/serial/ftdi_sio.c | 1249 ++++++++++-------- drivers/usb/serial/ftdi_sio.h | 126 +- drivers/usb/serial/funsoft.c | 2 drivers/usb/serial/garmin_gps.c | 400 +++--- drivers/usb/serial/generic.c | 122 +- drivers/usb/serial/hp4x.c | 3 drivers/usb/serial/io_edgeport.c | 2106 +++++++++++++++++-------------- drivers/usb/serial/io_fw_down3.h | 11 drivers/usb/serial/io_tables.h | 6 drivers/usb/serial/io_ti.c | 1924 +++++++++++++--------------- drivers/usb/serial/ipaq.c | 143 +- drivers/usb/serial/ipw.c | 294 ++-- drivers/usb/serial/ir-usb.c | 398 +++--- drivers/usb/serial/iuu_phoenix.c | 58 - drivers/usb/serial/keyspan.c | 969 +++++++------- drivers/usb/serial/keyspan.h | 39 - drivers/usb/serial/keyspan_pda.c | 238 ++-- drivers/usb/serial/kl5kusb105.c | 415 +++--- drivers/usb/serial/kobil_sct.c | 617 +++++---- drivers/usb/serial/mct_u232.c | 364 +++-- drivers/usb/serial/mos7720.c | 308 ++--- drivers/usb/serial/mos7840.c | 557 +++----- drivers/usb/serial/navman.c | 10 drivers/usb/serial/omninet.c | 171 +-- drivers/usb/serial/option.c | 166 +- drivers/usb/serial/oti6858.c | 255 ++-- drivers/usb/serial/pl2303.c | 140 +- drivers/usb/serial/safe_serial.c | 298 ++-- drivers/usb/serial/sierra.c | 95 - drivers/usb/serial/spcp8x5.c | 73 + drivers/usb/serial/ti_fw_3410.h | 4 drivers/usb/serial/ti_fw_5052.h | 5 drivers/usb/serial/ti_usb_3410_5052.c | 460 ++++--- drivers/usb/serial/usb-serial.c | 393 +++--- drivers/usb/serial/visor.c | 384 +++--- drivers/usb/serial/whiteheat.c | 484 ++++--- drivers/usb/serial/whiteheat.h | 78 + fs/proc/proc_tty.c | 48 - include/asm-avr32/ioctls.h | 4 include/asm-frv/ioctls.h | 4 include/asm-frv/termbits.h | 5 include/linux/cyclades.h | 13 include/linux/generic_serial.h | 8 include/linux/hayesesp.h | 9 include/linux/istallion.h | 6 include/linux/serial_core.h | 26 include/linux/stallion.h | 6 include/linux/tty.h | 204 ++- include/linux/tty_ldisc.h | 7 include/linux/usb/serial.h | 56 - net/bluetooth/rfcomm/tty.c | 13 net/irda/ircomm/ircomm_tty.c | 14 157 files changed, 10296 insertions(+), 10160 deletions(-)
Signature · 4 lines
"When you turn it on, listen and smell for anything odd and if it smells
or crackles, shut it off and let me know - that's the one I had to
realign with a hammer because it was slighly damaged in shipping"
-- Michael K JohnsonPATCH 1/70 tty: Ldisc revamp
From: Alan Cox <[email protected]>
Move the line disciplines towards a conventional ->ops arrangement. For the moment the actual 'tty_ldisc' struct in the tty is kept as part of the tty struct but this can then be changed if it turns out that when it all settles down we want to refcount ldiscs separately to the tty.
Pull the ldisc code out of /proc and put it with our ldisc code.
---
drivers/bluetooth/hci_ldisc.c | 6 - drivers/char/cyclades.c | 3 drivers/char/epca.c | 4 drivers/char/ip2/i2lib.c | 4 drivers/char/ip2/ip2main.c | 7 - drivers/char/n_hdlc.c | 6 - drivers/char/n_r3964.c | 2 drivers/char/n_tty.c | 2 drivers/char/pcmcia/synclink_cs.c | 4 drivers/char/pty.c | 10 + drivers/char/selection.c | 3 drivers/char/synclink.c | 4 drivers/char/synclink_gt.c | 4 drivers/char/synclinkmp.c | 4 drivers/char/tty_io.c | 336 +++++++++++++++++++++++------------- drivers/char/tty_ioctl.c | 16 +- drivers/input/serio/serport.c | 2 drivers/isdn/capi/capi.c | 4 drivers/isdn/gigaset/ser-gigaset.c | 2 drivers/net/hamradio/6pack.c | 2 drivers/net/hamradio/mkiss.c | 2 drivers/net/irda/irtty-sir.c | 2 drivers/net/ppp_async.c | 2 drivers/net/ppp_synctty.c | 2 drivers/net/slip.c | 2 drivers/net/wan/pc300_tty.c | 4 drivers/net/wan/x25_asy.c | 2 drivers/net/wireless/strip.c | 2 fs/proc/proc_tty.c | 48 ----- include/linux/tty.h | 9 - include/linux/tty_ldisc.h | 7 + net/bluetooth/rfcomm/tty.c | 13 - net/irda/ircomm/ircomm_tty.c | 14 +- 33 files changed, 287 insertions(+), 247 deletions(-)
drivers/bluetooth/hci_ldisc.c +3 -3
@@ -282,8 +282,8 @@ static int hci_uart_tty_open(struct tty_struct *tty)/* FIXME: why is this needed. Note don't use ldisc_ref here as the open path is before the ldisc is referencable */ -if (tty->ldisc.flush_buffer) - tty->ldisc.flush_buffer (tty); +if (tty->ldisc.ops->flush_buffer) + tty->ldisc.ops->flush_buffer (tty);tty_driver_flush_buffer (tty);return 0 ;
@@ -514,7 +514,7 @@ static unsigned int hci_uart_tty_poll(struct tty_struct *tty,static int __init hci_uart_init (void ) { -static struct tty_ldisc hci_uart_ldisc; +static struct tty_ldisc_ops hci_uart_ldisc;int err;BT_INFO ("HCI UART driver ver %s" ,VERSION );
drivers/char/cyclades.c +2 -1
@@ -5246,7 +5246,8 @@ cyclades_get_proc_info(char *buf, char **start, off_t offset, int length,HZ , info->idle_stats.recv_bytes, (cur_jifs - info->idle_stats.recv_idle)/HZ , info->idle_stats.overruns, - (long)info->tty->ldisc.num); +/* FIXME: double check locking */ + (long)info->tty->ldisc.ops->num); else size = sprintf(buf + len, "%3d %8lu %10lu %8lu " "%10lu %8lu %9lu %6ld\n",
drivers/char/epca.c +2 -2
@@ -2262,8 +2262,8 @@ static int pc_ioctl(struct tty_struct *tty, struct file *file,tty_wait_until_sent (tty,0 ); }else {/* ldisc lock already held in ioctl */ -if (tty->ldisc.flush_buffer) - tty->ldisc.flush_buffer (tty); +if (tty->ldisc.ops->flush_buffer) + tty->ldisc.ops->flush_buffer (tty); }unlock_kernel ();/* Fall Thru */
drivers/char/ip2/i2lib.c +2 -2
@@ -868,11 +868,11 @@ i2Input(i2ChanStrPtr pCh) amountToMove = count; }// Move the first block - pCh->pTTY->ldisc.receive_buf ( pCh->pTTY, + pCh->pTTY->ldisc.ops->receive_buf ( pCh->pTTY, &(pCh->Ibuf[stripIndex]),NULL , amountToMove );// If we needed to wrap, do the second data move if (count > amountToMove) { - pCh->pTTY->ldisc.receive_buf ( pCh->pTTY, + pCh->pTTY->ldisc.ops->receive_buf ( pCh->pTTY, pCh->Ibuf,NULL , count - amountToMove ); }// Bump and wrap the stripIndex all at once by the amount of data read. This
drivers/char/ip2/ip2main.c +4 -3
@@ -1263,11 +1263,12 @@ static void do_input(struct work_struct *work)// code duplicated from n_tty (ldisc) static inline void isig (int sig,struct tty_struct *tty,int flush) { +/* FIXME: This is completely bogus */ if (tty->pgrp)kill_pgrp (tty->pgrp, sig,1 );if (flush || !L_NOFLSH (tty)) { -if ( tty->ldisc.flush_buffer ) - tty->ldisc.flush_buffer (tty); +if ( tty->ldisc.ops->flush_buffer ) + tty->ldisc.ops->flush_buffer (tty);i2InputFlush ( tty->driver_data ); } }
@@ -1316,7 +1317,7 @@ static void do_status(struct work_struct *work) } tmp = pCh->pTTY->real_raw; pCh->pTTY->real_raw =0 ; - pCh->pTTY->ldisc.receive_buf ( pCh->pTTY, &brkc, &brkf,1 ); + pCh->pTTY->ldisc->ops.receive_buf ( pCh->pTTY, &brkc, &brkf,1 ); pCh->pTTY->real_raw = tmp; }#endif /* NEVER_HAPPENS_AS_SETUP_XXX */
drivers/char/n_hdlc.c +3 -3
@@ -199,7 +199,7 @@ static void n_hdlc_tty_wakeup(struct tty_struct *tty);#define tty2n_hdlc (tty) ((struct n_hdlc *) ((tty)->disc_data))#define n_hdlc2tty (n_hdlc) ((n_hdlc)->tty) -static struct tty_ldisc n_hdlc_ldisc = { +static struct tty_ldisc_ops n_hdlc_ldisc = { .owner =THIS_MODULE , .magic =TTY_LDISC_MAGIC , .name ="hdlc" ,
@@ -342,8 +342,8 @@ static int n_hdlc_tty_open (struct tty_struct *tty)#endif /* Flush any pending characters in the driver and discipline. */ -if (tty->ldisc.flush_buffer) - tty->ldisc.flush_buffer (tty); +if (tty->ldisc.ops->flush_buffer) + tty->ldisc.ops->flush_buffer (tty);tty_driver_flush_buffer (tty);
drivers/char/n_r3964.c +1 -1
@@ -143,7 +143,7 @@ static unsigned int r3964_poll(struct tty_struct *tty, struct file *file,static void r3964_receive_buf (struct tty_struct *tty,const unsigned char *cp,char *fp,int count); -static struct tty_ldisc tty_ldisc_N_R3964 = { +static struct tty_ldisc_ops tty_ldisc_N_R3964 = { .owner =THIS_MODULE , .magic =TTY_LDISC_MAGIC , .name ="R3964" ,
drivers/char/n_tty.c +1 -1
@@ -1573,7 +1573,7 @@ static unsigned int normal_poll(struct tty_struct *tty, struct file *file,return mask; } -struct tty_ldisc tty_ldisc_N_TTY = { +struct tty_ldisc_ops tty_ldisc_N_TTY = { .magic =TTY_LDISC_MAGIC , .name ="n_tty" , .open = n_tty_open,
drivers/char/pcmcia/synclink_cs.c +2 -2
@@ -514,8 +514,8 @@ static void ldisc_receive_buf(struct tty_struct *tty,return ; ld =tty_ldisc_ref (tty);if (ld) { -if (ld->receive_buf) - ld->receive_buf (tty, data, flags, count); +if (ld->ops->receive_buf) + ld->ops->receive_buf (tty, data, flags, count);tty_ldisc_deref (ld); } }
drivers/char/pty.c +5 -5
@@ -111,7 +111,7 @@ static int pty_write(struct tty_struct * tty, const unsigned char *buf, int coun c = to->receive_room;if (c > count) c = count; - to->ldisc.receive_buf (to, buf,NULL , c); + to->ldisc.ops->receive_buf (to, buf,NULL , c);return c; }
@@ -149,11 +149,11 @@ static int pty_chars_in_buffer(struct tty_struct *tty)int count;/* We should get the line discipline lock for "tty->link" */ -if (!to || !to->ldisc.chars_in_buffer) +if (!to || !to->ldisc.ops->chars_in_buffer)return 0 ;/* The ldisc must report 0 if no characters available to be read */ - count = to->ldisc.chars_in_buffer (to); + count = to->ldisc.ops->chars_in_buffer (to);if (tty->driver->subtype ==PTY_TYPE_SLAVE )return count;
@@ -186,8 +186,8 @@ static void pty_flush_buffer(struct tty_struct *tty)if (!to)return ; -if (to->ldisc.flush_buffer) - to->ldisc.flush_buffer (to); +if (to->ldisc.ops->flush_buffer) + to->ldisc.ops->flush_buffer (to);if (to->packet) {spin_lock_irqsave (&tty->ctrl_lock, flags);
drivers/char/selection.c +2 -1
@@ -327,7 +327,8 @@ int paste_selection(struct tty_struct *tty) } count = sel_buffer_lth - pasted; count =min (count, tty->receive_room); - tty->ldisc.receive_buf (tty, sel_buffer + pasted,NULL , count); + tty->ldisc.ops->receive_buf (tty, sel_buffer + pasted, +NULL , count); pasted += count; }remove_wait_queue (&vc->paste_wait, &wait);
drivers/char/synclink.c +2 -2
@@ -975,8 +975,8 @@ static void ldisc_receive_buf(struct tty_struct *tty,return ; ld =tty_ldisc_ref (tty);if (ld) { -if (ld->receive_buf) - ld->receive_buf (tty, data, flags, count); +if (ld->ops->receive_buf) + ld->ops->receive_buf (tty, data, flags, count);tty_ldisc_deref (ld); } }
drivers/char/synclink_gt.c +2 -2
@@ -641,8 +641,8 @@ static void ldisc_receive_buf(struct tty_struct *tty,return ; ld =tty_ldisc_ref (tty);if (ld) { -if (ld->receive_buf) - ld->receive_buf (tty, data, flags, count); +if (ld->ops->receive_buf) + ld->ops->receive_buf (tty, data, flags, count);tty_ldisc_deref (ld); } }
drivers/char/synclinkmp.c +2 -2
@@ -712,8 +712,8 @@ static void ldisc_receive_buf(struct tty_struct *tty,return ; ld =tty_ldisc_ref (tty);if (ld) { -if (ld->receive_buf) - ld->receive_buf (tty, data, flags, count); +if (ld->ops->receive_buf) + ld->ops->receive_buf (tty, data, flags, count);tty_ldisc_deref (ld); } }
drivers/char/tty_io.c +213 -123
606 lines not on this page · raw message
drivers/char/tty_ioctl.c +8 -8
@@ -491,8 +491,8 @@ static void change_termios(struct tty_struct *tty, struct ktermios *new_termios) ld =tty_ldisc_ref (tty);if (ld !=NULL ) { -if (ld->set_termios) - (ld->set_termios)(tty, &old_termios); +if (ld->ops->set_termios) + (ld->ops->set_termios)(tty, &old_termios);tty_ldisc_deref (ld); }mutex_unlock (&tty->termios_mutex);
@@ -552,8 +552,8 @@ static int set_termios(struct tty_struct *tty, void __user *arg, int opt) ld =tty_ldisc_ref (tty);if (ld !=NULL ) { -if ((opt &TERMIOS_FLUSH ) && ld->flush_buffer) - ld->flush_buffer (tty); +if ((opt &TERMIOS_FLUSH ) && ld->ops->flush_buffer) + ld->ops->flush_buffer (tty);tty_ldisc_deref (ld); }
@@ -959,12 +959,12 @@ int tty_perform_flush(struct tty_struct *tty, unsigned long arg) ld =tty_ldisc_ref (tty);switch (arg) {case TCIFLUSH : -if (ld && ld->flush_buffer) - ld->flush_buffer (tty); +if (ld && ld->ops->flush_buffer) + ld->ops->flush_buffer (tty);break ;case TCIOFLUSH : -if (ld && ld->flush_buffer) - ld->flush_buffer (tty); +if (ld && ld->ops->flush_buffer) + ld->ops->flush_buffer (tty);/* fall through */ case TCOFLUSH :tty_driver_flush_buffer (tty);
drivers/input/serio/serport.c +1 -1
@@ -216,7 +216,7 @@ static void serport_ldisc_write_wakeup(struct tty_struct * tty)* The line discipline structure. */ -static struct tty_ldisc serport_ldisc = { +static struct tty_ldisc_ops serport_ldisc = { .owner =THIS_MODULE , .name ="input" , .open = serport_ldisc_open,
drivers/isdn/capi/capi.c +2 -2
@@ -465,7 +465,7 @@ static int handle_recv_skb(struct capiminor *mp, struct sk_buff *skb) ld =tty_ldisc_ref (mp->tty);if (ld ==NULL )return -1 ; -if (ld->receive_buf ==NULL ) { +if (ld->ops->receive_buf ==NULL ) {#if defined(_DEBUG_DATAFLOW) || defined(_DEBUG_TTYFUNCS)printk (KERN_DEBUG "capi: ldisc has no receive_buf function\n" );#endif
@@ -500,7 +500,7 @@ static int handle_recv_skb(struct capiminor *mp, struct sk_buff *skb)printk (KERN_DEBUG "capi: DATA_B3_RESP %u len=%d => ldisc\n" , datahandle, skb->len);#endif - ld->receive_buf (mp->tty, skb->data,NULL , skb->len); + ld->ops->receive_buf (mp->tty, skb->data,NULL , skb->len);kfree_skb (skb);tty_ldisc_deref (ld);return 0 ;
drivers/isdn/gigaset/ser-gigaset.c +1 -1
@@ -766,7 +766,7 @@ gigaset_tty_wakeup(struct tty_struct *tty)cs_put (cs); } -static struct tty_ldisc gigaset_ldisc = { +static struct tty_ldisc_ops gigaset_ldisc = { .owner =THIS_MODULE , .magic =TTY_LDISC_MAGIC , .name ="ser_gigaset" ,
drivers/net/hamradio/6pack.c +1 -1
@@ -783,7 +783,7 @@ static int sixpack_ioctl(struct tty_struct *tty, struct file *file,return err; } -static struct tty_ldisc sp_ldisc = { +static struct tty_ldisc_ops sp_ldisc = { .owner =THIS_MODULE , .magic =TTY_LDISC_MAGIC , .name ="6pack" ,
drivers/net/hamradio/mkiss.c +1 -1
@@ -969,7 +969,7 @@ out:mkiss_put (ax); } -static struct tty_ldisc ax_ldisc = { +static struct tty_ldisc_ops ax_ldisc = { .owner =THIS_MODULE , .magic =TTY_LDISC_MAGIC , .name ="mkiss" ,
drivers/net/irda/irtty-sir.c +1 -1
@@ -533,7 +533,7 @@ static void irtty_close(struct tty_struct *tty)/* ------------------------------------------------------- */ -static struct tty_ldisc irda_ldisc = { +static struct tty_ldisc_ops irda_ldisc = { .magic =TTY_LDISC_MAGIC , .name ="irda" , .flags =0 ,
drivers/net/ppp_async.c +1 -1
@@ -378,7 +378,7 @@ ppp_asynctty_wakeup(struct tty_struct *tty) } -static struct tty_ldisc ppp_ldisc = { +static struct tty_ldisc_ops ppp_ldisc = { .owner =THIS_MODULE , .magic =TTY_LDISC_MAGIC , .name ="ppp" ,
drivers/net/ppp_synctty.c +1 -1
@@ -418,7 +418,7 @@ ppp_sync_wakeup(struct tty_struct *tty) } -static struct tty_ldisc ppp_sync_ldisc = { +static struct tty_ldisc_ops ppp_sync_ldisc = { .owner =THIS_MODULE , .magic =TTY_LDISC_MAGIC , .name ="pppsync" ,
drivers/net/slip.c +1 -1
@@ -1301,7 +1301,7 @@ static int sl_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)#endif /* VSV changes end */ -static struct tty_ldisc sl_ldisc = { +static struct tty_ldisc_ops sl_ldisc = { .owner =THIS_MODULE , .magic =TTY_LDISC_MAGIC , .name ="slip" ,
drivers/net/wan/pc300_tty.c +2 -2
@@ -688,9 +688,9 @@ static void cpc_tty_rx_work(struct work_struct *work)if (cpc_tty->tty) { ld =tty_ldisc_ref (cpc_tty->tty);if (ld) { -if (ld->receive_buf) { +if (ld->ops->receive_buf) {CPC_TTY_DBG ("%s: call line disc. receive_buf\n" ,cpc_tty->name); - ld->receive_buf (cpc_tty->tty, (char *)(buf->data), &flags, buf->size); + ld->ops->receive_buf (cpc_tty->tty, (char *)(buf->data), &flags, buf->size); }tty_ldisc_deref (ld); }
drivers/net/wan/x25_asy.c +1 -1
@@ -751,7 +751,7 @@ static void x25_asy_setup(struct net_device *dev) dev->flags =IFF_NOARP ; } -static struct tty_ldisc x25_ldisc = { +static struct tty_ldisc_ops x25_ldisc = { .owner =THIS_MODULE , .magic =TTY_LDISC_MAGIC , .name ="X.25" ,
drivers/net/wireless/strip.c +1 -1
@@ -2728,7 +2728,7 @@ static int strip_ioctl(struct tty_struct *tty, struct file *file,/************************************************************************/ /* Initialization */ -static struct tty_ldisc strip_ldisc = { +static struct tty_ldisc_ops strip_ldisc = { .magic =TTY_LDISC_MAGIC , .name ="strip" , .owner =THIS_MODULE ,
fs/proc/proc_tty.c +0 -48
54 lines not on this page · raw message
include/linux/tty.h +4 -5
@@ -185,6 +185,7 @@ struct tty_struct {struct tty_driver *driver;const struct tty_operations *ops;int index; +/* The ldisc objects are protected by tty_ldisc_lock at the moment */ struct tty_ldisc ldisc;struct mutex termios_mutex;spinlock_t ctrl_lock;
@@ -289,7 +290,7 @@ extern void tty_wait_until_sent(struct tty_struct * tty, long timeout);extern int tty_check_change (struct tty_struct * tty);extern void stop_tty (struct tty_struct * tty);extern void start_tty (struct tty_struct * tty); -extern int tty_register_ldisc (int disc,struct tty_ldisc *new_ldisc); +extern int tty_register_ldisc (int disc,struct tty_ldisc_ops *new_ldisc);extern int tty_unregister_ldisc (int disc);extern int tty_register_driver (struct tty_driver *driver);extern int tty_unregister_driver (struct tty_driver *driver);
@@ -330,9 +331,7 @@ extern int tty_termios_hw_change(struct ktermios *a, struct ktermios *b);extern struct tty_ldisc *tty_ldisc_ref (struct tty_struct *);extern void tty_ldisc_deref (struct tty_ldisc *);extern struct tty_ldisc *tty_ldisc_ref_wait (struct tty_struct *); - -extern struct tty_ldisc *tty_ldisc_get (int ); -extern void tty_ldisc_put (int ); +extern const struct file_operations tty_ldiscs_proc_fops;extern void tty_wakeup (struct tty_struct *tty);extern void tty_ldisc_flush (struct tty_struct *tty);
@@ -354,7 +353,7 @@ extern int tty_write_lock(struct tty_struct *tty, int ndelay);/* n_tty.c */ -extern struct tty_ldisc tty_ldisc_N_TTY; +extern struct tty_ldisc_ops tty_ldisc_N_TTY;/* tty_audit.c */ #ifdef CONFIG_AUDIT
include/linux/tty_ldisc.h +6 -1
@@ -104,7 +104,7 @@#include <linux/fs.h> #include <linux/wait.h> -struct tty_ldisc { +struct tty_ldisc_ops {int magic;char *name;int num;
@@ -142,6 +142,11 @@ struct tty_ldisc {int refcount; }; +struct tty_ldisc { +struct tty_ldisc_ops *ops; +int refcount; +}; +#define TTY_LDISC_MAGIC 0x5403#define LDISC_FLAG_DEFINED 0x00000001
net/bluetooth/rfcomm/tty.c +2 -11
@@ -617,14 +617,7 @@ static void rfcomm_tty_wakeup(unsigned long arg)return ;BT_DBG ("dev %p tty %p" , dev, tty); - -if (test_bit (TTY_DO_WRITE_WAKEUP , &tty->flags) && tty->ldisc.write_wakeup) - (tty->ldisc.write_wakeup)(tty); - -wake_up_interruptible (&tty->write_wait); -#ifdef SERIAL_HAVE_POLL_WAIT -wake_up_interruptible (&tty->poll_wait); -#endif +tty_wakeup (tty); }static int rfcomm_tty_open (struct tty_struct *tty,struct file *filp)
@@ -1005,9 +998,7 @@ static void rfcomm_tty_flush_buffer(struct tty_struct *tty)return ;skb_queue_purge (&dev->dlc->tx_queue); - -if (test_bit (TTY_DO_WRITE_WAKEUP , &tty->flags) && tty->ldisc.write_wakeup) - tty->ldisc.write_wakeup (tty); +tty_wakeup (tty); }static void rfcomm_tty_send_xchar (struct tty_struct *tty,char ch)
net/irda/ircomm/ircomm_tty.c +7 -7
@@ -650,12 +650,7 @@ static void ircomm_tty_do_softint(struct work_struct *work) }/* Check if user (still) wants to be waken up */ -if ((tty->flags & (1 <<TTY_DO_WRITE_WAKEUP )) && - tty->ldisc.write_wakeup) - { - (tty->ldisc.write_wakeup)(tty); - } -wake_up_interruptible (&tty->write_wait); +tty_wakeup (tty); }/*
@@ -1141,6 +1136,7 @@ static int ircomm_tty_data_indication(void *instance, void *sap, struct sk_buff *skb) {struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) instance; +struct tty_ldisc *ld;IRDA_DEBUG (2 ,"%s()\n" , __func__ );
@@ -1173,7 +1169,11 @@ static int ircomm_tty_data_indication(void *instance, void *sap,* involve the flip buffers, since we are not running in an interrupt * handler */ - self->tty->ldisc.receive_buf (self->tty, skb->data,NULL , skb->len); + + ld =tty_ldisc_ref (self->tty); +if (ld) + ld->ops->receive_buf (self->tty, skb->data,NULL , skb->len); +tty_ldisc_deref (ld);/* No need to kfree_skb - see ircomm_ttp_data_indication() */
Re: [PATCH 01/70] tty: Ldisc revamp
Quoted 9 lines · Alan Cox
From: Alan Cox <[email protected]>
Move the line disciplines towards a conventional ->ops arrangement. For the moment the actual '
tty_ldisc' struct in the tty is kept as part of the tty struct but this can then be changed if it turns out that when it all settles down we want to refcount ldiscs separately to the tty.Pull the ldisc code out of /proc and put it with our ldisc code.
[...]
Quoted 4 lines
drivers/char/tty_io.c +0
-0
[...]
drivers/char/tty_io.c static void tty_reset_termios(struct tty_struct *tty) · line 1473
Quoted 9 lines
drivers/char/tty_io.c +1
-1@@ -1386,7 +1467,7 @@ static void tty_reset_termios(struct tty_struct *tty)* do_tty_hangup - actual handler for hangup events * @work: tty device * -* This can be called by the "eventd" kernel thread. That is process +k * This can be called by the "eventd" kernel thread. That is process * synchronous but doesn't hold any locks, so we need to make sure we * have the appropriate locks for what we're doing. *
Sorry for such a trivial comment, but the leading 'k' above looks like a typo.
Louis
Signature · 4 lines
Dr Louis Rilling Kerlabs Skype: louis.rilling Batiment Germanium Phone: (+33|0) 6 80 89 08 23 80 avenue des Buttes de Coesmes http://www.kerlabs.com/ 35700 Rennes
Re: [PATCH 01/70] tty: Ldisc revamp
Quoted 7 lines
Quoted 5 lines
- * This can be called by the "eventd" kernel thread. That is process
+k * This can be called by the "eventd" kernel thread. That is process
* synchronous but doesn't hold any locks, so we need to make sure we
* have the appropriate locks for what we're doing.
*Sorry for such a trivial comment, but the leading 'k' above looks like a typo.
Thanks. I'll swat that in a follow up patch. Well spotted
PATCH 2/70 drivers/char/rio/: remove VCS tags
In reply to Alan CoxFrom: Adrian Bunk <[email protected]>
This patch removes ancient VCS tags (either protected by #ifdef SCCS_LABELS or commented out).
---
drivers/char/rio/cirrus.h | 3 --- drivers/char/rio/cmdblk.h | 6 ------ drivers/char/rio/cmdpkt.h | 6 ------ drivers/char/rio/daemon.h | 6 ------ drivers/char/rio/errors.h | 6 ------ drivers/char/rio/func.h | 6 ------ drivers/char/rio/map.h | 4 ---- drivers/char/rio/param.h | 5 ----- drivers/char/rio/parmmap.h | 7 ------- drivers/char/rio/pci.h | 4 ---- drivers/char/rio/protsts.h | 7 ------- drivers/char/rio/rio_linux.c | 5 ----- drivers/char/rio/rioboard.h | 6 ------ drivers/char/rio/riocmd.c | 3 --- drivers/char/rio/rioctrl.c | 4 ---- drivers/char/rio/riodrvr.h | 4 ---- drivers/char/rio/rioinfo.h | 4 ---- drivers/char/rio/rioinit.c | 3 --- drivers/char/rio/riointr.c | 4 ---- drivers/char/rio/rioparam.c | 4 ---- drivers/char/rio/rioroute.c | 3 --- drivers/char/rio/riospace.h | 4 ---- drivers/char/rio/riotable.c | 3 --- drivers/char/rio/riotty.c | 4 ---- drivers/char/rio/route.h | 6 ------ drivers/char/rio/unixrup.h | 4 ---- 26 files changed, 0 insertions(+), 121 deletions(-)
drivers/char/rio/cirrus.h +0 -3
@@ -35,9 +35,6 @@***************************************************************************/ #ifndef _cirrus_h -#ifndef lint -/* static char* _cirrus_h_sccs = "@(#)cirrus.h 1.16"; */ -#endif #define _cirrus_h 1/* Bit fields for particular registers shared with driver */
drivers/char/rio/cmdblk.h +0 -6
@@ -33,12 +33,6 @@#ifndef __rio_cmdblk_h__#define __rio_cmdblk_h__ -#ifdef SCCS_LABELS -#ifndef lint -static char *_cmdblk_h_sccs_ ="@(#)cmdblk.h 1.2" ; -#endif -#endif -/* ** the structure of a command block, used to queue commands destined for ** a rup.
drivers/char/rio/cmdpkt.h +0 -6
@@ -32,12 +32,6 @@#ifndef __rio_cmdpkt_h__#define __rio_cmdpkt_h__ -#ifdef SCCS_LABELS -#ifndef lint -static char *_cmdpkt_h_sccs_ ="@(#)cmdpkt.h 1.2" ; -#endif -#endif -/* ** overlays for the data area of a packet. Used in both directions ** (to build a packet to send, and to interpret a packet that arrives)
drivers/char/rio/daemon.h +0 -6
@@ -33,12 +33,6 @@#ifndef __rio_daemon_h__#define __rio_daemon_h__ -#ifdef SCCS_LABELS -#ifndef lint -static char *_daemon_h_sccs_ ="@(#)daemon.h 1.3" ; -#endif -#endif -/* ** structures used on /dev/rio
drivers/char/rio/errors.h +0 -6
@@ -33,12 +33,6 @@#ifndef __rio_errors_h__#define __rio_errors_h__ -#ifdef SCCS_LABELS -#ifndef lint -static char *_errors_h_sccs_ ="@(#)errors.h 1.2" ; -#endif -#endif -/* ** error codes */
drivers/char/rio/func.h +0 -6
@@ -35,12 +35,6 @@#include <linux/kdev_t.h> -#ifdef SCCS_LABELS -#ifndef lint -static char *_func_h_sccs_ ="@(#)func.h 1.3" ; -#endif -#endif -/* rioboot.c */ int RIOBootCodeRTA (struct rio_info *,struct DownLoad *);int RIOBootCodeHOST (struct rio_info *,struct DownLoad *);
drivers/char/rio/map.h +0 -4
@@ -33,10 +33,6 @@#ifndef __rio_map_h__#define __rio_map_h__ -#ifdef SCCS_LABELS -static char *_map_h_sccs_ ="@(#)map.h 1.2" ; -#endif -/* ** mapping structure passed to and from the config.rio program to ** determine the current topology of the world
drivers/char/rio/param.h +0 -5
@@ -33,11 +33,6 @@#ifndef __rio_param_h__#define __rio_param_h__ -#ifdef SCCS_LABELS -static char *_param_h_sccs_ ="@(#)param.h 1.2" ; -#endif - -/* ** the param command block, as used in OPEN and PARAM calls. */
drivers/char/rio/parmmap.h +0 -7
@@ -37,13 +37,6 @@#ifndef _parmap_h#define _parmap_h - -#ifdef SCCS_LABELS -#ifndef lint -/* static char *_rio_parmmap_h_sccs = "@(#)parmmap.h 1.4"; */ -#endif -#endif -typedef struct PARM_MAP PARM_MAP ; struct PARM_MAP {
drivers/char/rio/pci.h +0 -4
@@ -33,10 +33,6 @@#ifndef __rio_pci_h__#define __rio_pci_h__ -#ifdef SCCS_LABELS -static char *_pci_h_sccs_ ="@(#)pci.h 1.2" ; -#endif -/* ** PCI stuff */
drivers/char/rio/protsts.h +0 -7
@@ -37,13 +37,6 @@#ifndef _protsts_h#define _protsts_h 1 - -#ifdef SCCS_LABELS -#ifndef lint -/* static char *_rio_protsts_h_sccs = "@(#)protsts.h 1.4"; */ -#endif -#endif -/************************************************* * ACK bit. Last Packet received OK. Set by * rxpkt to indicate that the Packet has been
drivers/char/rio/rio_linux.c +0 -5
@@ -25,11 +25,6 @@* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, * USA. * -* Revision history: -* $Log: rio.c,v $ -* Revision 1.1 1999/07/11 10:13:54 wolff -* Initial revision -* * */ #include <linux/module.h>
drivers/char/rio/rioboard.h +0 -6
@@ -29,12 +29,6 @@/* */ /************************************************************************/ -/* History... - -1.0.0 26/04/99 NPV Creation. - -*/ -#ifndef _rioboard_h/* If RIOBOARD.H not already defined */ #define _rioboard_h 1
drivers/char/rio/riocmd.c +0 -3
@@ -30,9 +30,6 @@** ** ----------------------------------------------------------------------------- */ -#ifdef SCCS_LABELS -static char *_riocmd_c_sccs_ ="@(#)riocmd.c 1.2" ; -#endif #include <linux/module.h> #include <linux/slab.h>
drivers/char/rio/rioctrl.c +0 -4
@@ -29,10 +29,6 @@** ** ----------------------------------------------------------------------------- */ -#ifdef SCCS_LABELS -static char *_rioctrl_c_sccs_ ="@(#)rioctrl.c 1.3" ; -#endif -#include <linux/module.h> #include <linux/slab.h>
drivers/char/rio/riodrvr.h +0 -4
@@ -35,10 +35,6 @@#include <asm/param.h> /* for HZ */ -#ifdef SCCS_LABELS -static char *_riodrvr_h_sccs_ ="@(#)riodrvr.h 1.3" ; -#endif -#define MEMDUMP_SIZE 32#define MOD_DISABLE (RIO_NOREAD|RIO_NOWRITE|RIO_NOXPRINT)
drivers/char/rio/rioinfo.h +0 -4
@@ -33,10 +33,6 @@#ifndef __rioinfo_h#define __rioinfo_h -#ifdef SCCS_LABELS -static char *_rioinfo_h_sccs_ ="@(#)rioinfo.h 1.2" ; -#endif -/* ** Host card data structure */
drivers/char/rio/rioinit.c +0 -3
@@ -29,9 +29,6 @@** ** ----------------------------------------------------------------------------- */ -#ifdef SCCS_LABELS -static char *_rioinit_c_sccs_ ="@(#)rioinit.c 1.3" ; -#endif #include <linux/module.h> #include <linux/slab.h>
drivers/char/rio/riointr.c +0 -4
@@ -29,10 +29,6 @@** ** ----------------------------------------------------------------------------- */ -#ifdef SCCS_LABELS -static char *_riointr_c_sccs_ ="@(#)riointr.c 1.2" ; -#endif -#include <linux/module.h> #include <linux/slab.h>
drivers/char/rio/rioparam.c +0 -4
@@ -30,10 +30,6 @@** ----------------------------------------------------------------------------- */ -#ifdef SCCS_LABELS -static char *_rioparam_c_sccs_ ="@(#)rioparam.c 1.3" ; -#endif -#include <linux/module.h> #include <linux/slab.h> #include <linux/errno.h>
drivers/char/rio/rioroute.c +0 -3
@@ -29,9 +29,6 @@** ** ----------------------------------------------------------------------------- */ -#ifdef SCCS_LABELS -static char *_rioroute_c_sccs_ ="@(#)rioroute.c 1.3" ; -#endif #include <linux/module.h> #include <linux/slab.h>
drivers/char/rio/riospace.h +0 -4
@@ -33,10 +33,6 @@#ifndef __rio_riospace_h__#define __rio_riospace_h__ -#ifdef SCCS_LABELS -static char *_riospace_h_sccs_ ="@(#)riospace.h 1.2" ; -#endif -#define RIO_LOCATOR_LEN 16#define MAX_RIO_BOARDS 4
drivers/char/rio/riotable.c +0 -3
@@ -29,9 +29,6 @@** ** ----------------------------------------------------------------------------- */ -#ifdef SCCS_LABELS -static char *_riotable_c_sccs_ ="@(#)riotable.c 1.2" ; -#endif #include <linux/module.h> #include <linux/slab.h>
drivers/char/rio/riotty.c +0 -4
@@ -29,10 +29,6 @@** ** ----------------------------------------------------------------------------- */ -#ifdef SCCS_LABELS -static char *_riotty_c_sccs_ ="@(#)riotty.c 1.3" ; -#endif -#define __EXPLICIT_DEF_H__
drivers/char/rio/route.h +0 -6
@@ -37,12 +37,6 @@#ifndef _route_h#define _route_h -#ifdef SCCS_LABELS -#ifndef lint -/* static char *_rio_route_h_sccs = "@(#)route.h 1.3"; */ -#endif -#endif -#define MAX_LINKS 4#define MAX_NODES 17/* Maximum nodes in a subnet */ #define NODE_BYTES ((MAX_NODES / 8) + 1)/* Number of bytes needed for
drivers/char/rio/unixrup.h +0 -4
@@ -33,10 +33,6 @@#ifndef __rio_unixrup_h__#define __rio_unixrup_h__ -#ifdef SCCS_LABELS -static char *_unixrup_h_sccs_ ="@(#)unixrup.h 1.2" ; -#endif -/* ** UnixRup data structure. This contains pointers to actual RUPs on the ** host card, and all the command/boot control stuff.
PATCH 3/70 drivers/serial/: remove CVS keywords
In reply to Alan CoxFrom: Adrian Bunk <[email protected]>
This patch removes CVS keywords that weren't updated for a long time in comments, printk's and MODULE_DESCRIPTION's (no printk's or MODULE_DESCRIPTION's are completely removed).
While doing this I also found and fixed a missing \n in a printk in m32r_sio.c
---
drivers/serial/21285.c | 6 ++---- drivers/serial/8250.c | 6 ++---- drivers/serial/8250.h | 2 -- drivers/serial/8250_pci.c | 2 -- drivers/serial/8250_pnp.c | 2 -- drivers/serial/Kconfig | 2 -- drivers/serial/Makefile | 2 -- drivers/serial/amba-pl010.c | 6 ++---- drivers/serial/amba-pl011.c | 2 -- drivers/serial/clps711x.c | 7 ++----- drivers/serial/cpm_uart/cpm_uart_core.c | 4 ++-- drivers/serial/m32r_sio.c | 4 ++-- drivers/serial/mpsc.c | 4 ++-- drivers/serial/pnx8xxx_uart.c | 2 +- drivers/serial/sa1100.c | 7 ++----- drivers/serial/sunsu.c | 2 +- 16 files changed, 18 insertions(+), 42 deletions(-)
drivers/serial/21285.c +2 -4
@@ -4,8 +4,6 @@* Driver for the serial port on the 21285 StrongArm-110 core logic chip. * * Based on drivers/char/serial.c -* -* $Id: 21285.c,v 1.37 2002/07/28 10:03:27 rmk Exp $ */ #include <linux/module.h> #include <linux/tty.h>
@@ -494,7 +492,7 @@ static int __init serial21285_init(void) {int ret; -printk (KERN_INFO "Serial: 21285 driver $Revision: 1.37 $\n" ); +printk (KERN_INFO "Serial: 21285 driver\n" );serial21285_setup_ports ();
@@ -515,5 +513,5 @@ module_init(serial21285_init);module_exit (serial21285_exit);MODULE_LICENSE ("GPL" ); -MODULE_DESCRIPTION ("Intel Footbridge (21285) serial driver $Revision: 1.37 $" ); +MODULE_DESCRIPTION ("Intel Footbridge (21285) serial driver" );MODULE_ALIAS_CHARDEV (SERIAL_21285_MAJOR ,SERIAL_21285_MINOR );
drivers/serial/8250.c +2 -4
@@ -12,8 +12,6 @@* the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * -* $Id: 8250.c,v 1.90 2002/07/28 10:03:27 rmk Exp $ -* * A note about mapbase / membase * * mapbase is the physical address of the IO port.
@@ -2931,7 +2929,7 @@ static int __init serial8250_init(void)if (nr_uarts >UART_NR ) nr_uarts =UART_NR ; -printk (KERN_INFO "Serial: 8250/16550 driver $Revision: 1.90 $ " +printk (KERN_INFO "Serial: 8250/16550 driver" "%d ports, IRQ sharing %sabled\n" , nr_uarts, share_irqs ?"en" :"dis" );
@@ -2992,7 +2990,7 @@ EXPORT_SYMBOL(serial8250_suspend_port);EXPORT_SYMBOL (serial8250_resume_port);MODULE_LICENSE ("GPL" ); -MODULE_DESCRIPTION ("Generic 8250/16x50 serial driver $Revision: 1.90 $" ); +MODULE_DESCRIPTION ("Generic 8250/16x50 serial driver" );module_param (share_irqs, uint,0644 ); MODULE_PARM_DESC(share_irqs, "Share IRQs with other non-8250/16x50 devices"
drivers/serial/8250.h +0 -2
@@ -11,8 +11,6 @@* it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. -* -* $Id: 8250.h,v 1.8 2002/07/21 21:32:30 rmk Exp $ */ #include <linux/serial_8250.h>
drivers/serial/8250_pci.c +0 -2
@@ -10,8 +10,6 @@* This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License. -* -* $Id: 8250_pci.c,v 1.28 2002/11/02 11:14:18 rmk Exp $ */ #include <linux/module.h> #include <linux/init.h>
drivers/serial/8250_pnp.c +0 -2
@@ -12,8 +12,6 @@* This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License. -* -* $Id: 8250_pnp.c,v 1.10 2002/07/21 21:32:30 rmk Exp $ */ #include <linux/module.h> #include <linux/init.h>
drivers/serial/Kconfig +0 -2
@@ -1,8 +1,6 @@ # # Serial device configuration # -# $Id: Kconfig,v 1.11 2004/03/11 18:08:04 lethal Exp $ -# menu "Serial drivers" depends on HAS_IOMEM
drivers/serial/Makefile +0 -2
@@ -1,8 +1,6 @@ # # Makefile for the kernel serial device drivers. # -# $Id: Makefile,v 1.8 2002/07/21 21:32:30 rmk Exp $ -# obj-$(CONFIG_SERIAL_CORE) += serial_core.o obj-$(CONFIG_SERIAL_21285) += 21285.o
drivers/serial/amba-pl010.c +2 -4
@@ -22,8 +22,6 @@* along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * -* $Id: amba.c,v 1.41 2002/07/28 10:03:27 rmk Exp $ -* * This is a generic driver for ARM AMBA-type serial ports. They * have a lot of 16550-like features, but are not register compatible. * Note that although they do have CTS, DCD and DSR inputs, they do
@@ -791,7 +789,7 @@ static int __init pl010_init(void) {int ret; -printk (KERN_INFO "Serial: AMBA driver $Revision: 1.41 $\n" ); +printk (KERN_INFO "Serial: AMBA driver\n" ); ret =uart_register_driver (&amba_reg);if (ret ==0 ) {
@@ -812,5 +810,5 @@ module_init(pl010_init);module_exit (pl010_exit);MODULE_AUTHOR ("ARM Ltd/Deep Blue Solutions Ltd" ); -MODULE_DESCRIPTION ("ARM AMBA serial port driver $Revision: 1.41 $" ); +MODULE_DESCRIPTION ("ARM AMBA serial port driver" );MODULE_LICENSE ("GPL" );
drivers/serial/amba-pl011.c +0 -2
@@ -22,8 +22,6 @@* along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * -* $Id: amba.c,v 1.41 2002/07/28 10:03:27 rmk Exp $ -* * This is a generic driver for ARM AMBA-type serial ports. They * have a lot of 16550-like features, but are not register compatible. * Note that although they do have CTS, DCD and DSR inputs, they do
drivers/serial/clps711x.c +2 -5
@@ -21,9 +21,6 @@* You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* $Id: clps711x.c,v 1.42 2002/07/28 10:03:28 rmk Exp $ -* */ #if defined(CONFIG_SERIAL_CLPS711X_CONSOLE ) && defined(CONFIG_MAGIC_SYSRQ )
@@ -551,7 +548,7 @@ static int __init clps711xuart_init(void) {int ret, i; -printk (KERN_INFO "Serial: CLPS711x driver $Revision: 1.42 $\n" ); +printk (KERN_INFO "Serial: CLPS711x driver\n" ); ret =uart_register_driver (&clps711x_reg);if (ret)
@@ -577,6 +574,6 @@ module_init(clps711xuart_init);module_exit (clps711xuart_exit);MODULE_AUTHOR ("Deep Blue Solutions Ltd" ); -MODULE_DESCRIPTION ("CLPS-711x generic serial driver $Revision: 1.42 $" ); +MODULE_DESCRIPTION ("CLPS-711x generic serial driver" );MODULE_LICENSE ("GPL" );MODULE_ALIAS_CHARDEV (SERIAL_CLPS711X_MAJOR ,SERIAL_CLPS711X_MINOR );
drivers/serial/cpm_uart/cpm_uart_core.c +2 -2
@@ -1530,7 +1530,7 @@ static int cpm_uart_init(void) {int ret;int i;struct device *dev; -printk (KERN_INFO "Serial: CPM driver $Revision: 0.02 $\n" ); +printk (KERN_INFO "Serial: CPM driver\n" );/* lookup the bus for uart devices */ dev =bus_find_device (&platform_bus_type,NULL ,0 , match_is_uart);
@@ -1591,6 +1591,6 @@ module_init(cpm_uart_init);module_exit (cpm_uart_exit);MODULE_AUTHOR ("Kumar Gala/Antoniou Pantelis" ); -MODULE_DESCRIPTION ("CPM SCC/SMC port driver $Revision: 0.01 $" ); +MODULE_DESCRIPTION ("CPM SCC/SMC port driver" );MODULE_LICENSE ("GPL" );MODULE_ALIAS_CHARDEV (SERIAL_CPM_MAJOR ,SERIAL_CPM_MINOR );
drivers/serial/m32r_sio.c +2 -2
@@ -1160,7 +1160,7 @@ static int __init m32r_sio_init(void) {int ret, i; -printk (KERN_INFO "Serial: M32R SIO driver $Revision: 1.11 $ " ); +printk (KERN_INFO "Serial: M32R SIO driver\n" );for (i =0 ; i <NR_IRQS ; i++)spin_lock_init (&irq_lists[i].lock);
@@ -1189,4 +1189,4 @@ EXPORT_SYMBOL(m32r_sio_suspend_port);EXPORT_SYMBOL (m32r_sio_resume_port);MODULE_LICENSE ("GPL" ); -MODULE_DESCRIPTION ("Generic M32R SIO serial driver $Revision: 1.11 $" ); +MODULE_DESCRIPTION ("Generic M32R SIO serial driver" );
drivers/serial/mpsc.c +2 -2
@@ -1972,7 +1972,7 @@ static int __init mpsc_drv_init(void) {int rc; -printk (KERN_INFO "Serial: MPSC driver $Revision: 1.00 $\n" ); +printk (KERN_INFO "Serial: MPSC driver\n" );memset (mpsc_ports,0 ,sizeof (mpsc_ports));memset (&mpsc_shared_regs,0 ,sizeof (mpsc_shared_regs));
@@ -2004,7 +2004,7 @@ module_init(mpsc_drv_init);module_exit (mpsc_drv_exit);MODULE_AUTHOR ("Mark A. Greer <[email protected]>" ); -MODULE_DESCRIPTION ("Generic Marvell MPSC serial/UART driver $Revision: 1.00 $" ); +MODULE_DESCRIPTION ("Generic Marvell MPSC serial/UART driver" );MODULE_VERSION (MPSC_VERSION );MODULE_LICENSE ("GPL" );MODULE_ALIAS_CHARDEV_MAJOR (MPSC_MAJOR );
drivers/serial/pnx8xxx_uart.c +1 -1
@@ -824,7 +824,7 @@ static int __init pnx8xxx_serial_init(void) {int ret; -printk (KERN_INFO "Serial: PNX8XXX driver $Revision: 1.2 $\n" ); +printk (KERN_INFO "Serial: PNX8XXX driver\n" );pnx8xxx_init_ports ();
drivers/serial/sa1100.c +2 -5
@@ -20,9 +20,6 @@* You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* $Id: sa1100.c,v 1.50 2002/07/29 14:41:04 rmk Exp $ -* */ #if defined(CONFIG_SERIAL_SA1100_CONSOLE ) && defined(CONFIG_MAGIC_SYSRQ )
@@ -892,7 +889,7 @@ static int __init sa1100_serial_init(void) {int ret; -printk (KERN_INFO "Serial: SA11x0 driver $Revision: 1.50 $\n" ); +printk (KERN_INFO "Serial: SA11x0 driver\n" );sa1100_init_ports ();
@@ -915,7 +912,7 @@ module_init(sa1100_serial_init);module_exit (sa1100_serial_exit);MODULE_AUTHOR ("Deep Blue Solutions Ltd" ); -MODULE_DESCRIPTION ("SA1100 generic serial port driver $Revision: 1.50 $" ); +MODULE_DESCRIPTION ("SA1100 generic serial port driver" );MODULE_LICENSE ("GPL" );MODULE_ALIAS_CHARDEV_MAJOR (SERIAL_SA1100_MAJOR );MODULE_ALIAS ("platform:sa11x0-uart" );
drivers/serial/sunsu.c +1 -1
@@ -1,4 +1,4 @@ -/* $Id: su.c,v 1.55 2002/01/08 16:00:16 davem Exp $ +/* * su.c: Small serial driver for keyboard/mouse interface on sparc32/PCI * * Copyright (C) 1997 Eddie C. Dost ([email protected])
PATCH 4/70 tty: Introduce a tty_port common structure
In reply to Alan CoxFrom: Alan Cox <[email protected]>
Every tty driver has its own concept of a port structure and because they all differ we cannot extract commonality. Begin fixing this by creating a structure drivers can elect to use so that over time we can push fields into this and create commonality and then introduce common methods.
---
drivers/char/tty_io.c | 34 ++++++++++++++++++++++++++++++++++ include/linux/tty.h | 30 +++++++++++++++++++++++++++++- 2 files changed, 63 insertions(+), 1 deletions(-)
drivers/char/tty_io.c +34 -0
@@ -2088,6 +2088,40 @@ ssize_t redirected_tty_write(struct file *file, const char __user *buf,return tty_write (file, buf, count, ppos); } +void tty_port_init (struct tty_port *port) +{ +memset (port,0 ,sizeof (*port)); +init_waitqueue_head (&port->open_wait); +init_waitqueue_head (&port->close_wait); +mutex_init (&port->mutex); +} +EXPORT_SYMBOL (tty_port_init); + +int tty_port_alloc_xmit_buf (struct tty_port *port) +{ +/* We may sleep in get_zeroed_page() */ +mutex_lock (&port->mutex); +if (port->xmit_buf ==NULL ) + port->xmit_buf = (unsigned char *)get_zeroed_page (GFP_KERNEL ); +mutex_unlock (&port->mutex); +if (port->xmit_buf ==NULL ) +return -ENOMEM ; +return 0 ; +} +EXPORT_SYMBOL (tty_port_alloc_xmit_buf); + +void tty_port_free_xmit_buf (struct tty_port *port) +{ +mutex_lock (&port->mutex); +if (port->xmit_buf !=NULL ) { +free_page ((unsigned long )port->xmit_buf); + port->xmit_buf =NULL ; + } +mutex_unlock (&port->mutex); +} +EXPORT_SYMBOL (tty_port_free_xmit_buf); + +static char ptychar[] ="pqrstuvwxyzabcde" ;/**
include/linux/tty.h +29 -1
@@ -166,6 +166,29 @@ struct tty_bufhead {struct device ;struct signal_struct ; + +/* +* Port level information. Each device keeps its own port level information +* so provide a common structure for those ports wanting to use common support +* routines. +* +* The tty port has a different lifetime to the tty so must be kept apart. +* In addition be careful as tty -> port mappings are valid for the life +* of the tty object but in many cases port -> tty mappings are valid only +* until a hangup so don't use the wrong path. +*/ + +struct tty_port { +struct tty_struct *tty;/* Back pointer */ +int blocked_open;/* Waiting to open */ +int count;/* Usage count */ +wait_queue_head_t open_wait;/* Open waiters */ +wait_queue_head_t close_wait;/* Close waiters */ +unsigned long flags;/* TTY flags ASY_*/ +struct mutex mutex;/* Locking */ +unsigned char *xmit_buf;/* Optional buffer */ +}; +/* * Where all of the state associated with a tty is kept while the tty * is open. Since the termios state should be kept even if the tty
@@ -214,7 +237,7 @@ struct tty_struct {struct list_head tty_files;#define N_TTY_BUF_SIZE 4096 - +/* * The following is data for the N_TTY line discipline. For * historical reasons, this is included in the tty structure.
@@ -242,6 +265,7 @@ struct tty_struct {spinlock_t read_lock;/* If the tty has a pending do_SAK, queue it here - akpm */ struct work_struct SAK_work; +struct tty_port *port; };/* tty magic number */
@@ -350,6 +374,10 @@ extern void tty_write_unlock(struct tty_struct *tty);extern int tty_write_lock (struct tty_struct *tty,int ndelay);#define tty_is_writelocked (tty) (mutex_is_locked(&tty->atomic_write_lock)) +extern void tty_port_init (struct tty_port *port); +extern int tty_port_alloc_xmit_buf (struct tty_port *port); +extern void tty_port_free_xmit_buf (struct tty_port *port); +/* n_tty.c */
PATCH 5/70 tty.h: clean up
In reply to Alan CoxFrom: Alan Cox <[email protected]>
Coding style clean up and white space tidy
---
include/linux/tty.h | 165 ++++++++++++++++++++++++++------------------------- 1 files changed, 85 insertions(+), 80 deletions(-)
include/linux/tty.h +85 -80
@@ -71,7 +71,8 @@ struct tty_bufhead {struct tty_buffer *head;/* Queue head */ struct tty_buffer *tail;/* Active buffer */ struct tty_buffer *free;/* Free queue head */ -int memory_used;/* Buffer space used excluding free queue */ +int memory_used;/* Buffer space used excluding +free queue */ };/* * When a break, frame error, or parity error happens, these codes are
@@ -101,68 +102,68 @@ struct tty_bufhead {#define LNEXT_CHAR (tty) ((tty)->termios->c_cc[VLNEXT])#define EOL2_CHAR (tty) ((tty)->termios->c_cc[VEOL2]) -#define _I_FLAG (tty,f) ((tty)->termios->c_iflag & (f)) -#define _O_FLAG (tty,f) ((tty)->termios->c_oflag & (f)) -#define _C_FLAG (tty,f) ((tty)->termios->c_cflag & (f)) -#define _L_FLAG (tty,f) ((tty)->termios->c_lflag & (f)) - -#define I_IGNBRK (tty) _I_FLAG((tty),IGNBRK) -#define I_BRKINT (tty) _I_FLAG((tty),BRKINT) -#define I_IGNPAR (tty) _I_FLAG((tty),IGNPAR) -#define I_PARMRK (tty) _I_FLAG((tty),PARMRK) -#define I_INPCK (tty) _I_FLAG((tty),INPCK) -#define I_ISTRIP (tty) _I_FLAG((tty),ISTRIP) -#define I_INLCR (tty) _I_FLAG((tty),INLCR) -#define I_IGNCR (tty) _I_FLAG((tty),IGNCR) -#define I_ICRNL (tty) _I_FLAG((tty),ICRNL) -#define I_IUCLC (tty) _I_FLAG((tty),IUCLC) -#define I_IXON (tty) _I_FLAG((tty),IXON) -#define I_IXANY (tty) _I_FLAG((tty),IXANY) -#define I_IXOFF (tty) _I_FLAG((tty),IXOFF) -#define I_IMAXBEL (tty) _I_FLAG((tty),IMAXBEL) -#define I_IUTF8 (tty) _I_FLAG((tty),IUTF8) - -#define O_OPOST (tty) _O_FLAG((tty),OPOST) -#define O_OLCUC (tty) _O_FLAG((tty),OLCUC) -#define O_ONLCR (tty) _O_FLAG((tty),ONLCR) -#define O_OCRNL (tty) _O_FLAG((tty),OCRNL) -#define O_ONOCR (tty) _O_FLAG((tty),ONOCR) -#define O_ONLRET (tty) _O_FLAG((tty),ONLRET) -#define O_OFILL (tty) _O_FLAG((tty),OFILL) -#define O_OFDEL (tty) _O_FLAG((tty),OFDEL) -#define O_NLDLY (tty) _O_FLAG((tty),NLDLY) -#define O_CRDLY (tty) _O_FLAG((tty),CRDLY) -#define O_TABDLY (tty) _O_FLAG((tty),TABDLY) -#define O_BSDLY (tty) _O_FLAG((tty),BSDLY) -#define O_VTDLY (tty) _O_FLAG((tty),VTDLY) -#define O_FFDLY (tty) _O_FLAG((tty),FFDLY) - -#define C_BAUD (tty) _C_FLAG((tty),CBAUD) -#define C_CSIZE (tty) _C_FLAG((tty),CSIZE) -#define C_CSTOPB (tty) _C_FLAG((tty),CSTOPB) -#define C_CREAD (tty) _C_FLAG((tty),CREAD) -#define C_PARENB (tty) _C_FLAG((tty),PARENB) -#define C_PARODD (tty) _C_FLAG((tty),PARODD) -#define C_HUPCL (tty) _C_FLAG((tty),HUPCL) -#define C_CLOCAL (tty) _C_FLAG((tty),CLOCAL) -#define C_CIBAUD (tty) _C_FLAG((tty),CIBAUD) -#define C_CRTSCTS (tty) _C_FLAG((tty),CRTSCTS) - -#define L_ISIG (tty) _L_FLAG((tty),ISIG) -#define L_ICANON (tty) _L_FLAG((tty),ICANON) -#define L_XCASE (tty) _L_FLAG((tty),XCASE) -#define L_ECHO (tty) _L_FLAG((tty),ECHO) -#define L_ECHOE (tty) _L_FLAG((tty),ECHOE) -#define L_ECHOK (tty) _L_FLAG((tty),ECHOK) -#define L_ECHONL (tty) _L_FLAG((tty),ECHONL) -#define L_NOFLSH (tty) _L_FLAG((tty),NOFLSH) -#define L_TOSTOP (tty) _L_FLAG((tty),TOSTOP) -#define L_ECHOCTL (tty) _L_FLAG((tty),ECHOCTL) -#define L_ECHOPRT (tty) _L_FLAG((tty),ECHOPRT) -#define L_ECHOKE (tty) _L_FLAG((tty),ECHOKE) -#define L_FLUSHO (tty) _L_FLAG((tty),FLUSHO) -#define L_PENDIN (tty) _L_FLAG((tty),PENDIN) -#define L_IEXTEN (tty) _L_FLAG((tty),IEXTEN) +#define _I_FLAG (tty, f) ((tty)->termios->c_iflag & (f)) +#define _O_FLAG (tty, f) ((tty)->termios->c_oflag & (f)) +#define _C_FLAG (tty, f) ((tty)->termios->c_cflag & (f)) +#define _L_FLAG (tty, f) ((tty)->termios->c_lflag & (f)) + +#define I_IGNBRK (tty) _I_FLAG((tty), IGNBRK) +#define I_BRKINT (tty) _I_FLAG((tty), BRKINT) +#define I_IGNPAR (tty) _I_FLAG((tty), IGNPAR) +#define I_PARMRK (tty) _I_FLAG((tty), PARMRK) +#define I_INPCK (tty) _I_FLAG((tty), INPCK) +#define I_ISTRIP (tty) _I_FLAG((tty), ISTRIP) +#define I_INLCR (tty) _I_FLAG((tty), INLCR) +#define I_IGNCR (tty) _I_FLAG((tty), IGNCR) +#define I_ICRNL (tty) _I_FLAG((tty), ICRNL) +#define I_IUCLC (tty) _I_FLAG((tty), IUCLC) +#define I_IXON (tty) _I_FLAG((tty), IXON) +#define I_IXANY (tty) _I_FLAG((tty), IXANY) +#define I_IXOFF (tty) _I_FLAG((tty), IXOFF) +#define I_IMAXBEL (tty) _I_FLAG((tty), IMAXBEL) +#define I_IUTF8 (tty) _I_FLAG((tty), IUTF8) + +#define O_OPOST (tty) _O_FLAG((tty), OPOST) +#define O_OLCUC (tty) _O_FLAG((tty), OLCUC) +#define O_ONLCR (tty) _O_FLAG((tty), ONLCR) +#define O_OCRNL (tty) _O_FLAG((tty), OCRNL) +#define O_ONOCR (tty) _O_FLAG((tty), ONOCR) +#define O_ONLRET (tty) _O_FLAG((tty), ONLRET) +#define O_OFILL (tty) _O_FLAG((tty), OFILL) +#define O_OFDEL (tty) _O_FLAG((tty), OFDEL) +#define O_NLDLY (tty) _O_FLAG((tty), NLDLY) +#define O_CRDLY (tty) _O_FLAG((tty), CRDLY) +#define O_TABDLY (tty) _O_FLAG((tty), TABDLY) +#define O_BSDLY (tty) _O_FLAG((tty), BSDLY) +#define O_VTDLY (tty) _O_FLAG((tty), VTDLY) +#define O_FFDLY (tty) _O_FLAG((tty), FFDLY) + +#define C_BAUD (tty) _C_FLAG((tty), CBAUD) +#define C_CSIZE (tty) _C_FLAG((tty), CSIZE) +#define C_CSTOPB (tty) _C_FLAG((tty), CSTOPB) +#define C_CREAD (tty) _C_FLAG((tty), CREAD) +#define C_PARENB (tty) _C_FLAG((tty), PARENB) +#define C_PARODD (tty) _C_FLAG((tty), PARODD) +#define C_HUPCL (tty) _C_FLAG((tty), HUPCL) +#define C_CLOCAL (tty) _C_FLAG((tty), CLOCAL) +#define C_CIBAUD (tty) _C_FLAG((tty), CIBAUD) +#define C_CRTSCTS (tty) _C_FLAG((tty), CRTSCTS) + +#define L_ISIG (tty) _L_FLAG((tty), ISIG) +#define L_ICANON (tty) _L_FLAG((tty), ICANON) +#define L_XCASE (tty) _L_FLAG((tty), XCASE) +#define L_ECHO (tty) _L_FLAG((tty), ECHO) +#define L_ECHOE (tty) _L_FLAG((tty), ECHOE) +#define L_ECHOK (tty) _L_FLAG((tty), ECHOK) +#define L_ECHONL (tty) _L_FLAG((tty), ECHONL) +#define L_NOFLSH (tty) _L_FLAG((tty), NOFLSH) +#define L_TOSTOP (tty) _L_FLAG((tty), TOSTOP) +#define L_ECHOCTL (tty) _L_FLAG((tty), ECHOCTL) +#define L_ECHOPRT (tty) _L_FLAG((tty), ECHOPRT) +#define L_ECHOKE (tty) _L_FLAG((tty), ECHOKE) +#define L_FLUSHO (tty) _L_FLAG((tty), FLUSHO) +#define L_PENDIN (tty) _L_FLAG((tty), PENDIN) +#define L_IEXTEN (tty) _L_FLAG((tty), IEXTEN)struct device ;struct signal_struct ;
@@ -177,7 +178,7 @@ struct signal_struct;* of the tty object but in many cases port -> tty mappings are valid only * until a hangup so don't use the wrong path. */ - +struct tty_port {struct tty_struct *tty;/* Back pointer */ int blocked_open;/* Waiting to open */
@@ -273,14 +274,14 @@ struct tty_struct {/* * These bits are used in the flags field of the tty structure. -* +* * So that interrupts won't be able to mess up the queues, * copy_to_cooked must be atomic with respect to itself, as must * tty->write. Thus, you must use the inline functions set_bit() and * clear_bit() to make things atomic. */ #define TTY_THROTTLED 0/* Call unthrottle() at threshold min */ -#define TTY_IO_ERROR 1/* Canse an I/O error (may be no ldisc too) */ +#define TTY_IO_ERROR 1/* Cause an I/O error (may be no ldisc too) */ #define TTY_OTHER_CLOSED 2/* Other side (if any) has closed */ #define TTY_EXCLUSIVE 3/* Exclusive open mode */ #define TTY_DEBUG 4/* Debugging */
@@ -310,10 +311,10 @@ extern int vcs_init(void);extern int tty_paranoia_check (struct tty_struct *tty,struct inode *inode,const char *routine);extern char *tty_name (struct tty_struct *tty,char *buf); -extern void tty_wait_until_sent (struct tty_struct * tty,long timeout); -extern int tty_check_change (struct tty_struct * tty); -extern void stop_tty (struct tty_struct * tty); -extern void start_tty (struct tty_struct * tty); +extern void tty_wait_until_sent (struct tty_struct *tty,long timeout); +extern int tty_check_change (struct tty_struct *tty); +extern void stop_tty (struct tty_struct *tty); +extern void start_tty (struct tty_struct *tty);extern int tty_register_ldisc (int disc,struct tty_ldisc_ops *new_ldisc);extern int tty_unregister_ldisc (int disc);extern int tty_register_driver (struct tty_driver *driver);
@@ -335,10 +336,10 @@ extern int is_current_pgrp_orphaned(void);extern struct pid *tty_get_pgrp (struct tty_struct *tty);extern int is_ignored (int sig);extern int tty_signal (int sig,struct tty_struct *tty); -extern void tty_hangup (struct tty_struct * tty); -extern void tty_vhangup (struct tty_struct * tty); +extern void tty_hangup (struct tty_struct *tty); +extern void tty_vhangup (struct tty_struct *tty);extern void tty_unhangup (struct file *filp); -extern int tty_hung_up_p (struct file * filp); +extern int tty_hung_up_p (struct file *filp);extern void do_SAK (struct tty_struct *tty);extern void __do_SAK (struct tty_struct *tty);extern void disassociate_ctty (int priv);
@@ -347,8 +348,10 @@ extern void tty_flip_buffer_push(struct tty_struct *tty);extern speed_t tty_get_baud_rate (struct tty_struct *tty);extern speed_t tty_termios_baud_rate (struct ktermios *termios);extern speed_t tty_termios_input_baud_rate (struct ktermios *termios); -extern void tty_termios_encode_baud_rate (struct ktermios *termios,speed_t ibaud,speed_t obaud); -extern void tty_encode_baud_rate (struct tty_struct *tty,speed_t ibaud,speed_t obaud); +extern void tty_termios_encode_baud_rate (struct ktermios *termios, +speed_t ibaud,speed_t obaud); +extern void tty_encode_baud_rate (struct tty_struct *tty, +speed_t ibaud,speed_t obaud);extern void tty_termios_copy_hw (struct ktermios *new,struct ktermios *old);extern int tty_termios_hw_change (struct ktermios *a,struct ktermios *b);
@@ -390,7 +393,8 @@ extern void tty_audit_add_data(struct tty_struct *tty, unsigned char *data,extern void tty_audit_exit (void );extern void tty_audit_fork (struct signal_struct *sig);extern void tty_audit_push (struct tty_struct *tty); -extern void tty_audit_push_task (struct task_struct *tsk,uid_t loginuid,u32 sessionid); +extern void tty_audit_push_task (struct task_struct *tsk, +uid_t loginuid,u32 sessionid);#else static inline void tty_audit_add_data (struct tty_struct *tty,unsigned char *data,size_t size)
@@ -405,19 +409,20 @@ static inline void tty_audit_fork(struct signal_struct *sig)static inline void tty_audit_push (struct tty_struct *tty) { } -static inline void tty_audit_push_task (struct task_struct *tsk,uid_t loginuid,u32 sessionid) +static inline void tty_audit_push_task (struct task_struct *tsk, +uid_t loginuid,u32 sessionid) { }#endif /* tty_ioctl.c */ -extern int n_tty_ioctl (struct tty_struct * tty,struct file * file, +extern int n_tty_ioctl (struct tty_struct *tty,struct file *file,unsigned int cmd,unsigned long arg);/* serial.c */ extern void serial_console_init (void ); - +/* pcxx.c */ extern int pcxe_open (struct tty_struct *tty,struct file *filp);
@@ -428,7 +433,7 @@ extern void console_print(const char *);/* vt.c */ -extern int vt_ioctl (struct tty_struct *tty,struct file * file, +extern int vt_ioctl (struct tty_struct *tty,struct file *file,unsigned int cmd,unsigned long arg);#endif /* __KERNEL__ */
PATCH 6/70 epca: use tty_port
In reply to Alan CoxFrom: Alan Cox <[email protected]>
Switch the EPCA driver to include and begin using a tty_port structure
---
drivers/char/epca.c | 106 ++++++++++++++++++++++++++------------------------- drivers/char/epca.h | 7 --- 2 files changed, 54 insertions(+), 59 deletions(-)
drivers/char/epca.c +53 -53
@@ -432,7 +432,7 @@ static void pc_close(struct tty_struct *tty, struct file *filp)spin_unlock_irqrestore (&epca_lock, flags);return ; } -if (ch->count-- >1 ) { +if (ch->port.count-- >1 ) {/* Begin channel is open more than once */ /* * Return without doing anything. Someone might still
@@ -442,19 +442,19 @@ static void pc_close(struct tty_struct *tty, struct file *filp)return ; }/* Port open only once go ahead with shutdown & reset */ -BUG_ON (ch->count <0 ); +BUG_ON (ch->port.count <0 );/* * Let the rest of the driver know the channel is being closed. * This becomes important if an open is attempted before close * is finished. */ - ch->asyncflags |=ASYNC_CLOSING ; + ch->port.flags |=ASYNC_CLOSING ; tty->closing =1 ;spin_unlock_irqrestore (&epca_lock, flags); -if (ch->asyncflags &ASYNC_INITIALIZED ) { +if (ch->port.flags &ASYNC_INITIALIZED ) {/* Setup an event to indicate when the transmit buffer empties */ setup_empty_event (tty, ch);
@@ -469,17 +469,17 @@ static void pc_close(struct tty_struct *tty, struct file *filp)spin_lock_irqsave (&epca_lock, flags); tty->closing =0 ; ch->event =0 ; - ch->tty =NULL ; + ch->port.tty =NULL ;spin_unlock_irqrestore (&epca_lock, flags); -if (ch->blocked_open) { +if (ch->port.blocked_open) {if (ch->close_delay)msleep_interruptible (jiffies_to_msecs (ch->close_delay)); -wake_up_interruptible (&ch->open_wait); +wake_up_interruptible (&ch->port.open_wait); } - ch->asyncflags &= ~(ASYNC_NORMAL_ACTIVE |ASYNC_INITIALIZED | + ch->port.flags &= ~(ASYNC_NORMAL_ACTIVE |ASYNC_INITIALIZED |ASYNC_CLOSING ); -wake_up_interruptible (&ch->close_wait); +wake_up_interruptible (&ch->port.close_wait); } }
@@ -489,7 +489,7 @@ static void shutdown(struct channel *ch)struct tty_struct *tty;struct board_chan __iomem *bc; -if (!(ch->asyncflags &ASYNC_INITIALIZED )) +if (!(ch->port.flags &ASYNC_INITIALIZED ))return ;spin_lock_irqsave (&epca_lock, flags);
@@ -504,7 +504,7 @@ static void shutdown(struct channel *ch)*/ if (bc)writeb (0 , &bc->idata); - tty = ch->tty; + tty = ch->port.tty;/* If we're a modem control device and HUPCL is on, drop RTS & DTR. */ if (tty->termios->c_cflag &HUPCL ) {
@@ -518,7 +518,7 @@ static void shutdown(struct channel *ch)* will have to reinitialized. Set a flag to indicate this. */ /* Prevent future Digi programmed interrupts from coming active */ - ch->asyncflags &= ~ASYNC_INITIALIZED ; + ch->port.flags &= ~ASYNC_INITIALIZED ;spin_unlock_irqrestore (&epca_lock, flags); }
@@ -538,12 +538,12 @@ static void pc_hangup(struct tty_struct *tty)shutdown (ch);spin_lock_irqsave (&epca_lock, flags); - ch->tty =NULL ; + ch->port.tty =NULL ; ch->event =0 ; - ch->count =0 ; - ch->asyncflags &= ~(ASYNC_NORMAL_ACTIVE |ASYNC_INITIALIZED ); + ch->port.count =0 ; + ch->port.flags &= ~(ASYNC_NORMAL_ACTIVE |ASYNC_INITIALIZED );spin_unlock_irqrestore (&epca_lock, flags); -wake_up_interruptible (&ch->open_wait); +wake_up_interruptible (&ch->port.open_wait); } }
@@ -795,7 +795,7 @@ static int block_til_ready(struct tty_struct *tty,unsigned long flags;if (tty_hung_up_p (filp)) { -if (ch->asyncflags &ASYNC_HUP_NOTIFY ) +if (ch->port.flags &ASYNC_HUP_NOTIFY ) retval = -EAGAIN ;else retval = -ERESTARTSYS ;
@@ -806,10 +806,10 @@ static int block_til_ready(struct tty_struct *tty,* If the device is in the middle of being closed, then block until * it's done, and then try again. */ -if (ch->asyncflags &ASYNC_CLOSING ) { -interruptible_sleep_on (&ch->close_wait); +if (ch->port.flags &ASYNC_CLOSING ) { +interruptible_sleep_on (&ch->port.close_wait); -if (ch->asyncflags &ASYNC_HUP_NOTIFY ) +if (ch->port.flags &ASYNC_HUP_NOTIFY )return -EAGAIN ;else return -ERESTARTSYS ;
@@ -820,7 +820,7 @@ static int block_til_ready(struct tty_struct *tty,* If non-blocking mode is set, then make the check up front * and then exit. */ - ch->asyncflags |=ASYNC_NORMAL_ACTIVE ; + ch->port.flags |=ASYNC_NORMAL_ACTIVE ;return 0 ; }if (tty->termios->c_cflag &CLOCAL )
@@ -828,24 +828,24 @@ static int block_til_ready(struct tty_struct *tty,/* Block waiting for the carrier detect and the line to become free */ retval =0 ; -add_wait_queue (&ch->open_wait, &wait); +add_wait_queue (&ch->port.open_wait, &wait);spin_lock_irqsave (&epca_lock, flags);/* We dec count so that pc_close will know when to free things */ if (!tty_hung_up_p (filp)) - ch->count--; - ch->blocked_open++; + ch->port.count--; + ch->port.blocked_open++;while (1 ) {set_current_state (TASK_INTERRUPTIBLE );if (tty_hung_up_p (filp) || - !(ch->asyncflags &ASYNC_INITIALIZED )) { -if (ch->asyncflags &ASYNC_HUP_NOTIFY ) + !(ch->port.flags &ASYNC_INITIALIZED )) { +if (ch->port.flags &ASYNC_HUP_NOTIFY ) retval = -EAGAIN ;else retval = -ERESTARTSYS ;break ; } -if (!(ch->asyncflags &ASYNC_CLOSING ) && +if (!(ch->port.flags &ASYNC_CLOSING ) && (do_clocal || (ch->imodem & ch->dcd)))break ;if (signal_pending (current)) {
@@ -864,17 +864,17 @@ static int block_til_ready(struct tty_struct *tty, }__set_current_state (TASK_RUNNING ); -remove_wait_queue (&ch->open_wait, &wait); +remove_wait_queue (&ch->port.open_wait, &wait);if (!tty_hung_up_p (filp)) - ch->count++; - ch->blocked_open--; + ch->port.count++; + ch->port.blocked_open--;spin_unlock_irqrestore (&epca_lock, flags);if (retval)return retval; - ch->asyncflags |=ASYNC_NORMAL_ACTIVE ; + ch->port.flags |=ASYNC_NORMAL_ACTIVE ;return 0 ; }
@@ -933,7 +933,7 @@ static int pc_open(struct tty_struct *tty, struct file *filp)* necessary because we do not wish to flush and shutdown the channel * until the last app holding the channel open, closes it. */ - ch->count++; + ch->port.count++;/* * Set a kernel structures pointer to our local channel structure. This * way we can get to it when passed only a tty struct.
@@ -957,14 +957,14 @@ static int pc_open(struct tty_struct *tty, struct file *filp)writew (head, &bc->rout);/* Set the channels associated tty structure */ - ch->tty = tty; + ch->port.tty = tty;/* * The below routine generally sets up parity, baud, flow control * issues, etc.... It effect both control flags and input flags. */ epcaparam (tty, ch); - ch->asyncflags |=ASYNC_INITIALIZED ; + ch->port.flags |=ASYNC_INITIALIZED ;memoff (ch);spin_unlock_irqrestore (&epca_lock, flags);
@@ -976,7 +976,7 @@ static int pc_open(struct tty_struct *tty, struct file *filp)* waiting for the line... */ spin_lock_irqsave (&epca_lock, flags); - ch->tty = tty; + ch->port.tty = tty;globalwinon (ch);/* Enable Digi Data events */ writeb (1 , &bc->idata);
@@ -1017,8 +1017,8 @@ static void __exit epca_module_exit(void) } ch = card_ptr[crd];for (count =0 ; count < bd->numports; count++, ch++) { -if (ch && ch->tty) -tty_hangup (ch->tty); +if (ch && ch->port.tty) +tty_hangup (ch->port.tty); } }pci_unregister_driver (&epca_driver);
@@ -1427,7 +1427,7 @@ static void post_fep_init(unsigned int crd) ch->boardnum = crd; ch->channelnum = i; ch->magic =EPCA_MAGIC ; - ch->tty =NULL ; + ch->port.tty =NULL ;if (shrinkmem) {fepcmd (ch,SETBUFFER ,32 ,0 ,0 ,0 );
@@ -1510,10 +1510,10 @@ static void post_fep_init(unsigned int crd) ch->fepstopca =0 ; ch->close_delay =50 ; - ch->count =0 ; - ch->blocked_open =0 ; -init_waitqueue_head (&ch->open_wait); -init_waitqueue_head (&ch->close_wait); + ch->port.count =0 ; + ch->port.blocked_open =0 ; +init_waitqueue_head (&ch->port.open_wait); +init_waitqueue_head (&ch->port.close_wait);spin_unlock_irqrestore (&epca_lock, flags); }
@@ -1633,15 +1633,15 @@ static void doevent(int crd)if (event &MODEMCHG_IND ) {/* A modem signal change has been indicated */ ch->imodem = mstat; -if (ch->asyncflags &ASYNC_CHECK_CD ) { +if (ch->port.flags &ASYNC_CHECK_CD ) {/* We are now receiving dcd */ if (mstat & ch->dcd) -wake_up_interruptible (&ch->open_wait); +wake_up_interruptible (&ch->port.open_wait);else /* No dcd; hangup */ pc_sched_event (ch,EPCA_EVENT_HANGUP ); } } - tty = ch->tty; + tty = ch->port.tty;if (tty) {if (event &BREAK_IND ) {/* A break has been indicated */
@@ -1880,9 +1880,9 @@ static void epcaparam(struct tty_struct *tty, struct channel *ch)* that the driver will wait on carrier detect. */ if (ts->c_cflag &CLOCAL ) - ch->asyncflags &= ~ASYNC_CHECK_CD ; + ch->port.flags &= ~ASYNC_CHECK_CD ;else - ch->asyncflags |=ASYNC_CHECK_CD ; + ch->port.flags |=ASYNC_CHECK_CD ; mval = ch->m_dtr | ch->m_rts; }/* End CBAUD not detected */ iflag =termios2digi_i (ch, ts->c_iflag);
@@ -1972,7 +1972,7 @@ static void receive_data(struct channel *ch)globalwinon (ch);if (ch->statusflags &RXSTOPPED )return ; - tty = ch->tty; + tty = ch->port.tty;if (tty) ts = tty->termios; bc = ch->brdchan;
@@ -2032,7 +2032,7 @@ static void receive_data(struct channel *ch)globalwinon (ch);writew (tail, &bc->rout);/* Must be called with global data */ -tty_schedule_flip (ch->tty); +tty_schedule_flip (ch->port.tty); } static int info_ioctl(struct tty_struct *tty, struct file *file,
@@ -2376,7 +2376,7 @@ static void pc_set_termios(struct tty_struct *tty, struct ktermios *old_termios)if (!(old_termios->c_cflag &CLOCAL ) && (tty->termios->c_cflag &CLOCAL )) -wake_up_interruptible (&ch->open_wait); +wake_up_interruptible (&ch->port.open_wait); }/* End if channel valid */ }
@@ -2386,13 +2386,13 @@ static void do_softint(struct work_struct *work) struct channel *ch = container_of(work, struct channel, tqueue);/* Called in response to a modem change event */ if (ch && ch->magic ==EPCA_MAGIC ) { -struct tty_struct *tty = ch->tty; +struct tty_struct *tty = ch->port.tty;if (tty && tty->driver_data) {if (test_and_clear_bit (EPCA_EVENT_HANGUP , &ch->event)) {tty_hangup (tty); -wake_up_interruptible (&ch->open_wait); - ch->asyncflags &= ~ASYNC_NORMAL_ACTIVE ; +wake_up_interruptible (&ch->port.open_wait); + ch->port.flags &= ~ASYNC_NORMAL_ACTIVE ; } } }
drivers/char/epca.h +1 -6
@@ -84,6 +84,7 @@ static char *board_desc[] =struct channel {long magic; +struct tty_port port;unsigned char boardnum;unsigned char channelnum;unsigned char omodem;/* FEP output modem status */
@@ -117,10 +118,7 @@ struct channelunsigned short rxbufhead;unsigned short rxbufsize;int close_delay; -int count; -int blocked_open;unsigned long event; -int asyncflags;uint dev;unsigned long statusflags;unsigned long c_iflag;
@@ -132,9 +130,6 @@ struct channelstruct board_info *board;struct board_chan __iomem *brdchan;struct digi_struct digiext; -struct tty_struct *tty; -wait_queue_head_t open_wait; -wait_queue_head_t close_wait;struct work_struct tqueue;struct global_data __iomem *mailbox; };
PATCH 7/70 esp: use tty_port
In reply to Alan CoxFrom: Alan Cox <[email protected]>
Switch esp to use the new tty_port structures
---
drivers/char/esp.c | 272 +++++++++++++++++++++++----------------------- include/linux/hayesesp.h | 9 -- 2 files changed, 138 insertions(+), 143 deletions(-)
drivers/char/esp.c +136 -136
@@ -128,9 +128,9 @@ static struct tty_driver *esp_driver;#if defined(MODULE ) && defined(SERIAL_DEBUG_MCOUNT )#define DBG_CNT (s) printk(KERN_DEBUG "(%s): [%x] refc=%d, serc=%d, ttyc=%d -> %s\n", \ - tty->name, info->flags, \ + tty->name, info->port.flags, \ serial_driver.refcount, \ - info->count, tty->count, s) + info->port.count, tty->count, s)#else #define DBG_CNT (s)#endif
@@ -172,13 +172,13 @@ static inline int serial_paranoia_check(struct esp_struct *info,static inline unsigned int serial_in (struct esp_struct *info,int offset) { -return inb (info->port + offset); +return inb (info->io_port + offset); }static inline void serial_out (struct esp_struct *info,int offset,unsigned char value) { -outb (value, info->port+offset); +outb (value, info->io_port+offset); }/*
@@ -273,7 +273,7 @@ static inline void release_pio_buffer(struct esp_pio_buffer *buf)static inline void receive_chars_pio (struct esp_struct *info,int num_bytes) { -struct tty_struct *tty = info->tty; +struct tty_struct *tty = info->port.tty;int i;struct esp_pio_buffer *pio_buf;struct esp_pio_buffer *err_buf;
@@ -295,7 +295,7 @@ static inline void receive_chars_pio(struct esp_struct *info, int num_bytes)for (i =0 ; i < num_bytes -1 ; i +=2 ) { *((unsigned short *)(pio_buf->data + i)) = -inw (info->port +UART_ESI_RX ); +inw (info->io_port +UART_ESI_RX ); err_buf->data[i] =serial_in (info,UART_ESI_RWS ); err_buf->data[i +1 ] = (err_buf->data[i] >>3 ) & status_mask; err_buf->data[i] &= status_mask;
@@ -308,7 +308,7 @@ static inline void receive_chars_pio(struct esp_struct *info, int num_bytes) }/* make sure everything is still ok since interrupts were enabled */ - tty = info->tty; + tty = info->port.tty;if (!tty) {release_pio_buffer (pio_buf);
@@ -325,7 +325,7 @@ static inline void receive_chars_pio(struct esp_struct *info, int num_bytes)if (err_buf->data[i] &0x04 ) { flag =TTY_BREAK ; -if (info->flags &ASYNC_SAK ) +if (info->port.flags &ASYNC_SAK )do_SAK (tty); }else if (err_buf->data[i] &0x02 ) flag =TTY_FRAME ;
@@ -370,7 +370,7 @@ static void receive_chars_dma(struct esp_struct *info, int num_bytes)static inline void receive_chars_dma_done (struct esp_struct *info,int status) { -struct tty_struct *tty = info->tty; +struct tty_struct *tty = info->port.tty;int num_bytes;unsigned long flags;
@@ -396,7 +396,7 @@ static inline void receive_chars_dma_done(struct esp_struct *info,if (status &0x10 ) { statflag =TTY_BREAK ; (info->icount.brk)++; -if (info->flags &ASYNC_SAK ) +if (info->port.flags &ASYNC_SAK )do_SAK (tty); }else if (status &0x08 ) { statflag =TTY_FRAME ;
@@ -451,7 +451,7 @@ static inline void transmit_chars_pio(struct esp_struct *info,for (i =0 ; i < space_avail -1 ; i +=2 ) {outw (*((unsigned short *)(pio_buf->data + i)), - info->port +UART_ESI_TX ); + info->io_port +UART_ESI_TX ); }if (space_avail &0x0001 )
@@ -470,8 +470,8 @@ static inline void transmit_chars_pio(struct esp_struct *info, }if (info->xmit_cnt <WAKEUP_CHARS ) { -if (info->tty) -tty_wakeup (info->tty); +if (info->port.tty) +tty_wakeup (info->port.tty);#ifdef SERIAL_DEBUG_INTR printk ("THRE..." );
@@ -507,8 +507,8 @@ static inline void transmit_chars_dma(struct esp_struct *info, int num_bytes) info->xmit_tail = (info->xmit_tail + dma_bytes) & (ESP_XMIT_SIZE -1 );if (info->xmit_cnt <WAKEUP_CHARS ) { -if (info->tty) -tty_wakeup (info->tty); +if (info->port.tty) +tty_wakeup (info->port.tty);#ifdef SERIAL_DEBUG_INTR printk ("THRE..." );
@@ -575,18 +575,18 @@ static void check_modem_status(struct esp_struct *info)wake_up_interruptible (&info->delta_msr_wait); } -if ((info->flags &ASYNC_CHECK_CD ) && (status &UART_MSR_DDCD )) { +if ((info->port.flags &ASYNC_CHECK_CD ) && (status &UART_MSR_DDCD )) {#if (defined(SERIAL_DEBUG_OPEN ) || defined(SERIAL_DEBUG_INTR ))printk ("ttys%d CD now %s..." , info->line, (status &UART_MSR_DCD ) ?"on" :"off" );#endif if (status &UART_MSR_DCD ) -wake_up_interruptible (&info->open_wait); +wake_up_interruptible (&info->port.open_wait);else {#ifdef SERIAL_DEBUG_OPEN printk ("scheduling hangup..." );#endif -tty_hangup (info->tty); +tty_hangup (info->port.tty); } } }
@@ -609,7 +609,7 @@ static irqreturn_t rs_interrupt_single(int irq, void *dev_id)spin_lock (&info->lock); -if (!info->tty) { +if (!info->port.tty) {spin_unlock (&info->lock);return IRQ_NONE ; }
@@ -647,7 +647,7 @@ static irqreturn_t rs_interrupt_single(int irq, void *dev_id) num_bytes =serial_in (info,UART_ESI_STAT1 ) <<8 ; num_bytes |=serial_in (info,UART_ESI_STAT2 ); - num_bytes =tty_buffer_request_room (info->tty, num_bytes); + num_bytes =tty_buffer_request_room (info->port.tty, num_bytes);if (num_bytes) { if (dma_bytes ||
@@ -661,7 +661,7 @@ static irqreturn_t rs_interrupt_single(int irq, void *dev_id)if (!(info->stat_flags & (ESP_STAT_DMA_RX |ESP_STAT_DMA_TX )) && (scratch &0x02 ) && (info->IER &UART_IER_THRI )) { -if ((info->xmit_cnt <=0 ) || info->tty->stopped) { +if ((info->xmit_cnt <=0 ) || info->port.tty->stopped) { info->IER &= ~UART_IER_THRI ;serial_out (info,UART_ESI_CMD1 ,ESI_SET_SRV_MASK );serial_out (info,UART_ESI_CMD2 , info->IER);
@@ -782,7 +782,7 @@ static int startup(struct esp_struct *info)spin_lock_irqsave (&info->lock, flags); -if (info->flags &ASYNC_INITIALIZED ) +if (info->port.flags &ASYNC_INITIALIZED ) goto out;if (!info->xmit_buf) {
@@ -806,7 +806,7 @@ static int startup(struct esp_struct *info) num_chars |=serial_in (info,UART_ESI_STAT2 );while (num_chars >1 ) { -inw (info->port +UART_ESI_RX ); +inw (info->io_port +UART_ESI_RX ); num_chars -=2 ; }
@@ -834,9 +834,9 @@ static int startup(struct esp_struct *info)if (retval) {if (capable (CAP_SYS_ADMIN )) { -if (info->tty) +if (info->port.tty)set_bit (TTY_IO_ERROR , - &info->tty->flags); + &info->port.tty->flags); retval =0 ; } goto out_unlocked;
@@ -874,30 +874,30 @@ static int startup(struct esp_struct *info)serial_out (info,UART_ESI_CMD1 ,ESI_SET_SRV_MASK );serial_out (info,UART_ESI_CMD2 , info->IER); -if (info->tty) -clear_bit (TTY_IO_ERROR , &info->tty->flags); +if (info->port.tty) +clear_bit (TTY_IO_ERROR , &info->port.tty->flags); info->xmit_cnt = info->xmit_head = info->xmit_tail =0 ;spin_unlock_irqrestore (&info->lock, flags);/* * Set up the tty->alt_speed kludge */ -if (info->tty) { -if ((info->flags &ASYNC_SPD_MASK ) ==ASYNC_SPD_HI ) - info->tty->alt_speed =57600 ; -if ((info->flags &ASYNC_SPD_MASK ) ==ASYNC_SPD_VHI ) - info->tty->alt_speed =115200 ; -if ((info->flags &ASYNC_SPD_MASK ) ==ASYNC_SPD_SHI ) - info->tty->alt_speed =230400 ; -if ((info->flags &ASYNC_SPD_MASK ) ==ASYNC_SPD_WARP ) - info->tty->alt_speed =460800 ; +if (info->port.tty) { +if ((info->port.flags &ASYNC_SPD_MASK ) ==ASYNC_SPD_HI ) + info->port.tty->alt_speed =57600 ; +if ((info->port.flags &ASYNC_SPD_MASK ) ==ASYNC_SPD_VHI ) + info->port.tty->alt_speed =115200 ; +if ((info->port.flags &ASYNC_SPD_MASK ) ==ASYNC_SPD_SHI ) + info->port.tty->alt_speed =230400 ; +if ((info->port.flags &ASYNC_SPD_MASK ) ==ASYNC_SPD_WARP ) + info->port.tty->alt_speed =460800 ; }/* * set the speed of the serial port */ change_speed (info); - info->flags |=ASYNC_INITIALIZED ; + info->port.flags |=ASYNC_INITIALIZED ;return 0 ; out:
@@ -914,7 +914,7 @@ static void shutdown(struct esp_struct *info) {unsigned long flags, f; -if (!(info->flags &ASYNC_INITIALIZED )) +if (!(info->port.flags &ASYNC_INITIALIZED ))return ;#ifdef SERIAL_DEBUG_OPEN
@@ -951,7 +951,7 @@ static void shutdown(struct esp_struct *info)while (current_port) {if ((current_port != info) && - (current_port->flags &ASYNC_INITIALIZED )) + (current_port->port.flags &ASYNC_INITIALIZED ))break ; current_port = current_port->next_port;
@@ -974,7 +974,7 @@ static void shutdown(struct esp_struct *info)serial_out (info,UART_ESI_CMD1 ,ESI_SET_SRV_MASK );serial_out (info,UART_ESI_CMD2 ,0x00 ); -if (!info->tty || (info->tty->termios->c_cflag &HUPCL )) +if (!info->port.tty || (info->port.tty->termios->c_cflag &HUPCL )) info->MCR &= ~(UART_MCR_DTR |UART_MCR_RTS ); info->MCR &= ~UART_MCR_OUT2 ;
@@ -982,10 +982,10 @@ static void shutdown(struct esp_struct *info)serial_out (info,UART_ESI_CMD2 ,UART_MCR );serial_out (info,UART_ESI_CMD2 , info->MCR); -if (info->tty) -set_bit (TTY_IO_ERROR , &info->tty->flags); +if (info->port.tty) +set_bit (TTY_IO_ERROR , &info->port.tty->flags); - info->flags &= ~ASYNC_INITIALIZED ; + info->port.flags &= ~ASYNC_INITIALIZED ;spin_unlock_irqrestore (&info->lock, flags); }
@@ -1002,10 +1002,10 @@ static void change_speed(struct esp_struct *info)unsigned char flow1 =0 , flow2 =0 ;unsigned long flags; -if (!info->tty || !info->tty->termios) +if (!info->port.tty || !info->port.tty->termios)return ; - cflag = info->tty->termios->c_cflag; - port = info->port; + cflag = info->port.tty->termios->c_cflag; + port = info->io_port;/* byte size and parity */ switch (cflag &CSIZE ) {
@@ -1029,9 +1029,9 @@ static void change_speed(struct esp_struct *info)if (cflag &CMSPAR ) cval |=UART_LCR_SPAR ;#endif - baud =tty_get_baud_rate (info->tty); + baud =tty_get_baud_rate (info->port.tty);if (baud ==38400 && - ((info->flags &ASYNC_SPD_MASK ) ==ASYNC_SPD_CUST )) + ((info->port.flags &ASYNC_SPD_MASK ) ==ASYNC_SPD_CUST )) quot = info->custom_divisor;else {if (baud ==134 )/* Special case since 134 is really 134.5 */
@@ -1046,49 +1046,49 @@ static void change_speed(struct esp_struct *info)if (baud) {/* Actual rate */ baud =BASE_BAUD /quot; -tty_encode_baud_rate (info->tty, baud, baud); +tty_encode_baud_rate (info->port.tty, baud, baud); } info->timeout = ((1024 *HZ * bits * quot) /BASE_BAUD ) + (HZ /50 );/* CTS flow control flag and modem status interrupts */ /* info->IER &= ~UART_IER_MSI; */ if (cflag &CRTSCTS ) { - info->flags |=ASYNC_CTS_FLOW ; + info->port.flags |=ASYNC_CTS_FLOW ;/* info->IER |= UART_IER_MSI; */ flow1 =0x04 ; flow2 =0x10 ; }else - info->flags &= ~ASYNC_CTS_FLOW ; + info->port.flags &= ~ASYNC_CTS_FLOW ;if (cflag &CLOCAL ) - info->flags &= ~ASYNC_CHECK_CD ; + info->port.flags &= ~ASYNC_CHECK_CD ;else - info->flags |=ASYNC_CHECK_CD ; + info->port.flags |=ASYNC_CHECK_CD ;/* * Set up parity check flag */ info->read_status_mask =UART_LSR_OE |UART_LSR_THRE |UART_LSR_DR ; -if (I_INPCK (info->tty)) +if (I_INPCK (info->port.tty)) info->read_status_mask |=UART_LSR_FE |UART_LSR_PE ; -if (I_BRKINT (info->tty) ||I_PARMRK (info->tty)) +if (I_BRKINT (info->port.tty) ||I_PARMRK (info->port.tty)) info->read_status_mask |=UART_LSR_BI ; info->ignore_status_mask =0 ;#if 0 /* This should be safe, but for some broken bits of hardware... */ -if (I_IGNPAR (info->tty)) { +if (I_IGNPAR (info->port.tty)) { info->ignore_status_mask |=UART_LSR_PE |UART_LSR_FE ; info->read_status_mask |=UART_LSR_PE |UART_LSR_FE ; }#endif -if (I_IGNBRK (info->tty)) { +if (I_IGNBRK (info->port.tty)) { info->ignore_status_mask |=UART_LSR_BI ; info->read_status_mask |=UART_LSR_BI ;/* * If we're ignore parity and break indicators, ignore * overruns too. (For real raw support). */ -if (I_IGNPAR (info->tty)) { +if (I_IGNPAR (info->port.tty)) { info->ignore_status_mask |=UART_LSR_OE | \UART_LSR_PE |UART_LSR_FE ; info->read_status_mask |= UART_LSR_OE | \
@@ -1096,7 +1096,7 @@ static void change_speed(struct esp_struct *info) } } -if (I_IXOFF (info->tty)) +if (I_IXOFF (info->port.tty)) flow1 |=0x81 ;spin_lock_irqsave (&info->lock, flags);
@@ -1116,10 +1116,10 @@ static void change_speed(struct esp_struct *info)serial_out (info,UART_ESI_CMD2 , flow2);/* set flow control characters (XON/XOFF only) */ -if (I_IXOFF (info->tty)) { +if (I_IXOFF (info->port.tty)) {serial_out (info,UART_ESI_CMD1 ,ESI_SET_FLOW_CHARS ); -serial_out (info,UART_ESI_CMD2 ,START_CHAR (info->tty)); -serial_out (info,UART_ESI_CMD2 ,STOP_CHAR (info->tty)); +serial_out (info,UART_ESI_CMD2 ,START_CHAR (info->port.tty)); +serial_out (info,UART_ESI_CMD2 ,STOP_CHAR (info->port.tty));serial_out (info,UART_ESI_CMD2 ,0x10 );serial_out (info,UART_ESI_CMD2 ,0x21 );switch (cflag &CSIZE ) {
@@ -1355,9 +1355,9 @@ static int get_serial_info(struct esp_struct *info,memset (&tmp,0 ,sizeof (tmp)); tmp.type =PORT_16550A ; tmp.line = info->line; - tmp.port = info->port; + tmp.port = info->io_port; tmp.irq = info->irq; - tmp.flags = info->flags; + tmp.flags = info->port.flags; tmp.xmit_fifo_size =1024 ; tmp.baud_base =BASE_BAUD ; tmp.close_delay = info->close_delay;
@@ -1407,7 +1407,7 @@ static int set_serial_info(struct esp_struct *info, if ((new_serial.type != PORT_16550A) || (new_serial.hub6) || - (info->port != new_serial.port) || + (info->io_port != new_serial.port) || (new_serial.baud_base != BASE_BAUD) || (new_serial.irq > 15) || (new_serial.irq < 2) ||
@@ -1425,9 +1425,9 @@ static int set_serial_info(struct esp_struct *info,if (change_irq || (new_serial.close_delay != info->close_delay) || ((new_serial.flags & ~ASYNC_USR_MASK ) != - (info->flags & ~ASYNC_USR_MASK ))) + (info->port.flags & ~ASYNC_USR_MASK )))return -EPERM ; - info->flags = ((info->flags & ~ASYNC_USR_MASK ) | + info->port.flags = ((info->port.flags & ~ASYNC_USR_MASK ) | (new_serial.flags &ASYNC_USR_MASK )); info->custom_divisor = new_serial.custom_divisor; }else {
@@ -1441,9 +1441,9 @@ static int set_serial_info(struct esp_struct *info,if ((current_async->line >= info->line) && (current_async->line < (info->line +8 ))) {if (current_async == info) { -if (current_async->count >1 ) +if (current_async->port.count >1 )return -EBUSY ; - }else if (current_async->count) + }else if (current_async->port.count)return -EBUSY ; }
@@ -1456,7 +1456,7 @@ static int set_serial_info(struct esp_struct *info,* At this point, we start making changes..... */ - info->flags = ((info->flags & ~ASYNC_FLAGS ) | + info->port.flags = ((info->port.flags & ~ASYNC_FLAGS ) | (new_serial.flags &ASYNC_FLAGS )); info->custom_divisor = new_serial.custom_divisor; info->close_delay = new_serial.close_delay *HZ /100 ;
@@ -1487,18 +1487,18 @@ static int set_serial_info(struct esp_struct *info, } } -if (info->flags &ASYNC_INITIALIZED ) { -if (((old_info.flags &ASYNC_SPD_MASK ) != - (info->flags &ASYNC_SPD_MASK )) || +if (info->port.flags &ASYNC_INITIALIZED ) { +if (((old_info.port.flags &ASYNC_SPD_MASK ) != + (info->port.flags &ASYNC_SPD_MASK )) || (old_info.custom_divisor != info->custom_divisor)) { -if ((info->flags &ASYNC_SPD_MASK ) ==ASYNC_SPD_HI ) - info->tty->alt_speed =57600 ; -if ((info->flags &ASYNC_SPD_MASK ) ==ASYNC_SPD_VHI ) - info->tty->alt_speed =115200 ; -if ((info->flags &ASYNC_SPD_MASK ) ==ASYNC_SPD_SHI ) - info->tty->alt_speed =230400 ; -if ((info->flags &ASYNC_SPD_MASK ) ==ASYNC_SPD_WARP ) - info->tty->alt_speed =460800 ; +if ((info->port.flags &ASYNC_SPD_MASK ) ==ASYNC_SPD_HI ) + info->port.tty->alt_speed =57600 ; +if ((info->port.flags &ASYNC_SPD_MASK ) ==ASYNC_SPD_VHI ) + info->port.tty->alt_speed =115200 ; +if ((info->port.flags &ASYNC_SPD_MASK ) ==ASYNC_SPD_SHI ) + info->port.tty->alt_speed =230400 ; +if ((info->port.flags &ASYNC_SPD_MASK ) ==ASYNC_SPD_WARP ) + info->port.tty->alt_speed =460800 ;change_speed (info); } }else
@@ -1554,9 +1554,9 @@ static int set_esp_config(struct esp_struct *info,while (current_async) {if (current_async == info) { -if (current_async->count >1 ) +if (current_async->port.count >1 )return -EBUSY ; - }else if (current_async->count) + }else if (current_async->port.count)return -EBUSY ; current_async = current_async->next_port;
@@ -1578,7 +1578,7 @@ static int set_esp_config(struct esp_struct *info,spin_unlock_irqrestore (&info->lock, flags); }else {/* DMA mode to PIO mode only */ -if (info->count >1 ) +if (info->port.count >1 )return -EBUSY ;shutdown (info);
@@ -1634,7 +1634,7 @@ static int set_esp_config(struct esp_struct *info,spin_unlock_irqrestore (&info->lock, flags); } -if (!(info->flags &ASYNC_INITIALIZED )) +if (!(info->port.flags &ASYNC_INITIALIZED )) retval =startup (info);return retval;
@@ -1917,9 +1917,9 @@ static void rs_close(struct tty_struct *tty, struct file *filp)#ifdef SERIAL_DEBUG_OPEN printk (KERN_DEBUG "rs_close ttys%d, count = %d\n" , - info->line, info->count); + info->line, info->port.count);#endif -if (tty->count ==1 && info->count !=1 ) { +if (tty->count ==1 && info->port.count !=1 ) {/* * Uh, oh. tty->count is 1, which means that the tty * structure will be freed. Info->count should always
@@ -1927,19 +1927,19 @@ static void rs_close(struct tty_struct *tty, struct file *filp)* one, we've got real problems, since it means the * serial port won't be shutdown. */ -printk (KERN_DEBUG "rs_close: bad serial port count; tty->count is 1, info->count is %d\n" , info->count); - info->count =1 ; +printk (KERN_DEBUG "rs_close: bad serial port count; tty->count is 1, info->port.count is %d\n" , info->port.count); + info->port.count =1 ; } -if (--info->count <0 ) { +if (--info->port.count <0 ) {printk (KERN_ERR "rs_close: bad serial port count for ttys%d: %d\n" , - info->line, info->count); - info->count =0 ; + info->line, info->port.count); + info->port.count =0 ; } -if (info->count) { +if (info->port.count) {DBG_CNT ("before DEC-2" ); goto out; } - info->flags |=ASYNC_CLOSING ; + info->port.flags |=ASYNC_CLOSING ;spin_unlock_irqrestore (&info->lock, flags);/*
@@ -1958,7 +1958,7 @@ static void rs_close(struct tty_struct *tty, struct file *filp)/* info->IER &= ~UART_IER_RLSI; */ info->IER &= ~UART_IER_RDI ; info->read_status_mask &= ~UART_LSR_DR ; -if (info->flags &ASYNC_INITIALIZED ) { +if (info->port.flags &ASYNC_INITIALIZED ) {spin_lock_irqsave (&info->lock, flags);serial_out (info,UART_ESI_CMD1 ,ESI_SET_SRV_MASK );
@@ -1981,15 +1981,15 @@ static void rs_close(struct tty_struct *tty, struct file *filp)rs_flush_buffer (tty);tty_ldisc_flush (tty); tty->closing =0 ; - info->tty =NULL ; + info->port.tty =NULL ; -if (info->blocked_open) { +if (info->port.blocked_open) {if (info->close_delay)msleep_interruptible (jiffies_to_msecs (info->close_delay)); -wake_up_interruptible (&info->open_wait); +wake_up_interruptible (&info->port.open_wait); } - info->flags &= ~(ASYNC_NORMAL_ACTIVE |ASYNC_CLOSING ); -wake_up_interruptible (&info->close_wait); + info->port.flags &= ~(ASYNC_NORMAL_ACTIVE |ASYNC_CLOSING ); +wake_up_interruptible (&info->port.close_wait);return ; out:
@@ -2047,10 +2047,10 @@ static void esp_hangup(struct tty_struct *tty)rs_flush_buffer (tty);shutdown (info); - info->count =0 ; - info->flags &= ~ASYNC_NORMAL_ACTIVE ; - info->tty =NULL ; -wake_up_interruptible (&info->open_wait); + info->port.count =0 ; + info->port.flags &= ~ASYNC_NORMAL_ACTIVE ; + info->port.tty =NULL ; +wake_up_interruptible (&info->port.open_wait); }/*
@@ -2071,11 +2071,11 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,* until it's done, and then try again. */ if (tty_hung_up_p (filp) || - (info->flags &ASYNC_CLOSING )) { -if (info->flags &ASYNC_CLOSING ) -interruptible_sleep_on (&info->close_wait); + (info->port.flags &ASYNC_CLOSING )) { +if (info->port.flags &ASYNC_CLOSING ) +interruptible_sleep_on (&info->port.close_wait);#ifdef SERIAL_DO_RESTART -if (info->flags &ASYNC_HUP_NOTIFY ) +if (info->port.flags &ASYNC_HUP_NOTIFY )return -EAGAIN ;else return -ERESTARTSYS ;
@@ -2090,7 +2090,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,*/ if ((filp->f_flags &O_NONBLOCK ) || (tty->flags & (1 <<TTY_IO_ERROR ))) { - info->flags |=ASYNC_NORMAL_ACTIVE ; + info->port.flags |=ASYNC_NORMAL_ACTIVE ;return 0 ; }
@@ -2100,20 +2100,20 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,/* * Block waiting for the carrier detect and the line to become * free (i.e., not in use by the callout). While we are in -* this loop, info->count is dropped by one, so that +* this loop, info->port.count is dropped by one, so that * rs_close() knows when to free things. We restore it upon * exit, either normal or abnormal. */ retval =0 ; -add_wait_queue (&info->open_wait, &wait); +add_wait_queue (&info->port.open_wait, &wait);#ifdef SERIAL_DEBUG_OPEN printk (KERN_DEBUG "block_til_ready before block: ttys%d, count = %d\n" , - info->line, info->count); + info->line, info->port.count);#endif spin_lock_irqsave (&info->lock, flags);if (!tty_hung_up_p (filp)) - info->count--; - info->blocked_open++; + info->port.count--; + info->port.blocked_open++;while (1 ) {if ((tty->termios->c_cflag &CBAUD )) {unsigned int scratch;
@@ -2128,9 +2128,9 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp, }set_current_state (TASK_INTERRUPTIBLE );if (tty_hung_up_p (filp) || - !(info->flags &ASYNC_INITIALIZED )) { + !(info->port.flags &ASYNC_INITIALIZED )) {#ifdef SERIAL_DO_RESTART -if (info->flags &ASYNC_HUP_NOTIFY ) +if (info->port.flags &ASYNC_HUP_NOTIFY ) retval = -EAGAIN ;else retval = -ERESTARTSYS ;
@@ -2144,7 +2144,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,if (serial_in (info,UART_ESI_STAT2 ) &UART_MSR_DCD ) do_clocal =1 ; -if (!(info->flags &ASYNC_CLOSING ) && +if (!(info->port.flags &ASYNC_CLOSING ) && (do_clocal))break ;if (signal_pending (current)) {
@@ -2153,25 +2153,25 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp, }#ifdef SERIAL_DEBUG_OPEN printk (KERN_DEBUG "block_til_ready blocking: ttys%d, count = %d\n" , - info->line, info->count); + info->line, info->port.count);#endif spin_unlock_irqrestore (&info->lock, flags);schedule ();spin_lock_irqsave (&info->lock, flags); }set_current_state (TASK_RUNNING ); -remove_wait_queue (&info->open_wait, &wait); +remove_wait_queue (&info->port.open_wait, &wait);if (!tty_hung_up_p (filp)) - info->count++; - info->blocked_open--; + info->port.count++; + info->port.blocked_open--;spin_unlock_irqrestore (&info->lock, flags);#ifdef SERIAL_DEBUG_OPEN printk (KERN_DEBUG "block_til_ready after blocking: ttys%d, count = %d\n" , - info->line, info->count); + info->line, info->port.count);#endif if (retval)return retval; - info->flags |=ASYNC_NORMAL_ACTIVE ; + info->port.flags |=ASYNC_NORMAL_ACTIVE ;return 0 ; }
@@ -2204,12 +2204,12 @@ static int esp_open(struct tty_struct *tty, struct file *filp) }#ifdef SERIAL_DEBUG_OPEN -printk (KERN_DEBUG "esp_open %s, count = %d\n" , tty->name, info->count); +printk (KERN_DEBUG "esp_open %s, count = %d\n" , tty->name, info->port.count);#endif spin_lock_irqsave (&info->lock, flags); - info->count++; + info->port.count++; tty->driver_data = info; - info->tty = tty; + info->port.tty = tty;spin_unlock_irqrestore (&info->lock, flags);
@@ -2263,7 +2263,7 @@ static int autoconfig(struct esp_struct *info)int port_detected =0 ;unsigned long flags; -if (!request_region (info->port,REGION_SIZE ,"esp serial" )) +if (!request_region (info->io_port,REGION_SIZE ,"esp serial" ))return -EIO ;spin_lock_irqsave (&info->lock, flags);
@@ -2300,7 +2300,7 @@ static int autoconfig(struct esp_struct *info) } }if (!port_detected) -release_region (info->port,REGION_SIZE ); +release_region (info->io_port,REGION_SIZE );spin_unlock_irqrestore (&info->lock, flags);return (port_detected);
@@ -2414,7 +2414,7 @@ static int __init espserial_init(void) offset =0 ; do { - info->port = esp[i] + offset; + info->io_port = esp[i] + offset; info->irq = irq[i]; info->line = (i * 8) + (offset / 8);
@@ -2425,9 +2425,9 @@ static int __init espserial_init(void) } info->custom_divisor = (divisor[i] >> (offset /2 )) &0xf ; - info->flags =STD_COM_FLAGS ; + info->port.flags =STD_COM_FLAGS ;if (info->custom_divisor) - info->flags |=ASYNC_SPD_CUST ; + info->port.flags |=ASYNC_SPD_CUST ; info->magic =ESP_MAGIC ; info->close_delay =5 *HZ /10 ; info->closing_wait =30 *HZ ;
@@ -2436,13 +2436,13 @@ static int __init espserial_init(void) info->config.flow_off = flow_off; info->config.pio_threshold = pio_threshold; info->next_port = ports; -init_waitqueue_head (&info->open_wait); -init_waitqueue_head (&info->close_wait); +init_waitqueue_head (&info->port.open_wait); +init_waitqueue_head (&info->port.close_wait);init_waitqueue_head (&info->delta_msr_wait);init_waitqueue_head (&info->break_wait); ports = info;printk (KERN_INFO "ttyP%d at 0x%04x (irq = %d) is an ESP " , - info->line, info->port, info->irq); + info->line, info->io_port, info->irq);if (info->line %8 ) {printk ("secondary port\n" );
@@ -2498,8 +2498,8 @@ static void __exit espserial_exit(void)put_tty_driver (esp_driver);while (ports) { -if (ports->port) -release_region (ports->port,REGION_SIZE ); +if (ports->io_port) +release_region (ports->io_port,REGION_SIZE ); temp_async = ports->next_port;kfree (ports); ports = temp_async;
include/linux/hayesesp.h +2 -7
@@ -76,11 +76,10 @@ struct hayes_esp_config {struct esp_struct {int magic; +struct tty_port port;spinlock_t lock; -int port; +int io_port;int irq; -int flags;/* defined in tty.h */ -struct tty_struct *tty;int read_status_mask;int ignore_status_mask;int timeout;
@@ -93,14 +92,10 @@ struct esp_struct {int MCR ;/* Modem control register */ unsigned long last_active;int line; -int count;/* # of fd on device */ -int blocked_open;/* # of blocked opens */ unsigned char *xmit_buf;int xmit_head;int xmit_tail;int xmit_cnt; -wait_queue_head_t open_wait; -wait_queue_head_t close_wait;wait_queue_head_t delta_msr_wait;wait_queue_head_t break_wait;struct async_icount icount;/* kernel counters for the 4 input interrupts */
PATCH 8/70 gs: use tty_port
In reply to Alan CoxFrom: Alan Cox <[email protected]>
Switch drivers using the old "generic serial" driver to use the tty_port structures
---
drivers/char/generic_serial.c | 158 ++++++++++++++++++++-------------------- drivers/char/rio/rio_linux.c | 20 +++-- drivers/char/rio/riocmd.c | 10 +-- drivers/char/rio/riointr.c | 10 +-- drivers/char/rio/rioparam.c | 2 - drivers/char/rio/riotty.c | 16 ++-- drivers/char/sx.c | 115 ++++++++++++++--------------- include/linux/generic_serial.h | 8 +- 8 files changed, 166 insertions(+), 173 deletions(-)
drivers/char/generic_serial.c +79 -79
@@ -60,7 +60,7 @@ int gs_put_char(struct tty_struct * tty, unsigned char ch)if (!port)return 0 ; -if (! (port->flags &ASYNC_INITIALIZED ))return 0 ; +if (! (port->port.flags &ASYNC_INITIALIZED ))return 0 ;/* Take a lock on the serial tranmit buffer! */ mutex_lock (& port->port_write_mutex);
@@ -103,7 +103,7 @@ int gs_write(struct tty_struct * tty,if (!port)return 0 ; -if (! (port->flags &ASYNC_INITIALIZED )) +if (! (port->port.flags &ASYNC_INITIALIZED ))return 0 ;/* get exclusive "write" access to this port (problem 3) */
@@ -141,13 +141,13 @@ int gs_write(struct tty_struct * tty,mutex_unlock (& port->port_write_mutex);gs_dprintk (GS_DEBUG_WRITE ,"write: interrupts are %s\n" , - (port->flags &GS_TX_INTEN )?"enabled" :"disabled" ); + (port->port.flags &GS_TX_INTEN )?"enabled" :"disabled" );if (port->xmit_cnt && !tty->stopped && !tty->hw_stopped && - !(port->flags &GS_TX_INTEN )) { - port->flags |=GS_TX_INTEN ; + !(port->port.flags &GS_TX_INTEN )) { + port->port.flags |=GS_TX_INTEN ; port->rd->enable_tx_interrupts (port); }func_exit ();
@@ -208,7 +208,7 @@ static int gs_wait_tx_flushed (void * ptr, unsigned long timeout)gs_dprintk (GS_DEBUG_FLUSH ,"port=%p.\n" , port);if (port) {gs_dprintk (GS_DEBUG_FLUSH ,"xmit_cnt=%x, xmit_buf=%p, tty=%p.\n" , - port->xmit_cnt, port->xmit_buf, port->tty); + port->xmit_cnt, port->xmit_buf, port->port.tty); }if (!port || port->xmit_cnt <0 || !port->xmit_buf) {
@@ -217,7 +217,7 @@ static int gs_wait_tx_flushed (void * ptr, unsigned long timeout)return -EINVAL ;/* This is an error which we don't know how to handle. */ } - rcib =gs_real_chars_in_buffer (port->tty); + rcib =gs_real_chars_in_buffer (port->port.tty);if (rcib <=0 ) {gs_dprintk (GS_DEBUG_FLUSH ,"nothing to wait for.\n" );
@@ -236,7 +236,7 @@ static int gs_wait_tx_flushed (void * ptr, unsigned long timeout)/* the expression is actually jiffies < end_jiffies, but that won't work around the wraparound. Tricky eh? */ -while ((charsleft =gs_real_chars_in_buffer (port->tty)) && +while ((charsleft =gs_real_chars_in_buffer (port->port.tty)) &&time_after (end_jiffies, jiffies)) {/* Units check: chars * (bits/char) * (jiffies /sec) / (bits/sec) = jiffies!
@@ -309,7 +309,7 @@ void gs_flush_chars(struct tty_struct * tty) }/* Beats me -- REW */ - port->flags |=GS_TX_INTEN ; + port->port.flags |=GS_TX_INTEN ; port->rd->enable_tx_interrupts (port);func_exit (); }
@@ -329,8 +329,8 @@ void gs_stop(struct tty_struct * tty)if (port->xmit_cnt && port->xmit_buf && - (port->flags &GS_TX_INTEN ) ) { - port->flags &= ~GS_TX_INTEN ; + (port->port.flags &GS_TX_INTEN ) ) { + port->port.flags &= ~GS_TX_INTEN ; port->rd->disable_tx_interrupts (port); }func_exit ();
@@ -349,8 +349,8 @@ void gs_start(struct tty_struct * tty)if (port->xmit_cnt && port->xmit_buf && - !(port->flags &GS_TX_INTEN ) ) { - port->flags |=GS_TX_INTEN ; + !(port->port.flags &GS_TX_INTEN ) ) { + port->port.flags |=GS_TX_INTEN ; port->rd->enable_tx_interrupts (port); }func_exit ();
@@ -365,7 +365,7 @@ static void gs_shutdown_port (struct gs_port *port)if (!port)return ; -if (!(port->flags &ASYNC_INITIALIZED )) +if (!(port->port.flags &ASYNC_INITIALIZED ))return ;spin_lock_irqsave (&port->driver_lock, flags);
@@ -375,12 +375,12 @@ static void gs_shutdown_port (struct gs_port *port) port->xmit_buf =NULL ; } -if (port->tty) -set_bit (TTY_IO_ERROR , &port->tty->flags); +if (port->port.tty) +set_bit (TTY_IO_ERROR , &port->port.tty->flags); port->rd->shutdown_port (port); - port->flags &= ~ASYNC_INITIALIZED ; + port->port.flags &= ~ASYNC_INITIALIZED ;spin_unlock_irqrestore (&port->driver_lock, flags);func_exit ();
@@ -396,16 +396,16 @@ void gs_hangup(struct tty_struct *tty)if (!tty)return ; port = tty->driver_data; - tty = port->tty; + tty = port->port.tty;if (!tty)return ;gs_shutdown_port (port); - port->flags &= ~(ASYNC_NORMAL_ACTIVE |GS_ACTIVE ); - port->tty =NULL ; - port->count =0 ; + port->port.flags &= ~(ASYNC_NORMAL_ACTIVE |GS_ACTIVE ); + port->port.tty =NULL ; + port->port.count =0 ; -wake_up_interruptible (&port->open_wait); +wake_up_interruptible (&port->port.open_wait);func_exit (); }
@@ -424,7 +424,7 @@ int gs_block_til_ready(void *port_, struct file * filp)if (!port)return 0 ; - tty = port->tty; + tty = port->port.tty;if (!tty)return 0 ;
@@ -433,9 +433,9 @@ int gs_block_til_ready(void *port_, struct file * filp)* If the device is in the middle of being closed, then block * until it's done, and then try again. */ -if (tty_hung_up_p (filp) || port->flags &ASYNC_CLOSING ) { -interruptible_sleep_on (&port->close_wait); -if (port->flags &ASYNC_HUP_NOTIFY ) +if (tty_hung_up_p (filp) || port->port.flags &ASYNC_CLOSING ) { +interruptible_sleep_on (&port->port.close_wait); +if (port->port.flags &ASYNC_HUP_NOTIFY )return -EAGAIN ;else return -ERESTARTSYS ;
@@ -449,7 +449,7 @@ int gs_block_til_ready(void *port_, struct file * filp)*/ if ((filp->f_flags &O_NONBLOCK ) || (tty->flags & (1 <<TTY_IO_ERROR ))) { - port->flags |=ASYNC_NORMAL_ACTIVE ; + port->port.flags |=ASYNC_NORMAL_ACTIVE ;return 0 ; }
@@ -461,34 +461,34 @@ int gs_block_til_ready(void *port_, struct file * filp)/* * Block waiting for the carrier detect and the line to become * free (i.e., not in use by the callout). While we are in -* this loop, port->count is dropped by one, so that +* this loop, port->port.count is dropped by one, so that * rs_close() knows when to free things. We restore it upon * exit, either normal or abnormal. */ retval =0 ; -add_wait_queue (&port->open_wait, &wait); +add_wait_queue (&port->port.open_wait, &wait);gs_dprintk (GS_DEBUG_BTR ,"after add waitq.\n" );spin_lock_irqsave (&port->driver_lock, flags);if (!tty_hung_up_p (filp)) { - port->count--; + port->port.count--; }spin_unlock_irqrestore (&port->driver_lock, flags); - port->blocked_open++; + port->port.blocked_open++;while (1 ) {CD = port->rd->get_CD (port);gs_dprintk (GS_DEBUG_BTR ,"CD is now %d.\n" ,CD );set_current_state (TASK_INTERRUPTIBLE );if (tty_hung_up_p (filp) || - !(port->flags &ASYNC_INITIALIZED )) { -if (port->flags &ASYNC_HUP_NOTIFY ) + !(port->port.flags &ASYNC_INITIALIZED )) { +if (port->port.flags &ASYNC_HUP_NOTIFY ) retval = -EAGAIN ;else retval = -ERESTARTSYS ;break ; } -if (!(port->flags &ASYNC_CLOSING ) && +if (!(port->port.flags &ASYNC_CLOSING ) && (do_clocal ||CD ))break ; gs_dprintk (GS_DEBUG_BTR, "signal_pending is now: %d (%lx)\n",
@@ -500,17 +500,17 @@ int gs_block_til_ready(void *port_, struct file * filp)schedule (); }gs_dprintk (GS_DEBUG_BTR ,"Got out of the loop. (%d)\n" , - port->blocked_open); + port->port.blocked_open);set_current_state (TASK_RUNNING ); -remove_wait_queue (&port->open_wait, &wait); +remove_wait_queue (&port->port.open_wait, &wait);if (!tty_hung_up_p (filp)) { - port->count++; + port->port.count++; } - port->blocked_open--; + port->port.blocked_open--;if (retval)return retval; - port->flags |=ASYNC_NORMAL_ACTIVE ; + port->port.flags |=ASYNC_NORMAL_ACTIVE ;func_exit ();return 0 ; }
@@ -529,10 +529,10 @@ void gs_close(struct tty_struct * tty, struct file * filp)if (!port)return ; -if (!port->tty) { +if (!port->port.tty) {/* This seems to happen when this is called from vhangup. */ -gs_dprintk (GS_DEBUG_CLOSE ,"gs: Odd: port->tty is NULL\n" ); - port->tty = tty; +gs_dprintk (GS_DEBUG_CLOSE ,"gs: Odd: port->port.tty is NULL\n" ); + port->port.tty = tty; }spin_lock_irqsave (&port->driver_lock, flags);
@@ -545,23 +545,23 @@ void gs_close(struct tty_struct * tty, struct file * filp)return ; } -if ((tty->count ==1 ) && (port->count !=1 )) { +if ((tty->count ==1 ) && (port->port.count !=1 )) {printk (KERN_ERR "gs: gs_close port %p: bad port count;" -" tty->count is 1, port count is %d\n" , port, port->count); - port->count =1 ; +" tty->count is 1, port count is %d\n" , port, port->port.count); + port->port.count =1 ; } -if (--port->count <0 ) { -printk (KERN_ERR "gs: gs_close port %p: bad port count: %d\n" , port, port->count); - port->count =0 ; +if (--port->port.count <0 ) { +printk (KERN_ERR "gs: gs_close port %p: bad port count: %d\n" , port, port->port.count); + port->port.count =0 ; } -if (port->count) { -gs_dprintk (GS_DEBUG_CLOSE ,"gs_close port %p: count: %d\n" , port, port->count); +if (port->port.count) { +gs_dprintk (GS_DEBUG_CLOSE ,"gs_close port %p: count: %d\n" , port, port->port.count);spin_unlock_irqrestore (&port->driver_lock, flags);func_exit ();return ; } - port->flags |=ASYNC_CLOSING ; + port->port.flags |=ASYNC_CLOSING ;/* * Now we wait for the transmit buffer to clear; and we notify
@@ -585,7 +585,7 @@ void gs_close(struct tty_struct * tty, struct file * filp)if (port->closing_wait !=ASYNC_CLOSING_WAIT_NONE )gs_wait_tx_flushed (port, port->closing_wait); - port->flags &= ~GS_ACTIVE ; + port->port.flags &= ~GS_ACTIVE ;gs_flush_buffer (tty);
@@ -595,18 +595,18 @@ void gs_close(struct tty_struct * tty, struct file * filp) port->event =0 ; port->rd->close (port); port->rd->shutdown_port (port); - port->tty =NULL ; + port->port.tty =NULL ; -if (port->blocked_open) { +if (port->port.blocked_open) {if (port->close_delay) {spin_unlock_irqrestore (&port->driver_lock, flags);msleep_interruptible (jiffies_to_msecs (port->close_delay));spin_lock_irqsave (&port->driver_lock, flags); } -wake_up_interruptible (&port->open_wait); +wake_up_interruptible (&port->port.open_wait); } - port->flags &= ~(ASYNC_NORMAL_ACTIVE |ASYNC_CLOSING |ASYNC_INITIALIZED ); -wake_up_interruptible (&port->close_wait); + port->port.flags &= ~(ASYNC_NORMAL_ACTIVE |ASYNC_CLOSING |ASYNC_INITIALIZED ); +wake_up_interruptible (&port->port.close_wait);func_exit (); }
@@ -626,10 +626,10 @@ void gs_set_termios (struct tty_struct * tty, port = tty->driver_data;if (!port)return ; -if (!port->tty) { +if (!port->port.tty) {/* This seems to happen when this is called after gs_close. */ -gs_dprintk (GS_DEBUG_TERMIOS ,"gs: Odd: port->tty is NULL\n" ); - port->tty = tty; +gs_dprintk (GS_DEBUG_TERMIOS ,"gs: Odd: port->port.tty is NULL\n" ); + port->port.tty = tty; }
@@ -651,15 +651,15 @@ void gs_set_termios (struct tty_struct * tty, baudrate =tty_get_baud_rate (tty);if ((tiosp->c_cflag &CBAUD ) ==B38400 ) { -if ( (port->flags &ASYNC_SPD_MASK ) ==ASYNC_SPD_HI ) +if ( (port->port.flags &ASYNC_SPD_MASK ) ==ASYNC_SPD_HI ) baudrate =57600 ; -else if ((port->flags &ASYNC_SPD_MASK ) ==ASYNC_SPD_VHI ) +else if ((port->port.flags &ASYNC_SPD_MASK ) ==ASYNC_SPD_VHI ) baudrate =115200 ; -else if ((port->flags &ASYNC_SPD_MASK ) ==ASYNC_SPD_SHI ) +else if ((port->port.flags &ASYNC_SPD_MASK ) ==ASYNC_SPD_SHI ) baudrate =230400 ; -else if ((port->flags &ASYNC_SPD_MASK ) ==ASYNC_SPD_WARP ) +else if ((port->port.flags &ASYNC_SPD_MASK ) ==ASYNC_SPD_WARP ) baudrate =460800 ; -else if ((port->flags &ASYNC_SPD_MASK ) ==ASYNC_SPD_CUST ) +else if ((port->port.flags &ASYNC_SPD_MASK ) ==ASYNC_SPD_CUST ) baudrate = (port->baud_base / port->custom_divisor); }
@@ -715,7 +715,7 @@ int gs_init_port(struct gs_port *port)func_enter (); -if (port->flags &ASYNC_INITIALIZED ) { +if (port->port.flags &ASYNC_INITIALIZED ) {func_exit ();return 0 ; }
@@ -737,15 +737,15 @@ int gs_init_port(struct gs_port *port) }spin_lock_irqsave (&port->driver_lock, flags); -if (port->tty) -clear_bit (TTY_IO_ERROR , &port->tty->flags); +if (port->port.tty) +clear_bit (TTY_IO_ERROR , &port->port.tty->flags);mutex_init (&port->port_write_mutex); port->xmit_cnt = port->xmit_head = port->xmit_tail =0 ;spin_unlock_irqrestore (&port->driver_lock, flags); -gs_set_termios (port->tty,NULL ); +gs_set_termios (port->port.tty,NULL );spin_lock_irqsave (&port->driver_lock, flags); - port->flags |=ASYNC_INITIALIZED ; - port->flags &= ~GS_TX_INTEN ; + port->port.flags |=ASYNC_INITIALIZED ; + port->port.flags &= ~GS_TX_INTEN ;spin_unlock_irqrestore (&port->driver_lock, flags);func_exit ();
@@ -764,11 +764,11 @@ int gs_setserial(struct gs_port *port, struct serial_struct __user *sp)if ((sio.baud_base != port->baud_base) || (sio.close_delay != port->close_delay) || ((sio.flags & ~ASYNC_USR_MASK ) != - (port->flags & ~ASYNC_USR_MASK ))) + (port->port.flags & ~ASYNC_USR_MASK )))return (-EPERM ); } - port->flags = (port->flags & ~ASYNC_USR_MASK ) | + port->port.flags = (port->port.flags & ~ASYNC_USR_MASK ) | (sio.flags &ASYNC_USR_MASK ); port->baud_base = sio.baud_base;
@@ -776,7 +776,7 @@ int gs_setserial(struct gs_port *port, struct serial_struct __user *sp) port->closing_wait = sio.closing_wait; port->custom_divisor = sio.custom_divisor; -gs_set_termios (port->tty,NULL ); +gs_set_termios (port->port.tty,NULL );return 0 ; }
@@ -793,7 +793,7 @@ int gs_getserial(struct gs_port *port, struct serial_struct __user *sp)struct serial_struct sio;memset (&sio,0 ,sizeof (struct serial_struct )); - sio.flags = port->flags; + sio.flags = port->port.flags; sio.baud_base = port->baud_base; sio.close_delay = port->close_delay; sio.closing_wait = port->closing_wait;
@@ -821,10 +821,10 @@ void gs_got_break(struct gs_port *port) {func_enter (); -tty_insert_flip_char (port->tty,0 ,TTY_BREAK ); -tty_schedule_flip (port->tty); -if (port->flags &ASYNC_SAK ) { -do_SAK (port->tty); +tty_insert_flip_char (port->port.tty,0 ,TTY_BREAK ); +tty_schedule_flip (port->port.tty); +if (port->port.flags &ASYNC_SAK ) { +do_SAK (port->port.tty); }func_exit ();
drivers/char/rio/rio_linux.c +10 -10
@@ -431,7 +431,7 @@ static void rio_disable_tx_interrupts(void *ptr) {func_enter (); -/* port->gs.flags &= ~GS_TX_INTEN; */ +/* port->gs.port.flags &= ~GS_TX_INTEN; */ func_exit (); }
@@ -455,7 +455,7 @@ static void rio_enable_tx_interrupts(void *ptr)* In general we cannot count on "tx empty" interrupts, although * the interrupt routine seems to be able to tell the difference. */ - PortP->gs.flags &= ~GS_TX_INTEN ; + PortP->gs.port.flags &= ~GS_TX_INTEN ;func_exit (); }
@@ -510,7 +510,7 @@ static void rio_shutdown_port(void *ptr)func_enter (); PortP = (struct Port *) ptr; - PortP->gs.tty =NULL ; + PortP->gs.port.tty =NULL ;func_exit (); }
@@ -529,7 +529,7 @@ static void rio_hungup(void *ptr)func_enter (); PortP = (struct Port *) ptr; - PortP->gs.tty =NULL ; + PortP->gs.port.tty =NULL ;func_exit (); }
@@ -549,12 +549,12 @@ static void rio_close(void *ptr)riotclose (ptr); -if (PortP->gs.count) { -printk (KERN_ERR "WARNING port count:%d\n" , PortP->gs.count); - PortP->gs.count =0 ; +if (PortP->gs.port.count) { +printk (KERN_ERR "WARNING port count:%d\n" , PortP->gs.port.count); + PortP->gs.port.count =0 ; } - PortP->gs.tty =NULL ; + PortP->gs.port.tty =NULL ;func_exit (); }
@@ -849,8 +849,8 @@ static int rio_init_datastructures(void)/* * Initializing wait queue */ -init_waitqueue_head (&port->gs.open_wait); - init_waitqueue_head(&port->gs.close_wait); +init_waitqueue_head (&port->gs.port.open_wait); + init_waitqueue_head(&port->gs.port.close_wait); }#else /* We could postpone initializing them to when they are configured. */
drivers/char/rio/riocmd.c +5 -5
@@ -484,12 +484,12 @@ static int RIOCommandRup(struct rio_info *p, uint Rup, struct Host *HostP, struc** If the device is a modem, then check the modem ** carrier. */ -if (PortP->gs.tty ==NULL ) +if (PortP->gs.port.tty ==NULL )break ; -if (PortP->gs.tty->termios ==NULL ) +if (PortP->gs.port.tty->termios ==NULL )break ; -if (!(PortP->gs.tty->termios->c_cflag &CLOCAL ) && ((PortP->State & (RIO_MOPEN |RIO_WOPEN )))) { +if (!(PortP->gs.port.tty->termios->c_cflag &CLOCAL ) && ((PortP->State & (RIO_MOPEN |RIO_WOPEN )))) {rio_dprintk (RIO_DEBUG_CMD ,"Is there a Carrier?\n" );/*
@@ -506,7 +506,7 @@ static int RIOCommandRup(struct rio_info *p, uint Rup, struct Host *HostP, struc** wakeup anyone in WOPEN */ if (PortP->State & (PORT_ISOPEN |RIO_WOPEN )) -wake_up_interruptible (&PortP->gs.open_wait); +wake_up_interruptible (&PortP->gs.port.open_wait); } }else {/*
@@ -514,7 +514,7 @@ static int RIOCommandRup(struct rio_info *p, uint Rup, struct Host *HostP, struc*/ if (PortP->State &RIO_CARR_ON ) {if (PortP->State & (PORT_ISOPEN |RIO_WOPEN |RIO_MOPEN )) -tty_hangup (PortP->gs.tty); +tty_hangup (PortP->gs.port.tty); PortP->State &= ~RIO_CARR_ON ;rio_dprintk (RIO_DEBUG_CMD ,"Carrirer just went down\n" ); }
drivers/char/rio/riointr.c +5 -5
@@ -102,7 +102,7 @@ void RIOTxEnable(char *en) PortP = (struct Port *) en; p = (struct rio_info *) PortP->p; - tty = PortP->gs.tty; + tty = PortP->gs.port.tty;rio_dprintk (RIO_DEBUG_INTR ,"tx port %d: %d chars queued.\n" , PortP->PortNum, PortP->gs.xmit_cnt);
@@ -158,7 +158,7 @@ void RIOTxEnable(char *en)rio_spin_unlock_irqrestore (&PortP->portSem, flags);if (PortP->gs.xmit_cnt <= (PortP->gs.wakeup_chars +2 *PKT_MAX_DATA_LEN )) -tty_wakeup (PortP->gs.tty); +tty_wakeup (PortP->gs.port.tty); }
@@ -241,7 +241,7 @@ void RIOServiceHost(struct rio_info *p, struct Host *HostP)** find corresponding tty structure. The process of mapping ** the ports puts these here. */ - ttyP = PortP->gs.tty; + ttyP = PortP->gs.port.tty;/* ** Lock the port before we begin working on it.
@@ -335,7 +335,7 @@ void RIOServiceHost(struct rio_info *p, struct Host *HostP)** find corresponding tty structure. The process of mapping ** the ports puts these here. */ - ttyP = PortP->gs.tty; + ttyP = PortP->gs.port.tty;/* If ttyP is NULL, the port is getting closed. Forget about it. */ if (!ttyP) {rio_dprintk (RIO_DEBUG_INTR ,"no tty, so skipping.\n" );
@@ -542,7 +542,7 @@ static void RIOReceive(struct rio_info *p, struct Port *PortP) intCount++; - TtyP = PortP->gs.tty; + TtyP = PortP->gs.port.tty;if (!TtyP) {rio_dprintk (RIO_DEBUG_INTR ,"RIOReceive: tty is null. \n" );return ;
drivers/char/rio/rioparam.c +1 -1
@@ -160,7 +160,7 @@ int RIOParam(struct Port *PortP, int cmd, int Modem, int SleepFlag)func_enter (); - TtyP = PortP->gs.tty; + TtyP = PortP->gs.port.tty;rio_dprintk (RIO_DEBUG_PARAM ,"RIOParam: Port:%d cmd:%d Modem:%d SleepFlag:%d Mapped: %d, tty=%p\n" , PortP->PortNum, cmd, Modem, SleepFlag, PortP->Mapped, TtyP);
drivers/char/rio/riotty.c +8 -8
@@ -140,14 +140,14 @@ int riotopen(struct tty_struct *tty, struct file *filp) tty->driver_data = PortP; - PortP->gs.tty = tty; - PortP->gs.count++; + PortP->gs.port.tty = tty; + PortP->gs.port.count++;rio_dprintk (RIO_DEBUG_TTY ,"%d bytes in tx buffer\n" , PortP->gs.xmit_cnt); retval =gs_init_port (&PortP->gs);if (retval) { - PortP->gs.count--; + PortP->gs.port.count--;return -ENXIO ; }/*
@@ -293,7 +293,7 @@ int riotopen(struct tty_struct *tty, struct file *filp)** insert test for carrier here. -- ??? ** I already see that test here. What's the deal? -- REW */ -if ((PortP->gs.tty->termios->c_cflag &CLOCAL ) || +if ((PortP->gs.port.tty->termios->c_cflag &CLOCAL ) || (PortP->ModemState &RIOC_MSVR1_CD )) {rio_dprintk (RIO_DEBUG_TTY ,"open(%d) Modem carr on\n" , SysPort);/*
@@ -301,16 +301,16 @@ int riotopen(struct tty_struct *tty, struct file *filp)wakeup((caddr_t) &tp->tm.c_canq); */ PortP->State |=RIO_CARR_ON ; -wake_up_interruptible (&PortP->gs.open_wait); +wake_up_interruptible (&PortP->gs.port.open_wait); }else {/* no carrier - wait for DCD */ /* -while (!(PortP->gs.tty->termios->c_state & CARR_ON) && +while (!(PortP->gs.port.tty->termios->c_state & CARR_ON) && !(filp->f_flags & O_NONBLOCK) && !p->RIOHalted ) */ while (!(PortP->State &RIO_CARR_ON ) && !(filp->f_flags &O_NONBLOCK ) && !p->RIOHalted) {rio_dprintk (RIO_DEBUG_TTY ,"open(%d) sleeping for carr on\n" , SysPort);/* -PortP->gs.tty->termios->c_state |= WOPEN; +PortP->gs.port.tty->termios->c_state |= WOPEN; */ PortP->State |=RIO_WOPEN ;rio_spin_unlock_irqrestore (&PortP->portSem, flags);
@@ -380,7 +380,7 @@ int riotclose(void *ptr)/* PortP = p->RIOPortp[SysPort]; */ rio_dprintk (RIO_DEBUG_TTY ,"Port is at address %p\n" , PortP);/* tp = PortP->TtyP; *//* Get tty */ - tty = PortP->gs.tty; + tty = PortP->gs.port.tty;rio_dprintk (RIO_DEBUG_TTY ,"TTY is at address %p\n" , tty);if (PortP->gs.closing_wait)
drivers/char/sx.c +56 -59
283 lines not on this page · raw message
include/linux/generic_serial.h +2 -6
@@ -14,6 +14,7 @@ #ifdef __KERNEL__ #include <linux/mutex.h> +#include <linux/tty.h> struct real_driver { void (*disable_tx_interrupts) (void *);
@@ -33,17 +34,12 @@ struct real_driver {struct gs_port {int magic; +struct tty_port port;unsigned char *xmit_buf;int xmit_head;int xmit_tail;int xmit_cnt;struct mutex port_write_mutex; -int flags; -wait_queue_head_t open_wait; -wait_queue_head_t close_wait; -int count; -int blocked_open; -struct tty_struct *tty;unsigned long event;unsigned short closing_wait;int close_delay;
PATCH 9/70 riscom8: use tty_port
In reply to Alan CoxFrom: Alan Cox <[email protected]>
Switch riscom8 to use the new tty_port structure
---
drivers/char/riscom8.c | 145 ++++++++++++++++++++++-------------------------- drivers/char/riscom8.h | 8 --- 2 files changed, 68 insertions(+), 85 deletions(-)
drivers/char/riscom8.c +67 -78
@@ -322,7 +322,7 @@ static struct riscom_port *rc_get_port(struct riscom_board const *bp, channel =rc_in (bp,CD180_GICR ) >>GICR_CHAN_OFF ;if (channel <CD180_NCH ) { port = &rc_port[board_No (bp) *RC_NPORT + channel]; -if (port->flags &ASYNC_INITIALIZED ) +if (port->port.flags &ASYNC_INITIALIZED )return port; } printk(KERN_ERR "rc%d: %s interrupt from invalid port %d\n",
@@ -341,7 +341,7 @@ static void rc_receive_exc(struct riscom_board const *bp)if (port ==NULL )return ; - tty = port->tty; + tty = port->port.tty;#ifdef RC_REPORT_OVERRUN status =rc_in (bp,CD180_RCSR );
@@ -364,7 +364,7 @@ static void rc_receive_exc(struct riscom_board const *bp)printk (KERN_INFO "rc%d: port %d: Handling break...\n" ,board_No (bp),port_No (port)); flag =TTY_BREAK ; -if (port->flags &ASYNC_SAK ) +if (port->port.flags &ASYNC_SAK )do_SAK (tty); }else if (status &RCSR_PE )
@@ -392,7 +392,7 @@ static void rc_receive(struct riscom_board const *bp)if (port ==NULL )return ; - tty = port->tty; + tty = port->port.tty; count =rc_in (bp,CD180_RDCR );
@@ -422,7 +422,7 @@ static void rc_transmit(struct riscom_board const *bp)if (port ==NULL )return ; - tty = port->tty; + tty = port->port.tty;if (port->IER &IER_TXEMPTY ) {/* FIFO drained */
@@ -467,7 +467,7 @@ static void rc_transmit(struct riscom_board const *bp) count =CD180_NFIFO ; do { - rc_out(bp, CD180_TDR, port->xmit_buf[port->xmit_tail++]); + rc_out(bp, CD180_TDR, port->port.xmit_buf[port->xmit_tail++]); port->xmit_tail = port->xmit_tail & (SERIAL_XMIT_SIZE-1); if (--port->xmit_cnt <= 0) break;
@@ -492,12 +492,12 @@ static void rc_check_modem(struct riscom_board const *bp)if (port ==NULL )return ; - tty = port->tty; + tty = port->port.tty; mcr =rc_in (bp,CD180_MCR );if (mcr &MCR_CDCHG ) {if (rc_in (bp,CD180_MSVR ) &MSVR_CD ) -wake_up_interruptible (&port->open_wait); +wake_up_interruptible (&port->port.open_wait);else tty_hangup (tty); }
@@ -632,7 +632,7 @@ static void rc_shutdown_board(struct riscom_board *bp)*/ static void rc_change_speed (struct riscom_board *bp,struct riscom_port *port) { -struct tty_struct *tty = port->tty; +struct tty_struct *tty = port->port.tty;unsigned long baud;long tmp;unsigned char cor1 =0 , cor3 =0 ;
@@ -786,28 +786,21 @@ static int rc_setup_port(struct riscom_board *bp, struct riscom_port *port) {unsigned long flags; -if (port->flags &ASYNC_INITIALIZED ) +if (port->port.flags &ASYNC_INITIALIZED )return 0 ; -if (!port->xmit_buf) { -/* We may sleep in get_zeroed_page() */ -unsigned long tmp =get_zeroed_page (GFP_KERNEL ); -if (tmp ==0 ) -return -ENOMEM ; -if (port->xmit_buf) -free_page (tmp); -else - port->xmit_buf = (unsigned char *) tmp; - } +if (tty_port_alloc_xmit_buf (&port->port) <0 ) +return -ENOMEM ; +spin_lock_irqsave (&riscom_lock, flags); -if (port->tty) -clear_bit (TTY_IO_ERROR , &port->tty->flags); -if (port->count ==1 ) +if (port->port.tty) +clear_bit (TTY_IO_ERROR , &port->port.tty->flags); +if (port->port.count ==1 ) bp->count++; port->xmit_cnt = port->xmit_head = port->xmit_tail =0 ;rc_change_speed (bp, port); - port->flags |=ASYNC_INITIALIZED ; + port->port.flags |=ASYNC_INITIALIZED ;spin_unlock_irqrestore (&riscom_lock, flags);return 0 ;
@@ -818,7 +811,7 @@ static void rc_shutdown_port(struct riscom_board *bp, struct riscom_port *port) {struct tty_struct *tty; -if (!(port->flags &ASYNC_INITIALIZED )) +if (!(port->port.flags &ASYNC_INITIALIZED ))return ;#ifdef RC_REPORT_OVERRUN
@@ -836,12 +829,9 @@ static void rc_shutdown_port(struct riscom_board *bp, struct riscom_port *port) printk("].\n"); }#endif -if (port->xmit_buf) { -free_page ((unsigned long ) port->xmit_buf); - port->xmit_buf =NULL ; - } +tty_port_free_xmit_buf (&port->port); - tty = port->tty; + tty = port->port.tty;if (tty ==NULL ||C_HUPCL (tty)) {/* Drop DTR */
@@ -860,7 +850,7 @@ static void rc_shutdown_port(struct riscom_board *bp, struct riscom_port *port)if (tty)set_bit (TTY_IO_ERROR , &tty->flags); - port->flags &= ~ASYNC_INITIALIZED ; + port->port.flags &= ~ASYNC_INITIALIZED ;if (--bp->count <0 ) { printk(KERN_INFO "rc%d: rc_shutdown_port: "
@@ -890,9 +880,9 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,* If the device is in the middle of being closed, then block * until it's done, and then try again. */ -if (tty_hung_up_p (filp) || port->flags &ASYNC_CLOSING ) { -interruptible_sleep_on (&port->close_wait); -if (port->flags &ASYNC_HUP_NOTIFY ) +if (tty_hung_up_p (filp) || port->port.flags &ASYNC_CLOSING ) { +interruptible_sleep_on (&port->port.close_wait); +if (port->port.flags &ASYNC_HUP_NOTIFY )return -EAGAIN ;else return -ERESTARTSYS ;
@@ -904,7 +894,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,*/ if ((filp->f_flags &O_NONBLOCK ) || (tty->flags & (1 <<TTY_IO_ERROR ))) { - port->flags |=ASYNC_NORMAL_ACTIVE ; + port->port.flags |=ASYNC_NORMAL_ACTIVE ;return 0 ; }
@@ -919,16 +909,16 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,* exit, either normal or abnormal. */ retval =0 ; -add_wait_queue (&port->open_wait, &wait); +add_wait_queue (&port->port.open_wait, &wait);spin_lock_irqsave (&riscom_lock, flags);if (!tty_hung_up_p (filp)) - port->count--; + port->port.count--;spin_unlock_irqrestore (&riscom_lock, flags); - port->blocked_open++; + port->port.blocked_open++;while (1 ) {spin_lock_irqsave (&riscom_lock, flags);
@@ -942,14 +932,14 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,set_current_state (TASK_INTERRUPTIBLE );if (tty_hung_up_p (filp) || - !(port->flags &ASYNC_INITIALIZED )) { -if (port->flags &ASYNC_HUP_NOTIFY ) + !(port->port.flags &ASYNC_INITIALIZED )) { +if (port->port.flags &ASYNC_HUP_NOTIFY ) retval = -EAGAIN ;else retval = -ERESTARTSYS ;break ; } -if (!(port->flags &ASYNC_CLOSING ) && +if (!(port->port.flags &ASYNC_CLOSING ) && (do_clocal ||CD ))break ;if (signal_pending (current)) {
@@ -959,14 +949,14 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,schedule (); }__set_current_state (TASK_RUNNING ); -remove_wait_queue (&port->open_wait, &wait); +remove_wait_queue (&port->port.open_wait, &wait);if (!tty_hung_up_p (filp)) - port->count++; - port->blocked_open--; + port->port.count++; + port->port.blocked_open--;if (retval)return retval; - port->flags |=ASYNC_NORMAL_ACTIVE ; + port->port.flags |=ASYNC_NORMAL_ACTIVE ;return 0 ; }
@@ -990,9 +980,9 @@ static int rc_open(struct tty_struct *tty, struct file *filp)if (error)return error; - port->count++; + port->port.count++; tty->driver_data = port; - port->tty = tty; + port->port.tty = tty; error =rc_setup_port (bp, port);if (error ==0 )
@@ -1031,21 +1021,21 @@ static void rc_close(struct tty_struct *tty, struct file *filp) goto out; bp =port_Board (port); -if ((tty->count ==1 ) && (port->count !=1 )) { +if ((tty->count ==1 ) && (port->port.count !=1 )) {printk (KERN_INFO "rc%d: rc_close: bad port count;" " tty->count is 1, port count is %d\n" , -board_No (bp), port->count); - port->count =1 ; +board_No (bp), port->port.count); + port->port.count =1 ; } -if (--port->count <0 ) { +if (--port->port.count <0 ) {printk (KERN_INFO "rc%d: rc_close: bad port count " "for tty%d: %d\n" , -board_No (bp),port_No (port), port->count); - port->count =0 ; +board_No (bp),port_No (port), port->port.count); + port->port.count =0 ; } -if (port->count) +if (port->port.count) goto out; - port->flags |=ASYNC_CLOSING ; + port->port.flags |=ASYNC_CLOSING ;/* * Now we wait for the transmit buffer to clear; and we notify * the line discipline to only process XON/XOFF characters.
@@ -1060,7 +1050,7 @@ static void rc_close(struct tty_struct *tty, struct file *filp)* line status register. */ port->IER &= ~IER_RXD ; -if (port->flags &ASYNC_INITIALIZED ) { +if (port->port.flags &ASYNC_INITIALIZED ) { port->IER &= ~IER_TXRDY ; port->IER |=IER_TXEMPTY ;rc_out (bp,CD180_CAR ,port_No (port));
@@ -1082,14 +1072,14 @@ static void rc_close(struct tty_struct *tty, struct file *filp)tty_ldisc_flush (tty); tty->closing =0 ; - port->tty =NULL ; -if (port->blocked_open) { + port->port.tty =NULL ; +if (port->port.blocked_open) {if (port->close_delay)msleep_interruptible (jiffies_to_msecs (port->close_delay)); -wake_up_interruptible (&port->open_wait); +wake_up_interruptible (&port->port.open_wait); } - port->flags &= ~(ASYNC_NORMAL_ACTIVE |ASYNC_CLOSING ); -wake_up_interruptible (&port->close_wait); + port->port.flags &= ~(ASYNC_NORMAL_ACTIVE |ASYNC_CLOSING ); +wake_up_interruptible (&port->port.close_wait); out:spin_unlock_irqrestore (&riscom_lock, flags);
@@ -1108,7 +1098,7 @@ static int rc_write(struct tty_struct *tty, bp =port_Board (port); -if (!tty || !port->xmit_buf) +if (!tty || !port->port.xmit_buf)return 0 ;while (1 ) {
@@ -1119,7 +1109,7 @@ static int rc_write(struct tty_struct *tty,if (c <=0 )break ;/* lock continues to be held */ -memcpy (port->xmit_buf + port->xmit_head, buf, c); +memcpy (port->port.xmit_buf + port->xmit_head, buf, c); port->xmit_head = (port->xmit_head + c) & (SERIAL_XMIT_SIZE -1 ); port->xmit_cnt += c;
@@ -1151,7 +1141,7 @@ static int rc_put_char(struct tty_struct *tty, unsigned char ch)if (rc_paranoia_check (port, tty->name,"rc_put_char" ))return 0 ; -if (!tty || !port->xmit_buf) +if (!tty || !port->port.xmit_buf)return 0 ;spin_lock_irqsave (&riscom_lock, flags);
@@ -1159,7 +1149,7 @@ static int rc_put_char(struct tty_struct *tty, unsigned char ch)if (port->xmit_cnt >=SERIAL_XMIT_SIZE -1 ) goto out; - port->xmit_buf[port->xmit_head++] = ch; + port->port.xmit_buf[port->xmit_head++] = ch; port->xmit_head &=SERIAL_XMIT_SIZE -1 ; port->xmit_cnt++; ret =1 ;
@@ -1178,7 +1168,7 @@ static void rc_flush_chars(struct tty_struct *tty)return ;if (port->xmit_cnt <=0 || tty->stopped || tty->hw_stopped || - !port->xmit_buf) + !port->port.xmit_buf)return ;spin_lock_irqsave (&riscom_lock, flags);
@@ -1317,19 +1307,19 @@ static int rc_set_serial_info(struct riscom_port *port,return -EINVAL ;#endif - change_speed = ((port->flags &ASYNC_SPD_MASK ) != + change_speed = ((port->port.flags &ASYNC_SPD_MASK ) != (tmp.flags &ASYNC_SPD_MASK ));if (!capable (CAP_SYS_ADMIN )) {if ((tmp.close_delay != port->close_delay) || (tmp.closing_wait != port->closing_wait) || ((tmp.flags & ~ASYNC_USR_MASK ) != - (port->flags & ~ASYNC_USR_MASK ))) + (port->port.flags & ~ASYNC_USR_MASK )))return -EPERM ; - port->flags = ((port->flags & ~ASYNC_USR_MASK ) | + port->port.flags = ((port->port.flags & ~ASYNC_USR_MASK ) | (tmp.flags &ASYNC_USR_MASK )); }else { - port->flags = ((port->flags & ~ASYNC_FLAGS ) | + port->port.flags = ((port->port.flags & ~ASYNC_FLAGS ) | (tmp.flags &ASYNC_FLAGS )); port->close_delay = tmp.close_delay; port->closing_wait = tmp.closing_wait;
@@ -1355,7 +1345,7 @@ static int rc_get_serial_info(struct riscom_port *port, tmp.line = port - rc_port; tmp.port = bp->base; tmp.irq = bp->irq; - tmp.flags = port->flags; + tmp.flags = port->port.flags; tmp.baud_base = (RC_OSCFREQ +CD180_TPC /2 ) /CD180_TPC ; tmp.close_delay = port->close_delay *HZ /100 ; tmp.closing_wait = port->closing_wait *HZ /100 ;
@@ -1480,7 +1470,7 @@ static void rc_start(struct tty_struct *tty)spin_lock_irqsave (&riscom_lock, flags); -if (port->xmit_cnt && port->xmit_buf && !(port->IER &IER_TXRDY )) { +if (port->xmit_cnt && port->port.xmit_buf && !(port->IER &IER_TXRDY )) { port->IER |=IER_TXRDY ;rc_out (bp,CD180_CAR ,port_No (port));rc_out (bp,CD180_IER , port->IER);
@@ -1499,10 +1489,10 @@ static void rc_hangup(struct tty_struct *tty) bp =port_Board (port);rc_shutdown_port (bp, port); - port->count =0 ; - port->flags &= ~ASYNC_NORMAL_ACTIVE ; - port->tty =NULL ; -wake_up_interruptible (&port->open_wait); + port->port.count =0 ; + port->port.flags &= ~ASYNC_NORMAL_ACTIVE ; + port->port.tty =NULL ; +wake_up_interruptible (&port->port.open_wait); } static void rc_set_termios(struct tty_struct *tty,
@@ -1578,8 +1568,7 @@ static int __init rc_init_drivers(void) rc_port[i].magic =RISCOM8_MAGIC ; rc_port[i].close_delay =50 *HZ /100 ; rc_port[i].closing_wait =3000 *HZ /100 ; -init_waitqueue_head (&rc_port[i].open_wait); -init_waitqueue_head (&rc_port[i].close_wait); +tty_port_init (&rc_port[i].port); }return 0 ; }
drivers/char/riscom8.h +1 -7
@@ -66,20 +66,14 @@ struct riscom_board {struct riscom_port {int magic; +struct tty_port port;int baud_base; -int flags; -struct tty_struct * tty; -int count; -int blocked_open;int timeout;int close_delay; -unsigned char * xmit_buf;int custom_divisor;int xmit_head;int xmit_tail;int xmit_cnt; -wait_queue_head_t open_wait; -wait_queue_head_t close_wait;short wakeup_chars;short break_length;unsigned short closing_wait;
PATCH 10/70 riscom8: remove bogus checks
In reply to Alan CoxFrom: Alan Cox <[email protected]>
Chris Malley posted a patch removing a NULL check in the riscom8 driver. Further analysis shows that even more of the tests are irrelevant so we can delete lots of stuff
---
drivers/char/riscom8.c | 32 ++++++++------------------------ 1 files changed, 8 insertions(+), 24 deletions(-)
drivers/char/riscom8.c +8 -24
@@ -638,9 +638,6 @@ static void rc_change_speed(struct riscom_board *bp, struct riscom_port *port)unsigned char cor1 =0 , cor3 =0 ;unsigned char mcor1 =0 , mcor2 =0 ; -if (tty ==NULL || tty->termios ==NULL ) -return ; - port->IER =0 ; port->COR2 =0 ; port->MSVR =MSVR_RTS ;
@@ -794,8 +791,7 @@ static int rc_setup_port(struct riscom_board *bp, struct riscom_port *port)spin_lock_irqsave (&riscom_lock, flags); -if (port->port.tty) -clear_bit (TTY_IO_ERROR , &port->port.tty->flags); +clear_bit (TTY_IO_ERROR , &port->port.tty->flags);if (port->port.count ==1 ) bp->count++; port->xmit_cnt = port->xmit_head = port->xmit_tail =0 ;
@@ -807,10 +803,9 @@ static int rc_setup_port(struct riscom_board *bp, struct riscom_port *port) }/* Must be called with interrupts disabled */ -static void rc_shutdown_port (struct riscom_board *bp,struct riscom_port *port) +static void rc_shutdown_port (struct tty_struct *tty, +struct riscom_board *bp,struct riscom_port *port) { -struct tty_struct *tty; -if (!(port->port.flags &ASYNC_INITIALIZED ))return ;
@@ -830,10 +825,7 @@ static void rc_shutdown_port(struct riscom_board *bp, struct riscom_port *port) }#endif tty_port_free_xmit_buf (&port->port); - - tty = port->port.tty; - -if (tty ==NULL ||C_HUPCL (tty)) { +if (C_HUPCL (tty)) {/* Drop DTR */ bp->DTR |= (1u <<port_No (port));rc_out (bp,RC_DTR , bp->DTR);
@@ -848,8 +840,7 @@ static void rc_shutdown_port(struct riscom_board *bp, struct riscom_port *port) port->IER =0 ;rc_out (bp,CD180_IER , port->IER); -if (tty) -set_bit (TTY_IO_ERROR , &tty->flags); +set_bit (TTY_IO_ERROR , &tty->flags); port->port.flags &= ~ASYNC_INITIALIZED ;if (--bp->count <0 ) {
@@ -1067,7 +1058,7 @@ static void rc_close(struct tty_struct *tty, struct file *filp)break ; } } -rc_shutdown_port (bp, port); +rc_shutdown_port (tty, bp, port);rc_flush_buffer (tty);tty_ldisc_flush (tty);
@@ -1098,9 +1089,6 @@ static int rc_write(struct tty_struct *tty, bp =port_Board (port); -if (!tty || !port->port.xmit_buf) -return 0 ; -while (1 ) {spin_lock_irqsave (&riscom_lock, flags);
@@ -1141,9 +1129,6 @@ static int rc_put_char(struct tty_struct *tty, unsigned char ch)if (rc_paranoia_check (port, tty->name,"rc_put_char" ))return 0 ; -if (!tty || !port->port.xmit_buf) -return 0 ; -spin_lock_irqsave (&riscom_lock, flags);if (port->xmit_cnt >=SERIAL_XMIT_SIZE -1 )
@@ -1167,8 +1152,7 @@ static void rc_flush_chars(struct tty_struct *tty)if (rc_paranoia_check (port, tty->name,"rc_flush_chars" ))return ; -if (port->xmit_cnt <=0 || tty->stopped || tty->hw_stopped || - !port->port.xmit_buf) +if (port->xmit_cnt <=0 || tty->stopped || tty->hw_stopped)return ;spin_lock_irqsave (&riscom_lock, flags);
@@ -1488,7 +1472,7 @@ static void rc_hangup(struct tty_struct *tty) bp =port_Board (port); -rc_shutdown_port (bp, port); +rc_shutdown_port (tty, bp, port); port->port.count =0 ; port->port.flags &= ~ASYNC_NORMAL_ACTIVE ; port->port.tty =NULL ;
PATCH 11/70 isicom: use tty_port
In reply to Alan CoxFrom: Alan Cox <[email protected]>
Switch isicom to use a tty_port structure for some fields
---
drivers/char/isicom.c | 181 +++++++++++++++++++++---------------------------- 1 files changed, 79 insertions(+), 102 deletions(-)
drivers/char/isicom.c +79 -102
@@ -198,17 +198,12 @@ struct isi_board {struct isi_port {unsigned short magic; -unsigned int flags; -int count; -int blocked_open; +struct tty_port port;int close_delay;u16 channel;u16 status;u16 closing_wait;struct isi_board *card; -struct tty_struct *tty; -wait_queue_head_t close_wait; -wait_queue_head_t open_wait;unsigned char *xmit_buf;int xmit_head;int xmit_tail;
@@ -430,11 +425,11 @@ static void isicom_tx(unsigned long _data)for (; count >0 ; count--, port++) {/* port not active or tx disabled to force flow control */ -if (!(port->flags &ASYNC_INITIALIZED ) || +if (!(port->port.flags &ASYNC_INITIALIZED ) || !(port->status &ISI_TXOK ))continue ; - tty = port->tty; + tty = port->port.tty;if (tty ==NULL )continue ;
@@ -458,7 +453,7 @@ static void isicom_tx(unsigned long _data)if (residue ==YES ) { residue =NO ;if (cnt >0 ) { - wrd |= (port->xmit_buf[port->xmit_tail] + wrd |= (port->port.xmit_buf[port->xmit_tail] <<8 ); port->xmit_tail = (port->xmit_tail +1 ) & (SERIAL_XMIT_SIZE -1 );
@@ -474,14 +469,14 @@ static void isicom_tx(unsigned long _data)if (cnt <=0 )break ; word_count = cnt >>1 ; -outsw (base, port->xmit_buf+port->xmit_tail, word_count); +outsw (base, port->port.xmit_buf+port->xmit_tail, word_count); port->xmit_tail = (port->xmit_tail + (word_count <<1 )) & (SERIAL_XMIT_SIZE -1 ); txcount -= (word_count <<1 ); port->xmit_cnt -= (word_count <<1 );if (cnt &0x0001 ) { residue =YES ; - wrd = port->xmit_buf[port->xmit_tail]; + wrd = port->port.xmit_buf[port->xmit_tail]; port->xmit_tail = (port->xmit_tail +1 ) & (SERIAL_XMIT_SIZE -1 ); port->xmit_cnt--;
@@ -548,13 +543,13 @@ static irqreturn_t isicom_interrupt(int irq, void *dev_id)return IRQ_HANDLED ; } port = card->ports + channel; -if (!(port->flags &ASYNC_INITIALIZED )) { +if (!(port->port.flags &ASYNC_INITIALIZED )) {outw (0x0000 , base+0x04 );/* enable interrupts */ spin_unlock (&card->card_lock);return IRQ_HANDLED ; } - tty = port->tty; + tty = port->port.tty;if (tty ==NULL ) { word_count = byte_count >>1 ;while (byte_count >1 ) {
@@ -572,7 +567,7 @@ static irqreturn_t isicom_interrupt(int irq, void *dev_id) header =inw (base);switch (header &0xff ) {case 0 :/* Change in EIA signals */ -if (port->flags &ASYNC_CHECK_CD ) { +if (port->port.flags &ASYNC_CHECK_CD ) {if (port->status &ISI_DCD ) {if (!(header &ISI_DCD )) {/* Carrier has been lost */
@@ -585,7 +580,7 @@ static irqreturn_t isicom_interrupt(int irq, void *dev_id)/* Carrier has been detected */ pr_dbg ("interrupt: DCD->high.\n" ); port->status |=ISI_DCD ; -wake_up_interruptible (&port->open_wait); +wake_up_interruptible (&port->port.open_wait); } }else {if (header &ISI_DCD )
@@ -594,17 +589,17 @@ static irqreturn_t isicom_interrupt(int irq, void *dev_id) port->status &= ~ISI_DCD ; } -if (port->flags &ASYNC_CTS_FLOW ) { -if (port->tty->hw_stopped) { +if (port->port.flags &ASYNC_CTS_FLOW ) { +if (port->port.tty->hw_stopped) {if (header &ISI_CTS ) { - port->tty->hw_stopped =0 ; + port->port.tty->hw_stopped =0 ;/* start tx ing */ port->status |= (ISI_TXOK |ISI_CTS );tty_wakeup (tty); } }else if (!(header &ISI_CTS )) { - port->tty->hw_stopped =1 ; + port->port.tty->hw_stopped =1 ;/* stop tx ing */ port->status &= ~(ISI_TXOK |ISI_CTS ); }
@@ -629,7 +624,7 @@ static irqreturn_t isicom_interrupt(int irq, void *dev_id)case 1 :/* Received Break !!! */ tty_insert_flip_char (tty,0 ,TTY_BREAK ); -if (port->flags &ASYNC_SAK ) +if (port->port.flags &ASYNC_SAK )do_SAK (tty);tty_flip_buffer_push (tty);break ;
@@ -681,7 +676,7 @@ static void isicom_config_port(struct isi_port *port) shift_count = card->shift_count;unsigned char flow_ctrl; - tty = port->tty; + tty = port->port.tty;if (tty ==NULL )return ;
@@ -697,7 +692,7 @@ static void isicom_config_port(struct isi_port *port)/* 1,2,3,4 => 57.6, 115.2, 230, 460 kbps resp. */ if (baud <1 || baud >4 ) - port->tty->termios->c_cflag &= ~CBAUDEX ; + port->port.tty->termios->c_cflag &= ~CBAUDEX ;else baud +=15 ; }
@@ -708,13 +703,13 @@ static void isicom_config_port(struct isi_port *port)* the 'setserial' utility. */ -if ((port->flags &ASYNC_SPD_MASK ) ==ASYNC_SPD_HI ) +if ((port->port.flags &ASYNC_SPD_MASK ) ==ASYNC_SPD_HI ) baud++;/* 57.6 Kbps */ -if ((port->flags &ASYNC_SPD_MASK ) ==ASYNC_SPD_VHI ) +if ((port->port.flags &ASYNC_SPD_MASK ) ==ASYNC_SPD_VHI ) baud +=2 ;/* 115 Kbps */ -if ((port->flags &ASYNC_SPD_MASK ) ==ASYNC_SPD_SHI ) +if ((port->port.flags &ASYNC_SPD_MASK ) ==ASYNC_SPD_SHI ) baud +=3 ;/* 230 kbps*/ -if ((port->flags &ASYNC_SPD_MASK ) ==ASYNC_SPD_WARP ) +if ((port->port.flags &ASYNC_SPD_MASK ) ==ASYNC_SPD_WARP ) baud +=4 ;/* 460 kbps*/ }if (linuxb_to_isib[baud] ==-1 ) {
@@ -754,15 +749,15 @@ static void isicom_config_port(struct isi_port *port)InterruptTheCard (base); }if (C_CLOCAL (tty)) - port->flags &= ~ASYNC_CHECK_CD ; + port->port.flags &= ~ASYNC_CHECK_CD ;else - port->flags |=ASYNC_CHECK_CD ; + port->port.flags |=ASYNC_CHECK_CD ;/* flow control settings ...*/ flow_ctrl =0 ; - port->flags &= ~ASYNC_CTS_FLOW ; + port->port.flags &= ~ASYNC_CTS_FLOW ;if (C_CRTSCTS (tty)) { - port->flags |=ASYNC_CTS_FLOW ; + port->port.flags |=ASYNC_CTS_FLOW ; flow_ctrl |=ISICOM_CTSRTS ; }if (I_IXON (tty))
@@ -809,23 +804,15 @@ static int isicom_setup_port(struct isi_port *port)struct isi_board *card = port->card;unsigned long flags; -if (port->flags &ASYNC_INITIALIZED ) +if (port->port.flags &ASYNC_INITIALIZED )return 0 ; -if (!port->xmit_buf) { -/* Relies on BKL */ -unsigned long page =get_zeroed_page (GFP_KERNEL ); -if (page ==0 ) -return -ENOMEM ; -if (port->xmit_buf) -free_page (page); -else - port->xmit_buf = (unsigned char *) page; - } +if (tty_port_alloc_xmit_buf (&port->port) <0 ) +return -ENOMEM ;spin_lock_irqsave (&card->card_lock, flags); -if (port->tty) -clear_bit (TTY_IO_ERROR , &port->tty->flags); -if (port->count ==1 ) +if (port->port.tty) +clear_bit (TTY_IO_ERROR , &port->port.tty->flags); +if (port->port.count ==1 ) card->count++; port->xmit_cnt = port->xmit_head = port->xmit_tail =0 ;
@@ -839,7 +826,7 @@ static int isicom_setup_port(struct isi_port *port) }isicom_config_port (port); - port->flags |=ASYNC_INITIALIZED ; + port->port.flags |=ASYNC_INITIALIZED ;spin_unlock_irqrestore (&card->card_lock, flags);return 0 ;
@@ -855,10 +842,10 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,/* block if port is in the process of being closed */ -if (tty_hung_up_p (filp) || port->flags &ASYNC_CLOSING ) { +if (tty_hung_up_p (filp) || port->port.flags &ASYNC_CLOSING ) {pr_dbg ("block_til_ready: close in progress.\n" ); -interruptible_sleep_on (&port->close_wait); -if (port->flags &ASYNC_HUP_NOTIFY ) +interruptible_sleep_on (&port->port.close_wait); +if (port->port.flags &ASYNC_HUP_NOTIFY )return -EAGAIN ;else return -ERESTARTSYS ;
@@ -869,7 +856,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,if ((filp->f_flags &O_NONBLOCK ) || (tty->flags & (1 <<TTY_IO_ERROR ))) {pr_dbg ("block_til_ready: non-block mode.\n" ); - port->flags |=ASYNC_NORMAL_ACTIVE ; + port->port.flags |=ASYNC_NORMAL_ACTIVE ;return 0 ; }
@@ -879,26 +866,26 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,/* block waiting for DCD to be asserted, and while callout dev is busy */ retval =0 ; -add_wait_queue (&port->open_wait, &wait); +add_wait_queue (&port->port.open_wait, &wait);spin_lock_irqsave (&card->card_lock, flags);if (!tty_hung_up_p (filp)) - port->count--; - port->blocked_open++; + port->port.count--; + port->port.blocked_open++;spin_unlock_irqrestore (&card->card_lock, flags);while (1 ) {raise_dtr_rts (port);set_current_state (TASK_INTERRUPTIBLE ); -if (tty_hung_up_p (filp) || !(port->flags &ASYNC_INITIALIZED )) { -if (port->flags &ASYNC_HUP_NOTIFY ) +if (tty_hung_up_p (filp) || !(port->port.flags &ASYNC_INITIALIZED )) { +if (port->port.flags &ASYNC_HUP_NOTIFY ) retval = -EAGAIN ;else retval = -ERESTARTSYS ;break ; } -if (!(port->flags &ASYNC_CLOSING ) && +if (!(port->port.flags &ASYNC_CLOSING ) && (do_clocal || (port->status &ISI_DCD ))) {break ; }
@@ -909,15 +896,15 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,schedule (); }set_current_state (TASK_RUNNING ); -remove_wait_queue (&port->open_wait, &wait); +remove_wait_queue (&port->port.open_wait, &wait);spin_lock_irqsave (&card->card_lock, flags);if (!tty_hung_up_p (filp)) - port->count++; - port->blocked_open--; + port->port.count++; + port->port.blocked_open--;spin_unlock_irqrestore (&card->card_lock, flags);if (retval)return retval; - port->flags |=ASYNC_NORMAL_ACTIVE ; + port->port.flags |=ASYNC_NORMAL_ACTIVE ;return 0 ; }
@@ -947,9 +934,9 @@ static int isicom_open(struct tty_struct *tty, struct file *filp)isicom_setup_board (card); - port->count++; + port->port.count++; tty->driver_data = port; - port->tty = tty; + port->port.tty = tty; error =isicom_setup_port (port);if (error ==0 ) error =block_til_ready (tty, filp, port);
@@ -970,18 +957,15 @@ static void isicom_shutdown_port(struct isi_port *port)struct isi_board *card = port->card;struct tty_struct *tty; - tty = port->tty; + tty = port->port.tty; -if (!(port->flags &ASYNC_INITIALIZED )) +if (!(port->port.flags &ASYNC_INITIALIZED ))return ; -if (port->xmit_buf) { -free_page ((unsigned long ) port->xmit_buf); - port->xmit_buf =NULL ; - } - port->flags &= ~ASYNC_INITIALIZED ; +tty_port_free_xmit_buf (&port->port); + port->port.flags &= ~ASYNC_INITIALIZED ;/* 3rd October 2000 : Vinayak P Risbud */ - port->tty =NULL ; + port->port.tty =NULL ;/*Fix done by Anil .S on 30-04-2001 remote login through isi port has dtr toggle problem
@@ -1046,24 +1030,24 @@ static void isicom_close(struct tty_struct *tty, struct file *filp)return ; } -if (tty->count ==1 && port->count !=1 ) { +if (tty->count ==1 && port->port.count !=1 ) {printk (KERN_WARNING "ISICOM:(0x%lx) isicom_close: bad port " "count tty->count = 1 port count = %d.\n" , - card->base, port->count); - port->count =1 ; + card->base, port->port.count); + port->port.count =1 ; } -if (--port->count <0 ) { +if (--port->port.count <0 ) {printk (KERN_WARNING "ISICOM:(0x%lx) isicom_close: bad port " "count for channel%d = %d" , card->base, port->channel, - port->count); - port->count =0 ; + port->port.count); + port->port.count =0 ; } -if (port->count) { +if (port->port.count) {spin_unlock_irqrestore (&card->card_lock, flags);return ; } - port->flags |=ASYNC_CLOSING ; + port->port.flags |=ASYNC_CLOSING ; tty->closing =1 ;spin_unlock_irqrestore (&card->card_lock, flags);
@@ -1072,7 +1056,7 @@ static void isicom_close(struct tty_struct *tty, struct file *filp)/* indicate to the card that no more data can be received on this port */ spin_lock_irqsave (&card->card_lock, flags); -if (port->flags &ASYNC_INITIALIZED ) { +if (port->port.flags &ASYNC_INITIALIZED ) { card->port_status &= ~(1 << port->channel);outw (card->port_status, card->base +0x02 ); }
@@ -1085,7 +1069,7 @@ static void isicom_close(struct tty_struct *tty, struct file *filp)spin_lock_irqsave (&card->card_lock, flags); tty->closing =0 ; -if (port->blocked_open) { +if (port->port.blocked_open) {spin_unlock_irqrestore (&card->card_lock, flags);if (port->close_delay) {pr_dbg ("scheduling until time out.\n" );
@@ -1093,10 +1077,10 @@ static void isicom_close(struct tty_struct *tty, struct file *filp) jiffies_to_msecs(port->close_delay)); }spin_lock_irqsave (&card->card_lock, flags); -wake_up_interruptible (&port->open_wait); +wake_up_interruptible (&port->port.open_wait); } - port->flags &= ~(ASYNC_NORMAL_ACTIVE |ASYNC_CLOSING ); -wake_up_interruptible (&port->close_wait); + port->port.flags &= ~(ASYNC_NORMAL_ACTIVE |ASYNC_CLOSING ); +wake_up_interruptible (&port->port.close_wait);spin_unlock_irqrestore (&card->card_lock, flags); }
@@ -1112,9 +1096,6 @@ static int isicom_write(struct tty_struct *tty, const unsigned char *buf,if (isicom_paranoia_check (port, tty->name,"isicom_write" ))return 0 ; -if (!port->xmit_buf) -return 0 ; -spin_lock_irqsave (&card->card_lock, flags);while (1 ) {
@@ -1123,7 +1104,7 @@ static int isicom_write(struct tty_struct *tty, const unsigned char *buf,if (cnt <=0 )break ; -memcpy (port->xmit_buf + port->xmit_head, buf, cnt); +memcpy (port->port.xmit_buf + port->xmit_head, buf, cnt); port->xmit_head = (port->xmit_head + cnt) & (SERIAL_XMIT_SIZE -1 ); port->xmit_cnt += cnt;
@@ -1147,16 +1128,13 @@ static int isicom_put_char(struct tty_struct *tty, unsigned char ch)if (isicom_paranoia_check (port, tty->name,"isicom_put_char" ))return 0 ; -if (!port->xmit_buf) -return 0 ; -spin_lock_irqsave (&card->card_lock, flags);if (port->xmit_cnt >=SERIAL_XMIT_SIZE -1 ) {spin_unlock_irqrestore (&card->card_lock, flags);return 0 ; } - port->xmit_buf[port->xmit_head++] = ch; + port->port.xmit_buf[port->xmit_head++] = ch; port->xmit_head &= (SERIAL_XMIT_SIZE -1 ); port->xmit_cnt++;spin_unlock_irqrestore (&card->card_lock, flags);
@@ -1172,7 +1150,7 @@ static void isicom_flush_chars(struct tty_struct *tty)return ;if (port->xmit_cnt <=0 || tty->stopped || tty->hw_stopped || - !port->xmit_buf) + !port->port.xmit_buf)return ;/* this tells the transmitter to consider this port for
@@ -1274,23 +1252,23 @@ static int isicom_set_serial_info(struct isi_port *port,lock_kernel (); - reconfig_port = ((port->flags &ASYNC_SPD_MASK ) != + reconfig_port = ((port->port.flags &ASYNC_SPD_MASK ) != (newinfo.flags &ASYNC_SPD_MASK ));if (!capable (CAP_SYS_ADMIN )) {if ((newinfo.close_delay != port->close_delay) || (newinfo.closing_wait != port->closing_wait) || ((newinfo.flags & ~ASYNC_USR_MASK ) != - (port->flags & ~ASYNC_USR_MASK ))) { + (port->port.flags & ~ASYNC_USR_MASK ))) {unlock_kernel ();return -EPERM ; } - port->flags = ((port->flags & ~ASYNC_USR_MASK ) | + port->port.flags = ((port->port.flags & ~ASYNC_USR_MASK ) | (newinfo.flags &ASYNC_USR_MASK )); }else { port->close_delay = newinfo.close_delay; port->closing_wait = newinfo.closing_wait; - port->flags = ((port->flags & ~ASYNC_FLAGS ) | + port->port.flags = ((port->port.flags & ~ASYNC_FLAGS ) | (newinfo.flags &ASYNC_FLAGS )); }if (reconfig_port) {
@@ -1314,7 +1292,7 @@ static int isicom_get_serial_info(struct isi_port *port, out_info.line = port - isi_ports; out_info.port = port->card->base; out_info.irq = port->card->irq; - out_info.flags = port->flags; + out_info.flags = port->port.flags;/* out_info.baud_base = ? */ out_info.close_delay = port->close_delay; out_info.closing_wait = port->closing_wait;
@@ -1454,10 +1432,10 @@ static void isicom_hangup(struct tty_struct *tty)isicom_shutdown_port (port);spin_unlock_irqrestore (&port->card->card_lock, flags); - port->count =0 ; - port->flags &= ~ASYNC_NORMAL_ACTIVE ; - port->tty =NULL ; -wake_up_interruptible (&port->open_wait); + port->port.count =0 ; + port->port.flags &= ~ASYNC_NORMAL_ACTIVE ; + port->port.tty =NULL ; +wake_up_interruptible (&port->port.open_wait); }
@@ -1824,8 +1802,7 @@ static int __init isicom_init(void) port->close_delay =50 *HZ /100 ; port->closing_wait =3000 *HZ /100 ; port->status =0 ; -init_waitqueue_head (&port->open_wait); -init_waitqueue_head (&port->close_wait); +tty_port_init (&port->port);/* . . . */ } isi_card[idx].base =0 ;
PATCH 12/70 istallion: use tty_port
In reply to Alan CoxFrom: Alan Cox <[email protected]>
Switch istallion to use the new tty_port structure
---
drivers/char/istallion.c | 116 +++++++++++++++++++++++---------------------- include/linux/istallion.h | 6 -- 2 files changed, 59 insertions(+), 63 deletions(-)
drivers/char/istallion.c +58 -58
@@ -735,8 +735,8 @@ static void stli_cleanup_ports(struct stlibrd *brdp)for (j =0 ; j <STL_MAXPORTS ; j++) { portp = brdp->ports[j];if (portp !=NULL ) { -if (portp->tty !=NULL ) -tty_hangup (portp->tty); +if (portp->port.tty !=NULL ) +tty_hangup (portp->port.tty);kfree (portp); } }
@@ -811,9 +811,9 @@ static int stli_open(struct tty_struct *tty, struct file *filp)* The sleep here does not need interrupt protection since the wakeup * for it is done with the same context. */ -if (portp->flags &ASYNC_CLOSING ) { -interruptible_sleep_on (&portp->close_wait); -if (portp->flags &ASYNC_HUP_NOTIFY ) +if (portp->port.flags &ASYNC_CLOSING ) { +interruptible_sleep_on (&portp->port.close_wait); +if (portp->port.flags &ASYNC_HUP_NOTIFY )return -EAGAIN ;return -ERESTARTSYS ; }
@@ -824,7 +824,7 @@ static int stli_open(struct tty_struct *tty, struct file *filp)* requires several commands to the board we will need to wait for any * other open that is already initializing the port. */ - portp->tty = tty; + portp->port.tty = tty; tty->driver_data = portp; portp->refcount++;
@@ -833,10 +833,10 @@ static int stli_open(struct tty_struct *tty, struct file *filp)if (signal_pending (current))return -ERESTARTSYS ; -if ((portp->flags &ASYNC_INITIALIZED ) ==0 ) { +if ((portp->port.flags &ASYNC_INITIALIZED ) ==0 ) {set_bit (ST_INITIALIZING , &portp->state);if ((rc =stli_initopen (brdp, portp)) >=0 ) { - portp->flags |=ASYNC_INITIALIZED ; + portp->port.flags |=ASYNC_INITIALIZED ;clear_bit (TTY_IO_ERROR , &tty->flags); }clear_bit (ST_INITIALIZING , &portp->state);
@@ -851,9 +851,9 @@ static int stli_open(struct tty_struct *tty, struct file *filp)* The sleep here does not need interrupt protection since the wakeup * for it is done with the same context. */ -if (portp->flags &ASYNC_CLOSING ) { -interruptible_sleep_on (&portp->close_wait); -if (portp->flags &ASYNC_HUP_NOTIFY ) +if (portp->port.flags &ASYNC_CLOSING ) { +interruptible_sleep_on (&portp->port.close_wait); +if (portp->port.flags &ASYNC_HUP_NOTIFY )return -EAGAIN ;return -ERESTARTSYS ; }
@@ -867,7 +867,7 @@ static int stli_open(struct tty_struct *tty, struct file *filp)if ((rc =stli_waitcarrier (brdp, portp, filp)) !=0 )return rc; } - portp->flags |=ASYNC_NORMAL_ACTIVE ; + portp->port.flags |=ASYNC_NORMAL_ACTIVE ;return 0 ; }
@@ -895,7 +895,7 @@ static void stli_close(struct tty_struct *tty, struct file *filp)return ; } - portp->flags |=ASYNC_CLOSING ; + portp->port.flags |=ASYNC_CLOSING ;/* * May want to wait for data to drain before closing. The BUSY flag
@@ -911,7 +911,7 @@ static void stli_close(struct tty_struct *tty, struct file *filp)if (portp->closing_wait !=ASYNC_CLOSING_WAIT_NONE )tty_wait_until_sent (tty, portp->closing_wait); - portp->flags &= ~ASYNC_INITIALIZED ; + portp->port.flags &= ~ASYNC_INITIALIZED ; brdp = stli_brds[portp->brdnr];stli_rawclose (brdp, portp,0 ,0 );if (tty->termios->c_cflag &HUPCL ) {
@@ -931,16 +931,16 @@ static void stli_close(struct tty_struct *tty, struct file *filp)stli_flushbuffer (tty); tty->closing =0 ; - portp->tty =NULL ; + portp->port.tty =NULL ;if (portp->openwaitcnt) {if (portp->close_delay)msleep_interruptible (jiffies_to_msecs (portp->close_delay)); -wake_up_interruptible (&portp->open_wait); +wake_up_interruptible (&portp->port.open_wait); } - portp->flags &= ~(ASYNC_NORMAL_ACTIVE |ASYNC_CLOSING ); -wake_up_interruptible (&portp->close_wait); + portp->port.flags &= ~(ASYNC_NORMAL_ACTIVE |ASYNC_CLOSING ); +wake_up_interruptible (&portp->port.close_wait); }/*****************************************************************************/
@@ -970,7 +970,7 @@ static int stli_initopen(struct stlibrd *brdp, struct stliport *portp) sizeof(asynotify_t), 0)) < 0)return rc; - tty = portp->tty; + tty = portp->port.tty;if (tty ==NULL )return -ENODEV ;stli_mkasyport (portp, &aport, tty->termios);
@@ -1169,7 +1169,7 @@ static int stli_setport(struct stliport *portp)if (portp ==NULL )return -ENODEV ; -if (portp->tty ==NULL ) +if (portp->port.tty ==NULL )return -ENODEV ;if (portp->brdnr >= stli_nrbrds)return -ENODEV ;
@@ -1177,7 +1177,7 @@ static int stli_setport(struct stliport *portp)if (brdp ==NULL )return -ENODEV ; -stli_mkasyport (portp, &aport, portp->tty->termios); +stli_mkasyport (portp, &aport, portp->port.tty->termios);return (stli_cmdwait (brdp, portp,A_SETPORT , &aport,sizeof (asyport_t),0 )); }
@@ -1196,7 +1196,7 @@ static int stli_waitcarrier(struct stlibrd *brdp, struct stliport *portp, struct rc =0 ; doclocal =0 ; -if (portp->tty->termios->c_cflag &CLOCAL ) +if (portp->port.tty->termios->c_cflag &CLOCAL ) doclocal++;spin_lock_irqsave (&stli_lock, flags);
@@ -1211,14 +1211,14 @@ static int stli_waitcarrier(struct stlibrd *brdp, struct stliport *portp, struct &portp->asig, sizeof(asysigs_t), 0)) < 0)break ;if (tty_hung_up_p (filp) || - ((portp->flags &ASYNC_INITIALIZED ) ==0 )) { -if (portp->flags &ASYNC_HUP_NOTIFY ) + ((portp->port.flags &ASYNC_INITIALIZED ) ==0 )) { +if (portp->port.flags &ASYNC_HUP_NOTIFY ) rc = -EBUSY ;else rc = -ERESTARTSYS ;break ; } -if (((portp->flags &ASYNC_CLOSING ) ==0 ) && +if (((portp->port.flags &ASYNC_CLOSING ) ==0 ) && (doclocal || (portp->sigs &TIOCM_CD ))) {break ; }
@@ -1226,7 +1226,7 @@ static int stli_waitcarrier(struct stlibrd *brdp, struct stliport *portp, struct rc = -ERESTARTSYS ;break ; } -interruptible_sleep_on (&portp->open_wait); +interruptible_sleep_on (&portp->port.open_wait); }spin_lock_irqsave (&stli_lock, flags);
@@ -1548,7 +1548,7 @@ static int stli_getserial(struct stliport *portp, struct serial_struct __user *s sio.type =PORT_UNKNOWN ; sio.line = portp->portnr; sio.irq =0 ; - sio.flags = portp->flags; + sio.flags = portp->port.flags; sio.baud_base = portp->baud_base; sio.close_delay = portp->close_delay; sio.closing_wait = portp->closing_wait;
@@ -1583,11 +1583,11 @@ static int stli_setserial(struct stliport *portp, struct serial_struct __user *sif ((sio.baud_base != portp->baud_base) || (sio.close_delay != portp->close_delay) || ((sio.flags & ~ASYNC_USR_MASK ) != - (portp->flags & ~ASYNC_USR_MASK ))) + (portp->port.flags & ~ASYNC_USR_MASK )))return -EPERM ; } - portp->flags = (portp->flags & ~ASYNC_USR_MASK ) | + portp->port.flags = (portp->port.flags & ~ASYNC_USR_MASK ) | (sio.flags &ASYNC_USR_MASK ); portp->baud_base = sio.baud_base; portp->close_delay = sio.close_delay;
@@ -1751,7 +1751,7 @@ static void stli_settermios(struct tty_struct *tty, struct ktermios *old)if ((old->c_cflag &CRTSCTS ) && ((tiosp->c_cflag &CRTSCTS ) ==0 )) tty->hw_stopped =0 ;if (((old->c_cflag &CLOCAL ) ==0 ) && (tiosp->c_cflag &CLOCAL )) -wake_up_interruptible (&portp->open_wait); +wake_up_interruptible (&portp->port.open_wait); }/*****************************************************************************/
@@ -1834,7 +1834,7 @@ static void stli_hangup(struct tty_struct *tty)if (brdp ==NULL )return ; - portp->flags &= ~ASYNC_INITIALIZED ; + portp->port.flags &= ~ASYNC_INITIALIZED ;if (!test_bit (ST_CLOSING , &portp->state))stli_rawclose (brdp, portp,0 ,0 );
@@ -1855,12 +1855,12 @@ static void stli_hangup(struct tty_struct *tty)clear_bit (ST_TXBUSY , &portp->state);clear_bit (ST_RXSTOP , &portp->state);set_bit (TTY_IO_ERROR , &tty->flags); - portp->tty =NULL ; - portp->flags &= ~ASYNC_NORMAL_ACTIVE ; + portp->port.tty =NULL ; + portp->port.flags &= ~ASYNC_NORMAL_ACTIVE ; portp->refcount =0 ;spin_unlock_irqrestore (&stli_lock, flags); -wake_up_interruptible (&portp->open_wait); +wake_up_interruptible (&portp->port.open_wait); }/*****************************************************************************/
@@ -2188,7 +2188,7 @@ static void stli_read(struct stlibrd *brdp, struct stliport *portp)if (test_bit (ST_RXSTOP , &portp->state))return ; - tty = portp->tty; + tty = portp->port.tty;if (tty ==NULL )return ;
@@ -2362,7 +2362,7 @@ static int stli_hostcmd(struct stlibrd *brdp, struct stliport *portp)if (ap->notify) { nt = ap->changed; ap->notify =0 ; - tty = portp->tty; + tty = portp->port.tty;if (nt.signal &SG_DCD ) { oldsigs = portp->sigs;
@@ -2370,10 +2370,10 @@ static int stli_hostcmd(struct stlibrd *brdp, struct stliport *portp)clear_bit (ST_GETSIGS , &portp->state);if ((portp->sigs &TIOCM_CD ) && ((oldsigs &TIOCM_CD ) ==0 )) -wake_up_interruptible (&portp->open_wait); +wake_up_interruptible (&portp->port.open_wait);if ((oldsigs &TIOCM_CD ) && ((portp->sigs &TIOCM_CD ) ==0 )) { -if (portp->flags &ASYNC_CHECK_CD ) { +if (portp->port.flags &ASYNC_CHECK_CD ) {if (tty)tty_hangup (tty); }
@@ -2392,7 +2392,7 @@ static int stli_hostcmd(struct stlibrd *brdp, struct stliport *portp)if ((nt.data &DT_RXBREAK ) && (portp->rxmarkmsk &BRKINT )) {if (tty !=NULL ) {tty_insert_flip_char (tty,0 ,TTY_BREAK ); -if (portp->flags &ASYNC_SAK ) { +if (portp->port.flags &ASYNC_SAK ) {do_SAK (tty);EBRDENABLE (brdp); }
@@ -2542,17 +2542,17 @@ static void stli_mkasyport(struct stliport *portp, asyport_t *pp, struct ktermio/* * Start of by setting the baud, char size, parity and stop bit info. */ - pp->baudout =tty_get_baud_rate (portp->tty); + pp->baudout =tty_get_baud_rate (portp->port.tty);if ((tiosp->c_cflag &CBAUD ) ==B38400 ) { -if ((portp->flags &ASYNC_SPD_MASK ) ==ASYNC_SPD_HI ) +if ((portp->port.flags &ASYNC_SPD_MASK ) ==ASYNC_SPD_HI ) pp->baudout =57600 ; -else if ((portp->flags &ASYNC_SPD_MASK ) ==ASYNC_SPD_VHI ) +else if ((portp->port.flags &ASYNC_SPD_MASK ) ==ASYNC_SPD_VHI ) pp->baudout =115200 ; -else if ((portp->flags &ASYNC_SPD_MASK ) ==ASYNC_SPD_SHI ) +else if ((portp->port.flags &ASYNC_SPD_MASK ) ==ASYNC_SPD_SHI ) pp->baudout =230400 ; -else if ((portp->flags &ASYNC_SPD_MASK ) ==ASYNC_SPD_WARP ) +else if ((portp->port.flags &ASYNC_SPD_MASK ) ==ASYNC_SPD_WARP ) pp->baudout =460800 ; -else if ((portp->flags &ASYNC_SPD_MASK ) ==ASYNC_SPD_CUST ) +else if ((portp->port.flags &ASYNC_SPD_MASK ) ==ASYNC_SPD_CUST ) pp->baudout = (portp->baud_base / portp->custom_divisor); }if (pp->baudout >STL_MAXBAUD )
@@ -2625,9 +2625,9 @@ static void stli_mkasyport(struct stliport *portp, asyport_t *pp, struct ktermio* Set up clocal processing as required. */ if (tiosp->c_cflag &CLOCAL ) - portp->flags &= ~ASYNC_CHECK_CD ; + portp->port.flags &= ~ASYNC_CHECK_CD ;else - portp->flags |=ASYNC_CHECK_CD ; + portp->port.flags |=ASYNC_CHECK_CD ;/* * Transfer any persistent flags into the asyport structure.
@@ -2703,8 +2703,8 @@ static int stli_initports(struct stlibrd *brdp) portp->baud_base =STL_BAUDBASE ; portp->close_delay =STL_CLOSEDELAY ; portp->closing_wait =30 *HZ ; -init_waitqueue_head (&portp->open_wait); -init_waitqueue_head (&portp->close_wait); +init_waitqueue_head (&portp->port.open_wait); +init_waitqueue_head (&portp->port.close_wait);init_waitqueue_head (&portp->raw_wait); panelport++;if (panelport >= brdp->panels[panelnr]) {
@@ -4246,18 +4246,18 @@ static int stli_portcmdstats(struct stliport *portp) stli_comstats.panel = portp->panelnr; stli_comstats.port = portp->portnr; stli_comstats.state = portp->state; - stli_comstats.flags = portp->flags; + stli_comstats.flags = portp->port.flag;spin_lock_irqsave (&brd_lock, flags); -if (portp->tty !=NULL ) { -if (portp->tty->driver_data == portp) { - stli_comstats.ttystate = portp->tty->flags; +if (portp->port.tty !=NULL ) { +if (portp->port.tty->driver_data == portp) { + stli_comstats.ttystate = portp->port.tty->flags; stli_comstats.rxbuffered =-1 ; -if (portp->tty->termios !=NULL ) { - stli_comstats.cflags = portp->tty->termios->c_cflag; - stli_comstats.iflags = portp->tty->termios->c_iflag; - stli_comstats.oflags = portp->tty->termios->c_oflag; - stli_comstats.lflags = portp->tty->termios->c_lflag; +if (portp->port.tty->termios !=NULL ) { + stli_comstats.cflags = portp->port.tty->termios->c_cflag; + stli_comstats.iflags = portp->port.tty->termios->c_iflag; + stli_comstats.oflags = portp->port.tty->termios->c_oflag; + stli_comstats.lflags = portp->port.tty->termios->c_lflag; } } }
include/linux/istallion.h +1 -5
@@ -51,25 +51,21 @@*/ struct stliport {unsigned long magic; +struct tty_port port;unsigned int portnr;unsigned int panelnr;unsigned int brdnr;unsigned long state;unsigned int devnr; -int flags;int baud_base;int custom_divisor;int close_delay;int closing_wait; -int refcount;int openwaitcnt;int rc;int argsize;void *argp;unsigned int rxmarkmsk; -struct tty_struct *tty; -wait_queue_head_t open_wait; -wait_queue_head_t close_wait;wait_queue_head_t raw_wait;struct asysigs asig;unsigned long addr;
PATCH 13/70 moxa: use tty_port
In reply to Alan CoxFrom: Alan Cox <[email protected]>
Switch MOXA to use the new tty_port structure
---
drivers/char/moxa.c | 87 +++++++++++++++++++++++++-------------------------- 1 files changed, 42 insertions(+), 45 deletions(-)
drivers/char/moxa.c +42 -45
@@ -130,17 +130,14 @@ struct moxaq_str { };struct moxa_port { +struct tty_port port;struct moxa_board_conf *board; -struct tty_struct *tty;void __iomem *tableAddr;int type;int close_delay; -unsigned int count; -int asyncflags;int cflag;unsigned long statusflags; -wait_queue_head_t open_wait;u8 DCDState;u8 lineCtrl;
@@ -348,10 +345,10 @@ static int moxa_ioctl(struct tty_struct *tty, struct file *file,if (status &4 ) tmp.dcd =1 ; -if (!p->tty || !p->tty->termios) +if (!p->port.tty || !p->port.tty->termios) tmp.cflag = p->cflag;else - tmp.cflag = p->tty->termios->c_cflag; + tmp.cflag = p->port.tty->termios->c_cflag; copy:if (copy_to_user (argm, &tmp,sizeof (tmp))) {mutex_unlock (&moxa_openlock);
@@ -828,7 +825,7 @@ static int moxa_init_board(struct moxa_board_conf *brd, struct device *dev) p->type =PORT_16550A ; p->close_delay =5 *HZ /10 ; p->cflag =B9600 |CS8 |CREAD |CLOCAL |HUPCL ; -init_waitqueue_head (&p->open_wait); +tty_port_init (&p->port); }switch (brd->boardType) {
@@ -884,12 +881,12 @@ static void moxa_board_deinit(struct moxa_board_conf *brd)/* pci hot-un-plug support */ for (a =0 ; a < brd->numPorts; a++) -if (brd->ports[a].asyncflags &ASYNC_INITIALIZED ) -tty_hangup (brd->ports[a].tty); +if (brd->ports[a].port.flags &ASYNC_INITIALIZED ) +tty_hangup (brd->ports[a].port.tty);while (1 ) { opened =0 ;for (a =0 ; a < brd->numPorts; a++) -if (brd->ports[a].asyncflags &ASYNC_INITIALIZED ) +if (brd->ports[a].port.flags &ASYNC_INITIALIZED ) opened++;mutex_unlock (&moxa_openlock);if (!opened)
@@ -1104,9 +1101,9 @@ static void moxa_close_port(struct moxa_port *ch) {moxa_shut_down (ch);MoxaPortFlushData (ch,2 ); - ch->asyncflags &= ~ASYNC_NORMAL_ACTIVE ; - ch->tty->driver_data =NULL ; - ch->tty =NULL ; + ch->port.flags &= ~ASYNC_NORMAL_ACTIVE ; + ch->port.tty->driver_data =NULL ; + ch->port.tty =NULL ; } static int moxa_block_till_ready(struct tty_struct *tty, struct file *filp,
@@ -1117,7 +1114,7 @@ static int moxa_block_till_ready(struct tty_struct *tty, struct file *filp,u8 dcd;while (1 ) { -prepare_to_wait (&ch->open_wait, &wait,TASK_INTERRUPTIBLE ); +prepare_to_wait (&ch->port.open_wait, &wait,TASK_INTERRUPTIBLE );if (tty_hung_up_p (filp)) {#ifdef SERIAL_DO_RESTART retval = -ERESTARTSYS ;
@@ -1138,7 +1135,7 @@ static int moxa_block_till_ready(struct tty_struct *tty, struct file *filp, }schedule (); } -finish_wait (&ch->open_wait, &wait); +finish_wait (&ch->port.open_wait, &wait);return retval; }
@@ -1163,16 +1160,16 @@ static int moxa_open(struct tty_struct *tty, struct file *filp) } ch = &brd->ports[port %MAX_PORTS_PER_BOARD ]; - ch->count++; + ch->port.count++; tty->driver_data = ch; - ch->tty = tty; -if (!(ch->asyncflags &ASYNC_INITIALIZED )) { + ch->port.tty = tty; +if (!(ch->port.flags &ASYNC_INITIALIZED )) { ch->statusflags =0 ;moxa_set_tty_param (tty, tty->termios);MoxaPortLineCtrl (ch,1 ,1 );MoxaPortEnable (ch);MoxaSetFifo (ch, ch->type ==PORT_16550A ); - ch->asyncflags |=ASYNC_INITIALIZED ; + ch->port.flags |=ASYNC_INITIALIZED ; }mutex_unlock (&moxa_openlock);
@@ -1181,11 +1178,11 @@ static int moxa_open(struct tty_struct *tty, struct file *filp) retval =moxa_block_till_ready (tty, filp, ch);mutex_lock (&moxa_openlock);if (retval) { -if (ch->count)/* 0 means already hung up... */ -if (--ch->count ==0 ) +if (ch->port.count)/* 0 means already hung up... */ +if (--ch->port.count ==0 )moxa_close_port (ch); }else - ch->asyncflags |=ASYNC_NORMAL_ACTIVE ; + ch->port.flags |=ASYNC_NORMAL_ACTIVE ;mutex_unlock (&moxa_openlock);return retval;
@@ -1204,21 +1201,21 @@ static void moxa_close(struct tty_struct *tty, struct file *filp) ch = tty->driver_data;if (ch ==NULL ) goto unlock; -if (tty->count ==1 && ch->count !=1 ) { +if (tty->count ==1 && ch->port.count !=1 ) {printk (KERN_WARNING "moxa_close: bad serial port count; " -"tty->count is 1, ch->count is %d\n" , ch->count); - ch->count =1 ; +"tty->count is 1, ch->port.count is %d\n" , ch->port.count); + ch->port.count =1 ; } -if (--ch->count <0 ) { +if (--ch->port.count <0 ) {printk (KERN_WARNING "moxa_close: bad serial port count, " "device=%s\n" , tty->name); - ch->count =0 ; + ch->port.count =0 ; } -if (ch->count) +if (ch->port.count) goto unlock; ch->cflag = tty->termios->c_cflag; -if (ch->asyncflags &ASYNC_INITIALIZED ) { +if (ch->port.flags &ASYNC_INITIALIZED ) {moxa_setup_empty_event (tty);tty_wait_until_sent (tty,30 *HZ );/* 30 seconds timeout */ }
@@ -1374,7 +1371,7 @@ static void moxa_set_termios(struct tty_struct *tty,return ;moxa_set_tty_param (tty, old_termios);if (!(old_termios->c_cflag &CLOCAL ) &&C_CLOCAL (tty)) -wake_up_interruptible (&ch->open_wait); +wake_up_interruptible (&ch->port.open_wait); }static void moxa_stop (struct tty_struct *tty)
@@ -1412,20 +1409,20 @@ static void moxa_hangup(struct tty_struct *tty)mutex_unlock (&moxa_openlock);return ; } - ch->count =0 ; + ch->port.count =0 ;moxa_close_port (ch);mutex_unlock (&moxa_openlock); -wake_up_interruptible (&ch->open_wait); +wake_up_interruptible (&ch->port.open_wait); }static void moxa_new_dcdstate (struct moxa_port *p,u8 dcd) { dcd = !!dcd; -if (dcd != p->DCDState && p->tty &&C_CLOCAL (p->tty)) { +if (dcd != p->DCDState && p->port.tty &&C_CLOCAL (p->port.tty)) {if (!dcd) -tty_hangup (p->tty); +tty_hangup (p->port.tty); } p->DCDState = dcd; }
@@ -1433,9 +1430,9 @@ static void moxa_new_dcdstate(struct moxa_port *p, u8 dcd)static int moxa_poll_port (struct moxa_port *p,unsigned int handle,u16 __iomem *ip) { -struct tty_struct *tty = p->tty; +struct tty_struct *tty = p->port.tty;void __iomem *ofsAddr; -unsigned int inited = p->asyncflags &ASYNC_INITIALIZED ; +unsigned int inited = p->port.flags &ASYNC_INITIALIZED ;u16 intr;if (tty) {
@@ -1566,9 +1563,9 @@ static void moxa_setup_empty_event(struct tty_struct *tty)static void moxa_shut_down (struct moxa_port *ch) { -struct tty_struct *tp = ch->tty; +struct tty_struct *tp = ch->port.tty; -if (!(ch->asyncflags &ASYNC_INITIALIZED )) +if (!(ch->port.flags &ASYNC_INITIALIZED ))return ;MoxaPortDisable (ch);
@@ -1580,7 +1577,7 @@ static void moxa_shut_down(struct moxa_port *ch)MoxaPortLineCtrl (ch,0 ,0 );spin_lock_bh (&moxa_lock); - ch->asyncflags &= ~ASYNC_INITIALIZED ; + ch->port.flags &= ~ASYNC_INITIALIZED ;spin_unlock_bh (&moxa_lock); }
@@ -1975,7 +1972,7 @@ static int MoxaPortWriteData(struct moxa_port *port, c = (head > tail) ? (head - tail -1 ) : (head - tail + tx_mask);if (c > len) c = len; - moxaLog.txcnt[port->tty->index] += c; + moxaLog.txcnt[port->port.tty->index] += c; total = c;if (spage == epage) { bufhead =readw (ofsAddr + Ofs_txb);
@@ -2017,7 +2014,7 @@ static int MoxaPortWriteData(struct moxa_port *port,static int MoxaPortReadData (struct moxa_port *port) { -struct tty_struct *tty = port->tty; +struct tty_struct *tty = port->port.tty;unsigned char *dst;void __iomem *baseAddr, *ofsAddr, *ofs;unsigned int count, len, total;
@@ -2124,8 +2121,8 @@ static int moxa_get_serial_info(struct moxa_port *info, {struct serial_struct tmp = { .type = info->type, - .line = info->tty->index, - .flags = info->asyncflags, + .line = info->port.tty->index, + .flags = info->port.flags, .baud_base =921600 , .close_delay = info->close_delay };
@@ -2148,13 +2145,13 @@ static int moxa_set_serial_info(struct moxa_port *info,if (!capable (CAP_SYS_ADMIN )) {if (((new_serial.flags & ~ASYNC_USR_MASK ) != - (info->asyncflags & ~ASYNC_USR_MASK ))) + (info->port.flags & ~ASYNC_USR_MASK )))return -EPERM ; }else info->close_delay = new_serial.close_delay *HZ /100 ; new_serial.flags = (new_serial.flags & ~ASYNC_FLAGS ); - new_serial.flags |= (info->asyncflags &ASYNC_FLAGS ); + new_serial.flags |= (info->port.flags &ASYNC_FLAGS );MoxaSetFifo (info, new_serial.type ==PORT_16550A );
PATCH 14/70 mxser: use tty_port
In reply to Alan CoxFrom: Alan Cox <[email protected]>
Switch mxser to use the new tty_port structure
---
drivers/char/mxser.c | 257 +++++++++++++++++++++++++------------------------- 1 files changed, 126 insertions(+), 131 deletions(-)
drivers/char/mxser.c +126 -131
@@ -222,8 +222,8 @@ struct mxser_mon_ext {struct mxser_board ;struct mxser_port { +struct tty_port port;struct mxser_board *board; -struct tty_struct *tty;unsigned long ioaddr;unsigned long opmode_ioaddr;
@@ -234,7 +234,6 @@ struct mxser_port {int rx_low_water;int baud_base;/* max. speed */ int type;/* UART type */ -int flags;/* defined in tty.h */ int x_char;/* xon/xoff character */ int IER ;/* Interrupt Enable Register */
@@ -249,15 +248,12 @@ struct mxser_port {unsigned char err_shadow;unsigned long event; -int count;/* # of fd on device */ -int blocked_open;/* # of blocked opens */ struct async_icount icount;/* kernel counters for 4 input interrupts */ int timeout;int read_status_mask;int ignore_status_mask;int xmit_fifo_size; -unsigned char *xmit_buf;int xmit_head;int xmit_tail;int xmit_cnt;
@@ -267,7 +263,6 @@ struct mxser_port {struct mxser_mon mon_data;spinlock_t slock; -wait_queue_head_t open_wait;wait_queue_head_t delta_msr_wait; };
@@ -575,7 +570,7 @@ static int mxser_block_til_ready(struct tty_struct *tty, struct file *filp,*/ if ((filp->f_flags &O_NONBLOCK ) ||test_bit (TTY_IO_ERROR , &tty->flags)) { - port->flags |=ASYNC_NORMAL_ACTIVE ; + port->port.flags |=ASYNC_NORMAL_ACTIVE ;return 0 ; }
@@ -585,32 +580,32 @@ static int mxser_block_til_ready(struct tty_struct *tty, struct file *filp,/* * Block waiting for the carrier detect and the line to become * free (i.e., not in use by the callout). While we are in -* this loop, port->count is dropped by one, so that +* this loop, port->port.count is dropped by one, so that * mxser_close() knows when to free things. We restore it upon * exit, either normal or abnormal. */ retval =0 ; -add_wait_queue (&port->open_wait, &wait); +add_wait_queue (&port->port.open_wait, &wait);spin_lock_irqsave (&port->slock, flags);if (!tty_hung_up_p (filp)) - port->count--; + port->port.count--;spin_unlock_irqrestore (&port->slock, flags); - port->blocked_open++; + port->port.blocked_open++;while (1 ) {spin_lock_irqsave (&port->slock, flags);outb (inb (port->ioaddr +UART_MCR ) |UART_MCR_DTR |UART_MCR_RTS , port->ioaddr +UART_MCR );spin_unlock_irqrestore (&port->slock, flags);set_current_state (TASK_INTERRUPTIBLE ); -if (tty_hung_up_p (filp) || !(port->flags &ASYNC_INITIALIZED )) { -if (port->flags &ASYNC_HUP_NOTIFY ) +if (tty_hung_up_p (filp) || !(port->port.flags &ASYNC_INITIALIZED )) { +if (port->port.flags &ASYNC_HUP_NOTIFY ) retval = -EAGAIN ;else retval = -ERESTARTSYS ;break ; } -if (!(port->flags &ASYNC_CLOSING ) && +if (!(port->port.flags &ASYNC_CLOSING ) && (do_clocal || (inb (port->ioaddr +UART_MSR ) &UART_MSR_DCD )))break ;
@@ -621,13 +616,13 @@ static int mxser_block_til_ready(struct tty_struct *tty, struct file *filp,schedule (); }set_current_state (TASK_RUNNING ); -remove_wait_queue (&port->open_wait, &wait); +remove_wait_queue (&port->port.open_wait, &wait);if (!tty_hung_up_p (filp)) - port->count++; - port->blocked_open--; + port->port.count++; + port->port.blocked_open--;if (retval)return retval; - port->flags |=ASYNC_NORMAL_ACTIVE ; + port->port.flags |=ASYNC_NORMAL_ACTIVE ;return 0 ; }
@@ -636,7 +631,7 @@ static int mxser_set_baud(struct mxser_port *info, long newspd)int quot =0 , baud;unsigned char cval; -if (!info->tty || !info->tty->termios) +if (!info->port.tty || !info->port.tty->termios)return -1 ;if (!(info->ioaddr))
@@ -647,13 +642,13 @@ static int mxser_set_baud(struct mxser_port *info, long newspd)if (newspd ==134 ) { quot =2 * info->baud_base /269 ; -tty_encode_baud_rate (info->tty,134 ,134 ); +tty_encode_baud_rate (info->port.tty,134 ,134 ); }else if (newspd) { quot = info->baud_base / newspd;if (quot ==0 ) quot =1 ; baud = info->baud_base/quot; -tty_encode_baud_rate (info->tty, baud, baud); +tty_encode_baud_rate (info->port.tty, baud, baud); }else { quot =0 ; }
@@ -679,7 +674,7 @@ static int mxser_set_baud(struct mxser_port *info, long newspd)outb (cval, info->ioaddr +UART_LCR );/* reset DLAB */ #ifdef BOTHER -if (C_BAUD (info->tty) ==BOTHER ) { +if (C_BAUD (info->port.tty) ==BOTHER ) { quot = info->baud_base % newspd; quot *=8 ;if (quot % newspd > newspd /2 ) {
@@ -707,14 +702,14 @@ static int mxser_change_speed(struct mxser_port *info,int ret =0 ;unsigned char status; -if (!info->tty || !info->tty->termios) +if (!info->port.tty || !info->port.tty->termios)return ret; - cflag = info->tty->termios->c_cflag; + cflag = info->port.tty->termios->c_cflag;if (!(info->ioaddr))return ret; -if (mxser_set_baud_method[info->tty->index] ==0 ) -mxser_set_baud (info,tty_get_baud_rate (info->tty)); +if (mxser_set_baud_method[info->port.tty->index] ==0 ) +mxser_set_baud (info,tty_get_baud_rate (info->port.tty));/* byte size and parity */ switch (cflag &CSIZE ) {
@@ -777,15 +772,15 @@ static int mxser_change_speed(struct mxser_port *info, info->IER &= ~UART_IER_MSI ; info->MCR &= ~UART_MCR_AFE ;if (cflag &CRTSCTS ) { - info->flags |=ASYNC_CTS_FLOW ; + info->port.flags |=ASYNC_CTS_FLOW ; info->IER |=UART_IER_MSI ;if ((info->type ==PORT_16550A ) || (info->board->chip_flag)) { info->MCR |=UART_MCR_AFE ; }else { status =inb (info->ioaddr +UART_MSR ); -if (info->tty->hw_stopped) { +if (info->port.tty->hw_stopped) {if (status &UART_MSR_CTS ) { - info->tty->hw_stopped =0 ; + info->port.tty->hw_stopped =0 ;if (info->type !=PORT_16550A && !info->board->chip_flag) { outb(info->IER & ~UART_IER_THRI,
@@ -795,11 +790,11 @@ static int mxser_change_speed(struct mxser_port *info,outb (info->IER, info->ioaddr +UART_IER ); } -tty_wakeup (info->tty); +tty_wakeup (info->port.tty); } }else {if (!(status &UART_MSR_CTS )) { - info->tty->hw_stopped =1 ; + info->port.tty->hw_stopped =1 ;if ((info->type !=PORT_16550A ) && (!info->board->chip_flag)) { info->IER &= ~UART_IER_THRI ;
@@ -810,13 +805,13 @@ static int mxser_change_speed(struct mxser_port *info, } } }else { - info->flags &= ~ASYNC_CTS_FLOW ; + info->port.flags &= ~ASYNC_CTS_FLOW ; }outb (info->MCR, info->ioaddr +UART_MCR );if (cflag &CLOCAL ) { - info->flags &= ~ASYNC_CHECK_CD ; + info->port.flags &= ~ASYNC_CHECK_CD ; }else { - info->flags |=ASYNC_CHECK_CD ; + info->port.flags |=ASYNC_CHECK_CD ; info->IER |=UART_IER_MSI ; }outb (info->IER, info->ioaddr +UART_IER );
@@ -825,21 +820,21 @@ static int mxser_change_speed(struct mxser_port *info,* Set up parity check flag */ info->read_status_mask =UART_LSR_OE |UART_LSR_THRE |UART_LSR_DR ; -if (I_INPCK (info->tty)) +if (I_INPCK (info->port.tty)) info->read_status_mask |=UART_LSR_FE |UART_LSR_PE ; -if (I_BRKINT (info->tty) ||I_PARMRK (info->tty)) +if (I_BRKINT (info->port.tty) ||I_PARMRK (info->port.tty)) info->read_status_mask |=UART_LSR_BI ; info->ignore_status_mask =0 ; -if (I_IGNBRK (info->tty)) { +if (I_IGNBRK (info->port.tty)) { info->ignore_status_mask |=UART_LSR_BI ; info->read_status_mask |=UART_LSR_BI ;/* * If we're ignore parity and break indicators, ignore * overruns too. (For real raw support). */ -if (I_IGNPAR (info->tty)) { +if (I_IGNPAR (info->port.tty)) { info->ignore_status_mask |=UART_LSR_OE | UART_LSR_PE |
@@ -851,16 +846,16 @@ static int mxser_change_speed(struct mxser_port *info, } }if (info->board->chip_flag) { -mxser_set_must_xon1_value (info->ioaddr,START_CHAR (info->tty)); -mxser_set_must_xoff1_value (info->ioaddr,STOP_CHAR (info->tty)); -if (I_IXON (info->tty)) { +mxser_set_must_xon1_value (info->ioaddr,START_CHAR (info->port.tty)); +mxser_set_must_xoff1_value (info->ioaddr,STOP_CHAR (info->port.tty)); +if (I_IXON (info->port.tty)) {mxser_enable_must_rx_software_flow_control ( info->ioaddr); }else {mxser_disable_must_rx_software_flow_control ( info->ioaddr); } -if (I_IXOFF (info->tty)) { +if (I_IXOFF (info->port.tty)) {mxser_enable_must_tx_software_flow_control ( info->ioaddr); }else {
@@ -890,15 +885,15 @@ static void mxser_check_modem_status(struct mxser_port *port, int status) port->mon_data.modem_status = status;wake_up_interruptible (&port->delta_msr_wait); -if ((port->flags &ASYNC_CHECK_CD ) && (status &UART_MSR_DDCD )) { +if ((port->port.flags &ASYNC_CHECK_CD ) && (status &UART_MSR_DDCD )) {if (status &UART_MSR_DCD ) -wake_up_interruptible (&port->open_wait); +wake_up_interruptible (&port->port.open_wait); } -if (port->flags &ASYNC_CTS_FLOW ) { -if (port->tty->hw_stopped) { +if (port->port.flags &ASYNC_CTS_FLOW ) { +if (port->port.tty->hw_stopped) {if (status &UART_MSR_CTS ) { - port->tty->hw_stopped =0 ; + port->port.tty->hw_stopped =0 ;if ((port->type !=PORT_16550A ) && (!port->board->chip_flag)) {
@@ -908,11 +903,11 @@ static void mxser_check_modem_status(struct mxser_port *port, int status)outb (port->IER, port->ioaddr +UART_IER ); } -tty_wakeup (port->tty); +tty_wakeup (port->port.tty); } }else {if (!(status &UART_MSR_CTS )) { - port->tty->hw_stopped =1 ; + port->port.tty->hw_stopped =1 ;if (port->type !=PORT_16550A && !port->board->chip_flag) { port->IER &= ~UART_IER_THRI ;
@@ -935,23 +930,23 @@ static int mxser_startup(struct mxser_port *info)spin_lock_irqsave (&info->slock, flags); -if (info->flags &ASYNC_INITIALIZED ) { +if (info->port.flags &ASYNC_INITIALIZED ) {free_page (page);spin_unlock_irqrestore (&info->slock, flags);return 0 ; }if (!info->ioaddr || !info->type) { -if (info->tty) -set_bit (TTY_IO_ERROR , &info->tty->flags); +if (info->port.tty) +set_bit (TTY_IO_ERROR , &info->port.tty->flags);free_page (page);spin_unlock_irqrestore (&info->slock, flags);return 0 ; } -if (info->xmit_buf) +if (info->port.xmit_buf)free_page (page);else - info->xmit_buf = (unsigned char *) page; + info->port.xmit_buf = (unsigned char *) page;/* * Clear the FIFO buffers and disable them
@@ -973,8 +968,8 @@ static int mxser_startup(struct mxser_port *info)if (inb (info->ioaddr +UART_LSR ) ==0xff ) {spin_unlock_irqrestore (&info->slock, flags);if (capable (CAP_SYS_ADMIN )) { -if (info->tty) -set_bit (TTY_IO_ERROR , &info->tty->flags); +if (info->port.tty) +set_bit (TTY_IO_ERROR , &info->port.tty->flags);return 0 ; }else return -ENODEV ;
@@ -1012,15 +1007,15 @@ static int mxser_startup(struct mxser_port *info) (void )inb (info->ioaddr +UART_IIR ); (void )inb (info->ioaddr +UART_MSR ); -if (info->tty) -clear_bit (TTY_IO_ERROR , &info->tty->flags); +if (info->port.tty) +clear_bit (TTY_IO_ERROR , &info->port.tty->flags); info->xmit_cnt = info->xmit_head = info->xmit_tail =0 ;/* * and set the speed of the serial port */ mxser_change_speed (info,NULL ); - info->flags |=ASYNC_INITIALIZED ; + info->port.flags |=ASYNC_INITIALIZED ;spin_unlock_irqrestore (&info->slock, flags);return 0 ;
@@ -1034,7 +1029,7 @@ static void mxser_shutdown(struct mxser_port *info) {unsigned long flags; -if (!(info->flags &ASYNC_INITIALIZED )) +if (!(info->port.flags &ASYNC_INITIALIZED ))return ;spin_lock_irqsave (&info->slock, flags);
@@ -1048,15 +1043,15 @@ static void mxser_shutdown(struct mxser_port *info)/* * Free the IRQ, if necessary */ -if (info->xmit_buf) { -free_page ((unsigned long ) info->xmit_buf); - info->xmit_buf =NULL ; +if (info->port.xmit_buf) { +free_page ((unsigned long ) info->port.xmit_buf); + info->port.xmit_buf =NULL ; } info->IER =0 ;outb (0x00 , info->ioaddr +UART_IER ); -if (!info->tty || (info->tty->termios->c_cflag &HUPCL )) +if (!info->port.tty || (info->port.tty->termios->c_cflag &HUPCL )) info->MCR &= ~(UART_MCR_DTR |UART_MCR_RTS );outb (info->MCR, info->ioaddr +UART_MCR );
@@ -1072,10 +1067,10 @@ static void mxser_shutdown(struct mxser_port *info)/* read data port to reset things */ (void )inb (info->ioaddr +UART_RX ); -if (info->tty) -set_bit (TTY_IO_ERROR , &info->tty->flags); +if (info->port.tty) +set_bit (TTY_IO_ERROR , &info->port.tty->flags); - info->flags &= ~ASYNC_INITIALIZED ; + info->port.flags &= ~ASYNC_INITIALIZED ;if (info->board->chip_flag)SET_MOXA_MUST_NO_SOFTWARE_FLOW_CONTROL (info->ioaddr);
@@ -1105,12 +1100,12 @@ static int mxser_open(struct tty_struct *tty, struct file *filp)return -ENODEV ; tty->driver_data = info; - info->tty = tty; + info->port.tty = tty;/* * Start up serial port */ spin_lock_irqsave (&info->slock, flags); - info->count++; + info->port.count++;spin_unlock_irqrestore (&info->slock, flags); retval =mxser_startup (info);if (retval)
@@ -1170,34 +1165,34 @@ static void mxser_close(struct tty_struct *tty, struct file *filp)spin_unlock_irqrestore (&info->slock, flags);return ; } -if ((tty->count ==1 ) && (info->count !=1 )) { +if ((tty->count ==1 ) && (info->port.count !=1 )) {/* * Uh, oh. tty->count is 1, which means that the tty -* structure will be freed. Info->count should always +* structure will be freed. Info->port.count should always * be one in these conditions. If it's greater than * one, we've got real problems, since it means the * serial port won't be shutdown. */ printk (KERN_ERR "mxser_close: bad serial port count; " -"tty->count is 1, info->count is %d\n" , info->count); - info->count =1 ; +"tty->count is 1, info->port.count is %d\n" , info->port.count); + info->port.count =1 ; } -if (--info->count <0 ) { +if (--info->port.count <0 ) {printk (KERN_ERR "mxser_close: bad serial port count for " -"ttys%d: %d\n" , tty->index, info->count); - info->count =0 ; +"ttys%d: %d\n" , tty->index, info->port.count); + info->port.count =0 ; } -if (info->count) { +if (info->port.count) {spin_unlock_irqrestore (&info->slock, flags);return ; } - info->flags |=ASYNC_CLOSING ; + info->port.flags |=ASYNC_CLOSING ;spin_unlock_irqrestore (&info->slock, flags);/* * Save the termios structure, since this port may have * separate termios for callout and dialin. */ -if (info->flags &ASYNC_NORMAL_ACTIVE ) +if (info->port.flags &ASYNC_NORMAL_ACTIVE ) info->normal_termios = *tty->termios;/* * Now we wait for the transmit buffer to clear; and we notify
@@ -1216,7 +1211,7 @@ static void mxser_close(struct tty_struct *tty, struct file *filp)if (info->board->chip_flag) info->IER &= ~MOXA_MUST_RECV_ISR ; -if (info->flags &ASYNC_INITIALIZED ) { +if (info->port.flags &ASYNC_INITIALIZED ) {outb (info->IER, info->ioaddr +UART_IER );/* * Before we drop DTR, make sure the UART transmitter
@@ -1237,14 +1232,14 @@ static void mxser_close(struct tty_struct *tty, struct file *filp) tty->closing =0 ; info->event =0 ; - info->tty =NULL ; -if (info->blocked_open) { + info->port.tty =NULL ; +if (info->port.blocked_open) {if (info->close_delay)schedule_timeout_interruptible (info->close_delay); -wake_up_interruptible (&info->open_wait); +wake_up_interruptible (&info->port.open_wait); } - info->flags &= ~(ASYNC_NORMAL_ACTIVE |ASYNC_CLOSING ); + info->port.flags &= ~(ASYNC_NORMAL_ACTIVE |ASYNC_CLOSING ); }static int mxser_write (struct tty_struct *tty,const unsigned char *buf,int count)
@@ -1253,7 +1248,7 @@ static int mxser_write(struct tty_struct *tty, const unsigned char *buf, int coustruct mxser_port *info = tty->driver_data;unsigned long flags; -if (!info->xmit_buf) +if (!info->port.xmit_buf)return 0 ;while (1 ) {
@@ -1262,7 +1257,7 @@ static int mxser_write(struct tty_struct *tty, const unsigned char *buf, int couif (c <=0 )break ; -memcpy (info->xmit_buf + info->xmit_head, buf, c); +memcpy (info->port.xmit_buf + info->xmit_head, buf, c);spin_lock_irqsave (&info->slock, flags); info->xmit_head = (info->xmit_head + c) & (SERIAL_XMIT_SIZE -1 );
@@ -1294,14 +1289,14 @@ static int mxser_put_char(struct tty_struct *tty, unsigned char ch)struct mxser_port *info = tty->driver_data;unsigned long flags; -if (!info->xmit_buf) +if (!info->port.xmit_buf)return 0 ;if (info->xmit_cnt >=SERIAL_XMIT_SIZE -1 )return 0 ;spin_lock_irqsave (&info->slock, flags); - info->xmit_buf[info->xmit_head++] = ch; + info->port.xmit_buf[info->xmit_head++] = ch; info->xmit_head &=SERIAL_XMIT_SIZE -1 ; info->xmit_cnt++;spin_unlock_irqrestore (&info->slock, flags);
@@ -1327,7 +1322,7 @@ static void mxser_flush_chars(struct tty_struct *tty) if (info->xmit_cnt <= 0 || tty->stopped || - !info->xmit_buf || + !info->port.xmit_buf || (tty->hw_stopped && (info->type != PORT_16550A) && (!info->board->chip_flag)
@@ -1370,10 +1365,10 @@ static int mxser_get_serial_info(struct mxser_port *info, {struct serial_struct tmp = { .type = info->type, - .line = info->tty->index, + .line = info->port.tty->index, .port = info->ioaddr, .irq = info->board->irq, - .flags = info->flags, + .flags = info->port.flags, .baud_base = info->baud_base, .close_delay = info->close_delay, .closing_wait = info->closing_wait,
@@ -1403,33 +1398,33 @@ static int mxser_set_serial_info(struct mxser_port *info, new_serial.port != info->ioaddr)return -EINVAL ; - flags = info->flags &ASYNC_SPD_MASK ; + flags = info->port.flags &ASYNC_SPD_MASK ;if (!capable (CAP_SYS_ADMIN )) {if ((new_serial.baud_base != info->baud_base) || (new_serial.close_delay != info->close_delay) || - ((new_serial.flags & ~ASYNC_USR_MASK ) != (info->flags & ~ASYNC_USR_MASK ))) + ((new_serial.flags & ~ASYNC_USR_MASK ) != (info->port.flags & ~ASYNC_USR_MASK )))return -EPERM ; - info->flags = ((info->flags & ~ASYNC_USR_MASK ) | + info->port.flags = ((info->port.flags & ~ASYNC_USR_MASK ) | (new_serial.flags &ASYNC_USR_MASK )); }else {/* * OK, past this point, all the error checking has been done. * At this point, we start making changes..... */ - info->flags = ((info->flags & ~ASYNC_FLAGS ) | + info->port.flags = ((info->port.flags & ~ASYNC_FLAGS ) | (new_serial.flags &ASYNC_FLAGS )); info->close_delay = new_serial.close_delay *HZ /100 ; info->closing_wait = new_serial.closing_wait *HZ /100 ; - info->tty->low_latency = - (info->flags &ASYNC_LOW_LATENCY ) ?1 :0 ; - info->tty->low_latency =0 ; -if ((info->flags &ASYNC_SPD_MASK ) ==ASYNC_SPD_CUST && + info->port.tty->low_latency = + (info->port.flags &ASYNC_LOW_LATENCY ) ?1 :0 ; + info->port.tty->low_latency =0 ; +if ((info->port.flags &ASYNC_SPD_MASK ) ==ASYNC_SPD_CUST && (new_serial.baud_base != info->baud_base || new_serial.custom_divisor != info->custom_divisor)) { baud = new_serial.baud_base / new_serial.custom_divisor; -tty_encode_baud_rate (info->tty, baud, baud); +tty_encode_baud_rate (info->port.tty, baud, baud); } }
@@ -1437,8 +1432,8 @@ static int mxser_set_serial_info(struct mxser_port *info,process_txrx_fifo (info); -if (info->flags &ASYNC_INITIALIZED ) { -if (flags != (info->flags &ASYNC_SPD_MASK )) { +if (info->port.flags &ASYNC_INITIALIZED ) { +if (flags != (info->port.flags &ASYNC_SPD_MASK )) {spin_lock_irqsave (&info->slock, sl_flags);mxser_change_speed (info,NULL );spin_unlock_irqrestore (&info->slock, sl_flags);
@@ -1693,12 +1688,12 @@ static int mxser_ioctl_special(unsigned int cmd, void __user *argp)continue ; } -if (!port->tty || !port->tty->termios) +if (!port->port.tty || !port->port.tty->termios) GMStatus[i].cflag = port->normal_termios.c_cflag;else GMStatus[i].cflag = - port->tty->termios->c_cflag; + port->port.tty->termios->c_cflag; status =inb (port->ioaddr +UART_MSR );if (status &0x80 /*UART_MSR_DCD */ )
@@ -1755,14 +1750,14 @@ static int mxser_ioctl_special(unsigned int cmd, void __user *argp) mon_data_ext.modem_status[i] = port->mon_data.modem_status; mon_data_ext.baudrate[i] = -tty_get_baud_rate (port->tty); +tty_get_baud_rate (port->port.tty); -if (!port->tty || !port->tty->termios) { +if (!port->port.tty || !port->port.tty->termios) { cflag = port->normal_termios.c_cflag; iflag = port->normal_termios.c_iflag; }else { - cflag = port->tty->termios->c_cflag; - iflag = port->tty->termios->c_iflag; + cflag = port->port.tty->termios->c_cflag; + iflag = port->port.tty->termios->c_iflag; } mon_data_ext.databits[i] = cflag &CSIZE ;
@@ -1989,7 +1984,7 @@ static int mxser_ioctl(struct tty_struct *tty, struct file *file,else info->mon_data.hold_reason |=NPPI_NOTIFY_XOFFXENT ; -if (info->tty->hw_stopped) +if (info->port.tty->hw_stopped) info->mon_data.hold_reason |=NPPI_NOTIFY_CTSHOLD ;else info->mon_data.hold_reason &= ~NPPI_NOTIFY_CTSHOLD ;
@@ -2038,7 +2033,7 @@ static void mxser_stoprx(struct tty_struct *tty) } } -if (info->tty->termios->c_cflag &CRTSCTS ) { +if (info->port.tty->termios->c_cflag &CRTSCTS ) { info->MCR &= ~UART_MCR_RTS ;outb (info->MCR, info->ioaddr +UART_MCR ); }
@@ -2075,7 +2070,7 @@ static void mxser_unthrottle(struct tty_struct *tty) } } -if (info->tty->termios->c_cflag &CRTSCTS ) { +if (info->port.tty->termios->c_cflag &CRTSCTS ) { info->MCR |=UART_MCR_RTS ;outb (info->MCR, info->ioaddr +UART_MCR ); }
@@ -2106,7 +2101,7 @@ static void mxser_start(struct tty_struct *tty)unsigned long flags;spin_lock_irqsave (&info->slock, flags); -if (info->xmit_cnt && info->xmit_buf) { +if (info->xmit_cnt && info->port.xmit_buf) {outb (info->IER & ~UART_IER_THRI , info->ioaddr +UART_IER ); info->IER |=UART_IER_THRI ;outb (info->IER, info->ioaddr +UART_IER );
@@ -2220,10 +2215,10 @@ static void mxser_hangup(struct tty_struct *tty)mxser_flush_buffer (tty);mxser_shutdown (info); info->event =0 ; - info->count =0 ; - info->flags &= ~ASYNC_NORMAL_ACTIVE ; - info->tty =NULL ; -wake_up_interruptible (&info->open_wait); + info->port.count =0 ; + info->port.flags &= ~ASYNC_NORMAL_ACTIVE ; + info->port.tty =NULL ; +wake_up_interruptible (&info->port.open_wait); }/*
@@ -2246,7 +2241,7 @@ static void mxser_rs_break(struct tty_struct *tty, int break_state)static void mxser_receive_chars (struct mxser_port *port,int *status) { -struct tty_struct *tty = port->tty; +struct tty_struct *tty = port->port.tty;unsigned char ch, gdl;int ignored =0 ;int cnt =0 ;
@@ -2302,7 +2297,7 @@ intr_old: flag =TTY_BREAK ; port->icount.brk++; -if (port->flags &ASYNC_SAK ) +if (port->port.flags &ASYNC_SAK )do_SAK (tty); }else if (*status &UART_LSR_PE ) { flag =TTY_PARITY ;
@@ -2333,7 +2328,7 @@ intr_old: }while (*status &UART_LSR_DR ); end_intr: - mxvar_log.rxcnt[port->tty->index] += cnt; + mxvar_log.rxcnt[port->port.tty->index] += cnt; port->mon_data.rxcnt += cnt; port->mon_data.up_rxcnt += cnt;
@@ -2354,18 +2349,18 @@ static void mxser_transmit_chars(struct mxser_port *port)if (port->x_char) {outb (port->x_char, port->ioaddr +UART_TX ); port->x_char =0 ; - mxvar_log.txcnt[port->tty->index]++; + mxvar_log.txcnt[port->port.tty->index]++; port->mon_data.txcnt++; port->mon_data.up_txcnt++; port->icount.tx++;return ; } -if (port->xmit_buf ==NULL ) +if (port->port.xmit_buf ==NULL )return ; -if ((port->xmit_cnt <=0 ) || port->tty->stopped || - (port->tty->hw_stopped && +if ((port->xmit_cnt <=0 ) || port->port.tty->stopped || + (port->port.tty->hw_stopped && (port->type !=PORT_16550A ) && (!port->board->chip_flag))) { port->IER &= ~UART_IER_THRI ;
@@ -2376,20 +2371,20 @@ static void mxser_transmit_chars(struct mxser_port *port) cnt = port->xmit_cnt; count = port->xmit_fifo_size;do { -outb (port->xmit_buf[port->xmit_tail++], +outb (port->port.xmit_buf[port->xmit_tail++], port->ioaddr +UART_TX ); port->xmit_tail = port->xmit_tail & (SERIAL_XMIT_SIZE -1 );if (--port->xmit_cnt <=0 )break ; }while (--count >0 ); - mxvar_log.txcnt[port->tty->index] += (cnt - port->xmit_cnt); + mxvar_log.txcnt[port->port.tty->index] += (cnt - port->xmit_cnt); port->mon_data.txcnt += (cnt - port->xmit_cnt); port->mon_data.up_txcnt += (cnt - port->xmit_cnt); port->icount.tx += (cnt - port->xmit_cnt);if (port->xmit_cnt <WAKEUP_CHARS ) -tty_wakeup (port->tty); +tty_wakeup (port->port.tty);if (port->xmit_cnt <=0 ) { port->IER &= ~UART_IER_THRI ;
@@ -2440,9 +2435,9 @@ static irqreturn_t mxser_interrupt(int irq, void *dev_id)if (iir &UART_IIR_NO_INT )break ; iir &=MOXA_MUST_IIR_MASK ; -if (!port->tty || - (port->flags &ASYNC_CLOSING ) || - !(port->flags & +if (!port->port.tty || + (port->port.flags &ASYNC_CLOSING ) || + !(port->port.flags &ASYNC_INITIALIZED )) { status =inb (port->ioaddr +UART_LSR );outb (0x27 , port->ioaddr +UART_FCR );
@@ -2558,7 +2553,7 @@ static int __devinit mxser_initbrd(struct mxser_board *brd,if (brd->chip_flag !=MOXA_OTHER_UART )mxser_enable_must_enchance_mode (info->ioaddr); - info->flags =ASYNC_SHARE_IRQ ; + info->port.flags =ASYNC_SHARE_IRQ ; info->type = brd->uart_type;process_txrx_fifo (info);
@@ -2567,7 +2562,7 @@ static int __devinit mxser_initbrd(struct mxser_board *brd, info->close_delay =5 *HZ /10 ; info->closing_wait =30 *HZ ; info->normal_termios = mxvar_sdriver->init_termios; -init_waitqueue_head (&info->open_wait); +tty_port_init (&info->port);init_waitqueue_head (&info->delta_msr_wait);memset (&info->mon_data,0 ,sizeof (struct mxser_mon )); info->err_shadow =0 ;
PATCH 15/70 rocket: use tty_port
In reply to Alan CoxFrom: Alan Cox <[email protected]>
Switch the rocketport to use the new tty_port structure
---
drivers/char/rocket.c | 116 +++++++++++++++++++++++---------------------- drivers/char/rocket_int.h | 9 +-- 2 files changed, 61 insertions(+), 64 deletions(-)
drivers/char/rocket.c +58 -58
@@ -434,15 +434,15 @@ static void rp_do_transmit(struct r_port *info)#endif if (!info)return ; -if (!info->tty) { +if (!info->port.tty) {printk (KERN_WARNING "rp: WARNING %s called with " -"info->tty==NULL\n" , __func__); +"info->port.tty==NULL\n" , __func__);clear_bit ((info->aiop *8 ) + info->chan, (void *) &xmit_flags[info->board]);return ; }spin_lock_irqsave (&info->slock, flags); - tty = info->tty; + tty = info->port.tty; info->xmit_fifo_room =TXFIFO_SIZE -sGetTxCnt (cp);/* Loop sending data to FIFO until done or FIFO full */
@@ -502,13 +502,13 @@ static void rp_handle_port(struct r_port *info) "info->flags & NOT_INIT\n");return ; } -if (!info->tty) { +if (!info->port.tty) {printk (KERN_WARNING "rp: WARNING: rp_handle_port called with " -"info->tty==NULL\n" ); +"info->port.tty==NULL\n" );return ; } cp = &info->channel; - tty = info->tty; + tty = info->port.tty; IntMask =sGetChanIntID (cp) & info->intmask;#ifdef ROCKET_DEBUG_INTR
@@ -530,7 +530,7 @@ static void rp_handle_port(struct r_port *info)tty_hangup (tty); } info->cd_status = (ChanStatus &CD_ACT ) ?1 :0 ; -wake_up_interruptible (&info->open_wait); +wake_up_interruptible (&info->port.open_wait); }#ifdef ROCKET_DEBUG_INTR if (IntMask &DELTA_CTS ) {/* CTS change */
@@ -650,7 +650,7 @@ static void init_r_port(int board, int aiop, int chan, struct pci_dev *pci_dev) info->chan = chan; info->closing_wait =3000 ; info->close_delay =50 ; -init_waitqueue_head (&info->open_wait); +init_waitqueue_head (&info->port.open_wait);init_completion (&info->close_wait); info->flags &= ~ROCKET_MODE_MASK ;switch (pc104[board][line]) {
@@ -717,7 +717,7 @@ static void configure_r_port(struct r_port *info,unsigned rocketMode;int bits, baud, divisor;CHANNEL_t *cp; -struct ktermios *t = info->tty->termios; +struct ktermios *t = info->port.tty->termios; cp = &info->channel; cflag = t->c_cflag;
@@ -750,7 +750,7 @@ static void configure_r_port(struct r_port *info, }/* baud rate */ - baud =tty_get_baud_rate (info->tty); + baud =tty_get_baud_rate (info->port.tty);if (!baud) baud =9600 ; divisor = ((rp_baud_base[info->board] + (baud >>1 )) / baud) -1 ;
@@ -768,7 +768,7 @@ static void configure_r_port(struct r_port *info,sSetBaud (cp, divisor);/* FIXME: Should really back compute a baud rate from the divisor */ -tty_encode_baud_rate (info->tty, baud, baud); +tty_encode_baud_rate (info->port.tty, baud, baud);if (cflag &CRTSCTS ) { info->intmask |=DELTA_CTS ;
@@ -793,15 +793,15 @@ static void configure_r_port(struct r_port *info,* Handle software flow control in the board */ #ifdef ROCKET_SOFT_FLOW -if (I_IXON (info->tty)) { +if (I_IXON (info->port.tty)) {sEnTxSoftFlowCtl (cp); -if (I_IXANY (info->tty)) { +if (I_IXANY (info->port.tty)) {sEnIXANY (cp); }else {sDisIXANY (cp); } -sSetTxXONChar (cp,START_CHAR (info->tty)); -sSetTxXOFFChar (cp,STOP_CHAR (info->tty)); +sSetTxXONChar (cp,START_CHAR (info->port.tty)); +sSetTxXOFFChar (cp,STOP_CHAR (info->port.tty)); }else {sDisTxSoftFlowCtl (cp);sDisIXANY (cp);
@@ -813,24 +813,24 @@ static void configure_r_port(struct r_port *info,* Set up ignore/read mask words */ info->read_status_mask =STMRCVROVRH |0xFF ; -if (I_INPCK (info->tty)) +if (I_INPCK (info->port.tty)) info->read_status_mask |=STMFRAMEH |STMPARITYH ; -if (I_BRKINT (info->tty) ||I_PARMRK (info->tty)) +if (I_BRKINT (info->port.tty) ||I_PARMRK (info->port.tty)) info->read_status_mask |=STMBREAKH ;/* * Characters to ignore */ info->ignore_status_mask =0 ; -if (I_IGNPAR (info->tty)) +if (I_IGNPAR (info->port.tty)) info->ignore_status_mask |=STMFRAMEH |STMPARITYH ; -if (I_IGNBRK (info->tty)) { +if (I_IGNBRK (info->port.tty)) { info->ignore_status_mask |=STMBREAKH ;/* * If we're ignoring parity and break indicators, * ignore overruns too. (For real raw support). */ -if (I_IGNPAR (info->tty)) +if (I_IGNPAR (info->port.tty)) info->ignore_status_mask |=STMRCVROVRH ; }
@@ -863,7 +863,7 @@ static void configure_r_port(struct r_port *info, } } -/* info->count is considered critical, protected by spinlocks. */ +/* info->port.count is considered critical, protected by spinlocks. */ static int block_til_ready (struct tty_struct *tty,struct file *filp,struct r_port *info) {
@@ -897,13 +897,13 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,/* * Block waiting for the carrier detect and the line to become free. While we are in -* this loop, info->count is dropped by one, so that rp_close() knows when to free things. +* this loop, info->port.count is dropped by one, so that rp_close() knows when to free things. * We restore it upon exit, either normal or abnormal. */ retval =0 ; -add_wait_queue (&info->open_wait, &wait); +add_wait_queue (&info->port.open_wait, &wait);#ifdef ROCKET_DEBUG_OPEN -printk (KERN_INFO "block_til_ready before block: ttyR%d, count = %d\n" , info->line, info->count); +printk (KERN_INFO "block_til_ready before block: ttyR%d, count = %d\n" , info->line, info->port.count);#endif spin_lock_irqsave (&info->slock, flags);
@@ -912,10 +912,10 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,#else if (!tty_hung_up_p (filp)) { extra_count =1 ; - info->count--; + info->port.count--; }#endif - info->blocked_open++; + info->port.blocked_open++;spin_unlock_irqrestore (&info->slock, flags);
@@ -940,24 +940,24 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp, }#ifdef ROCKET_DEBUG_OPEN printk (KERN_INFO "block_til_ready blocking: ttyR%d, count = %d, flags=0x%0x\n" , - info->line, info->count, info->flags); + info->line, info->port.count, info->flags);#endif schedule ();/* Don't hold spinlock here, will hang PC */ }__set_current_state (TASK_RUNNING ); -remove_wait_queue (&info->open_wait, &wait); +remove_wait_queue (&info->port.open_wait, &wait);spin_lock_irqsave (&info->slock, flags);if (extra_count) - info->count++; - info->blocked_open--; + info->port.count++; + info->port.blocked_open--;spin_unlock_irqrestore (&info->slock, flags);#ifdef ROCKET_DEBUG_OPEN printk (KERN_INFO "block_til_ready after blocking: ttyR%d, count = %d\n" , - info->line, info->count); + info->line, info->port.count);#endif if (retval)return retval;
@@ -1001,9 +1001,9 @@ static int rp_open(struct tty_struct *tty, struct file *filp) info->xmit_buf = (unsigned char *) page; tty->driver_data = info; - info->tty = tty; + info->port.tty = tty; -if (info->count++ ==0 ) { +if (info->port.count++ ==0 ) {atomic_inc (&rp_num_ports_open);#ifdef ROCKET_DEBUG_OPEN
@@ -1012,7 +1012,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)#endif }#ifdef ROCKET_DEBUG_OPEN -printk (KERN_INFO "rp_open ttyR%d, count=%d\n" , info->line, info->count); +printk (KERN_INFO "rp_open ttyR%d, count=%d\n" , info->line, info->port.count);#endif /*
@@ -1048,13 +1048,13 @@ static int rp_open(struct tty_struct *tty, struct file *filp)* Set up the tty->alt_speed kludge */ if ((info->flags &ROCKET_SPD_MASK ) ==ROCKET_SPD_HI ) - info->tty->alt_speed =57600 ; + info->port.tty->alt_speed =57600 ;if ((info->flags &ROCKET_SPD_MASK ) ==ROCKET_SPD_VHI ) - info->tty->alt_speed =115200 ; + info->port.tty->alt_speed =115200 ;if ((info->flags &ROCKET_SPD_MASK ) ==ROCKET_SPD_SHI ) - info->tty->alt_speed =230400 ; + info->port.tty->alt_speed =230400 ;if ((info->flags &ROCKET_SPD_MASK ) ==ROCKET_SPD_WARP ) - info->tty->alt_speed =460800 ; + info->port.tty->alt_speed =460800 ;configure_r_port (info,NULL );if (tty->termios->c_cflag &CBAUD ) {
@@ -1076,7 +1076,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp) }/* -* Exception handler that closes a serial port. info->count is considered critical. +* Exception handler that closes a serial port. info->port.count is considered critical. */ static void rp_close (struct tty_struct *tty,struct file *filp) {
@@ -1089,14 +1089,14 @@ static void rp_close(struct tty_struct *tty, struct file *filp)return ;#ifdef ROCKET_DEBUG_OPEN -printk (KERN_INFO "rp_close ttyR%d, count = %d\n" , info->line, info->count); +printk (KERN_INFO "rp_close ttyR%d, count = %d\n" , info->line, info->port.count);#endif if (tty_hung_up_p (filp))return ;spin_lock_irqsave (&info->slock, flags); -if ((tty->count ==1 ) && (info->count !=1 )) { +if ((tty->count ==1 ) && (info->port.count !=1 )) {/* * Uh, oh. tty->count is 1, which means that the tty * structure will be freed. Info->count should always
@@ -1105,15 +1105,15 @@ static void rp_close(struct tty_struct *tty, struct file *filp)* serial port won't be shutdown. */ printk (KERN_WARNING "rp_close: bad serial port count; " -"tty->count is 1, info->count is %d\n" , info->count); - info->count =1 ; +"tty->count is 1, info->port.count is %d\n" , info->port.count); + info->port.count =1 ; } -if (--info->count <0 ) { +if (--info->port.count <0 ) {printk (KERN_WARNING "rp_close: bad serial port count for " -"ttyR%d: %d\n" , info->line, info->count); - info->count =0 ; +"ttyR%d: %d\n" , info->line, info->port.count); + info->port.count =0 ; } -if (info->count) { +if (info->port.count) {spin_unlock_irqrestore (&info->slock, flags);return ; }
@@ -1167,11 +1167,11 @@ static void rp_close(struct tty_struct *tty, struct file *filp)clear_bit ((info->aiop *8 ) + info->chan, (void *) &xmit_flags[info->board]); -if (info->blocked_open) { +if (info->port.blocked_open) {if (info->close_delay) {msleep_interruptible (jiffies_to_msecs (info->close_delay)); } -wake_up_interruptible (&info->open_wait); +wake_up_interruptible (&info->port.open_wait); }else {if (info->xmit_buf) {free_page ((unsigned long ) info->xmit_buf);
@@ -1357,13 +1357,13 @@ static int set_config(struct r_port *info, struct rocket_config __user *new_info info->closing_wait = new_serial.closing_wait;if ((info->flags &ROCKET_SPD_MASK ) ==ROCKET_SPD_HI ) - info->tty->alt_speed =57600 ; + info->port.tty->alt_speed =57600 ;if ((info->flags &ROCKET_SPD_MASK ) ==ROCKET_SPD_VHI ) - info->tty->alt_speed =115200 ; + info->port.tty->alt_speed =115200 ;if ((info->flags &ROCKET_SPD_MASK ) ==ROCKET_SPD_SHI ) - info->tty->alt_speed =230400 ; + info->port.tty->alt_speed =230400 ;if ((info->flags &ROCKET_SPD_MASK ) ==ROCKET_SPD_WARP ) - info->tty->alt_speed =460800 ; + info->port.tty->alt_speed =460800 ;configure_r_port (info,NULL );return 0 ;
@@ -1636,13 +1636,13 @@ static void rp_hangup(struct tty_struct *tty)rp_flush_buffer (tty);if (info->flags &ROCKET_CLOSING )return ; -if (info->count) +if (info->port.count)atomic_dec (&rp_num_ports_open);clear_bit ((info->aiop *8 ) + info->chan, (void *) &xmit_flags[info->board]); - info->count =0 ; + info->port.count =0 ; info->flags &= ~ROCKET_NORMAL_ACTIVE ; - info->tty =NULL ; + info->port.tty =NULL ; cp = &info->channel;sDisRxFIFO (cp);
@@ -1653,7 +1653,7 @@ static void rp_hangup(struct tty_struct *tty)sClrTxXOFF (cp); info->flags &= ~ROCKET_INITIALIZED ; -wake_up_interruptible (&info->open_wait); +wake_up_interruptible (&info->port.open_wait); }/*
@@ -1762,7 +1762,7 @@ static int rp_write(struct tty_struct *tty,/* Write remaining data into the port's xmit_buf */ while (1 ) { -if (!info->tty)/* Seemingly obligatory check... */ +if (!info->port.tty)/* Seemingly obligatory check... */ goto end; c =min (count,XMIT_BUF_SIZE - info->xmit_cnt -1 ); c =min (c,XMIT_BUF_SIZE - info->xmit_head);
drivers/char/rocket_int.h +3 -6
@@ -1125,11 +1125,9 @@ Warnings: This function writes the data byte without checking to see ifstruct r_port {int magic; +struct tty_port port;int line; -int flags; -int count; -int blocked_open; -struct tty_struct *tty; +int flags;/* Don't yet match the ASY_ flags!! */ unsigned int board:3 ;unsigned int aiop:2 ;unsigned int chan:3 ;
@@ -1148,8 +1146,7 @@ struct r_port {int read_status_mask;int cps; -wait_queue_head_t open_wait; -struct completion close_wait; +struct completion close_wait;/* Not yet matching the core */ spinlock_t slock;struct mutex write_mtx; };
PATCH 16/70 serial: use tty_port
In reply to Alan CoxFrom: Alan Cox <[email protected]>
Switch the serial_core based drivers to use the new tty_port structure. We can't quite use all of it yet because of the dynamically allocated extras in the serial_core layer.
---
drivers/serial/8250.c | 2 + drivers/serial/jsm/jsm_neo.c | 2 + drivers/serial/jsm/jsm_tty.c | 8 ++-- drivers/serial/serial_core.c | 80 ++++++++++++++++++++++-------------------- include/linux/serial_core.h | 26 ++++++-------- 5 files changed, 60 insertions(+), 58 deletions(-)
drivers/serial/8250.c +1 -1
@@ -1287,7 +1287,7 @@ static void serial8250_enable_ms(struct uart_port *port)static void receive_chars (struct uart_8250_port *up,unsigned int *status) { -struct tty_struct *tty = up->port.info->tty; +struct tty_struct *tty = up->port.info->port.tty;unsigned char ch, lsr = *status;int max_count =256 ;char flag;
drivers/serial/jsm/jsm_neo.c +1 -1
@@ -998,7 +998,7 @@ static void neo_param(struct jsm_channel *ch) { 50, B50 }, }; - cflag =C_BAUD (ch->uart_port.info->tty); + cflag =C_BAUD (ch->uart_port.info->port.tty); baud =9600 ;for (i =0 ; i <ARRAY_SIZE (baud_rates); i++) {if (baud_rates[i].cflag == cflag) {
drivers/serial/jsm/jsm_tty.c +4 -4
@@ -145,7 +145,7 @@ static void jsm_tty_send_xchar(struct uart_port *port, char ch)struct ktermios *termios;spin_lock_irqsave (&port->lock, lock_flags); - termios = port->info->tty->termios; + termios = port->info->port.tty->termios;if (ch == termios->c_cc[VSTART ]) channel->ch_bd->bd_ops->send_start_character (channel);
@@ -239,7 +239,7 @@ static int jsm_tty_open(struct uart_port *port) channel->ch_cached_lsr =0 ; channel->ch_stops_sent =0 ; - termios = port->info->tty->termios; + termios = port->info->port.tty->termios; channel->ch_c_cflag = termios->c_cflag; channel->ch_c_iflag = termios->c_iflag; channel->ch_c_oflag = termios->c_oflag;
@@ -272,7 +272,7 @@ static void jsm_tty_close(struct uart_port *port)jsm_printk (CLOSE ,INFO , &channel->ch_bd->pci_dev,"start\n" ); bd = channel->ch_bd; - ts = channel->uart_port.info->tty->termios; + ts = channel->uart_port.info->port.tty->termios; channel->ch_flags &= ~(CH_STOPI );
@@ -515,7 +515,7 @@ void jsm_input(struct jsm_channel *ch)if (!ch)return ; - tp = ch->uart_port.info->tty; + tp = ch->uart_port.info->port.tty; bd = ch->ch_bd;if (!bd)
drivers/serial/serial_core.c +42 -38
265 lines not on this page · raw message
include/linux/serial_core.h +12 -14
@@ -343,13 +343,15 @@ typedef unsigned int __bitwise__ uif_t;* stuff here. */ struct uart_info { -struct tty_struct *tty; +struct tty_port port;struct circ_buf xmit;uif_t flags;/* * Definitions for info->flags. These are _private_ to serial_core, and * are specific to this structure. They may be queried by low level drivers. +* +* FIXME: use the ASY_ definitions */ #define UIF_CHECK_CD ((__force uif_t) (1 << 25))#define UIF_CTS_FLOW ((__force uif_t) (1 << 26))
@@ -357,11 +359,7 @@ struct uart_info {#define UIF_INITIALIZED ((__force uif_t) (1 << 31))#define UIF_SUSPENDED ((__force uif_t) (1 << 30)) -int blocked_open; -struct tasklet_struct tlet; - -wait_queue_head_t open_wait;wait_queue_head_t delta_msr_wait; };
@@ -438,8 +436,8 @@ int uart_resume_port(struct uart_driver *reg, struct uart_port *port);#define uart_circ_chars_free (circ) \ (CIRC_SPACE((circ)->head, (circ)->tail, UART_XMIT_SIZE)) -#define uart_tx_stopped (port) \ - ((port)->info->tty->stopped || (port)->info->tty->hw_stopped) +#define uart_tx_stopped (portp) \ + ((portp)->info->port.tty->stopped || (portp)->info->port.tty->hw_stopped)/* * The following are helper functions for the low level drivers.
@@ -450,7 +448,7 @@ uart_handle_sysrq_char(struct uart_port *port, unsigned int ch)#ifdef SUPPORT_SYSRQ if (port->sysrq) {if (ch &&time_before (jiffies, port->sysrq)) { -handle_sysrq (ch, port->info ? port->info->tty :NULL ); +handle_sysrq (ch, port->info ? port->info->port.tty :NULL ); port->sysrq =0 ;return 1 ; }
@@ -479,7 +477,7 @@ static inline int uart_handle_break(struct uart_port *port) }#endif if (port->flags &UPF_SAK ) -do_SAK (info->tty); +do_SAK (info->port.tty);return 0 ; }
@@ -502,9 +500,9 @@ uart_handle_dcd_change(struct uart_port *port, unsigned int status)if (info->flags &UIF_CHECK_CD ) {if (status) -wake_up_interruptible (&info->open_wait); -else if (info->tty) -tty_hangup (info->tty); +wake_up_interruptible (&info->port.open_wait); +else if (info->port.tty) +tty_hangup (info->port.tty); } }
@@ -517,7 +515,7 @@ static inline void uart_handle_cts_change(struct uart_port *port, unsigned int status) {struct uart_info *info = port->info; -struct tty_struct *tty = info->tty; +struct tty_struct *tty = info->port.tty; port->icount.cts++;
@@ -543,7 +541,7 @@ static inline void uart_insert_char(struct uart_port *port, unsigned int status, unsigned int overrun, unsigned int ch, unsigned int flag) { - struct tty_struct *tty = port->info->tty; + struct tty_struct *tty = port->info->port.tty;if ((status & port->ignore_status_mask & ~overrun) ==0 )tty_insert_flip_char (tty, ch, flag);
PATCH 17/70 stallion: use tty_port
In reply to Alan CoxFrom: Alan Cox <[email protected]>
Switch the stallion driver to use the tty_port structure
---
drivers/char/stallion.c | 160 +++++++++++++++++++++++----------------------- include/linux/stallion.h | 6 -- 2 files changed, 81 insertions(+), 85 deletions(-)
drivers/char/stallion.c +80 -80
@@ -613,17 +613,17 @@ static void stl_cd_change(struct stlport *portp) {unsigned int oldsigs = portp->sigs; -if (!portp->tty) +if (!portp->port.tty)return ; portp->sigs =stl_getsignals (portp);if ((portp->sigs &TIOCM_CD ) && ((oldsigs &TIOCM_CD ) ==0 )) -wake_up_interruptible (&portp->open_wait); +wake_up_interruptible (&portp->port.open_wait);if ((oldsigs &TIOCM_CD ) && ((portp->sigs &TIOCM_CD ) ==0 )) -if (portp->flags &ASYNC_CHECK_CD ) -tty_hangup (portp->tty); +if (portp->port.flags &ASYNC_CHECK_CD ) +tty_hangup (portp->port.tty); }/*
@@ -734,11 +734,11 @@ static int stl_open(struct tty_struct *tty, struct file *filp)* On the first open of the device setup the port hardware, and * initialize the per port data structure. */ - portp->tty = tty; + portp->port.tty = tty; tty->driver_data = portp; - portp->refcount++; + portp->port.count++; -if ((portp->flags &ASYNC_INITIALIZED ) ==0 ) { +if ((portp->port.flags &ASYNC_INITIALIZED ) ==0 ) {if (!portp->tx.buf) { portp->tx.buf =kmalloc (STL_TXBUFSIZE ,GFP_KERNEL );if (!portp->tx.buf)
@@ -752,7 +752,7 @@ static int stl_open(struct tty_struct *tty, struct file *filp)stl_enablerxtx (portp,1 ,1 );stl_startrxtx (portp,1 ,0 );clear_bit (TTY_IO_ERROR , &tty->flags); - portp->flags |=ASYNC_INITIALIZED ; + portp->port.flags |=ASYNC_INITIALIZED ; }/*
@@ -761,9 +761,9 @@ static int stl_open(struct tty_struct *tty, struct file *filp)* The sleep here does not need interrupt protection since the wakeup * for it is done with the same context. */ -if (portp->flags &ASYNC_CLOSING ) { -interruptible_sleep_on (&portp->close_wait); -if (portp->flags &ASYNC_HUP_NOTIFY ) +if (portp->port.flags &ASYNC_CLOSING ) { +interruptible_sleep_on (&portp->port.close_wait); +if (portp->port.flags &ASYNC_HUP_NOTIFY )return -EAGAIN ;return -ERESTARTSYS ; }
@@ -777,7 +777,7 @@ static int stl_open(struct tty_struct *tty, struct file *filp)if ((rc =stl_waitcarrier (portp, filp)) !=0 )return rc; - portp->flags |=ASYNC_NORMAL_ACTIVE ; + portp->port.flags |=ASYNC_NORMAL_ACTIVE ;return 0 ; }
@@ -801,25 +801,25 @@ static int stl_waitcarrier(struct stlport *portp, struct file *filp)spin_lock_irqsave (&stallion_lock, flags); -if (portp->tty->termios->c_cflag &CLOCAL ) +if (portp->port.tty->termios->c_cflag &CLOCAL ) doclocal++; portp->openwaitcnt++;if (!tty_hung_up_p (filp)) - portp->refcount--; + portp->port.count--;for (;;) {/* Takes brd_lock internally */ stl_setsignals (portp,1 ,1 );if (tty_hung_up_p (filp) || - ((portp->flags &ASYNC_INITIALIZED ) ==0 )) { -if (portp->flags &ASYNC_HUP_NOTIFY ) + ((portp->port.flags &ASYNC_INITIALIZED ) ==0 )) { +if (portp->port.flags &ASYNC_HUP_NOTIFY ) rc = -EBUSY ;else rc = -ERESTARTSYS ;break ; } -if (((portp->flags &ASYNC_CLOSING ) ==0 ) && +if (((portp->port.flags &ASYNC_CLOSING ) ==0 ) && (doclocal || (portp->sigs &TIOCM_CD )))break ;if (signal_pending (current)) {
@@ -827,11 +827,11 @@ static int stl_waitcarrier(struct stlport *portp, struct file *filp)break ; }/* FIXME */ -interruptible_sleep_on (&portp->open_wait); +interruptible_sleep_on (&portp->port.open_wait); }if (!tty_hung_up_p (filp)) - portp->refcount++; + portp->port.count++; portp->openwaitcnt--;spin_unlock_irqrestore (&stallion_lock, flags);
@@ -904,15 +904,15 @@ static void stl_close(struct tty_struct *tty, struct file *filp)spin_unlock_irqrestore (&stallion_lock, flags);return ; } -if ((tty->count ==1 ) && (portp->refcount !=1 )) - portp->refcount =1 ; -if (portp->refcount-- >1 ) { +if ((tty->count ==1 ) && (portp->port.count !=1 )) + portp->port.count =1 ; +if (portp->port.count-- >1 ) {spin_unlock_irqrestore (&stallion_lock, flags);return ; } - portp->refcount =0 ; - portp->flags |=ASYNC_CLOSING ; + portp->port.count =0 ; + portp->port.flags |=ASYNC_CLOSING ;/* * May want to wait for any data to drain before closing. The BUSY
@@ -930,7 +930,7 @@ static void stl_close(struct tty_struct *tty, struct file *filp)spin_lock_irqsave (&stallion_lock, flags); - portp->flags &= ~ASYNC_INITIALIZED ; + portp->port.flags &= ~ASYNC_INITIALIZED ;spin_unlock_irqrestore (&stallion_lock, flags);stl_disableintrs (portp);
@@ -949,16 +949,16 @@ static void stl_close(struct tty_struct *tty, struct file *filp)tty_ldisc_flush (tty); tty->closing =0 ; - portp->tty =NULL ; + portp->port.tty =NULL ;if (portp->openwaitcnt) {if (portp->close_delay)msleep_interruptible (jiffies_to_msecs (portp->close_delay)); -wake_up_interruptible (&portp->open_wait); +wake_up_interruptible (&portp->port.open_wait); } - portp->flags &= ~(ASYNC_NORMAL_ACTIVE |ASYNC_CLOSING ); -wake_up_interruptible (&portp->close_wait); + portp->port.flags &= ~(ASYNC_NORMAL_ACTIVE |ASYNC_CLOSING ); +wake_up_interruptible (&portp->port.close_wait); }/*****************************************************************************/
@@ -1153,7 +1153,7 @@ static int stl_getserial(struct stlport *portp, struct serial_struct __user *sp)memset (&sio,0 ,sizeof (struct serial_struct )); sio.line = portp->portnr; sio.port = portp->ioaddr; - sio.flags = portp->flags; + sio.flags = portp->port.flags; sio.baud_base = portp->baud_base; sio.close_delay = portp->close_delay; sio.closing_wait = portp->closing_wait;
@@ -1194,17 +1194,17 @@ static int stl_setserial(struct stlport *portp, struct serial_struct __user *sp)if ((sio.baud_base != portp->baud_base) || (sio.close_delay != portp->close_delay) || ((sio.flags & ~ASYNC_USR_MASK ) != - (portp->flags & ~ASYNC_USR_MASK ))) + (portp->port.flags & ~ASYNC_USR_MASK )))return -EPERM ; } - portp->flags = (portp->flags & ~ASYNC_USR_MASK ) | + portp->port.flags = (portp->port.flags & ~ASYNC_USR_MASK ) | (sio.flags &ASYNC_USR_MASK ); portp->baud_base = sio.baud_base; portp->close_delay = sio.close_delay; portp->closing_wait = sio.closing_wait; portp->custom_divisor = sio.custom_divisor; -stl_setport (portp, portp->tty->termios); +stl_setport (portp, portp->port.tty->termios);return 0 ; }
@@ -1353,7 +1353,7 @@ static void stl_settermios(struct tty_struct *tty, struct ktermios *old)stl_start (tty); }if (((old->c_cflag &CLOCAL ) ==0 ) && (tiosp->c_cflag &CLOCAL )) -wake_up_interruptible (&portp->open_wait); +wake_up_interruptible (&portp->port.open_wait); }/*****************************************************************************/
@@ -1438,7 +1438,7 @@ static void stl_hangup(struct tty_struct *tty)if (portp ==NULL )return ; - portp->flags &= ~ASYNC_INITIALIZED ; + portp->port.flags &= ~ASYNC_INITIALIZED ;stl_disableintrs (portp);if (tty->termios->c_cflag &HUPCL )stl_setsignals (portp,0 ,0 );
@@ -1452,10 +1452,10 @@ static void stl_hangup(struct tty_struct *tty) portp->tx.head =NULL ; portp->tx.tail =NULL ; } - portp->tty =NULL ; - portp->flags &= ~ASYNC_NORMAL_ACTIVE ; - portp->refcount =0 ; -wake_up_interruptible (&portp->open_wait); + portp->port.tty =NULL ; + portp->port.flags &= ~ASYNC_NORMAL_ACTIVE ; + portp->port.count =0 ; +wake_up_interruptible (&portp->port.open_wait); }/*****************************************************************************/
@@ -1814,8 +1814,8 @@ static int __devinit stl_initports(struct stlbrd *brdp, struct stlpanel *panelp) portp->baud_base =STL_BAUDBASE ; portp->close_delay =STL_CLOSEDELAY ; portp->closing_wait =30 *HZ ; -init_waitqueue_head (&portp->open_wait); -init_waitqueue_head (&portp->close_wait); +init_waitqueue_head (&portp->port.open_wait); +init_waitqueue_head (&portp->port.close_wait); portp->stats.brd = portp->brdnr; portp->stats.panel = portp->panelnr; portp->stats.port = portp->portnr;
@@ -1840,8 +1840,8 @@ static void stl_cleanup_panels(struct stlbrd *brdp) portp = panelp->ports[k];if (portp ==NULL )continue ; -if (portp->tty !=NULL ) -stl_hangup (portp->tty); +if (portp->port.tty !=NULL ) +stl_hangup (portp->port.tty);kfree (portp->tx.buf);kfree (portp); }
@@ -2513,7 +2513,7 @@ static int stl_getportstats(struct stlport *portp, comstats_t __user *cp) } portp->stats.state = portp->istate; - portp->stats.flags = portp->flags; + portp->stats.flags = portp->port.flags; portp->stats.hwid = portp->hwid; portp->stats.ttystate =0 ;
@@ -2524,16 +2524,16 @@ static int stl_getportstats(struct stlport *portp, comstats_t __user *cp) portp->stats.rxbuffered =0 ;spin_lock_irqsave (&stallion_lock, flags); -if (portp->tty !=NULL ) -if (portp->tty->driver_data == portp) { - portp->stats.ttystate = portp->tty->flags; +if (portp->port.tty !=NULL ) +if (portp->port.tty->driver_data == portp) { + portp->stats.ttystate = portp->port.tty->flags;/* No longer available as a statistic */ - portp->stats.rxbuffered =1 ;/*portp->tty->flip.count; */ -if (portp->tty->termios !=NULL ) { - portp->stats.cflags = portp->tty->termios->c_cflag; - portp->stats.iflags = portp->tty->termios->c_iflag; - portp->stats.oflags = portp->tty->termios->c_oflag; - portp->stats.lflags = portp->tty->termios->c_lflag; + portp->stats.rxbuffered =1 ;/*portp->port.tty->flip.count; */ +if (portp->port.tty->termios !=NULL ) { + portp->stats.cflags = portp->port.tty->termios->c_cflag; + portp->stats.iflags = portp->port.tty->termios->c_iflag; + portp->stats.oflags = portp->port.tty->termios->c_oflag; + portp->stats.lflags = portp->port.tty->termios->c_lflag; } }spin_unlock_irqrestore (&stallion_lock, flags);
@@ -2939,15 +2939,15 @@ static void stl_cd1400setport(struct stlport *portp, struct ktermios *tiosp) } baudrate = stl_baudrates[baudrate];if ((tiosp->c_cflag &CBAUD ) ==B38400 ) { -if ((portp->flags &ASYNC_SPD_MASK ) ==ASYNC_SPD_HI ) +if ((portp->port.flags &ASYNC_SPD_MASK ) ==ASYNC_SPD_HI ) baudrate =57600 ; -else if ((portp->flags &ASYNC_SPD_MASK ) ==ASYNC_SPD_VHI ) +else if ((portp->port.flags &ASYNC_SPD_MASK ) ==ASYNC_SPD_VHI ) baudrate =115200 ; -else if ((portp->flags &ASYNC_SPD_MASK ) ==ASYNC_SPD_SHI ) +else if ((portp->port.flags &ASYNC_SPD_MASK ) ==ASYNC_SPD_SHI ) baudrate =230400 ; -else if ((portp->flags &ASYNC_SPD_MASK ) ==ASYNC_SPD_WARP ) +else if ((portp->port.flags &ASYNC_SPD_MASK ) ==ASYNC_SPD_WARP ) baudrate =460800 ; -else if ((portp->flags &ASYNC_SPD_MASK ) ==ASYNC_SPD_CUST ) +else if ((portp->port.flags &ASYNC_SPD_MASK ) ==ASYNC_SPD_CUST ) baudrate = (portp->baud_base / portp->custom_divisor); }if (baudrate >STL_CD1400MAXBAUD )
@@ -2969,9 +2969,9 @@ static void stl_cd1400setport(struct stlport *portp, struct ktermios *tiosp) mcor1 |=MCOR1_DCD ; mcor2 |=MCOR2_DCD ; sreron |=SRER_MODEM ; - portp->flags |=ASYNC_CHECK_CD ; + portp->port.flags |=ASYNC_CHECK_CD ; }else - portp->flags &= ~ASYNC_CHECK_CD ; + portp->port.flags &= ~ASYNC_CHECK_CD ;/* * Setup cd1400 enhanced modes if we can. In particular we want to
@@ -3242,7 +3242,7 @@ static void stl_cd1400flowctrl(struct stlport *portp, int state)if (portp ==NULL )return ; - tty = portp->tty; + tty = portp->port.tty;if (tty ==NULL )return ;
@@ -3304,7 +3304,7 @@ static void stl_cd1400sendflow(struct stlport *portp, int state)if (portp ==NULL )return ; - tty = portp->tty; + tty = portp->port.tty;if (tty ==NULL )return ;
@@ -3503,8 +3503,8 @@ static void stl_cd1400txisr(struct stlpanel *panelp, int ioaddr)if ((len ==0 ) || ((len <STL_TXBUFLOW ) && (test_bit (ASYI_TXLOW , &portp->istate) ==0 ))) {set_bit (ASYI_TXLOW , &portp->istate); -if (portp->tty) -tty_wakeup (portp->tty); +if (portp->port.tty) +tty_wakeup (portp->port.tty); }if (len ==0 ) {
@@ -3568,7 +3568,7 @@ static void stl_cd1400rxisr(struct stlpanel *panelp, int ioaddr)return ; } portp = panelp->ports[(ioack >>3 )]; - tty = portp->tty; + tty = portp->port.tty;if ((ioack &ACK_TYPMASK ) ==ACK_TYPRXGOOD ) {outb ((RDCR + portp->uartaddr), ioaddr);
@@ -3613,7 +3613,7 @@ static void stl_cd1400rxisr(struct stlpanel *panelp, int ioaddr)if (portp->rxmarkmsk & status) {if (status &ST_BREAK ) { status =TTY_BREAK ; -if (portp->flags &ASYNC_SAK ) { +if (portp->port.flags &ASYNC_SAK ) {do_SAK (tty);BRDENABLE (portp->brdnr, portp->pagenr); }
@@ -3899,15 +3899,15 @@ static void stl_sc26198setport(struct stlport *portp, struct ktermios *tiosp) } baudrate = stl_baudrates[baudrate];if ((tiosp->c_cflag &CBAUD ) ==B38400 ) { -if ((portp->flags &ASYNC_SPD_MASK ) ==ASYNC_SPD_HI ) +if ((portp->port.flags &ASYNC_SPD_MASK ) ==ASYNC_SPD_HI ) baudrate =57600 ; -else if ((portp->flags &ASYNC_SPD_MASK ) ==ASYNC_SPD_VHI ) +else if ((portp->port.flags &ASYNC_SPD_MASK ) ==ASYNC_SPD_VHI ) baudrate =115200 ; -else if ((portp->flags &ASYNC_SPD_MASK ) ==ASYNC_SPD_SHI ) +else if ((portp->port.flags &ASYNC_SPD_MASK ) ==ASYNC_SPD_SHI ) baudrate =230400 ; -else if ((portp->flags &ASYNC_SPD_MASK ) ==ASYNC_SPD_WARP ) +else if ((portp->port.flags &ASYNC_SPD_MASK ) ==ASYNC_SPD_WARP ) baudrate =460800 ; -else if ((portp->flags &ASYNC_SPD_MASK ) ==ASYNC_SPD_CUST ) +else if ((portp->port.flags &ASYNC_SPD_MASK ) ==ASYNC_SPD_CUST ) baudrate = (portp->baud_base / portp->custom_divisor); }if (baudrate >STL_SC26198MAXBAUD )
@@ -3922,11 +3922,11 @@ static void stl_sc26198setport(struct stlport *portp, struct ktermios *tiosp)* Check what form of modem signaling is required and set it up. */ if (tiosp->c_cflag &CLOCAL ) { - portp->flags &= ~ASYNC_CHECK_CD ; + portp->port.flags &= ~ASYNC_CHECK_CD ; }else { iopr |=IOPR_DCDCOS ; imron |=IR_IOPORT ; - portp->flags |=ASYNC_CHECK_CD ; + portp->port.flags |=ASYNC_CHECK_CD ; }/*
@@ -4174,7 +4174,7 @@ static void stl_sc26198flowctrl(struct stlport *portp, int state)if (portp ==NULL )return ; - tty = portp->tty; + tty = portp->port.tty;if (tty ==NULL )return ;
@@ -4243,7 +4243,7 @@ static void stl_sc26198sendflow(struct stlport *portp, int state)if (portp ==NULL )return ; - tty = portp->tty; + tty = portp->port.tty;if (tty ==NULL )return ;
@@ -4421,8 +4421,8 @@ static void stl_sc26198txisr(struct stlport *portp)if ((len ==0 ) || ((len <STL_TXBUFLOW ) && (test_bit (ASYI_TXLOW , &portp->istate) ==0 ))) {set_bit (ASYI_TXLOW , &portp->istate); -if (portp->tty) -tty_wakeup (portp->tty); +if (portp->port.tty) +tty_wakeup (portp->port.tty); }if (len ==0 ) {
@@ -4475,7 +4475,7 @@ static void stl_sc26198rxisr(struct stlport *portp, unsigned int iack)pr_debug ("stl_sc26198rxisr(portp=%p,iack=%x)\n" , portp, iack); - tty = portp->tty; + tty = portp->port.tty; ioaddr = portp->ioaddr;outb (GIBCR , (ioaddr +XP_ADDR )); len =inb (ioaddr +XP_DATA ) +1 ;
@@ -4527,7 +4527,7 @@ static void stl_sc26198rxbadch(struct stlport *portp, unsigned char status, charstruct tty_struct *tty;unsigned int ioaddr; - tty = portp->tty; + tty = portp->port.tty; ioaddr = portp->ioaddr;if (status &SR_RXPARITY )
@@ -4544,7 +4544,7 @@ static void stl_sc26198rxbadch(struct stlport *portp, unsigned char status, charif (portp->rxmarkmsk & status) {if (status &SR_RXBREAK ) { status =TTY_BREAK ; -if (portp->flags &ASYNC_SAK ) { +if (portp->port.flags &ASYNC_SAK ) {do_SAK (tty);BRDENABLE (portp->brdnr, portp->pagenr); }
include/linux/stallion.h +1 -5
@@ -69,6 +69,7 @@ struct stlrq {*/ struct stlport {unsigned long magic; +struct tty_port port;unsigned int portnr;unsigned int panelnr;unsigned int brdnr;
@@ -76,12 +77,10 @@ struct stlport {int uartaddr;unsigned int pagenr;unsigned long istate; -int flags;int baud_base;int custom_divisor;int close_delay;int closing_wait; -int refcount;int openwaitcnt;int brklen;unsigned int sigs;
@@ -92,9 +91,6 @@ struct stlport {unsigned long clk;unsigned long hwid;void *uartp; -struct tty_struct *tty; -wait_queue_head_t open_wait; -wait_queue_head_t close_wait;comstats_t stats;struct stlrq tx; };
PATCH 18/70 synclink: use tty_port
In reply to Alan CoxFrom: Alan Cox <[email protected]>
Switch the synclink ports to use the new tty_port structure
---
drivers/char/synclink.c | 195 ++++++++++++++++++++---------------------- drivers/char/synclink_gt.c | 201 +++++++++++++++++++++----------------------- drivers/char/synclinkmp.c | 203 +++++++++++++++++++++----------------------- 3 files changed, 289 insertions(+), 310 deletions(-)
drivers/char/synclink.c +94 -101
@@ -180,8 +180,7 @@ struct tx_holding_buffer {struct mgsl_struct {int magic; -int flags; -int count;/* count of opens */ +struct tty_port port;int line;int hw_version;unsigned short close_delay;
@@ -189,10 +188,8 @@ struct mgsl_struct {struct mgsl_icount icount; -struct tty_struct *tty;int timeout;int x_char;/* xon/xoff character */ -int blocked_open;/* # of blocked opens */ u16 read_status_mask;u16 ignore_status_mask;unsigned char *xmit_buf;
@@ -200,9 +197,6 @@ struct mgsl_struct {int xmit_tail;int xmit_cnt; -wait_queue_head_t open_wait; -wait_queue_head_t close_wait; -wait_queue_head_t status_event_wait_q;wait_queue_head_t event_wait_q;struct timer_list tx_timer;/* HDLC transmit timeout timer */
@@ -1134,7 +1128,7 @@ static void mgsl_bh_receive(struct mgsl_struct *info)static void mgsl_bh_transmit (struct mgsl_struct *info) { -struct tty_struct *tty = info->tty; +struct tty_struct *tty = info->port.tty;unsigned long flags;if ( debug_level >=DEBUG_LEVEL_BH )
@@ -1276,7 +1270,7 @@ static void mgsl_isr_transmit_status( struct mgsl_struct *info ) else#endif { -if (info->tty->stopped || info->tty->hw_stopped) { +if (info->port.tty->stopped || info->port.tty->hw_stopped) {usc_stop_transmitter (info);return ; }
@@ -1357,29 +1351,29 @@ static void mgsl_isr_io_pin( struct mgsl_struct *info )wake_up_interruptible (&info->status_event_wait_q);wake_up_interruptible (&info->event_wait_q); -if ( (info->flags &ASYNC_CHECK_CD ) && +if ( (info->port.flags &ASYNC_CHECK_CD ) && (status &MISCSTATUS_DCD_LATCHED ) ) {if ( debug_level >=DEBUG_LEVEL_ISR )printk ("%s CD now %s..." , info->device_name, (status &MISCSTATUS_DCD ) ?"on" :"off" );if (status &MISCSTATUS_DCD ) -wake_up_interruptible (&info->open_wait); +wake_up_interruptible (&info->port.open_wait);else {if ( debug_level >=DEBUG_LEVEL_ISR )printk ("doing serial hangup..." ); -if (info->tty) -tty_hangup (info->tty); +if (info->port.tty) +tty_hangup (info->port.tty); } } -if ( (info->flags &ASYNC_CTS_FLOW ) && +if ( (info->port.flags &ASYNC_CTS_FLOW ) && (status &MISCSTATUS_CTS_LATCHED ) ) { -if (info->tty->hw_stopped) { +if (info->port.tty->hw_stopped) {if (status &MISCSTATUS_CTS ) {if ( debug_level >=DEBUG_LEVEL_ISR )printk ("CTS tx start..." ); -if (info->tty) - info->tty->hw_stopped =0 ; +if (info->port.tty) + info->port.tty->hw_stopped =0 ;usc_start_transmitter (info); info->pending_bh |=BH_TRANSMIT ;return ;
@@ -1388,8 +1382,8 @@ static void mgsl_isr_io_pin( struct mgsl_struct *info )if (!(status &MISCSTATUS_CTS )) {if ( debug_level >=DEBUG_LEVEL_ISR )printk ("CTS tx stop..." ); -if (info->tty) - info->tty->hw_stopped =1 ; +if (info->port.tty) + info->port.tty->hw_stopped =1 ;usc_stop_transmitter (info); } }
@@ -1423,7 +1417,7 @@ static void mgsl_isr_transmit_data( struct mgsl_struct *info )usc_ClearIrqPendingBits ( info,TRANSMIT_DATA ); -if (info->tty->stopped || info->tty->hw_stopped) { +if (info->port.tty->stopped || info->port.tty->hw_stopped) {usc_stop_transmitter (info);return ; }
@@ -1453,7 +1447,7 @@ static void mgsl_isr_receive_data( struct mgsl_struct *info )u16 status;int work =0 ;unsigned char DataByte; -struct tty_struct *tty = info->tty; +struct tty_struct *tty = info->port.tty;struct mgsl_icount *icount = &info->icount;if ( debug_level >=DEBUG_LEVEL_ISR )
@@ -1514,7 +1508,7 @@ static void mgsl_isr_receive_data( struct mgsl_struct *info )if (status &RXSTATUS_BREAK_RECEIVED ) { flag =TTY_BREAK ; -if (info->flags &ASYNC_SAK ) +if (info->port.flags &ASYNC_SAK )do_SAK (tty); }else if (status &RXSTATUS_PARITY_ERROR ) flag =TTY_PARITY ;
@@ -1771,7 +1765,7 @@ static int startup(struct mgsl_struct * info)if ( debug_level >=DEBUG_LEVEL_INFO )printk ("%s(%d):mgsl_startup(%s)\n" ,__FILE__,__LINE__,info->device_name); -if (info->flags &ASYNC_INITIALIZED ) +if (info->port.flags &ASYNC_INITIALIZED )return 0 ;if (!info->xmit_buf) {
@@ -1798,8 +1792,8 @@ static int startup(struct mgsl_struct * info) retval =mgsl_adapter_test (info);if ( retval ) { -if (capable (CAP_SYS_ADMIN ) && info->tty) -set_bit (TTY_IO_ERROR , &info->tty->flags); +if (capable (CAP_SYS_ADMIN ) && info->port.tty) +set_bit (TTY_IO_ERROR , &info->port.tty->flags);mgsl_release_resources (info);return retval; }
@@ -1807,10 +1801,10 @@ static int startup(struct mgsl_struct * info)/* program hardware for current parameters */ mgsl_change_params (info); -if (info->tty) -clear_bit (TTY_IO_ERROR , &info->tty->flags); +if (info->port.tty) +clear_bit (TTY_IO_ERROR , &info->port.tty->flags); - info->flags |=ASYNC_INITIALIZED ; + info->port.flags |=ASYNC_INITIALIZED ;return 0 ;
@@ -1827,7 +1821,7 @@ static void shutdown(struct mgsl_struct * info) {unsigned long flags; -if (!(info->flags &ASYNC_INITIALIZED )) +if (!(info->port.flags &ASYNC_INITIALIZED ))return ;if (debug_level >=DEBUG_LEVEL_INFO )
@@ -1864,7 +1858,7 @@ static void shutdown(struct mgsl_struct * info)/* on the ISA adapter. This has no effect for the PCI adapter */ usc_OutReg (info,PCR , (u16)((usc_InReg (info,PCR ) |BIT13 ) |BIT12 )); -if (!info->tty || info->tty->termios->c_cflag &HUPCL ) { +if (!info->port.tty || info->port.tty->termios->c_cflag &HUPCL ) { info->serial_signals &= ~(SerialSignal_DTR + SerialSignal_RTS);usc_set_serial_signals (info); }
@@ -1873,10 +1867,10 @@ static void shutdown(struct mgsl_struct * info)mgsl_release_resources (info); -if (info->tty) -set_bit (TTY_IO_ERROR , &info->tty->flags); +if (info->port.tty) +set_bit (TTY_IO_ERROR , &info->port.tty->flags); - info->flags &= ~ASYNC_INITIALIZED ; + info->port.flags &= ~ASYNC_INITIALIZED ; }/* end of shutdown() */
@@ -1908,7 +1902,7 @@ static void mgsl_program_hw(struct mgsl_struct *info)usc_EnableInterrupts (info,IO_PIN );usc_get_serial_signals (info); -if (info->netcount || info->tty->termios->c_cflag &CREAD ) +if (info->netcount || info->port.tty->termios->c_cflag &CREAD )usc_start_receiver (info);spin_unlock_irqrestore (&info->irq_spinlock,flags);
@@ -1921,14 +1915,14 @@ static void mgsl_change_params(struct mgsl_struct *info)unsigned cflag;int bits_per_char; -if (!info->tty || !info->tty->termios) +if (!info->port.tty || !info->port.tty->termios)return ;if (debug_level >=DEBUG_LEVEL_INFO )printk ("%s(%d):mgsl_change_params(%s)\n" , __FILE__,__LINE__, info->device_name ); - cflag = info->tty->termios->c_cflag; + cflag = info->port.tty->termios->c_cflag;/* if B0 rate (hangup) specified then negate DTR and RTS */ /* otherwise assert DTR and RTS */
@@ -1976,7 +1970,7 @@ static void mgsl_change_params(struct mgsl_struct *info)* current data rate. */ if (info->params.data_rate <=460800 ) - info->params.data_rate =tty_get_baud_rate (info->tty); + info->params.data_rate =tty_get_baud_rate (info->port.tty);if ( info->params.data_rate ) { info->timeout = (32*HZ*bits_per_char) /
@@ -1985,31 +1979,31 @@ static void mgsl_change_params(struct mgsl_struct *info) info->timeout +=HZ /50 ;/* Add .02 seconds of slop */ if (cflag &CRTSCTS ) - info->flags |=ASYNC_CTS_FLOW ; + info->port.flags |=ASYNC_CTS_FLOW ;else - info->flags &= ~ASYNC_CTS_FLOW ; + info->port.flags &= ~ASYNC_CTS_FLOW ;if (cflag &CLOCAL ) - info->flags &= ~ASYNC_CHECK_CD ; + info->port.flags &= ~ASYNC_CHECK_CD ;else - info->flags |=ASYNC_CHECK_CD ; + info->port.flags |=ASYNC_CHECK_CD ;/* process tty input control flags */ info->read_status_mask =RXSTATUS_OVERRUN ; -if (I_INPCK (info->tty)) +if (I_INPCK (info->port.tty)) info->read_status_mask |=RXSTATUS_PARITY_ERROR |RXSTATUS_FRAMING_ERROR ; -if (I_BRKINT (info->tty) ||I_PARMRK (info->tty)) +if (I_BRKINT (info->port.tty) ||I_PARMRK (info->port.tty)) info->read_status_mask |=RXSTATUS_BREAK_RECEIVED ; -if (I_IGNPAR (info->tty)) +if (I_IGNPAR (info->port.tty)) info->ignore_status_mask |=RXSTATUS_PARITY_ERROR |RXSTATUS_FRAMING_ERROR ; -if (I_IGNBRK (info->tty)) { +if (I_IGNBRK (info->port.tty)) { info->ignore_status_mask |=RXSTATUS_BREAK_RECEIVED ;/* If ignoring parity and break indicators, ignore * overruns too. (For real raw support). */ -if (I_IGNPAR (info->tty)) +if (I_IGNPAR (info->port.tty)) info->ignore_status_mask |=RXSTATUS_OVERRUN ; }
@@ -3113,32 +3107,32 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)if (debug_level >=DEBUG_LEVEL_INFO )printk ("%s(%d):mgsl_close(%s) entry, count=%d\n" , - __FILE__,__LINE__, info->device_name, info->count); + __FILE__,__LINE__, info->device_name, info->port.count); -if (!info->count) +if (!info->port.count)return ;if (tty_hung_up_p (filp)) goto cleanup; -if ((tty->count ==1 ) && (info->count !=1 )) { +if ((tty->count ==1 ) && (info->port.count !=1 )) {/* * tty->count is 1 and the tty structure will be freed. -* info->count should be one in this case. +* info->port.count should be one in this case. * if it's not, correct it so that the port is shutdown. */ printk ("mgsl_close: bad refcount; tty->count is 1, " -"info->count is %d\n" , info->count); - info->count =1 ; +"info->port.count is %d\n" , info->port.count); + info->port.count =1 ; } - info->count--; + info->port.count--;/* if at least one open remaining, leave hardware active */ -if (info->count) +if (info->port.count) goto cleanup; - info->flags |=ASYNC_CLOSING ; + info->port.flags |=ASYNC_CLOSING ;/* set tty->closing to notify line discipline to * only process XON/XOFF characters. Only the N_TTY
@@ -3155,7 +3149,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)tty_wait_until_sent (tty, info->closing_wait); } -if (info->flags &ASYNC_INITIALIZED ) +if (info->port.flags &ASYNC_INITIALIZED )mgsl_wait_until_sent (tty, info->timeout);mgsl_flush_buffer (tty);
@@ -3165,23 +3159,23 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)shutdown (info); tty->closing =0 ; - info->tty =NULL ; + info->port.tty =NULL ; -if (info->blocked_open) { +if (info->port.blocked_open) {if (info->close_delay) {msleep_interruptible (jiffies_to_msecs (info->close_delay)); } -wake_up_interruptible (&info->open_wait); +wake_up_interruptible (&info->port.open_wait); } - info->flags &= ~(ASYNC_NORMAL_ACTIVE |ASYNC_CLOSING ); + info->port.flags &= ~(ASYNC_NORMAL_ACTIVE |ASYNC_CLOSING ); -wake_up_interruptible (&info->close_wait); +wake_up_interruptible (&info->port.close_wait); cleanup:if (debug_level >=DEBUG_LEVEL_INFO )printk ("%s(%d):mgsl_close(%s) exit, count=%d\n" , __FILE__,__LINE__, - tty->driver->name, info->count); + tty->driver->name, info->port.count); }/* end of mgsl_close() */
@@ -3211,7 +3205,7 @@ static void mgsl_wait_until_sent(struct tty_struct *tty, int timeout)if (mgsl_paranoia_check (info, tty->name,"mgsl_wait_until_sent" ))return ; -if (!(info->flags &ASYNC_INITIALIZED )) +if (!(info->port.flags &ASYNC_INITIALIZED )) goto exit; orig_jiffies = jiffies;
@@ -3283,11 +3277,11 @@ static void mgsl_hangup(struct tty_struct *tty)mgsl_flush_buffer (tty);shutdown (info); - info->count =0 ; - info->flags &= ~ASYNC_NORMAL_ACTIVE ; - info->tty =NULL ; + info->port.count =0 ; + info->port.flags &= ~ASYNC_NORMAL_ACTIVE ; + info->port.tty =NULL ; -wake_up_interruptible (&info->open_wait); +wake_up_interruptible (&info->port.open_wait); }/* end of mgsl_hangup() */
@@ -3319,7 +3313,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,if (filp->f_flags &O_NONBLOCK || tty->flags & (1 <<TTY_IO_ERROR )){/* nonblock mode is set or port is not enabled */ - info->flags |=ASYNC_NORMAL_ACTIVE ; + info->port.flags |=ASYNC_NORMAL_ACTIVE ;return 0 ; }
@@ -3328,25 +3322,25 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,/* Wait for carrier detect and the line to become * free (i.e., not in use by the callout). While we are in -* this loop, info->count is dropped by one, so that +* this loop, info->port.count is dropped by one, so that * mgsl_close() knows when to free things. We restore it upon * exit, either normal or abnormal. */ retval =0 ; -add_wait_queue (&info->open_wait, &wait); +add_wait_queue (&info->port.open_wait, &wait);if (debug_level >=DEBUG_LEVEL_INFO )printk ("%s(%d):block_til_ready before block on %s count=%d\n" , - __FILE__,__LINE__, tty->driver->name, info->count ); + __FILE__,__LINE__, tty->driver->name, info->port.count );spin_lock_irqsave (&info->irq_spinlock, flags);if (!tty_hung_up_p (filp)) { extra_count = true; - info->count--; + info->port.count--; }spin_unlock_irqrestore (&info->irq_spinlock, flags); - info->blocked_open++; + info->port.blocked_open++;while (1 ) {if (tty->termios->c_cflag &CBAUD ) {
@@ -3358,8 +3352,8 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,set_current_state (TASK_INTERRUPTIBLE ); -if (tty_hung_up_p (filp) || !(info->flags &ASYNC_INITIALIZED )){ - retval = (info->flags &ASYNC_HUP_NOTIFY ) ? +if (tty_hung_up_p (filp) || !(info->port.flags &ASYNC_INITIALIZED )){ + retval = (info->port.flags &ASYNC_HUP_NOTIFY ) ? -EAGAIN : -ERESTARTSYS ;break ; }
@@ -3368,7 +3362,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,usc_get_serial_signals (info);spin_unlock_irqrestore (&info->irq_spinlock,flags); -if (!(info->flags &ASYNC_CLOSING ) && +if (!(info->port.flags &ASYNC_CLOSING ) && (do_clocal || (info->serial_signals & SerialSignal_DCD)) ) {break ; }
@@ -3380,24 +3374,24 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,if (debug_level >=DEBUG_LEVEL_INFO )printk ("%s(%d):block_til_ready blocking on %s count=%d\n" , - __FILE__,__LINE__, tty->driver->name, info->count ); + __FILE__,__LINE__, tty->driver->name, info->port.count );schedule (); }set_current_state (TASK_RUNNING ); -remove_wait_queue (&info->open_wait, &wait); +remove_wait_queue (&info->port.open_wait, &wait);if (extra_count) - info->count++; - info->blocked_open--; + info->port.count++; + info->port.blocked_open--;if (debug_level >=DEBUG_LEVEL_INFO )printk ("%s(%d):block_til_ready after blocking on %s count=%d\n" , - __FILE__,__LINE__, tty->driver->name, info->count ); + __FILE__,__LINE__, tty->driver->name, info->port.count );if (!retval) - info->flags |=ASYNC_NORMAL_ACTIVE ; + info->port.flags |=ASYNC_NORMAL_ACTIVE ;return retval;
@@ -3435,22 +3429,22 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)return -ENODEV ; tty->driver_data = info; - info->tty = tty; + info->port.tty = tty;if (debug_level >=DEBUG_LEVEL_INFO )printk ("%s(%d):mgsl_open(%s), old ref count = %d\n" , - __FILE__,__LINE__,tty->driver->name, info->count); + __FILE__,__LINE__,tty->driver->name, info->port.count);/* If port is closing, signal caller to try again */ -if (tty_hung_up_p (filp) || info->flags &ASYNC_CLOSING ){ -if (info->flags &ASYNC_CLOSING ) -interruptible_sleep_on (&info->close_wait); - retval = ((info->flags &ASYNC_HUP_NOTIFY ) ? +if (tty_hung_up_p (filp) || info->port.flags &ASYNC_CLOSING ){ +if (info->port.flags &ASYNC_CLOSING ) +interruptible_sleep_on (&info->port.close_wait); + retval = ((info->port.flags &ASYNC_HUP_NOTIFY ) ? -EAGAIN : -ERESTARTSYS ); goto cleanup; } - info->tty->low_latency = (info->flags &ASYNC_LOW_LATENCY ) ?1 :0 ; + info->port.tty->low_latency = (info->port.flags &ASYNC_LOW_LATENCY ) ?1 :0 ;spin_lock_irqsave (&info->netlock, flags);if (info->netcount) {
@@ -3458,10 +3452,10 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)spin_unlock_irqrestore (&info->netlock, flags); goto cleanup; } - info->count++; + info->port.count++;spin_unlock_irqrestore (&info->netlock, flags); -if (info->count ==1 ) { +if (info->port.count ==1 ) {/* 1st open on this device, init hardware */ retval =startup (info);if (retval <0 )
@@ -3484,9 +3478,9 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp) cleanup:if (retval) {if (tty->count ==1 ) - info->tty =NULL ;/* tty layer will release tty struct */ -if (info->count) - info->count--; + info->port.tty =NULL ;/* tty layer will release tty struct */ +if (info->port.count) + info->port.count--; }return retval;
@@ -4337,8 +4331,7 @@ static struct mgsl_struct* mgsl_allocate_device(void) info->max_frame_size =4096 ; info->close_delay =5 *HZ /10 ; info->closing_wait =30 *HZ ; -init_waitqueue_head (&info->open_wait); -init_waitqueue_head (&info->close_wait); +tty_port_init (&info->port);init_waitqueue_head (&info->status_event_wait_q);init_waitqueue_head (&info->event_wait_q);spin_lock_init (&info->irq_spinlock);
@@ -6575,7 +6568,7 @@ static bool mgsl_get_rx_frame(struct mgsl_struct *info)unsigned int framesize =0 ;bool ReturnCode = false;unsigned long flags; -struct tty_struct *tty = info->tty; +struct tty_struct *tty = info->port.tty;bool return_frame = false;/*
@@ -6774,7 +6767,7 @@ static bool mgsl_get_raw_rx_frame(struct mgsl_struct *info)unsigned int framesize =0 ;bool ReturnCode = false;unsigned long flags; -struct tty_struct *tty = info->tty; +struct tty_struct *tty = info->port.tty;/* * current_rx_buffer points to the 1st buffer of the next available
@@ -7711,7 +7704,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,unsigned short new_crctype;/* return error if TTY interface open */ -if (info->count) +if (info->port.count)return -EBUSY ; switch (encoding)
@@ -7808,7 +7801,7 @@ static int hdlcdev_open(struct net_device *dev)/* arbitrate between network and tty opens */ spin_lock_irqsave (&info->netlock, flags); -if (info->count !=0 || info->netcount !=0 ) { +if (info->port.count !=0 || info->netcount !=0 ) {printk (KERN_WARNING "%s: hdlc_open returning busy\n" , dev->name);spin_unlock_irqrestore (&info->netlock, flags);return -EBUSY ;
@@ -7894,7 +7887,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)printk ("%s:hdlcdev_ioctl(%s)\n" ,__FILE__,dev->name);/* return error if TTY interface open */ -if (info->count) +if (info->port.count)return -EBUSY ;if (cmd !=SIOCWANDEV )
drivers/char/synclink_gt.c +97 -104
552 lines not on this page · raw message
drivers/char/synclinkmp.c +98 -105
569 lines not on this page · raw message
PATCH 19/70 tty: Clean up tiocmset
In reply to Alan CoxFrom: Alan Cox <[email protected]>
Reverse the order of one test and it gets much more readable
---
drivers/char/tty_io.c | 48 ++++++++++++++++++++++-------------------------- 1 files changed, 22 insertions(+), 26 deletions(-)
drivers/char/tty_io.c +22 -26
@@ -3488,35 +3488,31 @@ static int tty_tiocmget(struct tty_struct *tty, struct file *file, int __user *pstatic int tty_tiocmset (struct tty_struct *tty,struct file *file,unsigned int cmd,unsigned __user *p) { -int retval = -EINVAL ; - -if (tty->ops->tiocmset) { -unsigned int set, clear, val; - - retval =get_user (val, p); -if (retval) -return retval; - - set = clear =0 ; -switch (cmd) { -case TIOCMBIS : - set = val; -break ; -case TIOCMBIC : - clear = val; -break ; -case TIOCMSET : - set = val; - clear = ~val; -break ; - } +int retval; +unsigned int set, clear, val; - set &=TIOCM_DTR |TIOCM_RTS |TIOCM_OUT1 |TIOCM_OUT2 |TIOCM_LOOP ; - clear &=TIOCM_DTR |TIOCM_RTS |TIOCM_OUT1 |TIOCM_OUT2 |TIOCM_LOOP ; +if (tty->ops->tiocmset ==NULL ) +return -EINVAL ; - retval = tty->ops->tiocmset (tty, file, set, clear); + retval =get_user (val, p); +if (retval) +return retval; + set = clear =0 ; +switch (cmd) { +case TIOCMBIS : + set = val; +break ; +case TIOCMBIC : + clear = val; +break ; +case TIOCMSET : + set = val; + clear = ~val; +break ; } -return retval; + set &=TIOCM_DTR |TIOCM_RTS |TIOCM_OUT1 |TIOCM_OUT2 |TIOCM_LOOP ; + clear &=TIOCM_DTR |TIOCM_RTS |TIOCM_OUT1 |TIOCM_OUT2 |TIOCM_LOOP ; +return tty->ops->tiocmset (tty, file, set, clear); }/*
PATCH 20/70 cyclades: use tty_port
In reply to Alan CoxFrom: Alan Cox <[email protected]>
Switch cyclades to use the new tty_port structure
---
drivers/char/cyclades.c | 315 +++++++++++++++++++++++----------------------- include/linux/cyclades.h | 7 - 2 files changed, 158 insertions(+), 164 deletions(-)
drivers/char/cyclades.c +157 -158
@@ -762,7 +762,7 @@ static int cy_next_channel; /* next minor available *//* * This is used to look up the divisor speeds and the timeouts * We're normally limited to 15 distinct baud rates. The extra -* are accessed via settings in info->flags. +* are accessed via settings in info->port.flags. * 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, * 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, * HI VHI
@@ -1003,7 +1003,7 @@ static void cyy_chip_rx(struct cyclades_card *cinfo, int chip,cy_writeb (base_addr + (CyCAR << index), save_xir);/* if there is nowhere to put the data, discard it */ -if (info->tty ==NULL ) { +if (info->port.tty ==NULL ) {if ((readb (base_addr + (CyRIVR << index)) & CyIVRMask) == CyIVRRxEx) {/* exception */ data =readb (base_addr + (CyRDSR << index));
@@ -1015,7 +1015,7 @@ static void cyy_chip_rx(struct cyclades_card *cinfo, int chip, goto end; }/* there is an open port for this data */ - tty = info->tty; + tty = info->port.tty;if ((readb (base_addr + (CyRIVR << index)) & CyIVRMask) == CyIVRRxEx) {/* exception */ data =readb (base_addr + (CyRDSR << index));
@@ -1041,7 +1041,7 @@ static void cyy_chip_rx(struct cyclades_card *cinfo, int chip,readb (base_addr + (CyRDSR << index)), TTY_BREAK); info->icount.rx++; -if (info->flags &ASYNC_SAK ) +if (info->port.flags &ASYNC_SAK )do_SAK (tty); }else if (data & CyFRAME) { tty_insert_flip_char(tty,
@@ -1145,7 +1145,7 @@ static void cyy_chip_tx(struct cyclades_card *cinfo, unsigned int chip, goto end; } info = &cinfo->ports[channel + chip *4 ]; -if (info->tty ==NULL ) { +if (info->port.tty ==NULL ) {cy_writeb (base_addr + (CySRER << index),readb (base_addr + (CySRER << index)) & ~CyTxRdy); goto end;
@@ -1190,13 +1190,13 @@ static void cyy_chip_tx(struct cyclades_card *cinfo, unsigned int chip, } goto done; } -if (info->xmit_buf ==NULL ) { +if (info->port.xmit_buf ==NULL ) {cy_writeb (base_addr + (CySRER << index),readb (base_addr + (CySRER << index)) & ~CyTxRdy); goto done; } -if (info->tty->stopped || info->tty->hw_stopped) { +if (info->port.tty->stopped || info->port.tty->hw_stopped) {cy_writeb (base_addr + (CySRER << index),readb (base_addr + (CySRER << index)) & ~CyTxRdy);
@@ -1211,7 +1211,7 @@ static void cyy_chip_tx(struct cyclades_card *cinfo, unsigned int chip,* character. This is necessary because there may not be room * for the two chars needed to send a NULL.) */ - outch = info->xmit_buf[info->xmit_tail]; + outch = info->port.xmit_buf[info->xmit_tail];if (outch) { info->xmit_cnt--; info->xmit_tail = (info->xmit_tail + 1) &
@@ -1232,7 +1232,7 @@ static void cyy_chip_tx(struct cyclades_card *cinfo, unsigned int chip, } done: -tty_wakeup (info->tty); +tty_wakeup (info->port.tty); end:/* end of service */ cy_writeb (base_addr + (CyTIR << index), save_xir &0x3f );
@@ -1256,7 +1256,7 @@ static void cyy_chip_modem(struct cyclades_card *cinfo, int chip, mdm_change =readb (base_addr + (CyMISR << index)); mdm_status =readb (base_addr + (CyMSVR1 << index)); -if (!info->tty) +if (!info->port.tty) goto end;if (mdm_change & CyANY_DELTA) {
@@ -1273,29 +1273,29 @@ static void cyy_chip_modem(struct cyclades_card *cinfo, int chip,wake_up_interruptible (&info->delta_msr_wait); } -if ((mdm_change & CyDCD) && (info->flags &ASYNC_CHECK_CD )) { +if ((mdm_change & CyDCD) && (info->port.flags &ASYNC_CHECK_CD )) {if (!(mdm_status & CyDCD)) { -tty_hangup (info->tty); - info->flags &= ~ASYNC_NORMAL_ACTIVE ; +tty_hangup (info->port.tty); + info->port.flags &= ~ASYNC_NORMAL_ACTIVE ; } -wake_up_interruptible (&info->open_wait); +wake_up_interruptible (&info->port.open_wait); } -if ((mdm_change & CyCTS) && (info->flags &ASYNC_CTS_FLOW )) { -if (info->tty->hw_stopped) { +if ((mdm_change & CyCTS) && (info->port.flags &ASYNC_CTS_FLOW )) { +if (info->port.tty->hw_stopped) {if (mdm_status & CyCTS) {/* cy_start isn't used because... !!! */ - info->tty->hw_stopped =0 ; + info->port.tty->hw_stopped =0 ;cy_writeb (base_addr + (CySRER << index),readb (base_addr + (CySRER << index)) | CyTxRdy); -tty_wakeup (info->tty); +tty_wakeup (info->port.tty); } }else {if (!(mdm_status & CyCTS)) {/* cy_stop isn't used because ... !!! */ - info->tty->hw_stopped =1 ; + info->port.tty->hw_stopped =1 ;cy_writeb (base_addr + (CySRER << index),readb (base_addr + (CySRER << index)) & ~CyTxRdy);
@@ -1449,7 +1449,7 @@ static void cyz_handle_rx(struct cyclades_port *info, struct BUF_CTRL __iomem *buf_ctrl) {struct cyclades_card *cinfo = info->card; -struct tty_struct *tty = info->tty; +struct tty_struct *tty = info->port.tty;unsigned int char_count;int len;#ifdef BLOCKMOVE
@@ -1542,7 +1542,7 @@ static void cyz_handle_tx(struct cyclades_port *info, struct BUF_CTRL __iomem *buf_ctrl) {struct cyclades_card *cinfo = info->card; -struct tty_struct *tty = info->tty; +struct tty_struct *tty = info->port.tty;u8 data;unsigned int char_count;#ifdef BLOCKMOVE
@@ -1585,7 +1585,7 @@ static void cyz_handle_tx(struct cyclades_port *info,memcpy_toio ((char *)(cinfo->base_addr + tx_bufaddr + tx_put), - &info->xmit_buf[info->xmit_tail], + &info->port.xmit_buf[info->xmit_tail], small_count); tx_put = (tx_put + small_count) & (tx_bufsize -1 );
@@ -1597,7 +1597,7 @@ static void cyz_handle_tx(struct cyclades_port *info, }#else while (info->xmit_cnt && char_count) { - data = info->xmit_buf[info->xmit_tail]; + data = info->port.xmit_buf[info->xmit_tail]; info->xmit_cnt--; info->xmit_tail = (info->xmit_tail +1 ) & (SERIAL_XMIT_SIZE -1 );
@@ -1642,7 +1642,7 @@ static void cyz_handle_cmd(struct cyclades_card *cinfo) special_count =0 ; delta_count =0 ; info = &cinfo->ports[channel]; - tty = info->tty; + tty = info->port.tty;if (tty ==NULL )continue ;
@@ -1668,15 +1668,15 @@ static void cyz_handle_cmd(struct cyclades_card *cinfo)case C_CM_MDCD : info->icount.dcd++; delta_count++; -if (info->flags &ASYNC_CHECK_CD ) { +if (info->port.flags &ASYNC_CHECK_CD ) {if ((fw_ver >241 ? ((u_long ) param) :readl (&ch_ctrl->rs_status)) &C_RS_DCD ) { -wake_up_interruptible (&info->open_wait); +wake_up_interruptible (&info->port.open_wait); }else { -tty_hangup (info->tty); -wake_up_interruptible (&info->open_wait); - info->flags &= ~ASYNC_NORMAL_ACTIVE ; +tty_hangup (info->port.tty); +wake_up_interruptible (&info->port.open_wait); + info->port.flags &= ~ASYNC_NORMAL_ACTIVE ; } }break ;
@@ -1814,7 +1814,7 @@ static void cyz_poll(unsigned long arg)for (port =0 ; port < cinfo->nports; port++) { info = &cinfo->ports[port]; - tty = info->tty; + tty = info->port.tty; buf_ctrl = &(zfw_ctrl->buf_ctrl[port]);if (!info->throttle)
@@ -1853,22 +1853,22 @@ static int startup(struct cyclades_port *info)spin_lock_irqsave (&card->card_lock, flags); -if (info->flags &ASYNC_INITIALIZED ) { +if (info->port.flags &ASYNC_INITIALIZED ) {free_page (page); goto errout; }if (!info->type) { -if (info->tty) -set_bit (TTY_IO_ERROR , &info->tty->flags); +if (info->port.tty) +set_bit (TTY_IO_ERROR , &info->port.tty->flags);free_page (page); goto errout; } -if (info->xmit_buf) +if (info->port.xmit_buf)free_page (page);else - info->xmit_buf = (unsigned char *)page; + info->port.xmit_buf = (unsigned char *)page;spin_unlock_irqrestore (&card->card_lock, flags);
@@ -1909,10 +1909,10 @@ static int startup(struct cyclades_port *info)cy_writeb (base_addr + (CySRER << index),readb (base_addr + (CySRER << index)) | CyRxData); - info->flags |=ASYNC_INITIALIZED ; + info->port.flags |=ASYNC_INITIALIZED ; -if (info->tty) -clear_bit (TTY_IO_ERROR , &info->tty->flags); +if (info->port.tty) +clear_bit (TTY_IO_ERROR , &info->port.tty->flags); info->xmit_cnt = info->xmit_head = info->xmit_tail =0 ; info->breakon = info->breakoff =0 ;memset ((char *)&info->idle_stats,0 ,sizeof (info->idle_stats));
@@ -1994,9 +1994,9 @@ static int startup(struct cyclades_port *info)/* enable send, recv, modem !!! */ - info->flags |=ASYNC_INITIALIZED ; -if (info->tty) -clear_bit (TTY_IO_ERROR , &info->tty->flags); + info->port.flags |=ASYNC_INITIALIZED ; +if (info->port.tty) +clear_bit (TTY_IO_ERROR , &info->port.tty->flags); info->xmit_cnt = info->xmit_head = info->xmit_tail =0 ; info->breakon = info->breakoff =0 ;memset ((char *)&info->idle_stats,0 ,sizeof (info->idle_stats));
@@ -2065,7 +2065,7 @@ static void shutdown(struct cyclades_port *info)void __iomem *base_addr;int chip, channel, index; -if (!(info->flags &ASYNC_INITIALIZED )) +if (!(info->port.flags &ASYNC_INITIALIZED ))return ; card = info->card;
@@ -2087,14 +2087,14 @@ static void shutdown(struct cyclades_port *info)/* Clear delta_msr_wait queue to avoid mem leaks. */ wake_up_interruptible (&info->delta_msr_wait); -if (info->xmit_buf) { +if (info->port.xmit_buf) {unsigned char *temp; - temp = info->xmit_buf; - info->xmit_buf =NULL ; + temp = info->port.xmit_buf; + info->port.xmit_buf =NULL ;free_page ((unsigned long )temp); }cy_writeb (base_addr + (CyCAR << index), (u_char ) channel); -if (!info->tty || (info->tty->termios->c_cflag &HUPCL )) { +if (!info->port.tty || (info->port.tty->termios->c_cflag &HUPCL )) {cy_writeb (base_addr + (CyMSVR1 << index), ~CyRTS);cy_writeb (base_addr + (CyMSVR2 << index), ~CyDTR);#ifdef CY_DEBUG_DTR
@@ -2108,9 +2108,9 @@ static void shutdown(struct cyclades_port *info)/* it may be appropriate to clear _XMIT at some later date (after testing)!!! */ -if (info->tty) -set_bit (TTY_IO_ERROR , &info->tty->flags); - info->flags &= ~ASYNC_INITIALIZED ; +if (info->port.tty) +set_bit (TTY_IO_ERROR , &info->port.tty->flags); + info->port.flags &= ~ASYNC_INITIALIZED ;spin_unlock_irqrestore (&card->card_lock, flags); }else {struct FIRM_ID __iomem *firm_id;
@@ -2136,14 +2136,14 @@ static void shutdown(struct cyclades_port *info)spin_lock_irqsave (&card->card_lock, flags); -if (info->xmit_buf) { +if (info->port.xmit_buf) {unsigned char *temp; - temp = info->xmit_buf; - info->xmit_buf =NULL ; + temp = info->port.xmit_buf; + info->port.xmit_buf =NULL ;free_page ((unsigned long )temp); } -if (!info->tty || (info->tty->termios->c_cflag &HUPCL )) { +if (!info->port.tty || (info->port.tty->termios->c_cflag &HUPCL )) {cy_writel (&ch_ctrl[channel].rs_control, (__u32)(readl (&ch_ctrl[channel].rs_control) & ~(C_RS_RTS |C_RS_DTR )));
@@ -2158,9 +2158,9 @@ static void shutdown(struct cyclades_port *info)#endif } -if (info->tty) -set_bit (TTY_IO_ERROR , &info->tty->flags); - info->flags &= ~ASYNC_INITIALIZED ; +if (info->port.tty) +set_bit (TTY_IO_ERROR , &info->port.tty->flags); + info->port.flags &= ~ASYNC_INITIALIZED ;spin_unlock_irqrestore (&card->card_lock, flags); }
@@ -2194,10 +2194,10 @@ block_til_ready(struct tty_struct *tty, struct file *filp,* If the device is in the middle of being closed, then block * until it's done, and then try again. */ -if (tty_hung_up_p (filp) || (info->flags &ASYNC_CLOSING )) { -wait_event_interruptible (info->close_wait, - !(info->flags &ASYNC_CLOSING )); -return (info->flags &ASYNC_HUP_NOTIFY ) ? -EAGAIN : -ERESTARTSYS ; +if (tty_hung_up_p (filp) || (info->port.flags &ASYNC_CLOSING )) { +wait_event_interruptible (info->port.close_wait, + !(info->port.flags &ASYNC_CLOSING )); +return (info->port.flags &ASYNC_HUP_NOTIFY ) ? -EAGAIN : -ERESTARTSYS ; }/*
@@ -2206,32 +2206,32 @@ block_til_ready(struct tty_struct *tty, struct file *filp,*/ if ((filp->f_flags &O_NONBLOCK ) || (tty->flags & (1 <<TTY_IO_ERROR ))) { - info->flags |=ASYNC_NORMAL_ACTIVE ; + info->port.flags |=ASYNC_NORMAL_ACTIVE ;return 0 ; }/* * Block waiting for the carrier detect and the line to become * free (i.e., not in use by the callout). While we are in -* this loop, info->count is dropped by one, so that +* this loop, info->port.count is dropped by one, so that * cy_close() knows when to free things. We restore it upon * exit, either normal or abnormal. */ retval =0 ; -add_wait_queue (&info->open_wait, &wait); +add_wait_queue (&info->port.open_wait, &wait);#ifdef CY_DEBUG_OPEN printk (KERN_DEBUG "cyc block_til_ready before block: ttyC%d, " -"count = %d\n" , info->line, info->count); +"count = %d\n" , info->line, info->port.count);#endif spin_lock_irqsave (&cinfo->card_lock, flags);if (!tty_hung_up_p (filp)) - info->count--; + info->port.count--;spin_unlock_irqrestore (&cinfo->card_lock, flags);#ifdef CY_DEBUG_COUNT printk (KERN_DEBUG "cyc block_til_ready: (%d): decrementing count to " -"%d\n" , current->pid, info->count); +"%d\n" , current->pid, info->port.count);#endif - info->blocked_open++; + info->port.blocked_open++;if (!IS_CYC_Z (*cinfo)) { chip = channel >>2 ;
@@ -2260,8 +2260,8 @@ block_til_ready(struct tty_struct *tty, struct file *filp,set_current_state (TASK_INTERRUPTIBLE );if (tty_hung_up_p (filp) || - !(info->flags &ASYNC_INITIALIZED )) { - retval = ((info->flags &ASYNC_HUP_NOTIFY ) ? + !(info->port.flags &ASYNC_INITIALIZED )) { + retval = ((info->port.flags &ASYNC_HUP_NOTIFY ) ? -EAGAIN : -ERESTARTSYS );break ; }
@@ -2269,7 +2269,7 @@ block_til_ready(struct tty_struct *tty, struct file *filp,spin_lock_irqsave (&cinfo->card_lock, flags);cy_writeb (base_addr + (CyCAR << index), (u_char ) channel); -if (!(info->flags &ASYNC_CLOSING ) && (C_CLOCAL (tty) || +if (!(info->port.flags &ASYNC_CLOSING ) && (C_CLOCAL (tty) || (readb (base_addr + (CyMSVR1 << index)) & CyDCD))) {spin_unlock_irqrestore (&cinfo->card_lock, flags);
@@ -2284,7 +2284,7 @@ block_til_ready(struct tty_struct *tty, struct file *filp,#ifdef CY_DEBUG_OPEN printk (KERN_DEBUG "cyc block_til_ready blocking: " "ttyC%d, count = %d\n" , - info->line, info->count); + info->line, info->port.count);#endif schedule (); }
@@ -2298,7 +2298,7 @@ block_til_ready(struct tty_struct *tty, struct file *filp, firm_id = base_addr +ID_ADDRESS ;if (!ISZLOADED (*cinfo)) {__set_current_state (TASK_RUNNING ); -remove_wait_queue (&info->open_wait, &wait); +remove_wait_queue (&info->port.open_wait, &wait);return -EINVAL ; }
@@ -2327,12 +2327,12 @@ block_til_ready(struct tty_struct *tty, struct file *filp,set_current_state (TASK_INTERRUPTIBLE );if (tty_hung_up_p (filp) || - !(info->flags &ASYNC_INITIALIZED )) { - retval = ((info->flags &ASYNC_HUP_NOTIFY ) ? + !(info->port.flags &ASYNC_INITIALIZED )) { + retval = ((info->port.flags &ASYNC_HUP_NOTIFY ) ? -EAGAIN : -ERESTARTSYS );break ; } -if (!(info->flags &ASYNC_CLOSING ) && (C_CLOCAL (tty) || +if (!(info->port.flags &ASYNC_CLOSING ) && (C_CLOCAL (tty) || (readl (&ch_ctrl[channel].rs_status) &C_RS_DCD ))) {break ;
@@ -2344,28 +2344,28 @@ block_til_ready(struct tty_struct *tty, struct file *filp,#ifdef CY_DEBUG_OPEN printk (KERN_DEBUG "cyc block_til_ready blocking: " "ttyC%d, count = %d\n" , - info->line, info->count); + info->line, info->port.count);#endif schedule (); } }__set_current_state (TASK_RUNNING ); -remove_wait_queue (&info->open_wait, &wait); +remove_wait_queue (&info->port.open_wait, &wait);if (!tty_hung_up_p (filp)) { - info->count++; + info->port.count++;#ifdef CY_DEBUG_COUNT printk (KERN_DEBUG "cyc:block_til_ready (%d): incrementing " -"count to %d\n" , current->pid, info->count); +"count to %d\n" , current->pid, info->port.count);#endif } - info->blocked_open--; + info->port.blocked_open--;#ifdef CY_DEBUG_OPEN printk (KERN_DEBUG "cyc:block_til_ready after blocking: ttyC%d, " -"count = %d\n" , info->line, info->count); +"count = %d\n" , info->line, info->port.count);#endif if (retval)return retval; - info->flags |=ASYNC_NORMAL_ACTIVE ; + info->port.flags |=ASYNC_NORMAL_ACTIVE ;return 0 ; }/* block_til_ready */
@@ -2456,27 +2456,27 @@ static int cy_open(struct tty_struct *tty, struct file *filp)printk (KERN_DEBUG "cyc:cy_open ttyC%d\n" , info->line);#endif tty->driver_data = info; - info->tty = tty; + info->port.tty = tty;if (serial_paranoia_check (info, tty->name,"cy_open" ))return -ENODEV ;#ifdef CY_DEBUG_OPEN printk (KERN_DEBUG "cyc:cy_open ttyC%d, count = %d\n" , info->line, - info->count); + info->port.count);#endif - info->count++; + info->port.count++;#ifdef CY_DEBUG_COUNT printk (KERN_DEBUG "cyc:cy_open (%d): incrementing count to %d\n" , - current->pid, info->count); + current->pid, info->port.count);#endif /* * If the port is the middle of closing, bail out now */ -if (tty_hung_up_p (filp) || (info->flags &ASYNC_CLOSING )) { -wait_event_interruptible (info->close_wait, - !(info->flags &ASYNC_CLOSING )); -return (info->flags &ASYNC_HUP_NOTIFY ) ? -EAGAIN : -ERESTARTSYS ; +if (tty_hung_up_p (filp) || (info->port.flags &ASYNC_CLOSING )) { +wait_event_interruptible (info->port.close_wait, + !(info->port.flags &ASYNC_CLOSING )); +return (info->port.flags &ASYNC_HUP_NOTIFY ) ? -EAGAIN : -ERESTARTSYS ; }/*
@@ -2641,9 +2641,9 @@ static void cy_close(struct tty_struct *tty, struct file *filp) }#ifdef CY_DEBUG_OPEN printk (KERN_DEBUG "cyc:cy_close ttyC%d, count = %d\n" , info->line, - info->count); + info->port.count);#endif -if ((tty->count ==1 ) && (info->count !=1 )) { +if ((tty->count ==1 ) && (info->port.count !=1 )) {/* * Uh, oh. tty->count is 1, which means that the tty * structure will be freed. Info->count should always
@@ -2652,24 +2652,24 @@ static void cy_close(struct tty_struct *tty, struct file *filp)* serial port won't be shutdown. */ printk (KERN_ERR "cyc:cy_close: bad serial port count; " -"tty->count is 1, info->count is %d\n" , info->count); - info->count =1 ; +"tty->count is 1, info->port.count is %d\n" , info->port.count); + info->port.count =1 ; }#ifdef CY_DEBUG_COUNT printk (KERN_DEBUG "cyc:cy_close at (%d): decrementing count to %d\n" , - current->pid, info->count -1 ); + current->pid, info->port.count -1 );#endif -if (--info->count <0 ) { +if (--info->port.count <0 ) {#ifdef CY_DEBUG_COUNT printk (KERN_DEBUG "cyc:cyc_close setting count to 0\n" );#endif - info->count =0 ; + info->port.count =0 ; } -if (info->count) { +if (info->port.count) {spin_unlock_irqrestore (&card->card_lock, flags);return ; } - info->flags |=ASYNC_CLOSING ; + info->port.flags |=ASYNC_CLOSING ;/* * Now we wait for the transmit buffer to clear; and we notify
@@ -2692,7 +2692,7 @@ static void cy_close(struct tty_struct *tty, struct file *filp)cy_writeb (base_addr + (CyCAR << index), (u_char ) channel);cy_writeb (base_addr + (CySRER << index),readb (base_addr + (CySRER << index)) & ~CyRxData); -if (info->flags &ASYNC_INITIALIZED ) { +if (info->port.flags &ASYNC_INITIALIZED ) {/* Waiting for on-board buffers to be empty before closing the port */ spin_unlock_irqrestore (&card->card_lock, flags);
@@ -2731,18 +2731,18 @@ static void cy_close(struct tty_struct *tty, struct file *filp)spin_lock_irqsave (&card->card_lock, flags); tty->closing =0 ; - info->tty =NULL ; -if (info->blocked_open) { + info->port.tty =NULL ; +if (info->port.blocked_open) {spin_unlock_irqrestore (&card->card_lock, flags);if (info->close_delay) {msleep_interruptible (jiffies_to_msecs (info->close_delay)); } -wake_up_interruptible (&info->open_wait); +wake_up_interruptible (&info->port.open_wait);spin_lock_irqsave (&card->card_lock, flags); } - info->flags &= ~(ASYNC_NORMAL_ACTIVE |ASYNC_CLOSING ); -wake_up_interruptible (&info->close_wait); + info->port.flags &= ~(ASYNC_NORMAL_ACTIVE |ASYNC_CLOSING ); +wake_up_interruptible (&info->port.close_wait);#ifdef CY_DEBUG_OTHER printk (KERN_DEBUG "cyc:cy_close done\n" );
@@ -2777,7 +2777,7 @@ static int cy_write(struct tty_struct *tty, const unsigned char *buf, int count)if (serial_paranoia_check (info, tty->name,"cy_write" ))return 0 ; -if (!info->xmit_buf) +if (!info->port.xmit_buf)return 0 ;spin_lock_irqsave (&info->card->card_lock, flags);
@@ -2788,7 +2788,7 @@ static int cy_write(struct tty_struct *tty, const unsigned char *buf, int count)if (c <=0 )break ; -memcpy (info->xmit_buf + info->xmit_head, buf, c); +memcpy (info->port.xmit_buf + info->xmit_head, buf, c); info->xmit_head = (info->xmit_head + c) & (SERIAL_XMIT_SIZE -1 ); info->xmit_cnt += c;
@@ -2826,7 +2826,7 @@ static int cy_put_char(struct tty_struct *tty, unsigned char ch)if (serial_paranoia_check (info, tty->name,"cy_put_char" ))return 0 ; -if (!info->xmit_buf) +if (!info->port.xmit_buf)return 0 ;spin_lock_irqsave (&info->card->card_lock, flags);
@@ -2835,7 +2835,7 @@ static int cy_put_char(struct tty_struct *tty, unsigned char ch)return 0 ; } - info->xmit_buf[info->xmit_head++] = ch; + info->port.xmit_buf[info->xmit_head++] = ch; info->xmit_head &=SERIAL_XMIT_SIZE -1 ; info->xmit_cnt++; info->idle_stats.xmit_bytes++;
@@ -2860,7 +2860,7 @@ static void cy_flush_chars(struct tty_struct *tty)return ;if (info->xmit_cnt <=0 || tty->stopped || tty->hw_stopped || - !info->xmit_buf) + !info->port.xmit_buf)return ;start_xmit (info);
@@ -2988,27 +2988,27 @@ static void set_line_char(struct cyclades_port *info)int baud, baud_rate =0 ;int i; -if (!info->tty || !info->tty->termios) +if (!info->port.tty || !info->port.tty->termios)return ;if (info->line ==-1 )return ; - cflag = info->tty->termios->c_cflag; - iflag = info->tty->termios->c_iflag; + cflag = info->port.tty->termios->c_cflag; + iflag = info->port.tty->termios->c_iflag;/* * Set up the tty->alt_speed kludge */ -if (info->tty) { -if ((info->flags &ASYNC_SPD_MASK ) ==ASYNC_SPD_HI ) - info->tty->alt_speed =57600 ; -if ((info->flags &ASYNC_SPD_MASK ) ==ASYNC_SPD_VHI ) - info->tty->alt_speed =115200 ; -if ((info->flags &ASYNC_SPD_MASK ) ==ASYNC_SPD_SHI ) - info->tty->alt_speed =230400 ; -if ((info->flags &ASYNC_SPD_MASK ) ==ASYNC_SPD_WARP ) - info->tty->alt_speed =460800 ; +if (info->port.tty) { +if ((info->port.flags &ASYNC_SPD_MASK ) ==ASYNC_SPD_HI ) + info->port.tty->alt_speed =57600 ; +if ((info->port.flags &ASYNC_SPD_MASK ) ==ASYNC_SPD_VHI ) + info->port.tty->alt_speed =115200 ; +if ((info->port.flags &ASYNC_SPD_MASK ) ==ASYNC_SPD_SHI ) + info->port.tty->alt_speed =230400 ; +if ((info->port.flags &ASYNC_SPD_MASK ) ==ASYNC_SPD_WARP ) + info->port.tty->alt_speed =460800 ; } card = info->card;
@@ -3020,8 +3020,8 @@ static void set_line_char(struct cyclades_port *info) index = card->bus_index;/* baud rate */ - baud =tty_get_baud_rate (info->tty); -if (baud ==38400 && (info->flags &ASYNC_SPD_MASK ) == + baud =tty_get_baud_rate (info->port.tty); +if (baud ==38400 && (info->port.flags &ASYNC_SPD_MASK ) ==ASYNC_SPD_CUST ) {if (info->custom_divisor) baud_rate = info->baud / info->custom_divisor;
@@ -3038,7 +3038,7 @@ static void set_line_char(struct cyclades_port *info)if (i ==20 ) i =19 ;/* CD1400_MAX_SPEED */ -if (baud ==38400 && (info->flags &ASYNC_SPD_MASK ) == +if (baud ==38400 && (info->port.flags &ASYNC_SPD_MASK ) ==ASYNC_SPD_CUST ) {cyy_baud_calc (info, baud_rate); }else {
@@ -3059,7 +3059,7 @@ static void set_line_char(struct cyclades_port *info)/* get it right for 134.5 baud */ info->timeout = (info->xmit_fifo_size *HZ *30 /269 ) +2 ; - }else if (baud ==38400 && (info->flags &ASYNC_SPD_MASK ) == + }else if (baud ==38400 && (info->port.flags &ASYNC_SPD_MASK ) ==ASYNC_SPD_CUST ) { info->timeout = (info->xmit_fifo_size *HZ *15 / baud_rate) +2 ;
@@ -3108,16 +3108,16 @@ static void set_line_char(struct cyclades_port *info)/* CTS flow control flag */ if (cflag &CRTSCTS ) { - info->flags |=ASYNC_CTS_FLOW ; + info->port.flags |=ASYNC_CTS_FLOW ; info->cor2 |= CyCtsAE; }else { - info->flags &= ~ASYNC_CTS_FLOW ; + info->port.flags &= ~ASYNC_CTS_FLOW ; info->cor2 &= ~CyCtsAE; }if (cflag &CLOCAL ) - info->flags &= ~ASYNC_CHECK_CD ; + info->port.flags &= ~ASYNC_CHECK_CD ;else - info->flags |=ASYNC_CHECK_CD ; + info->port.flags |=ASYNC_CHECK_CD ;/*********************************************** The hardware option, CyRtsAO, presents RTS when
@@ -3146,8 +3146,8 @@ static void set_line_char(struct cyclades_port *info)/* set line characteristics according configuration */ cy_writeb (base_addr + (CySCHR1 << index), -START_CHAR (info->tty)); -cy_writeb (base_addr + (CySCHR2 << index),STOP_CHAR (info->tty)); +START_CHAR (info->port.tty)); +cy_writeb (base_addr + (CySCHR2 << index),STOP_CHAR (info->port.tty));cy_writeb (base_addr + (CyCOR1 << index), info->cor1);cy_writeb (base_addr + (CyCOR2 << index), info->cor2);cy_writeb (base_addr + (CyCOR3 << index), info->cor3);
@@ -3163,7 +3163,7 @@ static void set_line_char(struct cyclades_port *info) (info->default_timeout ? info->default_timeout : 0x02));/* 10ms rx timeout */ -if (C_CLOCAL (info->tty)) { +if (C_CLOCAL (info->port.tty)) {/* without modem intr */ cy_writeb (base_addr + (CySRER << index),readb (base_addr + (CySRER << index)) | CyMdmCh);
@@ -3226,8 +3226,8 @@ static void set_line_char(struct cyclades_port *info)#endif } -if (info->tty) -clear_bit (TTY_IO_ERROR , &info->tty->flags); +if (info->port.tty) +clear_bit (TTY_IO_ERROR , &info->port.tty->flags);spin_unlock_irqrestore (&card->card_lock, flags); }else {
@@ -3250,8 +3250,8 @@ static void set_line_char(struct cyclades_port *info) buf_ctrl = &zfw_ctrl->buf_ctrl[channel];/* baud rate */ - baud =tty_get_baud_rate (info->tty); -if (baud ==38400 && (info->flags &ASYNC_SPD_MASK ) == + baud =tty_get_baud_rate (info->port.tty); +if (baud ==38400 && (info->port.flags &ASYNC_SPD_MASK ) ==ASYNC_SPD_CUST ) {if (info->custom_divisor) baud_rate = info->baud / info->custom_divisor;
@@ -3266,7 +3266,7 @@ static void set_line_char(struct cyclades_port *info)/* get it right for 134.5 baud */ info->timeout = (info->xmit_fifo_size *HZ *30 /269 ) +2 ; - }else if (baud ==38400 && (info->flags &ASYNC_SPD_MASK ) == + }else if (baud ==38400 && (info->port.flags &ASYNC_SPD_MASK ) ==ASYNC_SPD_CUST ) { info->timeout = (info->xmit_fifo_size *HZ *15 / baud_rate) +2 ;
@@ -3318,7 +3318,7 @@ static void set_line_char(struct cyclades_port *info) }/* As the HW flow control is done in firmware, the driver doesn't need to care about it */ - info->flags &= ~ASYNC_CTS_FLOW ; + info->port.flags &= ~ASYNC_CTS_FLOW ;/* XON/XOFF/XANY flow control flags */ sw_flow =0 ;
@@ -3337,9 +3337,9 @@ static void set_line_char(struct cyclades_port *info)/* CD sensitivity */ if (cflag &CLOCAL ) - info->flags &= ~ASYNC_CHECK_CD ; + info->port.flags &= ~ASYNC_CHECK_CD ;else - info->flags |=ASYNC_CHECK_CD ; + info->port.flags |=ASYNC_CHECK_CD ;if (baud ==0 ) {/* baud rate is zero, turn off line */ cy_writel(&ch_ctrl->rs_control,
@@ -3361,8 +3361,8 @@ static void set_line_char(struct cyclades_port *info) "was %x\n", info->line, retval); } -if (info->tty) -clear_bit (TTY_IO_ERROR , &info->tty->flags); +if (info->port.tty) +clear_bit (TTY_IO_ERROR , &info->port.tty->flags); } }/* set_line_char */
@@ -3381,7 +3381,7 @@ get_serial_info(struct cyclades_port *info, tmp.port = (info->card - cy_card) *0x100 + info->line - cinfo->first_line; tmp.irq = cinfo->irq; - tmp.flags = info->flags; + tmp.flags = info->port.flags; tmp.close_delay = info->close_delay; tmp.closing_wait = info->closing_wait; tmp.baud_base = info->baud;
@@ -3406,9 +3406,9 @@ set_serial_info(struct cyclades_port *info, new_serial.baud_base != info->baud || (new_serial.flags &ASYNC_FLAGS & ~ASYNC_USR_MASK ) != - (info->flags & ASYNC_FLAGS & ~ASYNC_USR_MASK)) + (info->port.flags & ASYNC_FLAGS & ~ASYNC_USR_MASK)) return -EPERM; - info->flags = (info->flags & ~ASYNC_USR_MASK ) | + info->port.flags = (info->port.flags & ~ASYNC_USR_MASK ) | (new_serial.flags &ASYNC_USR_MASK ); info->baud = new_serial.baud_base; info->custom_divisor = new_serial.custom_divisor;
@@ -3422,13 +3422,13 @@ set_serial_info(struct cyclades_port *info, info->baud = new_serial.baud_base; info->custom_divisor = new_serial.custom_divisor; - info->flags = (info->flags & ~ASYNC_FLAGS ) | + info->port.flags = (info->port.flags & ~ASYNC_FLAGS ) | (new_serial.flags &ASYNC_FLAGS ); info->close_delay = new_serial.close_delay *HZ /100 ; info->closing_wait = new_serial.closing_wait *HZ /100 ; check_and_exit: -if (info->flags &ASYNC_INITIALIZED ) { +if (info->port.flags &ASYNC_INITIALIZED ) {set_line_char (info);return 0 ; }else {
@@ -4097,7 +4097,7 @@ static void cy_set_termios(struct tty_struct *tty, struct ktermios *old_termios)*/ if (!(old_termios->c_cflag &CLOCAL ) && (tty->termios->c_cflag &CLOCAL )) -wake_up_interruptible (&info->open_wait); +wake_up_interruptible (&info->port.open_wait);#endif }/* cy_set_termios */
@@ -4326,14 +4326,14 @@ static void cy_hangup(struct tty_struct *tty)cy_flush_buffer (tty);shutdown (info); - info->count =0 ; + info->port.count =0 ;#ifdef CY_DEBUG_COUNT printk (KERN_DEBUG "cyc:cy_hangup (%d): setting count to 0\n" , current->pid);#endif - info->tty =NULL ; - info->flags &= ~ASYNC_NORMAL_ACTIVE ; -wake_up_interruptible (&info->open_wait); + info->port.tty =NULL ; + info->port.flags &= ~ASYNC_NORMAL_ACTIVE ; +wake_up_interruptible (&info->port.open_wait); }/* cy_hangup */ /*
@@ -4379,12 +4379,11 @@ static int __devinit cy_init_card(struct cyclades_card *cinfo) info->magic =CYCLADES_MAGIC ; info->card = cinfo; info->line = port; - info->flags =STD_COM_FLAGS ; info->closing_wait =CLOSING_WAIT_DELAY ; info->close_delay =5 *HZ /10 ; -init_waitqueue_head (&info->open_wait); -init_waitqueue_head (&info->close_wait); +tty_port_init (&info->port); + info->port.flags =STD_COM_FLAGS ;init_completion (&info->shutdown_wait);init_waitqueue_head (&info->delta_msr_wait);
@@ -5237,7 +5236,7 @@ cyclades_get_proc_info(char *buf, char **start, off_t offset, int length,for (j =0 ; j < cy_card[i].nports; j++) { info = &cy_card[i].ports[j]; -if (info->count) +if (info->port.count) size = sprintf(buf + len, "%3d %8lu %10lu %8lu " "%10lu %8lu %9lu %6ld\n", info->line, (cur_jifs - info->idle_stats.in_use) /
@@ -5247,7 +5246,7 @@ cyclades_get_proc_info(char *buf, char **start, off_t offset, int length, (cur_jifs - info->idle_stats.recv_idle)/HZ , info->idle_stats.overruns,/* FIXME: double check locking */ - (long)info->tty->ldisc.ops->num); + (long)info->port.tty->ldisc.ops->num); else size = sprintf(buf + len, "%3d %8lu %10lu %8lu " "%10lu %8lu %9lu %6ld\n",
include/linux/cyclades.h +1 -6
@@ -550,11 +550,11 @@ struct cyclades_icount {struct cyclades_port {int magic; +struct tty_port port;struct cyclades_card *card;int line;int flags;/* defined in tty.h */ int type;/* UART type */ -struct tty_struct *tty;int read_status_mask;int ignore_status_mask;int timeout;
@@ -569,11 +569,8 @@ struct cyclades_port {u8 x_char;/* to be pushed out ASAP */ int close_delay;unsigned short closing_wait; -int count;/* # of fd on device */ int breakon;int breakoff; -int blocked_open;/* # of blocked opens */ -unsigned char *xmit_buf;int xmit_head;int xmit_tail;int xmit_cnt;
@@ -583,8 +580,6 @@ struct cyclades_port {struct cyclades_monitor mon;struct cyclades_idle_stats idle_stats;struct cyclades_icount icount; -wait_queue_head_t open_wait; -wait_queue_head_t close_wait;struct completion shutdown_wait;wait_queue_head_t delta_msr_wait;int throttle;
PATCH 21/70 termios: Termios defines for other platforms
In reply to Alan CoxFrom: Alan Cox <[email protected]>
Fix up the termios of the people who have not yet got with the program
---
include/asm-avr32/ioctls.h | 4 ++++ include/asm-frv/ioctls.h | 4 ++++ include/asm-frv/termbits.h | 5 ++++- 3 files changed, 12 insertions(+), 1 deletions(-)
include/asm-avr32/ioctls.h +4 -0
@@ -47,6 +47,10 @@#define TIOCSBRK 0x5427/* BSD compatibility */ #define TIOCCBRK 0x5428/* BSD compatibility */ #define TIOCGSID 0x5429/* Return the session ID of FD */ +#define TCGETS2 _IOR('T',0x2A, struct termios2) +#define TCSETS2 _IOW('T',0x2B, struct termios2) +#define TCSETSW2 _IOW('T',0x2C, struct termios2) +#define TCSETSF2 _IOW('T',0x2D, struct termios2)#define TIOCGPTN _IOR('T',0x30, unsigned int)/* Get Pty Number (of pty-mux device) */ #define TIOCSPTLCK _IOW('T',0x31, int)/* Lock/unlock Pty */
include/asm-frv/ioctls.h +4 -0
@@ -47,6 +47,10 @@#define TIOCSBRK 0x5427/* BSD compatibility */ #define TIOCCBRK 0x5428/* BSD compatibility */ #define TIOCGSID 0x5429/* Return the session ID of FD */ +#define TCGETS2 _IOR('T',0x2A, struct termios2) +#define TCSETS2 _IOW('T',0x2B, struct termios2) +#define TCSETSW2 _IOW('T',0x2C, struct termios2) +#define TCSETSF2 _IOW('T',0x2D, struct termios2)#define TIOCGPTN _IOR('T',0x30, unsigned int)/* Get Pty Number (of pty-mux device) */ #define TIOCSPTLCK _IOW('T',0x31, int)/* Lock/unlock Pty */
include/asm-frv/termbits.h +4 -1
@@ -141,6 +141,7 @@ struct ktermios {#define HUPCL 0002000#define CLOCAL 0004000#define CBAUDEX 0010000 +#define BOTHER 0010000#define B57600 0010001#define B115200 0010002#define B230400 0010003
@@ -156,11 +157,13 @@ struct ktermios {#define B3000000 0010015#define B3500000 0010016#define B4000000 0010017 -#define CIBAUD 002003600000/* input baud rate (not used) */ +#define CIBAUD 002003600000/* Input baud rate */ #define CTVB 004000000000/* VisioBraille Terminal flow control */ #define CMSPAR 010000000000/* mark or space (stick) parity */ #define CRTSCTS 020000000000/* flow control */ +#define IBSHIFT 16/* Shift from CBAUD to CIBAUD */ +/* c_lflag bits */ #define ISIG 0000001#define ICANON 0000002
PATCH 22/70 tty: add more tty_port fields
In reply to Alan CoxFrom: Alan Cox <[email protected]>
Move more bits into the tty_port structure
---
drivers/char/cyclades.c | 28 ++++---- drivers/char/isicom.c | 28 ++++---- drivers/char/moxa.c | 8 +- drivers/char/mxser.c | 29 +++----- drivers/char/riscom8.c | 24 +++---- drivers/char/riscom8.h | 2 - drivers/char/rocket.c | 23 +++--- drivers/char/rocket.h | 4 + drivers/char/rocket_int.h | 2 - drivers/char/specialix.c | 153 ++++++++++++++++++++---------------------- drivers/char/specialix_io8.h | 8 -- drivers/char/sx.c | 2 - drivers/char/synclink.c | 16 ++-- drivers/char/synclink_gt.c | 16 ++-- drivers/char/synclinkmp.c | 14 ++-- drivers/char/tty_io.c | 2 + include/linux/cyclades.h | 6 +- include/linux/tty.h | 2 + 18 files changed, 169 insertions(+), 198 deletions(-)
drivers/char/cyclades.c +14 -14
@@ -2677,8 +2677,8 @@ static void cy_close(struct tty_struct *tty, struct file *filp)*/ tty->closing =1 ;spin_unlock_irqrestore (&card->card_lock, flags); -if (info->closing_wait !=CY_CLOSING_WAIT_NONE ) -tty_wait_until_sent (tty, info->closing_wait); +if (info->port.closing_wait !=CY_CLOSING_WAIT_NONE ) +tty_wait_until_sent (tty, info->port.closing_wait);spin_lock_irqsave (&card->card_lock, flags);
@@ -2734,9 +2734,9 @@ static void cy_close(struct tty_struct *tty, struct file *filp) info->port.tty =NULL ;if (info->port.blocked_open) {spin_unlock_irqrestore (&card->card_lock, flags); -if (info->close_delay) { +if (info->port.close_delay) {msleep_interruptible (jiffies_to_msecs - (info->close_delay)); + (info->port.close_delay)); }wake_up_interruptible (&info->port.open_wait);spin_lock_irqsave (&card->card_lock, flags);
@@ -3382,8 +3382,8 @@ get_serial_info(struct cyclades_port *info, cinfo->first_line; tmp.irq = cinfo->irq; tmp.flags = info->port.flags; - tmp.close_delay = info->close_delay; - tmp.closing_wait = info->closing_wait; + tmp.close_delay = info->port.close_delay; + tmp.closing_wait = info->port.closing_wait; tmp.baud_base = info->baud; tmp.custom_divisor = info->custom_divisor; tmp.hub6 =0 ;/*!!! */
@@ -3402,7 +3402,7 @@ set_serial_info(struct cyclades_port *info, old_info = *info; if (!capable(CAP_SYS_ADMIN)) { - if (new_serial.close_delay != info->close_delay || + if (new_serial.close_delay != info->port.close_delay || new_serial.baud_base != info->baud || (new_serial.flags & ASYNC_FLAGS & ~ASYNC_USR_MASK) !=
@@ -3424,8 +3424,8 @@ set_serial_info(struct cyclades_port *info, info->custom_divisor = new_serial.custom_divisor; info->port.flags = (info->port.flags & ~ASYNC_FLAGS ) | (new_serial.flags &ASYNC_FLAGS ); - info->close_delay = new_serial.close_delay *HZ /100 ; - info->closing_wait = new_serial.closing_wait *HZ /100 ; + info->port.close_delay = new_serial.close_delay *HZ /100 ; + info->port.closing_wait = new_serial.closing_wait *HZ /100 ; check_and_exit:if (info->port.flags &ASYNC_INITIALIZED ) {
@@ -3971,11 +3971,11 @@ cy_ioctl(struct tty_struct *tty, struct file *file,break ;#endif /* CONFIG_CYZ_INTR */ case CYSETWAIT : - info->closing_wait = (unsigned short )arg *HZ /100 ; + info->port.closing_wait = (unsigned short )arg *HZ /100 ; ret_val =0 ;break ;case CYGETWAIT : - ret_val = info->closing_wait / (HZ /100 ); + ret_val = info->port.closing_wait / (HZ /100 );break ;case TIOCGSERIAL : ret_val =get_serial_info (info, argp);
@@ -4376,13 +4376,13 @@ static int __devinit cy_init_card(struct cyclades_card *cinfo)for (port = cinfo->first_line; port < cinfo->first_line + nports; port++) { info = &cinfo->ports[port - cinfo->first_line]; +tty_port_init (&info->port); info->magic =CYCLADES_MAGIC ; info->card = cinfo; info->line = port; - info->closing_wait =CLOSING_WAIT_DELAY ; - info->close_delay =5 *HZ /10 ; -tty_port_init (&info->port); + info->port.closing_wait =CLOSING_WAIT_DELAY ; + info->port.close_delay =5 *HZ /10 ; info->port.flags =STD_COM_FLAGS ;init_completion (&info->shutdown_wait);init_waitqueue_head (&info->delta_msr_wait);
drivers/char/isicom.c +13 -15
@@ -199,10 +199,8 @@ struct isi_board {struct isi_port {unsigned short magic;struct tty_port port; -int close_delay;u16 channel;u16 status; -u16 closing_wait;struct isi_board *card;unsigned char *xmit_buf;int xmit_head;
@@ -1051,8 +1049,8 @@ static void isicom_close(struct tty_struct *tty, struct file *filp) tty->closing =1 ;spin_unlock_irqrestore (&card->card_lock, flags); -if (port->closing_wait !=ASYNC_CLOSING_WAIT_NONE ) -tty_wait_until_sent (tty, port->closing_wait); +if (port->port.closing_wait !=ASYNC_CLOSING_WAIT_NONE ) +tty_wait_until_sent (tty, port->port.closing_wait);/* indicate to the card that no more data can be received on this port */ spin_lock_irqsave (&card->card_lock, flags);
@@ -1071,10 +1069,10 @@ static void isicom_close(struct tty_struct *tty, struct file *filp)if (port->port.blocked_open) {spin_unlock_irqrestore (&card->card_lock, flags); -if (port->close_delay) { +if (port->port.close_delay) {pr_dbg ("scheduling until time out.\n" );msleep_interruptible ( -jiffies_to_msecs (port->close_delay)); +jiffies_to_msecs (port->port.close_delay)); }spin_lock_irqsave (&card->card_lock, flags);wake_up_interruptible (&port->port.open_wait);
@@ -1256,8 +1254,8 @@ static int isicom_set_serial_info(struct isi_port *port, (newinfo.flags & ASYNC_SPD_MASK));if (!capable (CAP_SYS_ADMIN )) { -if ((newinfo.close_delay != port->close_delay) || - (newinfo.closing_wait != port->closing_wait) || +if ((newinfo.close_delay != port->port.close_delay) || + (newinfo.closing_wait != port->port.closing_wait) || ((newinfo.flags & ~ASYNC_USR_MASK ) != (port->port.flags & ~ASYNC_USR_MASK ))) {unlock_kernel ();
@@ -1266,8 +1264,8 @@ static int isicom_set_serial_info(struct isi_port *port, port->port.flags = ((port->port.flags & ~ASYNC_USR_MASK ) | (newinfo.flags &ASYNC_USR_MASK )); }else { - port->close_delay = newinfo.close_delay; - port->closing_wait = newinfo.closing_wait; + port->port.close_delay = newinfo.close_delay; + port->port.closing_wait = newinfo.closing_wait; port->port.flags = ((port->port.flags & ~ASYNC_FLAGS ) | (newinfo.flags &ASYNC_FLAGS )); }
@@ -1294,8 +1292,8 @@ static int isicom_get_serial_info(struct isi_port *port, out_info.irq = port->card->irq; out_info.flags = port->port.flags;/* out_info.baud_base = ? */ - out_info.close_delay = port->close_delay; - out_info.closing_wait = port->closing_wait; + out_info.close_delay = port->port.close_delay; + out_info.closing_wait = port->port.closing_wait;unlock_kernel ();if (copy_to_user (info, &out_info,sizeof (out_info)))return -EFAULT ;
@@ -1796,13 +1794,13 @@ static int __init isicom_init(void) isi_card[idx].ports = port;spin_lock_init (&isi_card[idx].card_lock);for (channel =0 ; channel <16 ; channel++, port++) { +tty_port_init (&port->port); port->magic =ISICOM_MAGIC ; port->card = &isi_card[idx]; port->channel = channel; - port->close_delay =50 *HZ /100 ; - port->closing_wait =3000 *HZ /100 ; + port->port.close_delay =50 *HZ /100 ; + port->port.closing_wait =3000 *HZ /100 ; port->status =0 ; -tty_port_init (&port->port);/* . . . */ } isi_card[idx].base =0 ;
drivers/char/moxa.c +3 -5
@@ -135,7 +135,6 @@ struct moxa_port {void __iomem *tableAddr;int type; -int close_delay;int cflag;unsigned long statusflags;
@@ -822,10 +821,9 @@ static int moxa_init_board(struct moxa_board_conf *brd, struct device *dev) }for (i =0 , p = brd->ports; i <MAX_PORTS_PER_BOARD ; i++, p++) { +tty_port_init (&p->port); p->type =PORT_16550A ; - p->close_delay =5 *HZ /10 ; p->cflag =B9600 |CS8 |CREAD |CLOCAL |HUPCL ; -tty_port_init (&p->port); }switch (brd->boardType) {
@@ -2124,7 +2122,7 @@ static int moxa_get_serial_info(struct moxa_port *info, .line = info->port.tty->index, .flags = info->port.flags, .baud_base = 921600, - .close_delay = info->close_delay + .close_delay = info->port.close_delay };return copy_to_user (retinfo, &tmp,sizeof (*retinfo)) ? -EFAULT :0 ; }
@@ -2148,7 +2146,7 @@ static int moxa_set_serial_info(struct moxa_port *info, (info->port.flags & ~ASYNC_USR_MASK)))return -EPERM ; }else - info->close_delay = new_serial.close_delay *HZ /100 ; + info->port.close_delay = new_serial.close_delay *HZ /100 ; new_serial.flags = (new_serial.flags & ~ASYNC_FLAGS ); new_serial.flags |= (info->port.flags &ASYNC_FLAGS );
drivers/char/mxser.c +12 -17
@@ -243,10 +243,7 @@ struct mxser_port {unsigned char ldisc_stop_rx;int custom_divisor; -int close_delay; -unsigned short closing_wait;unsigned char err_shadow; -unsigned long event;struct async_icount icount;/* kernel counters for 4 input interrupts */ int timeout;
@@ -1199,8 +1196,8 @@ static void mxser_close(struct tty_struct *tty, struct file *filp)* the line discipline to only process XON/XOFF characters. */ tty->closing =1 ; -if (info->closing_wait !=ASYNC_CLOSING_WAIT_NONE ) -tty_wait_until_sent (tty, info->closing_wait); +if (info->port.closing_wait !=ASYNC_CLOSING_WAIT_NONE ) +tty_wait_until_sent (tty, info->port.closing_wait);/* * At this point we stop accepting input. To do this, we * disable the receive line status interrupts, and tell the
@@ -1231,11 +1228,10 @@ static void mxser_close(struct tty_struct *tty, struct file *filp)tty_ldisc_flush (tty); tty->closing =0 ; - info->event =0 ; info->port.tty =NULL ;if (info->port.blocked_open) { -if (info->close_delay) -schedule_timeout_interruptible (info->close_delay); +if (info->port.close_delay) +schedule_timeout_interruptible (info->port.close_delay);wake_up_interruptible (&info->port.open_wait); }
@@ -1370,8 +1366,8 @@ static int mxser_get_serial_info(struct mxser_port *info, .irq = info->board->irq, .flags = info->port.flags, .baud_base = info->baud_base, - .close_delay = info->close_delay, - .closing_wait = info->closing_wait, + .close_delay = info->port.close_delay, + .closing_wait = info->port.closing_wait, .custom_divisor = info->custom_divisor, .hub6 = 0 };
@@ -1402,7 +1398,7 @@ static int mxser_set_serial_info(struct mxser_port *info,if (!capable (CAP_SYS_ADMIN )) {if ((new_serial.baud_base != info->baud_base) || - (new_serial.close_delay != info->close_delay) || + (new_serial.close_delay != info->port.close_delay) || ((new_serial.flags & ~ASYNC_USR_MASK ) != (info->port.flags & ~ASYNC_USR_MASK )))return -EPERM ; info->port.flags = ((info->port.flags & ~ASYNC_USR_MASK) |
@@ -1414,8 +1410,8 @@ static int mxser_set_serial_info(struct mxser_port *info,*/ info->port.flags = ((info->port.flags & ~ASYNC_FLAGS ) | (new_serial.flags &ASYNC_FLAGS )); - info->close_delay = new_serial.close_delay *HZ /100 ; - info->closing_wait = new_serial.closing_wait *HZ /100 ; + info->port.close_delay = new_serial.close_delay *HZ /100 ; + info->port.closing_wait = new_serial.closing_wait *HZ /100 ; info->port.tty->low_latency = (info->port.flags &ASYNC_LOW_LATENCY ) ?1 :0 ; info->port.tty->low_latency =0 ;
@@ -2214,7 +2210,6 @@ static void mxser_hangup(struct tty_struct *tty)mxser_flush_buffer (tty);mxser_shutdown (info); - info->event =0 ; info->port.count =0 ; info->port.flags &= ~ASYNC_NORMAL_ACTIVE ; info->port.tty =NULL ;
@@ -2545,6 +2540,7 @@ static int __devinit mxser_initbrd(struct mxser_board *brd,for (i =0 ; i < brd->info->nports; i++) { info = &brd->ports[i]; +tty_port_init (&info->port); info->board = brd; info->stop_rx =0 ; info->ldisc_stop_rx =0 ;
@@ -2559,10 +2555,9 @@ static int __devinit mxser_initbrd(struct mxser_board *brd,process_txrx_fifo (info); info->custom_divisor = info->baud_base *16 ; - info->close_delay =5 *HZ /10 ; - info->closing_wait =30 *HZ ; + info->port.close_delay =5 *HZ /10 ; + info->port.closing_wait =30 *HZ ; info->normal_termios = mxvar_sdriver->init_termios; -tty_port_init (&info->port);init_waitqueue_head (&info->delta_msr_wait);memset (&info->mon_data,0 ,sizeof (struct mxser_mon )); info->err_shadow =0 ;
drivers/char/riscom8.c +11 -13
@@ -1032,8 +1032,8 @@ static void rc_close(struct tty_struct *tty, struct file *filp)* the line discipline to only process XON/XOFF characters. */ tty->closing =1 ; -if (port->closing_wait !=ASYNC_CLOSING_WAIT_NONE ) -tty_wait_until_sent (tty, port->closing_wait); +if (port->port.closing_wait !=ASYNC_CLOSING_WAIT_NONE ) +tty_wait_until_sent (tty, port->port.closing_wait);/* * At this point we stop accepting input. To do this, we * disable the receive line status interrupts, and tell the
@@ -1065,8 +1065,8 @@ static void rc_close(struct tty_struct *tty, struct file *filp) tty->closing =0 ; port->port.tty =NULL ;if (port->port.blocked_open) { -if (port->close_delay) -msleep_interruptible (jiffies_to_msecs (port->close_delay)); +if (port->port.close_delay) +msleep_interruptible (jiffies_to_msecs (port->port.close_delay));wake_up_interruptible (&port->port.open_wait); } port->port.flags &= ~(ASYNC_NORMAL_ACTIVE |ASYNC_CLOSING );
@@ -1295,8 +1295,8 @@ static int rc_set_serial_info(struct riscom_port *port, (tmp.flags & ASYNC_SPD_MASK));if (!capable (CAP_SYS_ADMIN )) { -if ((tmp.close_delay != port->close_delay) || - (tmp.closing_wait != port->closing_wait) || +if ((tmp.close_delay != port->port.close_delay) || + (tmp.closing_wait != port->port.closing_wait) || ((tmp.flags & ~ASYNC_USR_MASK ) != (port->port.flags & ~ASYNC_USR_MASK )))return -EPERM ;
@@ -1305,8 +1305,8 @@ static int rc_set_serial_info(struct riscom_port *port, }else { port->port.flags = ((port->port.flags & ~ASYNC_FLAGS ) | (tmp.flags &ASYNC_FLAGS )); - port->close_delay = tmp.close_delay; - port->closing_wait = tmp.closing_wait; + port->port.close_delay = tmp.close_delay; + port->port.closing_wait = tmp.closing_wait; }if (change_speed) {unsigned long flags;
@@ -1331,8 +1331,8 @@ static int rc_get_serial_info(struct riscom_port *port, tmp.irq = bp->irq; tmp.flags = port->port.flags; tmp.baud_base = (RC_OSCFREQ +CD180_TPC /2 ) /CD180_TPC ; - tmp.close_delay = port->close_delay *HZ /100 ; - tmp.closing_wait = port->closing_wait *HZ /100 ; + tmp.close_delay = port->port.close_delay *HZ /100 ; + tmp.closing_wait = port->port.closing_wait *HZ /100 ; tmp.xmit_fifo_size =CD180_NFIFO ;return copy_to_user (retinfo, &tmp,sizeof (tmp)) ? -EFAULT :0 ; }
@@ -1549,10 +1549,8 @@ static int __init rc_init_drivers(void) }memset (rc_port,0 ,sizeof (rc_port));for (i =0 ; i <RC_NPORT *RC_NBOARD ; i++) { - rc_port[i].magic =RISCOM8_MAGIC ; - rc_port[i].close_delay =50 *HZ /100 ; - rc_port[i].closing_wait =3000 *HZ /100 ;tty_port_init (&rc_port[i].port); + rc_port[i].magic =RISCOM8_MAGIC ; }return 0 ; }
drivers/char/riscom8.h +0 -2
@@ -69,14 +69,12 @@ struct riscom_port {struct tty_port port;int baud_base;int timeout; -int close_delay;int custom_divisor;int xmit_head;int xmit_tail;int xmit_cnt;short wakeup_chars;short break_length; -unsigned short closing_wait;unsigned char mark_mask;unsigned char IER ;unsigned char MSVR ;
drivers/char/rocket.c +12 -11
@@ -72,6 +72,7 @@#include <linux/tty.h> #include <linux/tty_driver.h> #include <linux/tty_flip.h> +#include <linux/serial.h> #include <linux/string.h> #include <linux/fcntl.h> #include <linux/ptrace.h>
@@ -81,7 +82,7 @@#include <linux/completion.h> #include <linux/wait.h> #include <linux/pci.h> -#include <asm/uaccess.h> +#include <linux/uaccess.h> #include <asm/atomic.h> #include <asm/unaligned.h> #include <linux/bitops.h>
@@ -648,8 +649,8 @@ static void init_r_port(int board, int aiop, int chan, struct pci_dev *pci_dev) info->board = board; info->aiop = aiop; info->chan = chan; - info->closing_wait =3000 ; - info->close_delay =50 ; + info->port.closing_wait =3000 ; + info->port.close_delay =50 ;init_waitqueue_head (&info->port.open_wait);init_completion (&info->close_wait); info->flags &= ~ROCKET_MODE_MASK ;
@@ -1137,8 +1138,8 @@ static void rp_close(struct tty_struct *tty, struct file *filp)/* * Wait for the transmit buffer to clear */ -if (info->closing_wait !=ROCKET_CLOSING_WAIT_NONE ) -tty_wait_until_sent (tty, info->closing_wait); +if (info->port.closing_wait !=ROCKET_CLOSING_WAIT_NONE ) +tty_wait_until_sent (tty, info->port.closing_wait);/* * Before we drop DTR, make sure the UART transmitter * has completely drained; this is especially
@@ -1168,8 +1169,8 @@ static void rp_close(struct tty_struct *tty, struct file *filp)clear_bit ((info->aiop *8 ) + info->chan, (void *) &xmit_flags[info->board]);if (info->port.blocked_open) { -if (info->close_delay) { -msleep_interruptible (jiffies_to_msecs (info->close_delay)); +if (info->port.close_delay) { +msleep_interruptible (jiffies_to_msecs (info->port.close_delay)); }wake_up_interruptible (&info->port.open_wait); }else {
@@ -1327,8 +1328,8 @@ static int get_config(struct r_port *info, struct rocket_config __user *retinfo)memset (&tmp,0 ,sizeof (tmp)); tmp.line = info->line; tmp.flags = info->flags; - tmp.close_delay = info->close_delay; - tmp.closing_wait = info->closing_wait; + tmp.close_delay = info->port.close_delay; + tmp.closing_wait = info->port.closing_wait; tmp.port = rcktpt_io_addr[(info->line >>5 ) &3 ];if (copy_to_user (retinfo, &tmp,sizeof (*retinfo)))
@@ -1353,8 +1354,8 @@ static int set_config(struct r_port *info, struct rocket_config __user *new_info } info->flags = ((info->flags & ~ROCKET_FLAGS ) | (new_serial.flags &ROCKET_FLAGS )); - info->close_delay = new_serial.close_delay; - info->closing_wait = new_serial.closing_wait; + info->port.close_delay = new_serial.close_delay; + info->port.closing_wait = new_serial.closing_wait;if ((info->flags &ROCKET_SPD_MASK ) ==ROCKET_SPD_HI ) info->port.tty->alt_speed =57600 ;
drivers/char/rocket.h +2 -2
@@ -64,8 +64,8 @@ struct rocket_version {/* * For closing_wait and closing_wait2 */ -#define ROCKET_CLOSING_WAIT_NONE 65535 -#define ROCKET_CLOSING_WAIT_INF 0 +#define ROCKET_CLOSING_WAIT_NONE ASYNC_CLOSING_WAIT_NONE +#define ROCKET_CLOSING_WAIT_INF ASYNC_CLOSING_WAIT_INF/* * Rocketport ioctls -- "RP"
drivers/char/rocket_int.h +0 -2
@@ -1133,8 +1133,6 @@ struct r_port { unsigned int chan:3;CONTROLLER_t *ctlp;CHANNEL_t channel; -int closing_wait; -int close_delay;int intmask;int xmit_fifo_room;/* room in xmit fifo */ unsigned char *xmit_buf;
drivers/char/specialix.c +73 -80
410 lines not on this page · raw message
drivers/char/specialix_io8.h +1 -7
@@ -107,23 +107,17 @@ struct specialix_board {struct specialix_port {int magic; +struct tty_port port;int baud_base;int flags; -struct tty_struct * tty; -int count; -int blocked_open;int timeout; -int close_delay;unsigned char * xmit_buf;int custom_divisor;int xmit_head;int xmit_tail;int xmit_cnt; -wait_queue_head_t open_wait; -wait_queue_head_t close_wait;short wakeup_chars;short break_length; -unsigned short closing_wait;unsigned char mark_mask;unsigned char IER;unsigned char MSVR;
drivers/char/sx.c +1 -1
@@ -2395,6 +2395,7 @@ static int sx_init_portstructs(int nboards, int nports) board->ports = port;for (j =0 ; j < boards[i].nports; j++) {sx_dprintk (SX_DEBUG_INIT ,"initing port %d\n" , j); +tty_port_init (&port->gs.port); port->gs.magic =SX_MAGIC ; port->gs.close_delay =HZ /2 ; port->gs.closing_wait =30 *HZ ;
@@ -2407,7 +2408,6 @@ static int sx_init_portstructs(int nboards, int nports)/* * Initializing wait queue */ -tty_port_init (&port->gs.port); port++; } }
drivers/char/synclink.c +7 -9
@@ -183,8 +183,6 @@ struct mgsl_struct {struct tty_port port;int line;int hw_version; -unsigned short close_delay; -unsigned short closing_wait;/* time to wait before closing */ struct mgsl_icount icount;
@@ -3142,11 +3140,11 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)/* wait for transmit data to clear all layers */ -if (info->closing_wait !=ASYNC_CLOSING_WAIT_NONE ) { +if (info->port.closing_wait !=ASYNC_CLOSING_WAIT_NONE ) {if (debug_level >=DEBUG_LEVEL_INFO )printk ("%s(%d):mgsl_close(%s) calling tty_wait_until_sent\n" , __FILE__,__LINE__, info->device_name ); -tty_wait_until_sent (tty, info->closing_wait); +tty_wait_until_sent (tty, info->port.closing_wait); }if (info->port.flags &ASYNC_INITIALIZED )
@@ -3162,8 +3160,8 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp) info->port.tty =NULL ;if (info->port.blocked_open) { -if (info->close_delay) { -msleep_interruptible (jiffies_to_msecs (info->close_delay)); +if (info->port.close_delay) { +msleep_interruptible (jiffies_to_msecs (info->port.close_delay)); }wake_up_interruptible (&info->port.open_wait); }
@@ -4326,12 +4324,12 @@ static struct mgsl_struct* mgsl_allocate_device(void)if (!info) {printk ("Error can't allocate device instance data\n" ); }else { +tty_port_init (&info->port); info->magic =MGSL_MAGIC ;INIT_WORK (&info->task, mgsl_bh_handler); info->max_frame_size =4096 ; - info->close_delay =5 *HZ /10 ; - info->closing_wait =30 *HZ ; -tty_port_init (&info->port); + info->port.close_delay =5 *HZ /10 ; + info->port.closing_wait =30 *HZ ;init_waitqueue_head (&info->status_event_wait_q);init_waitqueue_head (&info->event_wait_q);spin_lock_init (&info->irq_spinlock);
drivers/char/synclink_gt.c +7 -9
@@ -261,8 +261,6 @@ struct slgt_info {struct slgt_info *port_array[SLGT_MAX_PORTS ];int line;/* tty line instance number */ -unsigned short close_delay; -unsigned short closing_wait;/* time to wait before closing */ struct mgsl_icount icount;
@@ -758,9 +756,9 @@ static void close(struct tty_struct *tty, struct file *filp)/* wait for transmit data to clear all layers */ -if (info->closing_wait !=ASYNC_CLOSING_WAIT_NONE ) { +if (info->port.closing_wait !=ASYNC_CLOSING_WAIT_NONE ) {DBGINFO (("%s call tty_wait_until_sent\n" , info->device_name)); -tty_wait_until_sent (tty, info->closing_wait); +tty_wait_until_sent (tty, info->port.closing_wait); }if (info->port.flags &ASYNC_INITIALIZED )
@@ -774,8 +772,8 @@ static void close(struct tty_struct *tty, struct file *filp) info->port.tty =NULL ;if (info->port.blocked_open) { -if (info->close_delay) { -msleep_interruptible (jiffies_to_msecs (info->close_delay)); +if (info->port.close_delay) { +msleep_interruptible (jiffies_to_msecs (info->port.close_delay)); }wake_up_interruptible (&info->port.open_wait); }
@@ -3448,13 +3446,13 @@ static struct slgt_info *alloc_dev(int adapter_num, int port_num, struct pci_devDBGERR (("%s device alloc failed adapter=%d port=%d\n" , driver_name, adapter_num, port_num)); }else { +tty_port_init (&info->port); info->magic =MGSL_MAGIC ;INIT_WORK (&info->task, bh_handler); info->max_frame_size =4096 ; info->raw_rx_size =DMABUFSIZE ; - info->close_delay =5 *HZ /10 ; - info->closing_wait =30 *HZ ; -tty_port_init (&info->port); + info->port.close_delay =5 *HZ /10 ; + info->port.closing_wait =30 *HZ ;init_waitqueue_head (&info->status_event_wait_q);init_waitqueue_head (&info->event_wait_q);spin_lock_init (&info->netlock);
drivers/char/synclinkmp.c +7 -7
@@ -846,11 +846,11 @@ static void close(struct tty_struct *tty, struct file *filp)/* wait for transmit data to clear all layers */ -if (info->closing_wait !=ASYNC_CLOSING_WAIT_NONE ) { +if (info->port.closing_wait !=ASYNC_CLOSING_WAIT_NONE ) {if (debug_level >=DEBUG_LEVEL_INFO )printk ("%s(%d):%s close() calling tty_wait_until_sent\n" , __FILE__,__LINE__, info->device_name ); -tty_wait_until_sent (tty, info->closing_wait); +tty_wait_until_sent (tty, info->port.closing_wait); }if (info->port.flags &ASYNC_INITIALIZED )
@@ -866,8 +866,8 @@ static void close(struct tty_struct *tty, struct file *filp) info->port.tty =NULL ;if (info->port.blocked_open) { -if (info->close_delay) { -msleep_interruptible (jiffies_to_msecs (info->close_delay)); +if (info->port.close_delay) { +msleep_interruptible (jiffies_to_msecs (info->port.close_delay)); }wake_up_interruptible (&info->port.open_wait); }
@@ -3802,12 +3802,12 @@ static SLMP_INFO *alloc_dev(int adapter_num, int port_num, struct pci_dev *pdev)printk ("%s(%d) Error can't allocate device instance data for adapter %d, port %d\n" , __FILE__,__LINE__, adapter_num, port_num); }else { +tty_port_init (&info->port); info->magic =MGSL_MAGIC ;INIT_WORK (&info->task, bh_handler); info->max_frame_size =4096 ; - info->close_delay =5 *HZ /10 ; - info->closing_wait =30 *HZ ; -tty_port_init (&info->port); + info->port.close_delay =5 *HZ /10 ; + info->port.closing_wait =30 *HZ ;init_waitqueue_head (&info->status_event_wait_q);init_waitqueue_head (&info->event_wait_q);spin_lock_init (&info->netlock);
drivers/char/tty_io.c +2 -0
@@ -2094,6 +2094,8 @@ void tty_port_init(struct tty_port *port)init_waitqueue_head (&port->open_wait);init_waitqueue_head (&port->close_wait);mutex_init (&port->mutex); + port->close_delay = (50 *HZ ) /100 ; + port->closing_wait = (3000 *HZ ) /100 ; }EXPORT_SYMBOL (tty_port_init);
include/linux/cyclades.h +2 -4
@@ -567,8 +567,6 @@ struct cyclades_port {int chip_rev;int custom_divisor;u8 x_char;/* to be pushed out ASAP */ -int close_delay; -unsigned short closing_wait;int breakon;int breakoff;int xmit_head;
@@ -586,8 +584,8 @@ struct cyclades_port { };#define CLOSING_WAIT_DELAY 30*HZ -#define CY_CLOSING_WAIT_NONE 65535 -#define CY_CLOSING_WAIT_INF 0 +#define CY_CLOSING_WAIT_NONE ASYNC_CLOSING_WAIT_NONE +#define CY_CLOSING_WAIT_INF ASYNC_CLOSING_WAIT_INF#define CyMAX_CHIPS_PER_CARD 8
include/linux/tty.h +2 -0
@@ -188,6 +188,8 @@ struct tty_port {unsigned long flags;/* TTY flags ASY_*/ struct mutex mutex;/* Locking */ unsigned char *xmit_buf;/* Optional buffer */ +int close_delay;/* Close port delay */ +int closing_wait;/* Delay for output */ };/*
PATCH 24/70 whiteheat: coding style
In reply to Alan CoxFrom: Alan Cox <[email protected]>
Bring ezusb and whiteheat into line with the coding style
---
drivers/usb/serial/ezusb.c | 22 +- drivers/usb/serial/whiteheat.c | 429 ++++++++++++++++++++++------------------ drivers/usb/serial/whiteheat.h | 78 +++++-- 3 files changed, 302 insertions(+), 227 deletions(-)
drivers/usb/serial/ezusb.c +12 -10
@@ -20,7 +20,8 @@/* EZ-USB Control and Status Register. Bit 0 controls 8051 reset */ #define CPUCS_REG 0x7F92 -int ezusb_writememory (struct usb_serial *serial,int address,unsigned char *data,int length,__u8 bRequest) +int ezusb_writememory (struct usb_serial *serial,int address, +unsigned char *data,int length,__u8 request) {int result;unsigned char *transfer_buffer;
@@ -33,26 +34,27 @@ int ezusb_writememory (struct usb_serial *serial, int address, unsigned char *da transfer_buffer =kmemdup (data, length,GFP_KERNEL );if (!transfer_buffer) { -dev_err (&serial->dev->dev,"%s - kmalloc(%d) failed.\n" , __func__, length); +dev_err (&serial->dev->dev,"%s - kmalloc(%d) failed.\n" , + __func__, length);return -ENOMEM ; } - result =usb_control_msg (serial->dev,usb_sndctrlpipe (serial->dev,0 ), bRequest,0x40 , address,0 , transfer_buffer, length,3000 ); -kfree (transfer_buffer); + result =usb_control_msg (serial->dev,usb_sndctrlpipe (serial->dev,0 ), + request,0x40 , address,0 , transfer_buffer, length,3000 ); +kfree (transfer_buffer);return result; } +EXPORT_SYMBOL_GPL (ezusb_writememory); -int ezusb_set_reset (struct usb_serial *serial,unsigned char reset_bit) +int ezusb_set_reset (struct usb_serial *serial,unsigned char reset_bit) {int response;/* dbg("%s - %d", __func__, reset_bit); */ - response =ezusb_writememory (serial,CPUCS_REG , &reset_bit,1 ,0xa0 ); + response =ezusb_writememory (serial,CPUCS_REG , &reset_bit,1 ,0xa0 );if (response <0 ) -dev_err (&serial->dev->dev,"%s- %d failed\n" , __func__, reset_bit); +dev_err (&serial->dev->dev,"%s- %d failed\n" , + __func__, reset_bit);return response; } - - -EXPORT_SYMBOL_GPL (ezusb_writememory);EXPORT_SYMBOL_GPL (ezusb_set_reset);
drivers/usb/serial/whiteheat.c +239 -190
905 lines not on this page · raw message
drivers/usb/serial/whiteheat.h +51 -27
143 lines not on this page · raw message
PATCH 25/70 whiteheat: fix bugs found in the tidy and audit
In reply to Alan CoxFrom: Alan Cox <[email protected]>
Termios tidy up, plus fix break and DTR.
---
drivers/usb/serial/whiteheat.c | 12 ++++-------- 1 files changed, 4 insertions(+), 8 deletions(-)
drivers/usb/serial/whiteheat.c +4 -8
@@ -652,11 +652,8 @@ static int whiteheat_open(struct tty_struct *tty, goto exit; } -if (tty) { - old_term.c_cflag = ~tty->termios->c_cflag; - old_term.c_iflag = ~tty->termios->c_iflag; -whiteheat_set_termios (tty, port, &old_term); - } +if (tty) +firm_setup_port (tty);/* Work around HCD bugs */ usb_clear_halt (port->serial->dev, port->read_urb->pipe);
@@ -907,7 +904,6 @@ static int whiteheat_ioctl(struct tty_struct *tty, struct file *file,static void whiteheat_set_termios (struct tty_struct *tty,struct usb_serial_port *port,struct ktermios *old_termios) { -/* FIXME */ firm_setup_port (tty); }
@@ -1303,7 +1299,7 @@ static int firm_set_dtr(struct usb_serial_port *port, __u8 onoff) dtr_command.port = port->number - port->serial->minor +1 ; dtr_command.state = onoff; -return firm_send_command (port,WHITEHEAT_SET_RTS , +return firm_send_command (port,WHITEHEAT_SET_DTR , (__u8 *)&dtr_command,sizeof (dtr_command)); }
@@ -1314,7 +1310,7 @@ static int firm_set_break(struct usb_serial_port *port, __u8 onoff) break_command.port = port->number - port->serial->minor +1 ; break_command.state = onoff; -return firm_send_command (port,WHITEHEAT_SET_RTS , +return firm_send_command (port,WHITEHEAT_SET_BREAK , (__u8 *)&break_command,sizeof (break_command)); }
PATCH 26/70 belkin_sa: clean up code
In reply to Alan CoxFrom: Alan Cox <[email protected]>
Coding style tidy up for belkin_sa
---
drivers/usb/serial/belkin_sa.c | 148 +++++++++++++++++++++++----------------- drivers/usb/serial/belkin_sa.h | 15 ++-- 2 files changed, 94 insertions(+), 69 deletions(-)
drivers/usb/serial/belkin_sa.c +86 -62
@@ -7,13 +7,14 @@* This program is largely derived from work by the linux-usb group * and associated source files. Please see the usb/serial files for * individual credits and copyrights. -* +* * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * -* See Documentation/usb/usb-serial.txt for more information on using this driver +* See Documentation/usb/usb-serial.txt for more information on using this +* driver * * TODO: * -- Add true modem contol line query capability. Currently we track the
@@ -28,7 +29,8 @@* compressed all the differnent device entries into 1. * * 30-May-2001 gkh -* switched from using spinlock to a semaphore, which fixes lots of problems. +* switched from using spinlock to a semaphore, which fixes lots of +* problems. * * 08-Apr-2001 gb * - Identify version on module load.
@@ -41,7 +43,7 @@* - Added support for the old Belkin and Peracom devices. * - Made the port able to be opened multiple times. * - Added some defaults incase the line settings are things these devices -* can't support. +* can't support. * * 18-Oct-2000 William Greathouse * Released into the wild (linux-usb-devel)
@@ -72,7 +74,7 @@#include <linux/tty_flip.h> #include <linux/module.h> #include <linux/spinlock.h> -#include <asm/uaccess.h> +#include <linux/uaccess.h> #include <linux/usb.h> #include <linux/usb/serial.h> #include "belkin_sa.h"
@@ -87,15 +89,19 @@ static int debug;#define DRIVER_DESC "USB Belkin Serial converter driver"/* function prototypes for a Belkin USB Serial Adapter F5U103 */ -static int belkin_sa_startup (struct usb_serial *serial); -static void belkin_sa_shutdown (struct usb_serial *serial); -static int belkin_sa_open (struct tty_struct *tty,struct usb_serial_port *port,struct file *filp); -static void belkin_sa_close (struct tty_struct *tty,struct usb_serial_port *port,struct file *filp); -static void belkin_sa_read_int_callback (struct urb *urb); -static void belkin_sa_set_termios (struct tty_struct *tty,struct usb_serial_port *port,struct ktermios * old); -static void belkin_sa_break_ctl (struct tty_struct *tty,int break_state ); -static int belkin_sa_tiocmget (struct tty_struct *tty,struct file *file); -static int belkin_sa_tiocmset (struct tty_struct *tty,struct file *file,unsigned int set,unsigned int clear); +static int belkin_sa_startup (struct usb_serial *serial); +static void belkin_sa_shutdown (struct usb_serial *serial); +static int belkin_sa_open (struct tty_struct *tty, +struct usb_serial_port *port,struct file *filp); +static void belkin_sa_close (struct tty_struct *tty, +struct usb_serial_port *port,struct file *filp); +static void belkin_sa_read_int_callback (struct urb *urb); +static void belkin_sa_set_termios (struct tty_struct *tty, +struct usb_serial_port *port,struct ktermios * old); +static void belkin_sa_break_ctl (struct tty_struct *tty,int break_state); +static int belkin_sa_tiocmget (struct tty_struct *tty,struct file *file); +static int belkin_sa_tiocmset (struct tty_struct *tty,struct file *file, +unsigned int set,unsigned int clear);static struct usb_device_id id_table_combined [] = {
@@ -105,10 +111,10 @@ static struct usb_device_id id_table_combined [] = { { USB_DEVICE(GOHUBS_VID, GOHUBS_PID) }, { USB_DEVICE(GOHUBS_VID, HANDYLINK_PID) }, { USB_DEVICE(BELKIN_DOCKSTATION_VID, BELKIN_DOCKSTATION_PID) }, - { } /* Terminating entry */ + { } /* Terminating entry */ }; -MODULE_DEVICE_TABLE (usb, id_table_combined); +MODULE_DEVICE_TABLE (usb, id_table_combined);static struct usb_driver belkin_driver = { .name = "belkin",
@@ -130,7 +136,8 @@ static struct usb_serial_driver belkin_device = { .num_ports = 1, .open = belkin_sa_open, .close = belkin_sa_close, - .read_int_callback = belkin_sa_read_int_callback, /* How we get the status info */ + .read_int_callback = belkin_sa_read_int_callback, +/* How we get the status info */ .set_termios = belkin_sa_set_termios, .break_ctl = belkin_sa_break_ctl, .tiocmget = belkin_sa_tiocmget,
@@ -158,12 +165,12 @@ struct belkin_sa_private {#define WDR_TIMEOUT 5000/* default urb timeout */ /* assumes that struct usb_serial *serial is available */ -#define BSA_USB_CMD (c,v) usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), \ +#define BSA_USB_CMD (c, v) usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), \ (c), BELKIN_SA_SET_REQUEST_TYPE, \ (v), 0, NULL, 0, WDR_TIMEOUT)/* do some startup allocations not currently performed by usb_serial_probe() */ -static int belkin_sa_startup (struct usb_serial *serial) +static int belkin_sa_startup (struct usb_serial *serial) {struct usb_device *dev = serial->dev;struct belkin_sa_private *priv;
@@ -171,20 +178,23 @@ static int belkin_sa_startup (struct usb_serial *serial)/* allocate the private data structure */ priv =kmalloc (sizeof (struct belkin_sa_private ),GFP_KERNEL );if (!priv) -return (-1 );/* error */ +return -1 ;/* error */ /* set initial values for control structures */ spin_lock_init (&priv->lock); priv->control_state =0 ; priv->last_lsr =0 ; priv->last_msr =0 ;/* see comments at top of file */ - priv->bad_flow_control = (le16_to_cpu (dev->descriptor.bcdDevice) <=0x0206 ) ?1 :0 ; -info ("bcdDevice: %04x, bfc: %d" ,le16_to_cpu (dev->descriptor.bcdDevice), priv->bad_flow_control); + priv->bad_flow_control = + (le16_to_cpu (dev->descriptor.bcdDevice) <=0x0206 ) ?1 :0 ; +info ("bcdDevice: %04x, bfc: %d" , +le16_to_cpu (dev->descriptor.bcdDevice), + priv->bad_flow_control);init_waitqueue_head (&serial->port[0 ]->write_wait);usb_set_serial_port_data (serial->port[0 ], priv); - -return (0 ); + +return 0 ; }
@@ -192,11 +202,11 @@ static void belkin_sa_shutdown(struct usb_serial *serial) {struct belkin_sa_private *priv;int i; - -dbg ("%s" , __func__); + +dbg ("%s" , __func__);/* stop reads and writes on all ports */ -for (i=0 ; i < serial->num_ports; ++i) { +for (i =0 ; i < serial->num_ports; ++i) {/* My special items, the standard routines free my urbs */ priv =usb_get_serial_port_data (serial->port[i]);kfree (priv);
@@ -204,7 +214,8 @@ static void belkin_sa_shutdown(struct usb_serial *serial) } -static int belkin_sa_open (struct tty_struct *tty,struct usb_serial_port *port,struct file *filp) +static int belkin_sa_open (struct tty_struct *tty, +struct usb_serial_port *port,struct file *filp) {int retval =0 ;
@@ -233,7 +244,7 @@ exit: }/* belkin_sa_open */ -static void belkin_sa_close (struct tty_struct *tty, +static void belkin_sa_close (struct tty_struct *tty,struct usb_serial_port *port,struct file *filp) {dbg ("%s port %d" , __func__, port->number);
@@ -271,7 +282,8 @@ static void belkin_sa_read_int_callback(struct urb *urb) goto exit; } -usb_serial_debug_data (debug, &port->dev, __func__, urb->actual_length, data); +usb_serial_debug_data (debug, &port->dev, __func__, + urb->actual_length, data);/* Handle known interrupt data */ /* ignore data[0] and data[1] */
@@ -279,7 +291,7 @@ static void belkin_sa_read_int_callback(struct urb *urb) priv =usb_get_serial_port_data (port);spin_lock_irqsave (&priv->lock, flags); priv->last_msr = data[BELKIN_SA_MSR_INDEX ]; - +/* Record Control Line states */ if (priv->last_msr &BELKIN_SA_MSR_DSR ) priv->control_state |=TIOCM_DSR ;
@@ -327,9 +339,9 @@ static void belkin_sa_read_int_callback(struct urb *urb)#endif spin_unlock_irqrestore (&priv->lock, flags); exit: - retval =usb_submit_urb (urb,GFP_ATOMIC ); + retval =usb_submit_urb (urb,GFP_ATOMIC );if (retval) -err ("%s - usb_submit_urb failed with result %d" , +err ("%s - usb_submit_urb failed with result %d" , __func__, retval); }
@@ -348,7 +360,7 @@ static void belkin_sa_set_termios(struct tty_struct *tty,int bad_flow_control;speed_t baud;struct ktermios *termios = tty->termios; - + iflag = termios->c_iflag; cflag = termios->c_cflag;
@@ -359,20 +371,21 @@ static void belkin_sa_set_termios(struct tty_struct *tty, control_state = priv->control_state; bad_flow_control = priv->bad_flow_control;spin_unlock_irqrestore (&priv->lock, flags); - + old_iflag = old_termios->c_iflag; old_cflag = old_termios->c_cflag;/* Set the baud rate */ if ((cflag &CBAUD ) != (old_cflag &CBAUD )) {/* reassert DTR and (maybe) RTS on transition from B0 */ -if ( (old_cflag&CBAUD ) ==B0 ) { +if ((old_cflag &CBAUD ) ==B0 ) { control_state |= (TIOCM_DTR |TIOCM_RTS );if (BSA_USB_CMD (BELKIN_SA_SET_DTR_REQUEST ,1 ) <0 )err ("Set DTR error" );/* don't set RTS if using hardware flow control */ if (!(old_cflag &CRTSCTS )) -if (BSA_USB_CMD (BELKIN_SA_SET_RTS_REQUEST ,1 ) <0 ) +if (BSA_USB_CMD (BELKIN_SA_SET_RTS_REQUEST + ,1 ) <0 )err ("Set RTS error" ); } }
@@ -392,7 +405,8 @@ static void belkin_sa_set_termios(struct tty_struct *tty,err ("Set baudrate error" ); }else {/* Disable flow control */ -if (BSA_USB_CMD (BELKIN_SA_SET_FLOW_CTRL_REQUEST ,BELKIN_SA_FLOW_NONE ) <0 ) +if (BSA_USB_CMD (BELKIN_SA_SET_FLOW_CTRL_REQUEST , +BELKIN_SA_FLOW_NONE ) <0 )err ("Disable flowcontrol error" );/* Drop RTS and DTR */ control_state &= ~(TIOCM_DTR |TIOCM_RTS );
@@ -403,9 +417,10 @@ static void belkin_sa_set_termios(struct tty_struct *tty, }/* set the parity */ -if ( (cflag&(PARENB |PARODD )) != (old_cflag&(PARENB |PARODD )) ) { +if ((cflag ^ old_cflag) & (PARENB |PARODD )) {if (cflag &PARENB ) - urb_value = (cflag &PARODD ) ?BELKIN_SA_PARITY_ODD :BELKIN_SA_PARITY_EVEN ; + urb_value = (cflag &PARODD ) ?BELKIN_SA_PARITY_ODD + :BELKIN_SA_PARITY_EVEN ;else urb_value =BELKIN_SA_PARITY_NONE ;if (BSA_USB_CMD (BELKIN_SA_SET_PARITY_REQUEST , urb_value) <0 )
@@ -413,31 +428,40 @@ static void belkin_sa_set_termios(struct tty_struct *tty, }/* set the number of data bits */ -if ( (cflag&CSIZE ) != (old_cflag&CSIZE ) ) { +if ((cflag &CSIZE ) != (old_cflag &CSIZE )) {switch (cflag &CSIZE ) { -case CS5 : urb_value =BELKIN_SA_DATA_BITS (5 );break ; -case CS6 : urb_value =BELKIN_SA_DATA_BITS (6 );break ; -case CS7 : urb_value =BELKIN_SA_DATA_BITS (7 );break ; -case CS8 : urb_value =BELKIN_SA_DATA_BITS (8 );break ; -default :dbg ("CSIZE was not CS5-CS8, using default of 8" ); - urb_value =BELKIN_SA_DATA_BITS (8 ); -break ; +case CS5 : + urb_value =BELKIN_SA_DATA_BITS (5 ); +break ; +case CS6 : + urb_value =BELKIN_SA_DATA_BITS (6 ); +break ; +case CS7 : + urb_value =BELKIN_SA_DATA_BITS (7 ); +break ; +case CS8 : + urb_value =BELKIN_SA_DATA_BITS (8 ); +break ; +default :dbg ("CSIZE was not CS5-CS8, using default of 8" ); + urb_value =BELKIN_SA_DATA_BITS (8 ); +break ; }if (BSA_USB_CMD (BELKIN_SA_SET_DATA_BITS_REQUEST , urb_value) <0 )err ("Set data bits error" ); }/* set the number of stop bits */ -if ( (cflag&CSTOPB ) != (old_cflag&CSTOPB ) ) { - urb_value = (cflag &CSTOPB ) ?BELKIN_SA_STOP_BITS (2 ) :BELKIN_SA_STOP_BITS (1 ); -if (BSA_USB_CMD (BELKIN_SA_SET_STOP_BITS_REQUEST , urb_value) <0 ) +if ((cflag &CSTOPB ) != (old_cflag &CSTOPB )) { + urb_value = (cflag &CSTOPB ) ?BELKIN_SA_STOP_BITS (2 ) + :BELKIN_SA_STOP_BITS (1 ); +if (BSA_USB_CMD (BELKIN_SA_SET_STOP_BITS_REQUEST , + urb_value) <0 )err ("Set stop bits error" ); }/* Set flow control */ -if ( (iflag&IXOFF ) != (old_iflag&IXOFF ) - || (iflag&IXON ) != (old_iflag&IXON ) - || (cflag&CRTSCTS ) != (old_cflag&CRTSCTS ) ) { +if (((iflag ^ old_iflag) & (IXOFF |IXON )) || + ((cflag ^ old_cflag) &CRTSCTS )) { urb_value =0 ;if ((iflag &IXOFF ) || (iflag &IXON )) urb_value |= (BELKIN_SA_FLOW_OXON |BELKIN_SA_FLOW_IXON );
@@ -479,7 +503,7 @@ static int belkin_sa_tiocmget(struct tty_struct *tty, struct file *file)struct belkin_sa_private *priv =usb_get_serial_port_data (port);unsigned long control_state;unsigned long flags; - +dbg ("%s" , __func__);spin_lock_irqsave (&priv->lock, flags);
@@ -501,7 +525,7 @@ static int belkin_sa_tiocmset(struct tty_struct *tty, struct file *file,int retval;int rts =0 ;int dtr =0 ; - +dbg ("%s" , __func__);spin_lock_irqsave (&priv->lock, flags);
@@ -563,17 +587,17 @@ failed_usb_serial_register: static void __exit belkin_sa_exit (void) { -usb_deregister (&belkin_driver); +usb_deregister (&belkin_driver);usb_serial_deregister (&belkin_device); } -module_init (belkin_sa_init); -module_exit (belkin_sa_exit); +module_init (belkin_sa_init); +module_exit (belkin_sa_exit); -MODULE_AUTHOR (DRIVER_AUTHOR ); -MODULE_DESCRIPTION (DRIVER_DESC ); -MODULE_VERSION (DRIVER_VERSION ); +MODULE_AUTHOR (DRIVER_AUTHOR ); +MODULE_DESCRIPTION (DRIVER_DESC ); +MODULE_VERSION (DRIVER_VERSION );MODULE_LICENSE ("GPL" );module_param (debug, bool,S_IRUGO |S_IWUSR );
drivers/usb/serial/belkin_sa.h +8 -7
@@ -7,13 +7,14 @@* This program is largely derived from work by the linux-usb group * and associated source files. Please see the usb/serial files for * individual credits and copyrights. -* +* * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * -* See Documentation/usb/usb-serial.txt for more information on using this driver +* See Documentation/usb/usb-serial.txt for more information on using this +* driver * * 12-Mar-2001 gkh * Added GoHubs GO-COM232 device id.
@@ -27,7 +28,7 @@* adapter, so pardon any stupid mistakes. All of the information * I am using to write this driver was acquired by using a modified * UsbSnoop on Windows2000. -* +* */ #ifndef __LINUX_USB_SERIAL_BSA_H
@@ -96,20 +97,20 @@/* * It seems that the interrupt pipe is closely modelled after the -* 16550 register layout. This is probably because the adapter can +* 16550 register layout. This is probably because the adapter can * be used in a "DOS" environment to simulate a standard hardware port. */ -#define BELKIN_SA_LSR_INDEX 2/* Line Status Register */ +#define BELKIN_SA_LSR_INDEX 2/* Line Status Register */ #define BELKIN_SA_LSR_RDR 0x01/* receive data ready */ #define BELKIN_SA_LSR_OE 0x02/* overrun error */ #define BELKIN_SA_LSR_PE 0x04/* parity error */ #define BELKIN_SA_LSR_FE 0x08/* framing error */ #define BELKIN_SA_LSR_BI 0x10/* break indicator */ -#define BELKIN_SA_LSR_THE 0x20/* transmit holding register empty */ +#define BELKIN_SA_LSR_THE 0x20/* tx holding register empty */ #define BELKIN_SA_LSR_TE 0x40/* transmit register empty */ #define BELKIN_SA_LSR_ERR 0x80/* OE | PE | FE | BI */ -#define BELKIN_SA_MSR_INDEX 3/* Modem Status Register */ +#define BELKIN_SA_MSR_INDEX 3/* Modem Status Register */ #define BELKIN_SA_MSR_DCTS 0x01/* Delta CTS */ #define BELKIN_SA_MSR_DDSR 0x02/* Delta DSR */ #define BELKIN_SA_MSR_DRI 0x04/* Delta RI */
PATCH 27/70 usb-serial-bus: tidy coding style
In reply to Alan CoxFrom: Alan Cox <[email protected]>
Tidy up
---
drivers/usb/serial/bus.c | 20 ++++++++++---------- 1 files changed, 10 insertions(+), 10 deletions(-)
drivers/usb/serial/bus.c +10 -10
@@ -15,7 +15,8 @@#include <linux/usb.h> #include <linux/usb/serial.h> -static int usb_serial_device_match (struct device *dev,struct device_driver *drv) +static int usb_serial_device_match (struct device *dev, +struct device_driver *drv) {struct usb_serial_driver *driver;const struct usb_serial_port *port;
@@ -46,7 +47,7 @@ static ssize_t show_port_number(struct device *dev, static DEVICE_ATTR(port_number, S_IRUGO, show_port_number, NULL); -static int usb_serial_device_probe (struct device *dev) +static int usb_serial_device_probe (struct device *dev) {struct usb_serial_driver *driver;struct usb_serial_port *port;
@@ -66,7 +67,7 @@ static int usb_serial_device_probe (struct device *dev) retval = -EIO ; goto exit; } - retval = driver->port_probe (port); + retval = driver->port_probe (port);module_put (driver->driver.owner);if (retval) goto exit;
@@ -77,8 +78,8 @@ static int usb_serial_device_probe (struct device *dev) goto exit; minor = port->number; -tty_register_device (usb_serial_tty_driver, minor, dev); -dev_info (&port->serial->dev->dev, +tty_register_device (usb_serial_tty_driver, minor, dev); +dev_info (&port->serial->dev->dev,"%s converter now attached to ttyUSB%d\n" , driver->description, minor);
@@ -86,7 +87,7 @@ exit:return retval; } -static int usb_serial_device_remove (struct device *dev) +static int usb_serial_device_remove (struct device *dev) {struct usb_serial_driver *driver;struct usb_serial_port *port;
@@ -94,9 +95,8 @@ static int usb_serial_device_remove (struct device *dev)int minor; port =to_usb_serial_port (dev); -if (!port) { +if (!port)return -ENODEV ; - }device_remove_file (&port->dev, &dev_attr_port_number);
@@ -107,12 +107,12 @@ static int usb_serial_device_remove (struct device *dev) retval = -EIO ; goto exit; } - retval = driver->port_remove (port); + retval = driver->port_remove (port);module_put (driver->driver.owner); } exit: minor = port->number; -tty_unregister_device (usb_serial_tty_driver, minor); +tty_unregister_device (usb_serial_tty_driver, minor);dev_info (dev,"%s converter now disconnected from ttyUSB%d\n" , driver->description, minor);
PATCH 28/70 tty-usb-console: tidy the USB console code
In reply to Alan CoxFrom: Alan Cox <[email protected]>
Code tidy
---
drivers/usb/serial/console.c | 127 ++++++++++++++++++++++-------------------- 1 files changed, 66 insertions(+), 61 deletions(-)
drivers/usb/serial/console.c +66 -61
@@ -6,7 +6,7 @@* This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License version * 2 as published by the Free Software Foundation. -* +* * Thanks to Randy Dunlap for the original version of this code. * */
@@ -67,7 +67,7 @@ static int usb_console_setup(struct console *co, char *options)struct tty_struct *tty =NULL ;struct ktermios *termios =NULL , dummy; -dbg ("%s" , __func__); +dbg ("%s" , __func__);if (options) { baud =simple_strtoul (options,NULL ,10 );
@@ -84,52 +84,52 @@ static int usb_console_setup(struct console *co, char *options)/* build a cflag setting */ switch (baud) { -case 1200 : - cflag |=B1200 ; -break ; -case 2400 : - cflag |=B2400 ; -break ; -case 4800 : - cflag |=B4800 ; -break ; -case 19200 : - cflag |=B19200 ; -break ; -case 38400 : - cflag |=B38400 ; -break ; -case 57600 : - cflag |=B57600 ; -break ; -case 115200 : - cflag |=B115200 ; -break ; -case 9600 : -default : - cflag |=B9600 ; -/* -* Set this to a sane value to prevent a divide error -*/ - baud =9600 ; -break ; +case 1200 : + cflag |=B1200 ; +break ; +case 2400 : + cflag |=B2400 ; +break ; +case 4800 : + cflag |=B4800 ; +break ; +case 19200 : + cflag |=B19200 ; +break ; +case 38400 : + cflag |=B38400 ; +break ; +case 57600 : + cflag |=B57600 ; +break ; +case 115200 : + cflag |=B115200 ; +break ; +case 9600 : +default : + cflag |=B9600 ; +/* +* Set this to a sane value to prevent a divide error +*/ + baud =9600 ; +break ; }switch (bits) { -case 7 : - cflag |=CS7 ; -break ; -default : -case 8 : - cflag |=CS8 ; -break ; +case 7 : + cflag |=CS7 ; +break ; +default : +case 8 : + cflag |=CS8 ; +break ; }switch (parity) { -case 'o' :case 'O' : - cflag |=PARODD ; -break ; -case 'e' :case 'E' : - cflag |=PARENB ; -break ; +case 'o' :case 'O' : + cflag |=PARODD ; +break ; +case 'e' :case 'E' : + cflag |=PARENB ; +break ; } co->cflag = cflag;
@@ -140,7 +140,7 @@ static int usb_console_setup(struct console *co, char *options) serial =usb_serial_get_by_index (co->index);if (serial ==NULL ) {/* no device is connected yet, sorry :( */ -err ("No USB device connected to ttyUSB%i" , co->index); +err ("No USB device connected to ttyUSB%i" , co->index);return -ENODEV ; }
@@ -148,7 +148,7 @@ static int usb_console_setup(struct console *co, char *options) port->port.tty =NULL ; info->port = port; - + ++port->port.count;if (port->port.count ==1 ) {if (serial->type->set_termios) {
@@ -174,7 +174,7 @@ static int usb_console_setup(struct console *co, char *options) port->port.tty = tty; } -/* only call the device specific open if this +/* only call the device specific open if this * is the first time the port is opened */ if (serial->type->open) retval = serial->type->open (NULL , port,NULL );
@@ -211,7 +211,8 @@ reset_open_count: goto out; } -static void usb_console_write (struct console *co,const char *buf,unsigned count) +static void usb_console_write (struct console *co, +const char *buf,unsigned count) {static struct usbcons_info *info = &usbcons_info;struct usb_serial_port *port = info->port;
@@ -228,7 +229,7 @@ static void usb_console_write(struct console *co, const char *buf, unsigned coundbg ("%s - port %d, %d byte(s)" , __func__, port->number, count);if (!port->port.count) { -dbg ("%s - port not opened" , __func__); +dbg ("%s - port not opened" , __func__);return ; }
@@ -236,14 +237,15 @@ static void usb_console_write(struct console *co, const char *buf, unsigned coununsigned int i;unsigned int lf;/* search for LF so we can insert CR if necessary */ -for (i=0 , lf=0 ; i < count ; i++) { +for (i =0 , lf =0 ; i < count ; i++) {if (*(buf + i) ==10 ) { lf =1 ; i++;break ; } } -/* pass on to the driver specific version of this function if it is available */ +/* pass on to the driver specific version of this function if +it is available */ if (serial->type->write) retval = serial->type->write (NULL , port, buf, i);else
@@ -253,9 +255,11 @@ static void usb_console_write(struct console *co, const char *buf, unsigned coun/* append CR after LF */ unsigned char cr =13 ;if (serial->type->write) - retval = serial->type->write (NULL , port, &cr,1 ); + retval = serial->type->write (NULL , + port, &cr,1 );else - retval =usb_serial_generic_write (NULL , port, &cr,1 ); + retval =usb_serial_generic_write (NULL , + port, &cr,1 );dbg ("%s - return value : %d" , __func__, retval); } buf += i;
@@ -273,18 +277,19 @@ static struct console usbcons = {void usb_serial_console_disconnect (struct usb_serial *serial) { -if (serial && serial->port && serial->port[0 ] && serial->port[0 ] == usbcons_info.port) { +if (serial && serial->port && serial->port[0 ] + && serial->port[0 ] == usbcons_info.port) {usb_serial_console_exit ();usb_serial_put (serial); } } -void usb_serial_console_init (int serial_debug,int minor) +void usb_serial_console_init (int serial_debug,int minor) { debug = serial_debug;if (minor ==0 ) { -/* +/* * Call register_console() if this is the first device plugged * in. If we call it earlier, then the callback to * console_setup() will fail, as there is not a device seen by
@@ -293,16 +298,16 @@ void usb_serial_console_init (int serial_debug, int minor)/* * Register console. * NOTES: -* console_setup() is called (back) immediately (from register_console). -* console_write() is called immediately from register_console iff -* CON_PRINTBUFFER is set in flags. +* console_setup() is called (back) immediately (from +* register_console). console_write() is called immediately +* from register_console iff CON_PRINTBUFFER is set in flags. */ -dbg ("registering the USB serial console." ); +dbg ("registering the USB serial console." );register_console (&usbcons); } } -void usb_serial_console_exit (void ) +void usb_serial_console_exit (void ) {if (usbcons_info.port) {unregister_console (&usbcons);
PATCH 29/70 tty-usb-console: Fix termios
In reply to Alan CoxFrom: Alan Cox <[email protected]>
Setting CFLAG bits is all well and good but you must sort out ispeed and ospeed properly.
---
drivers/usb/serial/console.c | 37 +++++-------------------------------- 1 files changed, 5 insertions(+), 32 deletions(-)
drivers/usb/serial/console.c +5 -32
@@ -81,39 +81,11 @@ static int usb_console_setup(struct console *co, char *options)if (*s) doflow = (*s++ =='r' ); } + +/* Sane default */ +if (baud ==0 ) + baud =9600 ; -/* build a cflag setting */ -switch (baud) { -case 1200 : - cflag |=B1200 ; -break ; -case 2400 : - cflag |=B2400 ; -break ; -case 4800 : - cflag |=B4800 ; -break ; -case 19200 : - cflag |=B19200 ; -break ; -case 38400 : - cflag |=B38400 ; -break ; -case 57600 : - cflag |=B57600 ; -break ; -case 115200 : - cflag |=B115200 ; -break ; -case 9600 : -default : - cflag |=B9600 ; -/* -* Set this to a sane value to prevent a divide error -*/ - baud =9600 ; -break ; - }switch (bits) {case 7 : cflag |=CS7 ;
@@ -188,6 +160,7 @@ static int usb_console_setup(struct console *co, char *options)if (serial->type->set_termios) { termios->c_cflag = cflag; +tty_termios_encode_baud_rate (termios, baud, baud); serial->type->set_termios (NULL , port, &dummy); port->port.tty =NULL ;
PATCH 30/70 cp2101: coding style
In reply to Alan CoxFrom: Alan Cox <[email protected]>
Bring up to coding style
---
drivers/usb/serial/cp2101.c | 318 +++++++++++++++++++++---------------------- 1 files changed, 158 insertions(+), 160 deletions(-)
drivers/usb/serial/cp2101.c +158 -160
@@ -25,7 +25,7 @@#include <linux/module.h> #include <linux/moduleparam.h> #include <linux/usb.h> -#include <asm/uaccess.h> +#include <linux/uaccess.h> #include <linux/usb/serial.h> /*
@@ -45,12 +45,12 @@ static void cp2101_close(struct tty_struct *, struct usb_serial_port *,static void cp2101_get_termios (struct tty_struct *);static void cp2101_set_termios (struct tty_struct *,struct usb_serial_port *,struct ktermios *); -static int cp2101_tiocmget (struct tty_struct *,struct file *); -static int cp2101_tiocmset (struct tty_struct *,struct file *, +static int cp2101_tiocmget (struct tty_struct *,struct file *); +static int cp2101_tiocmset (struct tty_struct *,struct file *,unsigned int ,unsigned int );static void cp2101_break_ctl (struct tty_struct *,int ); -static int cp2101_startup (struct usb_serial *); -static void cp2101_shutdown (struct usb_serial *); +static int cp2101_startup (struct usb_serial *); +static void cp2101_shutdown (struct usb_serial *);static int debug;
@@ -96,7 +96,7 @@ static struct usb_device_id id_table [] = { { }/* Terminating Entry */ }; -MODULE_DEVICE_TABLE (usb, id_table); +MODULE_DEVICE_TABLE (usb, id_table);static struct usb_driver cp2101_driver = { .name ="cp2101" ,
@@ -205,12 +205,12 @@ static int cp2101_get_config(struct usb_serial_port *port, u8 request, request++;/* Issue the request, attempting to read 'size' bytes */ - result =usb_control_msg (serial->dev,usb_rcvctrlpipe (serial->dev,0 ), + result =usb_control_msg (serial->dev,usb_rcvctrlpipe (serial->dev,0 ), request,REQTYPE_DEVICE_TO_HOST ,0x0000 ,0 , buf, size,300 );/* Convert data into an array of integers */ -for (i=0 ; i<length; i++) +for (i =0 ; i < length; i++) data[i] =le32_to_cpu (buf[i]);kfree (buf);
@@ -253,12 +253,12 @@ static int cp2101_set_config(struct usb_serial_port *port, u8 request, buf[i] =cpu_to_le32 (data[i]);if (size >2 ) { - result =usb_control_msg (serial->dev, + result =usb_control_msg (serial->dev,usb_sndctrlpipe (serial->dev,0 ), request,REQTYPE_HOST_TO_DEVICE ,0x0000 ,0 , buf, size,300 ); }else { - result =usb_control_msg (serial->dev, + result =usb_control_msg (serial->dev,usb_sndctrlpipe (serial->dev,0 ), request,REQTYPE_HOST_TO_DEVICE , data[0 ],0 ,NULL ,0 ,300 );
@@ -274,7 +274,7 @@ static int cp2101_set_config(struct usb_serial_port *port, u8 request, }/* Single data value */ - result =usb_control_msg (serial->dev, + result =usb_control_msg (serial->dev,usb_sndctrlpipe (serial->dev,0 ), request,REQTYPE_HOST_TO_DEVICE , data[0 ],0 ,NULL ,0 ,300 );
@@ -292,7 +292,7 @@ static inline int cp2101_set_config_single(struct usb_serial_port *port,return cp2101_set_config (port, request, &data,2 ); } -static int cp2101_open (struct tty_struct *tty,struct usb_serial_port *port, +static int cp2101_open (struct tty_struct *tty,struct usb_serial_port *port,struct file *filp) {struct usb_serial *serial = port->serial;
@@ -307,7 +307,7 @@ static int cp2101_open (struct tty_struct *tty, struct usb_serial_port *port, }/* Start reading from the device */ - usb_fill_bulk_urb (port->read_urb, serial->dev, + usb_fill_bulk_urb(port->read_urb, serial->dev, usb_rcvbulkpipe(serial->dev, port->bulk_in_endpointAddress), port->read_urb->transfer_buffer,
@@ -330,7 +330,7 @@ static int cp2101_open (struct tty_struct *tty, struct usb_serial_port *port,return 0 ; } -static void cp2101_cleanup (struct usb_serial_port *port) +static void cp2101_cleanup (struct usb_serial_port *port) {struct usb_serial *serial = port->serial;
@@ -346,7 +346,7 @@ static void cp2101_cleanup (struct usb_serial_port *port) }static void cp2101_close (struct tty_struct *tty,struct usb_serial_port *port, -struct file * filp) +struct file *filp) {dbg ("%s - port %d" , __func__, port->number);
@@ -367,6 +367,7 @@ static void cp2101_close(struct tty_struct *tty, struct usb_serial_port *port,* from the device, corrects any unsupported values, and configures the * termios structure to reflect the state of the device */ +static void cp2101_get_termios (struct tty_struct *tty) {struct usb_serial_port *port = tty->driver_data;
@@ -391,99 +392,97 @@ static void cp2101_get_termios(struct tty_struct *tty)cp2101_get_config (port,CP2101_BITS , &bits,2 ); cflag &= ~CSIZE ; -switch (bits &BITS_DATA_MASK ) { -case BITS_DATA_5 : -dbg ("%s - data bits = 5" , __func__); - cflag |=CS5 ; -break ; -case BITS_DATA_6 : -dbg ("%s - data bits = 6" , __func__); - cflag |=CS6 ; -break ; -case BITS_DATA_7 : -dbg ("%s - data bits = 7" , __func__); - cflag |=CS7 ; -break ; -case BITS_DATA_8 : -dbg ("%s - data bits = 8" , __func__); - cflag |=CS8 ; -break ; -case BITS_DATA_9 : -dbg ("%s - data bits = 9 (not supported, " -"using 8 data bits)" , __func__); - cflag |=CS8 ; - bits &= ~BITS_DATA_MASK ; - bits |=BITS_DATA_8 ; -cp2101_set_config (port,CP2101_BITS , &bits,2 ); -break ; -default : -dbg ("%s - Unknown number of data bits, " -"using 8" , __func__); - cflag |=CS8 ; - bits &= ~BITS_DATA_MASK ; - bits |=BITS_DATA_8 ; -cp2101_set_config (port,CP2101_BITS , &bits,2 ); -break ; +switch (bits &BITS_DATA_MASK ) { +case BITS_DATA_5 : +dbg ("%s - data bits = 5" , __func__); + cflag |=CS5 ; +break ; +case BITS_DATA_6 : +dbg ("%s - data bits = 6" , __func__); + cflag |=CS6 ; +break ; +case BITS_DATA_7 : +dbg ("%s - data bits = 7" , __func__); + cflag |=CS7 ; +break ; +case BITS_DATA_8 : +dbg ("%s - data bits = 8" , __func__); + cflag |=CS8 ; +break ; +case BITS_DATA_9 : +dbg ("%s - data bits = 9 (not supported, using 8 data bits)" , + __func__); + cflag |=CS8 ; + bits &= ~BITS_DATA_MASK ; + bits |=BITS_DATA_8 ; +cp2101_set_config (port,CP2101_BITS , &bits,2 ); +break ; +default : +dbg ("%s - Unknown number of data bits, using 8" , __func__); + cflag |=CS8 ; + bits &= ~BITS_DATA_MASK ; + bits |=BITS_DATA_8 ; +cp2101_set_config (port,CP2101_BITS , &bits,2 ); +break ; } -switch (bits &BITS_PARITY_MASK ) { -case BITS_PARITY_NONE : -dbg ("%s - parity = NONE" , __func__); - cflag &= ~PARENB ; -break ; -case BITS_PARITY_ODD : -dbg ("%s - parity = ODD" , __func__); - cflag |= (PARENB |PARODD ); -break ; -case BITS_PARITY_EVEN : -dbg ("%s - parity = EVEN" , __func__); - cflag &= ~PARODD ; - cflag |=PARENB ; -break ; -case BITS_PARITY_MARK : -dbg ("%s - parity = MARK (not supported, " -"disabling parity)" , __func__); - cflag &= ~PARENB ; - bits &= ~BITS_PARITY_MASK ; -cp2101_set_config (port,CP2101_BITS , &bits,2 ); -break ; -case BITS_PARITY_SPACE : -dbg ("%s - parity = SPACE (not supported, " -"disabling parity)" , __func__); - cflag &= ~PARENB ; - bits &= ~BITS_PARITY_MASK ; -cp2101_set_config (port,CP2101_BITS , &bits,2 ); -break ; -default : -dbg ("%s - Unknown parity mode, " -"disabling parity" , __func__); - cflag &= ~PARENB ; - bits &= ~BITS_PARITY_MASK ; -cp2101_set_config (port,CP2101_BITS , &bits,2 ); -break ; +switch (bits &BITS_PARITY_MASK ) { +case BITS_PARITY_NONE : +dbg ("%s - parity = NONE" , __func__); + cflag &= ~PARENB ; +break ; +case BITS_PARITY_ODD : +dbg ("%s - parity = ODD" , __func__); + cflag |= (PARENB |PARODD ); +break ; +case BITS_PARITY_EVEN : +dbg ("%s - parity = EVEN" , __func__); + cflag &= ~PARODD ; + cflag |=PARENB ; +break ; +case BITS_PARITY_MARK : +dbg ("%s - parity = MARK (not supported, disabling parity)" , + __func__); + cflag &= ~PARENB ; + bits &= ~BITS_PARITY_MASK ; +cp2101_set_config (port,CP2101_BITS , &bits,2 ); +break ; +case BITS_PARITY_SPACE : +dbg ("%s - parity = SPACE (not supported, disabling parity)" , + __func__); + cflag &= ~PARENB ; + bits &= ~BITS_PARITY_MASK ; +cp2101_set_config (port,CP2101_BITS , &bits,2 ); +break ; +default : +dbg ("%s - Unknown parity mode, disabling parity" , __func__); + cflag &= ~PARENB ; + bits &= ~BITS_PARITY_MASK ; +cp2101_set_config (port,CP2101_BITS , &bits,2 ); +break ; } cflag &= ~CSTOPB ; -switch (bits &BITS_STOP_MASK ) { -case BITS_STOP_1 : -dbg ("%s - stop bits = 1" , __func__); -break ; -case BITS_STOP_1_5 : -dbg ("%s - stop bits = 1.5 (not supported, " -"using 1 stop bit)" , __func__); - bits &= ~BITS_STOP_MASK ; -cp2101_set_config (port,CP2101_BITS , &bits,2 ); -break ; -case BITS_STOP_2 : -dbg ("%s - stop bits = 2" , __func__); - cflag |=CSTOPB ; -break ; -default : -dbg ("%s - Unknown number of stop bits, " -"using 1 stop bit" , __func__); - bits &= ~BITS_STOP_MASK ; -cp2101_set_config (port,CP2101_BITS , &bits,2 ); -break ; +switch (bits &BITS_STOP_MASK ) { +case BITS_STOP_1 : +dbg ("%s - stop bits = 1" , __func__); +break ; +case BITS_STOP_1_5 : +dbg ("%s - stop bits = 1.5 (not supported, using 1 stop bit)" , + __func__); + bits &= ~BITS_STOP_MASK ; +cp2101_set_config (port,CP2101_BITS , &bits,2 ); +break ; +case BITS_STOP_2 : +dbg ("%s - stop bits = 2" , __func__); + cflag |=CSTOPB ; +break ; +default : +dbg ("%s - Unknown number of stop bits, using 1 stop bit" , + __func__); + bits &= ~BITS_STOP_MASK ; +cp2101_set_config (port,CP2101_BITS , &bits,2 ); +break ; }cp2101_get_config (port,CP2101_MODEMCTL , modem_ctl,16 );
@@ -498,11 +497,11 @@ static void cp2101_get_termios(struct tty_struct *tty) tty->termios->c_cflag = cflag; } -static void cp2101_set_termios (struct tty_struct *tty, +static void cp2101_set_termios (struct tty_struct *tty,struct usb_serial_port *port,struct ktermios *old_termios) {unsigned int cflag, old_cflag; -int baud=0 , bits; +int baud =0 , bits;unsigned int modem_ctl[4 ];dbg ("%s - port %d" , __func__, port->number);
@@ -518,30 +517,30 @@ static void cp2101_set_termios (struct tty_struct *tty,/* If the baud rate is to be updated*/ if (baud !=tty_termios_baud_rate (old_termios)) {switch (baud) { -case 0 : -case 600 : -case 1200 : -case 1800 : -case 2400 : -case 4800 : -case 7200 : -case 9600 : -case 14400 : -case 19200 : -case 28800 : -case 38400 : -case 55854 : -case 57600 : -case 115200 : -case 127117 : -case 230400 : -case 460800 : -case 921600 : -case 3686400 : -break ; -default : - baud =9600 ; -break ; +case 0 : +case 600 : +case 1200 : +case 1800 : +case 2400 : +case 4800 : +case 7200 : +case 9600 : +case 14400 : +case 19200 : +case 28800 : +case 38400 : +case 55854 : +case 57600 : +case 115200 : +case 127117 : +case 230400 : +case 460800 : +case 921600 : +case 3686400 : +break ; +default : + baud =9600 ; +break ; }if (baud) {
@@ -563,28 +562,28 @@ static void cp2101_set_termios (struct tty_struct *tty,cp2101_get_config (port,CP2101_BITS , &bits,2 ); bits &= ~BITS_DATA_MASK ;switch (cflag &CSIZE ) { -case CS5 : - bits |=BITS_DATA_5 ; -dbg ("%s - data bits = 5" , __func__); -break ; -case CS6 : - bits |=BITS_DATA_6 ; -dbg ("%s - data bits = 6" , __func__); -break ; -case CS7 : - bits |=BITS_DATA_7 ; -dbg ("%s - data bits = 7" , __func__); -break ; -case CS8 : - bits |=BITS_DATA_8 ; -dbg ("%s - data bits = 8" , __func__); -break ; -/*case CS9: -bits |= BITS_DATA_9; -dbg("%s - data bits = 9", __func__); -break;*/ -default : -dev_err (&port->dev,"cp2101 driver does not " +case CS5 : + bits |=BITS_DATA_5 ; +dbg ("%s - data bits = 5" , __func__); +break ; +case CS6 : + bits |=BITS_DATA_6 ; +dbg ("%s - data bits = 6" , __func__); +break ; +case CS7 : + bits |=BITS_DATA_7 ; +dbg ("%s - data bits = 7" , __func__); +break ; +case CS8 : + bits |=BITS_DATA_8 ; +dbg ("%s - data bits = 8" , __func__); +break ; +/*case CS9: +bits |= BITS_DATA_9; +dbg("%s - data bits = 9", __func__); +break;*/ +default : +dev_err (&port->dev,"cp2101 driver does not " "support the number of bits requested," " using 8 bit mode\n" ); bits |=BITS_DATA_8 ;
@@ -716,30 +715,29 @@ static void cp2101_break_ctl(struct tty_struct *tty, int break_state)else state =BREAK_ON ;dbg ("%s - turning break %s" , __func__, - state==BREAK_OFF ?"off" :"on" ); + state ==BREAK_OFF ?"off" :"on" );cp2101_set_config (port,CP2101_BREAK , &state,2 ); } -static int cp2101_startup (struct usb_serial *serial) +static int cp2101_startup (struct usb_serial *serial) {/* CP2101 buffers behave strangely unless device is reset */ usb_reset_device (serial->dev);return 0 ; } -static void cp2101_shutdown (struct usb_serial *serial) +static void cp2101_shutdown (struct usb_serial *serial) {int i;dbg ("%s" , __func__);/* Stop reads and writes on all ports */ -for (i=0 ; i < serial->num_ports; ++i) { +for (i =0 ; i < serial->num_ports; ++i)cp2101_cleanup (serial->port[i]); - } } -static int __init cp2101_init (void ) +static int __init cp2101_init (void ) {int retval;
@@ -759,10 +757,10 @@ static int __init cp2101_init (void)return 0 ; } -static void __exit cp2101_exit (void) +static void __exit cp2101_exit(void) { -usb_deregister (&cp2101_driver); -usb_serial_deregister (&cp2101_device); +usb_deregister (&cp2101_driver); +usb_serial_deregister (&cp2101_device); }module_init (cp2101_init);
PATCH 31/70 cyberjack: Coding style
In reply to Alan CoxFrom: Alan Cox <[email protected]>
Coding style fixups
---
drivers/usb/serial/cyberjack.c | 131 +++++++++++++++++++++------------------- 1 files changed, 69 insertions(+), 62 deletions(-)
drivers/usb/serial/cyberjack.c +69 -62
@@ -37,7 +37,7 @@#include <linux/tty_flip.h> #include <linux/module.h> #include <linux/spinlock.h> -#include <asm/uaccess.h> +#include <linux/uaccess.h> #include <linux/usb.h> #include <linux/usb/serial.h>
@@ -65,7 +65,7 @@ static void cyberjack_close(struct tty_struct *tty, struct usb_serial_port *port, struct file *filp);static int cyberjack_write (struct tty_struct *tty,struct usb_serial_port *port,const unsigned char *buf,int count); -static int cyberjack_write_room (struct tty_struct *tty); +static int cyberjack_write_room (struct tty_struct *tty);static void cyberjack_read_int_callback (struct urb *urb);static void cyberjack_read_bulk_callback (struct urb *urb);static void cyberjack_write_bulk_callback (struct urb *urb);
@@ -75,7 +75,7 @@ static struct usb_device_id id_table [] = { { }/* Terminating entry */ }; -MODULE_DEVICE_TABLE (usb, id_table); +MODULE_DEVICE_TABLE (usb, id_table);static struct usb_driver cyberjack_driver = { .name ="cyberjack" ,
@@ -138,20 +138,20 @@ static int cyberjack_startup(struct usb_serial *serial)for (i =0 ; i < serial->num_ports; ++i) {int result; serial->port[i]->interrupt_in_urb->dev = serial->dev; - result =usb_submit_urb (serial->port[i]->interrupt_in_urb, + result =usb_submit_urb (serial->port[i]->interrupt_in_urb,GFP_KERNEL );if (result)err (" usb_submit_urb(read int) failed" );dbg ("%s - usb_submit_urb(int urb)" , __func__); } -return (0 ); +return 0 ; }static void cyberjack_shutdown (struct usb_serial *serial) {int i; - +dbg ("%s" , __func__);for (i =0 ; i < serial->num_ports; ++i) {
@@ -161,7 +161,7 @@ static void cyberjack_shutdown(struct usb_serial *serial)usb_set_serial_port_data (serial->port[i],NULL ); } } - +static int cyberjack_open (struct tty_struct *tty,struct usb_serial_port *port,struct file *filp) {
@@ -171,7 +171,7 @@ static int cyberjack_open(struct tty_struct *tty,dbg ("%s - port %d" , __func__, port->number); -dbg ("%s - usb_clear_halt" , __func__ ); +dbg ("%s - usb_clear_halt" , __func__);usb_clear_halt (port->serial->dev, port->write_urb->pipe);/* force low_latency on so that our tty_push actually forces
@@ -230,7 +230,7 @@ static int cyberjack_write(struct tty_struct *tty,spin_lock_irqsave (&priv->lock, flags); -if ( (count+priv->wrfilled) >sizeof (priv->wrbuf) ) { +if (count+priv->wrfilled >sizeof (priv->wrbuf)) {/* To much data for buffer. Reset buffer. */ priv->wrfilled =0 ; port->write_urb_busy =0 ;
@@ -239,42 +239,43 @@ static int cyberjack_write(struct tty_struct *tty, }/* Copy data */ -memcpy (priv->wrbuf+priv->wrfilled, buf, count); +memcpy (priv->wrbuf + priv->wrfilled, buf, count);usb_serial_debug_data (debug, &port->dev, __func__, count, - priv->wrbuf+priv->wrfilled); + priv->wrbuf + priv->wrfilled); priv->wrfilled += count; -if ( priv->wrfilled >=3 ) { +if (priv->wrfilled >=3 ) { wrexpected = ((int )priv->wrbuf[2 ]<<8 )+priv->wrbuf[1 ]+3 ;dbg ("%s - expected data: %d" , __func__, wrexpected); - }else { + }else wrexpected =sizeof (priv->wrbuf); - } -if ( priv->wrfilled >= wrexpected ) { +if (priv->wrfilled >= wrexpected) {/* We have enough data to begin transmission */ int length;dbg ("%s - transmitting data (frame 1)" , __func__); - length = (wrexpected > port->bulk_out_size) ? port->bulk_out_size : wrexpected; + length = (wrexpected > port->bulk_out_size) ? + port->bulk_out_size : wrexpected; -memcpy (port->write_urb->transfer_buffer, priv->wrbuf, length ); - priv->wrsent=length; +memcpy (port->write_urb->transfer_buffer, priv->wrbuf, length); + priv->wrsent = length;/* set up our urb */ -usb_fill_bulk_urb (port->write_urb, serial->dev, +usb_fill_bulk_urb (port->write_urb, serial->dev,usb_sndbulkpipe (serial->dev, port->bulk_out_endpointAddress), port->write_urb->transfer_buffer, length, - ((serial->type->write_bulk_callback) ? - serial->type->write_bulk_callback : - cyberjack_write_bulk_callback), + ((serial->type->write_bulk_callback) ? + serial->type->write_bulk_callback : + cyberjack_write_bulk_callback), port);/* send the data out the bulk port */ result =usb_submit_urb (port->write_urb,GFP_ATOMIC );if (result) { -err ("%s - failed submitting write urb, error %d" , __func__, result); +err ("%s - failed submitting write urb, error %d" , + __func__, result);/* Throw away data. No better idea what to do with it. */ priv->wrfilled =0 ; priv->wrsent =0 ;
@@ -283,12 +284,12 @@ static int cyberjack_write(struct tty_struct *tty,return 0 ; } -dbg ("%s - priv->wrsent=%d" , __func__,priv->wrsent); -dbg ("%s - priv->wrfilled=%d" , __func__,priv->wrfilled); +dbg ("%s - priv->wrsent=%d" , __func__, priv->wrsent); +dbg ("%s - priv->wrfilled=%d" , __func__, priv->wrfilled); -if ( priv->wrsent>=priv->wrfilled ) { +if (priv->wrsent >= priv->wrfilled) {dbg ("%s - buffer cleaned" , __func__); -memset ( priv->wrbuf,0 ,sizeof (priv->wrbuf) ); +memset (priv->wrbuf,0 ,sizeof (priv->wrbuf)); priv->wrfilled =0 ; priv->wrsent =0 ; }
@@ -296,8 +297,8 @@ static int cyberjack_write(struct tty_struct *tty,spin_unlock_irqrestore (&priv->lock, flags); -return (count); -} +return count; +}static int cyberjack_write_room (struct tty_struct *tty) {
@@ -319,10 +320,11 @@ static void cyberjack_read_int_callback(struct urb *urb)if (status)return ; -usb_serial_debug_data (debug, &port->dev, __func__, urb->actual_length, data); +usb_serial_debug_data (debug, &port->dev, __func__, + urb->actual_length, data);/* React only to interrupts signaling a bulk_in transfer */ -if ( (urb->actual_length ==4 ) && (data[0 ] ==0x01 ) ) { +if (urb->actual_length ==4 && data[0 ] ==0x01 ) {short old_rdtodo;/* This is a announcement of coming bulk_ins. */
@@ -332,8 +334,8 @@ static void cyberjack_read_int_callback(struct urb *urb) old_rdtodo = priv->rdtodo; -if ( (old_rdtodo+size)<(old_rdtodo) ) { -dbg ("To many bulk_in urbs to do." ); +if (old_rdtodo + size < old_rdtodo) { +dbg ("To many bulk_in urbs to do." );spin_unlock (&priv->lock); goto resubmit; }
@@ -345,10 +347,10 @@ static void cyberjack_read_int_callback(struct urb *urb)spin_unlock (&priv->lock); -if ( !old_rdtodo ) { +if (!old_rdtodo) { port->read_urb->dev = port->serial->dev; result =usb_submit_urb (port->read_urb,GFP_ATOMIC ); -if ( result ) +if (result)err ("%s - failed resubmitting read urb, error %d" , __func__, result);dbg ("%s - usb_submit_urb(read urb)" , __func__); }
@@ -374,7 +376,8 @@ static void cyberjack_read_bulk_callback(struct urb *urb)dbg ("%s - port %d" , __func__, port->number); -usb_serial_debug_data (debug, &port->dev, __func__, urb->actual_length, data); +usb_serial_debug_data (debug, &port->dev, __func__, + urb->actual_length, data);if (status) {dbg ("%s - nonzero read bulk status received: %d" , __func__, status);
@@ -389,15 +392,16 @@ static void cyberjack_read_bulk_callback(struct urb *urb)if (urb->actual_length) {tty_buffer_request_room (tty, urb->actual_length);tty_insert_flip_string (tty, data, urb->actual_length); -tty_flip_buffer_push (tty); +tty_flip_buffer_push (tty); }spin_lock (&priv->lock);/* Reduce urbs to do by one. */ - priv->rdtodo-=urb->actual_length; + priv->rdtodo -= urb->actual_length;/* Just to be sure */ -if ( priv->rdtodo<0 ) priv->rdtodo =0 ; +if (priv->rdtodo <0 ) + priv->rdtodo =0 ; todo = priv->rdtodo;spin_unlock (&priv->lock);
@@ -405,11 +409,12 @@ static void cyberjack_read_bulk_callback(struct urb *urb)dbg ("%s - rdtodo: %d" , __func__, todo);/* Continue to read if we have still urbs to do. */ -if ( todo/* || (urb->actual_length==port->bulk_in_endpointAddress)*/ ) { +if (todo/* || (urb->actual_length==port->bulk_in_endpointAddress)*/ ) { port->read_urb->dev = port->serial->dev; result =usb_submit_urb (port->read_urb,GFP_ATOMIC );if (result) -err ("%s - failed resubmitting read urb, error %d" , __func__, result); +err ("%s - failed resubmitting read urb, error %d" , + __func__, result);dbg ("%s - usb_submit_urb(read urb)" , __func__); } }
@@ -432,7 +437,7 @@ static void cyberjack_write_bulk_callback(struct urb *urb)spin_lock (&priv->lock);/* only do something if we have more data to send */ -if ( priv->wrfilled ) { +if (priv->wrfilled) {int length, blksize, result;dbg ("%s - transmitting data (frame n)" , __func__);
@@ -440,37 +445,39 @@ static void cyberjack_write_bulk_callback(struct urb *urb) length = ((priv->wrfilled - priv->wrsent) > port->bulk_out_size) ? port->bulk_out_size : (priv->wrfilled - priv->wrsent); -memcpy (port->write_urb->transfer_buffer, priv->wrbuf + priv->wrsent, - length ); - priv->wrsent+=length; +memcpy (port->write_urb->transfer_buffer, + priv->wrbuf + priv->wrsent, length); + priv->wrsent += length;/* set up our urb */ -usb_fill_bulk_urb (port->write_urb, port->serial->dev, +usb_fill_bulk_urb (port->write_urb, port->serial->dev,usb_sndbulkpipe (port->serial->dev, port->bulk_out_endpointAddress), port->write_urb->transfer_buffer, length, - ((port->serial->type->write_bulk_callback) ? - port->serial->type->write_bulk_callback : - cyberjack_write_bulk_callback), + ((port->serial->type->write_bulk_callback) ? + port->serial->type->write_bulk_callback : + cyberjack_write_bulk_callback), port);/* send the data out the bulk port */ result =usb_submit_urb (port->write_urb,GFP_ATOMIC );if (result) { -err ("%s - failed submitting write urb, error %d" , __func__, result); +err ("%s - failed submitting write urb, error %d" , + __func__, result);/* Throw away data. No better idea what to do with it. */ priv->wrfilled =0 ; priv->wrsent =0 ; goto exit; } -dbg ("%s - priv->wrsent=%d" , __func__,priv->wrsent); -dbg ("%s - priv->wrfilled=%d" , __func__,priv->wrfilled); +dbg ("%s - priv->wrsent=%d" , __func__, priv->wrsent); +dbg ("%s - priv->wrfilled=%d" , __func__, priv->wrfilled); blksize = ((int )priv->wrbuf[2 ]<<8 )+priv->wrbuf[1 ]+3 ; -if ( (priv->wrsent>=priv->wrfilled) || (priv->wrsent>=blksize) ) { +if (priv->wrsent >= priv->wrfilled || + priv->wrsent >= blksize) {dbg ("%s - buffer cleaned" , __func__); -memset ( priv->wrbuf,0 ,sizeof (priv->wrbuf) ); +memset (priv->wrbuf,0 ,sizeof (priv->wrbuf)); priv->wrfilled =0 ; priv->wrsent =0 ; }
@@ -481,14 +488,14 @@ exit:usb_serial_port_softint (port); } -static int __init cyberjack_init (void ) +static int __init cyberjack_init (void ) {int retval; retval =usb_serial_register (&cyberjack_device);if (retval) goto failed_usb_serial_register; retval =usb_register (&cyberjack_driver); -if (retval) +if (retval) goto failed_usb_register;info (DRIVER_VERSION " " DRIVER_AUTHOR );
@@ -501,18 +508,18 @@ failed_usb_serial_register:return retval; } -static void __exit cyberjack_exit (void) +static void __exit cyberjack_exit(void) { -usb_deregister (&cyberjack_driver); -usb_serial_deregister (&cyberjack_device); +usb_deregister (&cyberjack_driver); +usb_serial_deregister (&cyberjack_device); }module_init (cyberjack_init);module_exit (cyberjack_exit); -MODULE_AUTHOR (DRIVER_AUTHOR ); -MODULE_DESCRIPTION (DRIVER_DESC ); -MODULE_VERSION (DRIVER_VERSION ); +MODULE_AUTHOR (DRIVER_AUTHOR ); +MODULE_DESCRIPTION (DRIVER_DESC ); +MODULE_VERSION (DRIVER_VERSION );MODULE_LICENSE ("GPL" );module_param (debug, bool,S_IRUGO |S_IWUSR );
PATCH 32/70 cypress_m8: coding style
In reply to Alan CoxFrom: Alan Cox <[email protected]>
Coding style clean ups
---
drivers/usb/serial/cypress_m8.c | 617 ++++++++++++++++++++------------------- drivers/usb/serial/cypress_m8.h | 2 2 files changed, 325 insertions(+), 294 deletions(-)
drivers/usb/serial/cypress_m8.c +324 -293
@@ -2,7 +2,7 @@* USB Cypress M8 driver * * Copyright (C) 2004 -* Lonnie Mendez ([email protected]) +* Lonnie Mendez ([email protected]) * Copyright (C) 2003,2004 * Neil Whelchel ([email protected]) *
@@ -11,19 +11,21 @@* the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * -* See Documentation/usb/usb-serial.txt for more information on using this driver +* See Documentation/usb/usb-serial.txt for more information on using this +* driver * * See http://geocities.com/i0xox0i for information on this driver and the * earthmate usb device. * * Lonnie Mendez <[email protected]> * 4-29-2005 -* Fixed problem where setting or retreiving the serial config would fail with -* EPIPE. Removed CRTS toggling so the driver behaves more like other usbserial -* adapters. Issued new interval of 1ms instead of the default 10ms. As a -* result, transfer speed has been substantially increased. From avg. 850bps to -* avg. 3300bps. initial termios has also been modified. Cleaned up code and -* formatting issues so it is more readable. Replaced the C++ style comments. +* Fixed problem where setting or retreiving the serial config would fail +* with EPIPE. Removed CRTS toggling so the driver behaves more like +* other usbserial adapters. Issued new interval of 1ms instead of the +* default 10ms. As a result, transfer speed has been substantially +* increased from avg. 850bps to avg. 3300bps. initial termios has also +* been modified. Cleaned up code and formatting issues so it is more +* readable. Replaced the C++ style comments. * * Lonnie Mendez <[email protected]> * 12-15-2004
@@ -42,10 +44,11 @@* */ -/* Thanks to Neil Whelchel for writing the first cypress m8 implementation for linux. */ +/* Thanks to Neil Whelchel for writing the first cypress m8 implementation +for linux. */ /* Thanks to cypress for providing references for the hid reports. */ /* Thanks to Jiang Zhang for providing links and for general help. */ -/* Code originates and was built up from ftdi_sio, belkin, pl2303 and others. */ +/* Code originates and was built up from ftdi_sio, belkin, pl2303 and others.*/ #include <linux/kernel.h>
@@ -62,7 +65,7 @@#include <linux/usb/serial.h> #include <linux/serial.h> #include <linux/delay.h> -#include <asm/uaccess.h> +#include <linux/uaccess.h> #include "cypress_m8.h"
@@ -112,7 +115,7 @@ static struct usb_device_id id_table_combined [] = { { }/* Terminating entry */ }; -MODULE_DEVICE_TABLE (usb, id_table_combined); +MODULE_DEVICE_TABLE (usb, id_table_combined);static struct usb_driver cypress_driver = { .name ="cypress" ,
@@ -146,11 +149,13 @@ struct cypress_private {__u8 rx_flags;/* throttling - used from whiteheat/ftdi_sio */ enum packet_format pkt_fmt;/* format to use for packet send / receive */ int get_cfg_unsafe;/* If true, the CYPRESS_GET_CONFIG is unsafe */ -int baud_rate;/* stores current baud rate in integer form */ +int baud_rate;/* stores current baud rate in +integer form */ int isthrottled;/* if throttled, discard reads */ wait_queue_head_t delta_msr_wait;/* used for TIOCMIWAIT */ char prev_status, diff_status;/* used for TIOCMIWAIT */ -/* we pass a pointer to this as the arguement sent to cypress_set_termios old_termios */ +/* we pass a pointer to this as the arguement sent to +cypress_set_termios old_termios */ struct ktermios tmp_termios;/* stores the old termios settings */ };
@@ -163,33 +168,41 @@ struct cypress_buf { };/* function prototypes for the Cypress USB to serial device */ -static int cypress_earthmate_startup (struct usb_serial *serial); -static int cypress_hidcom_startup (struct usb_serial *serial); -static int cypress_ca42v2_startup (struct usb_serial *serial); -static void cypress_shutdown (struct usb_serial *serial); -static int cypress_open (struct tty_struct *tty,struct usb_serial_port *port,struct file *filp); -static void cypress_close (struct tty_struct *tty,struct usb_serial_port *port,struct file *filp); -static int cypress_write (struct tty_struct *tty,struct usb_serial_port *port,const unsigned char *buf,int count); -static void cypress_send (struct usb_serial_port *port); -static int cypress_write_room (struct tty_struct *tty); -static int cypress_ioctl (struct tty_struct *tty,struct file * file,unsigned int cmd,unsigned long arg); -static void cypress_set_termios (struct tty_struct *tty,struct usb_serial_port *port,struct ktermios * old); -static int cypress_tiocmget (struct tty_struct *tty,struct file *file); -static int cypress_tiocmset (struct tty_struct *tty,struct file *file,unsigned int set,unsigned int clear); -static int cypress_chars_in_buffer (struct tty_struct *tty); -static void cypress_throttle (struct tty_struct *tty); -static void cypress_unthrottle (struct tty_struct *tty); -static void cypress_set_dead (struct usb_serial_port *port); -static void cypress_read_int_callback (struct urb *urb); -static void cypress_write_int_callback (struct urb *urb); +static int cypress_earthmate_startup (struct usb_serial *serial); +static int cypress_hidcom_startup (struct usb_serial *serial); +static int cypress_ca42v2_startup (struct usb_serial *serial); +static void cypress_shutdown (struct usb_serial *serial); +static int cypress_open (struct tty_struct *tty, +struct usb_serial_port *port,struct file *filp); +static void cypress_close (struct tty_struct *tty, +struct usb_serial_port *port,struct file *filp); +static int cypress_write (struct tty_struct *tty,struct usb_serial_port *port, +const unsigned char *buf,int count); +static void cypress_send (struct usb_serial_port *port); +static int cypress_write_room (struct tty_struct *tty); +static int cypress_ioctl (struct tty_struct *tty,struct file *file, +unsigned int cmd,unsigned long arg); +static void cypress_set_termios (struct tty_struct *tty, +struct usb_serial_port *port,struct ktermios *old); +static int cypress_tiocmget (struct tty_struct *tty,struct file *file); +static int cypress_tiocmset (struct tty_struct *tty,struct file *file, +unsigned int set,unsigned int clear); +static int cypress_chars_in_buffer (struct tty_struct *tty); +static void cypress_throttle (struct tty_struct *tty); +static void cypress_unthrottle (struct tty_struct *tty); +static void cypress_set_dead (struct usb_serial_port *port); +static void cypress_read_int_callback (struct urb *urb); +static void cypress_write_int_callback (struct urb *urb);/* write buffer functions */ static struct cypress_buf *cypress_buf_alloc (unsigned int size); -static void cypress_buf_free (struct cypress_buf *cb); -static void cypress_buf_clear (struct cypress_buf *cb); -static unsigned int cypress_buf_data_avail (struct cypress_buf *cb); -static unsigned int cypress_buf_space_avail (struct cypress_buf *cb); -static unsigned int cypress_buf_put (struct cypress_buf *cb,const char *buf,unsigned int count); -static unsigned int cypress_buf_get (struct cypress_buf *cb,char *buf,unsigned int count); +static void cypress_buf_free (struct cypress_buf *cb); +static void cypress_buf_clear (struct cypress_buf *cb); +static unsigned int cypress_buf_data_avail (struct cypress_buf *cb); +static unsigned int cypress_buf_space_avail (struct cypress_buf *cb); +static unsigned int cypress_buf_put (struct cypress_buf *cb, +const char *buf,unsigned int count); +static unsigned int cypress_buf_get (struct cypress_buf *cb, +char *buf,unsigned int count);static struct usb_serial_driver cypress_earthmate_device = {
@@ -247,7 +260,7 @@ static struct usb_serial_driver cypress_hidcom_device = {static struct usb_serial_driver cypress_ca42v2_device = { .driver = { .owner =THIS_MODULE , - .name ="nokiaca42v2" , + .name ="nokiaca42v2" , }, .description ="Nokia CA-42 V2 Adapter" , .usb_driver = &cypress_driver,
@@ -322,7 +335,7 @@ static int analyze_baud_rate(struct usb_serial_port *port, speed_t new_rate)/* This function can either set or retrieve the current serial line settings */ -static int cypress_serial_control (struct tty_struct *tty, +static int cypress_serial_control (struct tty_struct *tty,struct usb_serial_port *port,speed_t baud_rate,int data_bits,int stop_bits,int parity_enable,int parity_type,int reset,int cypress_request_type)
@@ -333,111 +346,114 @@ static int cypress_serial_control (struct tty_struct *tty,unsigned long flags;dbg ("%s" , __func__); - + priv =usb_get_serial_port_data (port);if (!priv->comm_is_ok)return -ENODEV ; -switch (cypress_request_type) { -case CYPRESS_SET_CONFIG : +switch (cypress_request_type) { +case CYPRESS_SET_CONFIG : + new_baudrate = priv->baud_rate; +/* 0 means 'Hang up' so doesn't change the true bit rate */ +if (baud_rate ==0 ) new_baudrate = priv->baud_rate; -/* 0 means 'Hang up' so doesn't change the true bit rate */ -if (baud_rate ==0 ) - new_baudrate = priv->baud_rate; -/* Change of speed ? */ -else if (baud_rate != priv->baud_rate) { -dbg ("%s - baud rate is changing" , __func__); - retval =analyze_baud_rate (port, baud_rate); -if (retval >=0 ) { - new_baudrate = retval; -dbg ("%s - New baud rate set to %d" , - __func__, new_baudrate); - } - } -dbg ("%s - baud rate is being sent as %d" , __func__, new_baudrate); - -memset (feature_buffer,0 ,sizeof (feature_buffer)); -/* fill the feature_buffer with new configuration */ - *((u_int32_t *)feature_buffer) = new_baudrate; - - feature_buffer[4 ] |= data_bits;/* assign data bits in 2 bit space ( max 3 ) */ -/* 1 bit gap */ - feature_buffer[4 ] |= (stop_bits <<3 );/* assign stop bits in 1 bit space */ - feature_buffer[4 ] |= (parity_enable <<4 );/* assign parity flag in 1 bit space */ - feature_buffer[4 ] |= (parity_type <<5 );/* assign parity type in 1 bit space */ -/* 1 bit gap */ - feature_buffer[4 ] |= (reset <<7 );/* assign reset at end of byte, 1 bit space */ - -dbg ("%s - device is being sent this feature report:" , __func__); -dbg ("%s - %02X - %02X - %02X - %02X - %02X" , __func__, feature_buffer[0 ], feature_buffer[1 ], - feature_buffer[2 ], feature_buffer[3 ], feature_buffer[4 ]); - -do { - retval =usb_control_msg (port->serial->dev, -usb_sndctrlpipe (port->serial->dev,0 ), -HID_REQ_SET_REPORT , -USB_DIR_OUT |USB_RECIP_INTERFACE |USB_TYPE_CLASS , -0x0300 ,0 , feature_buffer, -sizeof (feature_buffer),500 ); - -if (tries++ >=3 ) -break ; - - }while (retval !=sizeof (feature_buffer) && - retval != -ENODEV ); - -if (retval !=sizeof (feature_buffer)) { -err ("%s - failed sending serial line settings - %d" , __func__, retval); -cypress_set_dead (port); - }else { -spin_lock_irqsave (&priv->lock, flags); - priv->baud_rate = new_baudrate; - priv->current_config = feature_buffer[4 ]; -spin_unlock_irqrestore (&priv->lock, flags); -/* If we asked for a speed change encode it */ -if (baud_rate) -tty_encode_baud_rate (tty, - new_baudrate, new_baudrate); - } -break ; -case CYPRESS_GET_CONFIG : -if (priv->get_cfg_unsafe) { -/* Not implemented for this device, -and if we try to do it we're likely -to crash the hardware. */ -return -ENOTTY ; - } -dbg ("%s - retreiving serial line settings" , __func__); -/* set initial values in feature buffer */ -memset (feature_buffer,0 ,sizeof (feature_buffer)); - -do { - retval =usb_control_msg (port->serial->dev, -usb_rcvctrlpipe (port->serial->dev,0 ), -HID_REQ_GET_REPORT , -USB_DIR_IN |USB_RECIP_INTERFACE |USB_TYPE_CLASS , -0x0300 ,0 , feature_buffer, -sizeof (feature_buffer),500 ); - -if (tries++ >=3 ) -break ; - - }while (retval !=sizeof (feature_buffer) && - retval != -ENODEV ); - -if (retval !=sizeof (feature_buffer)) { -err ("%s - failed to retrieve serial line settings - %d" , __func__, retval); -cypress_set_dead (port); -return retval; - }else { -spin_lock_irqsave (&priv->lock, flags); - -/* store the config in one byte, and later use bit masks to check values */ - priv->current_config = feature_buffer[4 ]; - priv->baud_rate = *((u_int32_t *)feature_buffer); -spin_unlock_irqrestore (&priv->lock, flags); +/* Change of speed ? */ +else if (baud_rate != priv->baud_rate) { +dbg ("%s - baud rate is changing" , __func__); + retval =analyze_baud_rate (port, baud_rate); +if (retval >=0 ) { + new_baudrate = retval; +dbg ("%s - New baud rate set to %d" , + __func__, new_baudrate); } + } +dbg ("%s - baud rate is being sent as %d" , + __func__, new_baudrate); + +memset (feature_buffer,0 ,sizeof (feature_buffer)); +/* fill the feature_buffer with new configuration */ + *((u_int32_t *)feature_buffer) = new_baudrate; + feature_buffer[4 ] |= data_bits;/* assign data bits in 2 bit space ( max 3 ) */ +/* 1 bit gap */ + feature_buffer[4 ] |= (stop_bits <<3 );/* assign stop bits in 1 bit space */ + feature_buffer[4 ] |= (parity_enable <<4 );/* assign parity flag in 1 bit space */ + feature_buffer[4 ] |= (parity_type <<5 );/* assign parity type in 1 bit space */ +/* 1 bit gap */ + feature_buffer[4 ] |= (reset <<7 );/* assign reset at end of byte, 1 bit space */ + +dbg ("%s - device is being sent this feature report:" , + __func__); +dbg ("%s - %02X - %02X - %02X - %02X - %02X" , __func__, + feature_buffer[0 ], feature_buffer[1 ], + feature_buffer[2 ], feature_buffer[3 ], + feature_buffer[4 ]); + +do { + retval =usb_control_msg (port->serial->dev, +usb_sndctrlpipe (port->serial->dev,0 ), +HID_REQ_SET_REPORT , +USB_DIR_OUT |USB_RECIP_INTERFACE |USB_TYPE_CLASS , +0x0300 ,0 , feature_buffer, +sizeof (feature_buffer),500 ); + +if (tries++ >=3 ) +break ; + + }while (retval !=sizeof (feature_buffer) && + retval != -ENODEV ); + +if (retval !=sizeof (feature_buffer)) { +err ("%s - failed sending serial line settings - %d" , + __func__, retval); +cypress_set_dead (port); + }else { +spin_lock_irqsave (&priv->lock, flags); + priv->baud_rate = new_baudrate; + priv->current_config = feature_buffer[4 ]; +spin_unlock_irqrestore (&priv->lock, flags); +/* If we asked for a speed change encode it */ +if (baud_rate) +tty_encode_baud_rate (tty, + new_baudrate, new_baudrate); + } +break ; +case CYPRESS_GET_CONFIG : +if (priv->get_cfg_unsafe) { +/* Not implemented for this device, +and if we try to do it we're likely +to crash the hardware. */ +return -ENOTTY ; + } +dbg ("%s - retreiving serial line settings" , __func__); +/* set initial values in feature buffer */ +memset (feature_buffer,0 ,sizeof (feature_buffer)); + +do { + retval =usb_control_msg (port->serial->dev, +usb_rcvctrlpipe (port->serial->dev,0 ), +HID_REQ_GET_REPORT , +USB_DIR_IN |USB_RECIP_INTERFACE |USB_TYPE_CLASS , +0x0300 ,0 , feature_buffer, +sizeof (feature_buffer),500 ); + +if (tries++ >=3 ) +break ; + }while (retval !=sizeof (feature_buffer) + && retval != -ENODEV ); + +if (retval !=sizeof (feature_buffer)) { +err ("%s - failed to retrieve serial line settings - %d" , __func__, retval); +cypress_set_dead (port); +return retval; + }else { +spin_lock_irqsave (&priv->lock, flags); +/* store the config in one byte, and later +use bit masks to check values */ + priv->current_config = feature_buffer[4 ]; + priv->baud_rate = *((u_int32_t *)feature_buffer); +spin_unlock_irqrestore (&priv->lock, flags); + } }spin_lock_irqsave (&priv->lock, flags); ++priv->cmd_count;
@@ -470,14 +486,14 @@ static void cypress_set_dead(struct usb_serial_port *port)*****************************************************************************/ -static int generic_startup (struct usb_serial *serial) +static int generic_startup (struct usb_serial *serial) {struct cypress_private *priv;struct usb_serial_port *port = serial->port[0 ];dbg ("%s - port %d" , __func__, port->number); - priv =kzalloc (sizeof (struct cypress_private ),GFP_KERNEL ); + priv =kzalloc (sizeof (struct cypress_private ),GFP_KERNEL );if (!priv)return -ENOMEM ;
@@ -489,9 +505,9 @@ static int generic_startup (struct usb_serial *serial)return -ENOMEM ; }init_waitqueue_head (&priv->delta_msr_wait); - -usb_reset_configuration (serial->dev); - + +usb_reset_configuration (serial->dev); + priv->cmd_ctrl =0 ; priv->line_control =0 ; priv->termios_initialized =0 ;
@@ -502,30 +518,30 @@ static int generic_startup (struct usb_serial *serial)small. Otherwise we can use the slightly more compact format. This is in accordance with the cypress_m8 serial converter app note. */ -if (port->interrupt_out_size >9 ) { +if (port->interrupt_out_size >9 ) priv->pkt_fmt = packet_format_1; - }else { +else priv->pkt_fmt = packet_format_2; - } +if (interval >0 ) { priv->write_urb_interval = interval; priv->read_urb_interval = interval;dbg ("%s - port %d read & write intervals forced to %d" , - __func__,port->number,interval); + __func__, port->number, interval); }else { priv->write_urb_interval = port->interrupt_out_urb->interval; priv->read_urb_interval = port->interrupt_in_urb->interval;dbg ("%s - port %d intervals: read=%d write=%d" , - __func__,port->number, - priv->read_urb_interval,priv->write_urb_interval); + __func__, port->number, + priv->read_urb_interval, priv->write_urb_interval); }usb_set_serial_port_data (port, priv); - +return 0 ; } -static int cypress_earthmate_startup (struct usb_serial *serial) +static int cypress_earthmate_startup (struct usb_serial *serial) {struct cypress_private *priv;struct usb_serial_port *port = serial->port[0 ];
@@ -543,7 +559,8 @@ static int cypress_earthmate_startup (struct usb_serial *serial)/* All Earthmate devices use the separated-count packet format! Idiotic. */ priv->pkt_fmt = packet_format_1; -if (serial->dev->descriptor.idProduct !=cpu_to_le16 (PRODUCT_ID_EARTHMATEUSB )) { +if (serial->dev->descriptor.idProduct != +cpu_to_le16 (PRODUCT_ID_EARTHMATEUSB )) {/* The old original USB Earthmate seemed able to handle GET_CONFIG requests; everything they've produced since that time crashes if this command is
@@ -557,7 +574,7 @@ static int cypress_earthmate_startup (struct usb_serial *serial) }/* cypress_earthmate_startup */ -static int cypress_hidcom_startup (struct usb_serial *serial) +static int cypress_hidcom_startup (struct usb_serial *serial) {struct cypress_private *priv;
@@ -571,12 +588,12 @@ static int cypress_hidcom_startup (struct usb_serial *serial) priv =usb_get_serial_port_data (serial->port[0 ]); priv->chiptype =CT_CYPHIDCOM ; - +return 0 ; }/* cypress_hidcom_startup */ -static int cypress_ca42v2_startup (struct usb_serial *serial) +static int cypress_ca42v2_startup (struct usb_serial *serial) {struct cypress_private *priv;
@@ -595,11 +612,11 @@ static int cypress_ca42v2_startup (struct usb_serial *serial) }/* cypress_ca42v2_startup */ -static void cypress_shutdown (struct usb_serial *serial) +static void cypress_shutdown (struct usb_serial *serial) {struct cypress_private *priv; -dbg ("%s - port %d" , __func__, serial->port[0 ]->number); +dbg ("%s - port %d" , __func__, serial->port[0 ]->number);/* all open ports are closed at this point */
@@ -650,7 +667,9 @@ static int cypress_open(struct tty_struct *tty, result =cypress_write (tty, port,NULL ,0 );if (result) { -dev_err (&port->dev,"%s - failed setting the control lines - error %d\n" , __func__, result); +dev_err (&port->dev, +"%s - failed setting the control lines - error %d\n" , + __func__, result);return result; }else dbg ("%s - success setting the control lines" , __func__);
@@ -659,19 +678,22 @@ static int cypress_open(struct tty_struct *tty,cypress_set_termios (tty, port, &priv->tmp_termios);/* setup the port and start reading from the device */ -if (!port->interrupt_in_urb){ +if (!port->interrupt_in_urb) {err ("%s - interrupt_in_urb is empty!" , __func__); -return (-1 ); +return -1 ; }usb_fill_int_urb (port->interrupt_in_urb, serial->dev,usb_rcvintpipe (serial->dev, port->interrupt_in_endpointAddress), - port->interrupt_in_urb->transfer_buffer, port->interrupt_in_urb->transfer_buffer_length, + port->interrupt_in_urb->transfer_buffer, + port->interrupt_in_urb->transfer_buffer_length, cypress_read_int_callback, port, priv->read_urb_interval); result =usb_submit_urb (port->interrupt_in_urb,GFP_KERNEL ); -if (result){ -dev_err (&port->dev,"%s - failed submitting read urb, error %d\n" , __func__, result); +if (result) { +dev_err (&port->dev, +"%s - failed submitting read urb, error %d\n" , + __func__, result);cypress_set_dead (port); }
@@ -680,7 +702,7 @@ static int cypress_open(struct tty_struct *tty,static void cypress_close (struct tty_struct *tty, -struct usb_serial_port *port,struct file * filp) +struct usb_serial_port *port,struct file *filp) {struct cypress_private *priv =usb_get_serial_port_data (port);unsigned int c_cflag;
@@ -722,15 +744,15 @@ static void cypress_close(struct tty_struct *tty,if (tty) { bps =tty_get_baud_rate (tty);if (bps >1200 ) - timeout =max ((HZ *2560 )/bps,HZ /10 ); + timeout =max ((HZ *2560 ) / bps,HZ /10 );else - timeout =2 *HZ ; + timeout =2 *HZ ;schedule_timeout_interruptible (timeout); }dbg ("%s - stopping urbs" , __func__); -usb_kill_urb (port->interrupt_in_urb); -usb_kill_urb (port->interrupt_out_urb); +usb_kill_urb (port->interrupt_in_urb); +usb_kill_urb (port->interrupt_out_urb);if (tty) { c_cflag = tty->termios->c_cflag;
@@ -746,8 +768,8 @@ static void cypress_close(struct tty_struct *tty, }if (stats) -dev_info (&port->dev,"Statistics: %d Bytes In | %d Bytes Out | %d Commands Issued\n" , - priv->bytes_in, priv->bytes_out, priv->cmd_count); +dev_info (&port->dev,"Statistics: %d Bytes In | %d Bytes Out | %d Commands Issued\n" , + priv->bytes_in, priv->bytes_out, priv->cmd_count);mutex_unlock (&port->serial->disc_mutex); }/* cypress_close */
@@ -757,7 +779,7 @@ static int cypress_write(struct tty_struct *tty, struct usb_serial_port *port, {struct cypress_private *priv =usb_get_serial_port_data (port);unsigned long flags; - +dbg ("%s - port %d, %d bytes" , __func__, port->number, count);/* line control commands, which need to be executed immediately,
@@ -767,10 +789,10 @@ static int cypress_write(struct tty_struct *tty, struct usb_serial_port *port, count =0 ; goto finish; } - +if (!count)return count; - +spin_lock_irqsave (&priv->lock, flags); count =cypress_buf_put (priv->buf, buf, count);spin_unlock_irqrestore (&priv->lock, flags);
@@ -787,13 +809,14 @@ static void cypress_send(struct usb_serial_port *port)int count =0 , result, offset, actual_size;struct cypress_private *priv =usb_get_serial_port_data (port);unsigned long flags; - +if (!priv->comm_is_ok)return ;dbg ("%s - port %d" , __func__, port->number); -dbg ("%s - interrupt out size is %d" , __func__, port->interrupt_out_size); - +dbg ("%s - interrupt out size is %d" , __func__, + port->interrupt_out_size); +spin_lock_irqsave (&priv->lock, flags);if (priv->write_urb_in_use) {dbg ("%s - can't write, urb in use" , __func__);
@@ -803,7 +826,8 @@ static void cypress_send(struct usb_serial_port *port)spin_unlock_irqrestore (&priv->lock, flags);/* clear buffer */ -memset (port->interrupt_out_urb->transfer_buffer,0 , port->interrupt_out_size); +memset (port->interrupt_out_urb->transfer_buffer,0 , + port->interrupt_out_size);spin_lock_irqsave (&priv->lock, flags);switch (priv->pkt_fmt) {
@@ -834,9 +858,8 @@ static void cypress_send(struct usb_serial_port *port) count =cypress_buf_get (priv->buf, &port->interrupt_out_buffer[offset], port->interrupt_out_size-offset); -if (count ==0 ) { +if (count ==0 )return ; - }switch (priv->pkt_fmt) {default :
@@ -860,26 +883,29 @@ send: actual_size = count + (priv->pkt_fmt == packet_format_1 ?2 :1 ); -usb_serial_debug_data (debug, &port->dev, __func__, port->interrupt_out_size, - port->interrupt_out_urb->transfer_buffer); +usb_serial_debug_data (debug, &port->dev, __func__, + port->interrupt_out_size, + port->interrupt_out_urb->transfer_buffer);usb_fill_int_urb (port->interrupt_out_urb, port->serial->dev,usb_sndintpipe (port->serial->dev, port->interrupt_out_endpointAddress), port->interrupt_out_buffer, port->interrupt_out_size, cypress_write_int_callback, port, priv->write_urb_interval); - result =usb_submit_urb (port->interrupt_out_urb,GFP_ATOMIC ); + result =usb_submit_urb (port->interrupt_out_urb,GFP_ATOMIC );if (result) { -dev_err (&port->dev,"%s - failed submitting write urb, error %d\n" , __func__, - result); +dev_err (&port->dev, +"%s - failed submitting write urb, error %d\n" , + __func__, result); priv->write_urb_in_use =0 ;cypress_set_dead (port); }spin_lock_irqsave (&priv->lock, flags); -if (priv->cmd_ctrl) { +if (priv->cmd_ctrl) priv->cmd_ctrl =0 ; - } - priv->bytes_out += count;/* do not count the line control and size bytes */ + +/* do not count the line control and size bytes */ + priv->bytes_out += count;spin_unlock_irqrestore (&priv->lock, flags);usb_serial_port_softint (port);
@@ -912,7 +938,7 @@ static int cypress_tiocmget(struct tty_struct *tty, struct file *file)__u8 status, control;unsigned int result =0 ;unsigned long flags; - +dbg ("%s - port %d" , __func__, port->number);spin_lock_irqsave (&priv->lock, flags);
@@ -939,7 +965,7 @@ static int cypress_tiocmset(struct tty_struct *tty, struct file *file,struct usb_serial_port *port = tty->driver_data;struct cypress_private *priv =usb_get_serial_port_data (port);unsigned long flags; - +dbg ("%s - port %d" , __func__, port->number);spin_lock_irqsave (&priv->lock, flags);
@@ -958,7 +984,7 @@ static int cypress_tiocmset(struct tty_struct *tty, struct file *file, } -static int cypress_ioctl (struct tty_struct *tty,struct file * file, +static int cypress_ioctl (struct tty_struct *tty,struct file *file,unsigned int cmd,unsigned long arg) {struct usb_serial_port *port = tty->driver_data;
@@ -967,38 +993,37 @@ static int cypress_ioctl(struct tty_struct *tty, struct file * file,dbg ("%s - port %d, cmd 0x%.4x" , __func__, port->number, cmd);switch (cmd) { -/* This code comes from drivers/char/serial.c and ftdi_sio.c */ -case TIOCMIWAIT : -while (priv !=NULL ) { -interruptible_sleep_on (&priv->delta_msr_wait); -/* see if a signal did it */ -if (signal_pending (current)) -return -ERESTARTSYS ; -else { -char diff = priv->diff_status; - -if (diff ==0 ) { -return -EIO ;/* no change => error */ - } - -/* consume all events */ - priv->diff_status =0 ; - -/* return 0 if caller wanted to know about these bits */ -if ( ((arg &TIOCM_RNG ) && (diff &UART_RI )) || - ((arg &TIOCM_DSR ) && (diff &UART_DSR )) || - ((arg &TIOCM_CD ) && (diff &UART_CD )) || - ((arg &TIOCM_CTS ) && (diff &UART_CTS )) ) { -return 0 ; - } -/* otherwise caller can't care less about what happened, -* and so we continue to wait for more events. -*/ - } +/* This code comes from drivers/char/serial.c and ftdi_sio.c */ +case TIOCMIWAIT : +while (priv !=NULL ) { +interruptible_sleep_on (&priv->delta_msr_wait); +/* see if a signal did it */ +if (signal_pending (current)) +return -ERESTARTSYS ; +else { +char diff = priv->diff_status; +if (diff ==0 ) +return -EIO ;/* no change => error */ + +/* consume all events */ + priv->diff_status =0 ; + +/* return 0 if caller wanted to know about +these bits */ +if (((arg &TIOCM_RNG ) && (diff &UART_RI )) || + ((arg &TIOCM_DSR ) && (diff &UART_DSR )) || + ((arg &TIOCM_CD ) && (diff &UART_CD )) || + ((arg &TIOCM_CTS ) && (diff &UART_CTS ))) +return 0 ; +/* otherwise caller can't care less about what +* happened, and so we continue to wait for +* more events. +*/ } -return 0 ; -default : -break ; + } +return 0 ; +default : +break ; }dbg ("%s - arg not supported - it was 0x%04x - check include/asm/ioctls.h" , __func__, cmd);return -ENOIOCTLCMD ;
@@ -1070,23 +1095,22 @@ static void cypress_set_termios(struct tty_struct *tty,if (cflag &CSIZE ) {switch (cflag &CSIZE ) { -case CS5 : - data_bits =0 ; -break ; -case CS6 : - data_bits =1 ; -break ; -case CS7 : - data_bits =2 ; -break ; -case CS8 : - data_bits =3 ; -break ; -default : -err ("%s - CSIZE was set, but not CS5-CS8" , - __func__); - data_bits =3 ; - } +case CS5 : + data_bits =0 ; +break ; +case CS6 : + data_bits =1 ; +break ; +case CS7 : + data_bits =2 ; +break ; +case CS8 : + data_bits =3 ; +break ; +default : +err ("%s - CSIZE was set, but not CS5-CS8" , + __func__); + data_bits =3 ; } else data_bits =3 ;
@@ -1104,8 +1128,10 @@ static void cypress_set_termios(struct tty_struct *tty,"%d data_bits (+5)" , __func__, stop_bits, parity_enable, parity_type, data_bits); -cypress_serial_control (tty, port,tty_get_baud_rate (tty), data_bits, stop_bits, - parity_enable, parity_type,0 ,CYPRESS_SET_CONFIG ); +cypress_serial_control (tty, port,tty_get_baud_rate (tty), + data_bits, stop_bits, + parity_enable, parity_type, +0 ,CYPRESS_SET_CONFIG );/* we perform a CYPRESS_GET_CONFIG so that the current settings are * filled into the private structure this should confirm that all is
@@ -1116,7 +1142,7 @@ static void cypress_set_termios(struct tty_struct *tty,* termios flag base comes from empeg.c */ spin_lock_irqsave (&priv->lock, flags); -if ( (priv->chiptype ==CT_EARTHMATE ) && (priv->baud_rate ==4800 ) ) { +if (priv->chiptype ==CT_EARTHMATE && priv->baud_rate ==4800 ) {dbg ("Using custom termios settings for a baud rate of " "4800bps." );/* define custom termios settings for NMEA protocol */
@@ -1164,7 +1190,7 @@ static int cypress_chars_in_buffer(struct tty_struct *tty)unsigned long flags;dbg ("%s - port %d" , __func__, port->number); - +spin_lock_irqsave (&priv->lock, flags); chars =cypress_buf_data_avail (priv->buf);spin_unlock_irqrestore (&priv->lock, flags);
@@ -1243,12 +1269,13 @@ static void cypress_read_int_callback(struct urb *urb)/* precursor to disconnect so just go away */ return ;case -EPIPE : -usb_clear_halt (port->serial->dev,0x81 ); +usb_clear_halt (port->serial->dev,0x81 );break ;default :/* something ugly is going on... */ -dev_err (&urb->dev->dev,"%s - unexpected nonzero read status received: %d\n" , - __func__, status); +dev_err (&urb->dev->dev, +"%s - unexpected nonzero read status received: %d\n" , + __func__, status);cypress_set_dead (port);return ; }
@@ -1296,8 +1323,8 @@ static void cypress_read_int_callback(struct urb *urb) goto continue_read; } -usb_serial_debug_data (debug, &port->dev, __func__, - urb->actual_length, data); +usb_serial_debug_data (debug, &port->dev, __func__, + urb->actual_length, data);spin_lock_irqsave (&priv->lock, flags);/* check to see if status has changed */
@@ -1356,7 +1383,8 @@ continue_read: port->interrupt_in_endpointAddress), port->interrupt_in_urb->transfer_buffer, port->interrupt_in_urb->transfer_buffer_length, - cypress_read_int_callback, port, priv->read_urb_interval); + cypress_read_int_callback, port, + priv->read_urb_interval); result =usb_submit_urb (port->interrupt_in_urb,GFP_ATOMIC );if (result) { dev_err(&urb->dev->dev, "%s - failed resubmitting "
@@ -1380,42 +1408,43 @@ static void cypress_write_int_callback(struct urb *urb)dbg ("%s - port %d" , __func__, port->number);switch (status) { -case 0 : -/* success */ +case 0 : +/* success */ +break ; +case -ECONNRESET : +case -ENOENT : +case -ESHUTDOWN : +/* this urb is terminated, clean up */ +dbg ("%s - urb shutting down with status: %d" , + __func__, status); + priv->write_urb_in_use =0 ; +return ; +case -EPIPE :/* no break needed; clear halt and resubmit */ +if (!priv->comm_is_ok)break ; -case -ECONNRESET : -case -ENOENT : -case -ESHUTDOWN : -/* this urb is terminated, clean up */ -dbg ("%s - urb shutting down with status: %d" , - __func__, status); - priv->write_urb_in_use =0 ; +usb_clear_halt (port->serial->dev,0x02 ); +/* error in the urb, so we have to resubmit it */ +dbg ("%s - nonzero write bulk status received: %d" , + __func__, status); + port->interrupt_out_urb->transfer_buffer_length =1 ; + port->interrupt_out_urb->dev = port->serial->dev; + result =usb_submit_urb (port->interrupt_out_urb,GFP_ATOMIC ); +if (!result)return ; -case -EPIPE :/* no break needed; clear halt and resubmit */ -if (!priv->comm_is_ok) -break ; -usb_clear_halt (port->serial->dev,0x02 ); -/* error in the urb, so we have to resubmit it */ -dbg ("%s - nonzero write bulk status received: %d" , - __func__, status); - port->interrupt_out_urb->transfer_buffer_length =1 ; - port->interrupt_out_urb->dev = port->serial->dev; - result =usb_submit_urb (port->interrupt_out_urb,GFP_ATOMIC ); -if (!result) -return ; -dev_err (&urb->dev->dev,"%s - failed resubmitting write urb, error %d\n" , - __func__, result); -cypress_set_dead (port); -break ; -default : -dev_err (&urb->dev->dev,"%s - unexpected nonzero write status received: %d\n" , - __func__, status); -cypress_set_dead (port); -break ; +dev_err (&urb->dev->dev, +"%s - failed resubmitting write urb, error %d\n" , + __func__, result); +cypress_set_dead (port); +break ; +default : +dev_err (&urb->dev->dev, +"%s - unexpected nonzero write status received: %d\n" , + __func__, status); +cypress_set_dead (port); +break ; } - priv->write_urb_in_use =0 ; - +/* send any buffered data */ cypress_send (port); }
@@ -1497,7 +1526,8 @@ static void cypress_buf_clear(struct cypress_buf *cb)static unsigned int cypress_buf_data_avail (struct cypress_buf *cb) {if (cb !=NULL ) -return ((cb->buf_size + cb->buf_put - cb->buf_get) % cb->buf_size); +return (cb->buf_size + cb->buf_put - cb->buf_get) + % cb->buf_size;else return 0 ; }
@@ -1513,7 +1543,8 @@ static unsigned int cypress_buf_data_avail(struct cypress_buf *cb)static unsigned int cypress_buf_space_avail (struct cypress_buf *cb) {if (cb !=NULL ) -return ((cb->buf_size + cb->buf_get - cb->buf_put -1 ) % cb->buf_size); +return (cb->buf_size + cb->buf_get - cb->buf_put -1 ) + % cb->buf_size;else return 0 ; }
@@ -1613,9 +1644,9 @@ static unsigned int cypress_buf_get(struct cypress_buf *cb, char *buf,static int __init cypress_init (void ) {int retval; - +dbg ("%s" , __func__); - + retval =usb_serial_register (&cypress_earthmate_device);if (retval) goto failed_em_register;
@@ -1643,23 +1674,23 @@ failed_em_register: } -static void __exit cypress_exit (void) +static void __exit cypress_exit(void) {dbg ("%s" , __func__); -usb_deregister (&cypress_driver); -usb_serial_deregister (&cypress_earthmate_device); -usb_serial_deregister (&cypress_hidcom_device); -usb_serial_deregister (&cypress_ca42v2_device); +usb_deregister (&cypress_driver); +usb_serial_deregister (&cypress_earthmate_device); +usb_serial_deregister (&cypress_hidcom_device); +usb_serial_deregister (&cypress_ca42v2_device); }module_init (cypress_init);module_exit (cypress_exit); -MODULE_AUTHOR (DRIVER_AUTHOR ); -MODULE_DESCRIPTION (DRIVER_DESC ); -MODULE_VERSION (DRIVER_VERSION ); +MODULE_AUTHOR (DRIVER_AUTHOR ); +MODULE_DESCRIPTION (DRIVER_DESC ); +MODULE_VERSION (DRIVER_VERSION );MODULE_LICENSE ("GPL" );module_param (debug, bool,S_IRUGO |S_IWUSR );
drivers/usb/serial/cypress_m8.h +1 -1
@@ -54,7 +54,7 @@#define UART_DSR 0x20/* data set ready - flow control - device to host */ #define CONTROL_RTS 0x10/* request to send - flow control - host to device */ #define UART_CTS 0x10/* clear to send - flow control - device to host */ -#define UART_RI 0x10/* ring indicator - modem - device to host */ +#define UART_RI 0x10/* ring indicator - modem - device to host */ #define UART_CD 0x40/* carrier detect - modem - device to host */ #define CYP_ERROR 0x08/* received from input report - device to host */ /* Note - the below has nothing to to with the "feature report" reset */
PATCH 33/70 usb-cypress: There is no 0 case to go with CS5/6/7/8 so remove the test
In reply to Alan CoxFrom: Alan Cox <[email protected]>
---
drivers/usb/serial/cypress_m8.c | 37 +++++++++++++++++-------------------- 1 files changed, 17 insertions(+), 20 deletions(-)
drivers/usb/serial/cypress_m8.c +17 -20
@@ -1093,27 +1093,24 @@ static void cypress_set_termios(struct tty_struct *tty, }else parity_enable = parity_type =0 ; -if (cflag &CSIZE ) { -switch (cflag &CSIZE ) { -case CS5 : - data_bits =0 ; -break ; -case CS6 : - data_bits =1 ; -break ; -case CS7 : - data_bits =2 ; -break ; -case CS8 : - data_bits =3 ; -break ; -default : -err ("%s - CSIZE was set, but not CS5-CS8" , - __func__); - data_bits =3 ; - } else +switch (cflag &CSIZE ) { +case CS5 : + data_bits =0 ; +break ; +case CS6 : + data_bits =1 ; +break ; +case CS7 : + data_bits =2 ; +break ; +case CS8 : data_bits =3 ; - +break ; +default : +err ("%s - CSIZE was set, but not CS5-CS8" , + __func__); + data_bits =3 ; + }spin_lock_irqsave (&priv->lock, flags); oldlines = priv->line_control;if ((cflag &CBAUD ) ==B0 ) {
PATCH 34/70 digi_acceleport: coding style
In reply to Alan CoxFrom: Alan Cox <[email protected]>
Code tidy
---
drivers/usb/serial/digi_acceleport.c | 693 ++++++++++++++++++---------------- 1 files changed, 358 insertions(+), 335 deletions(-)
drivers/usb/serial/digi_acceleport.c +358 -335
@@ -1,237 +1,236 @@/* -* Digi AccelePort USB-4 and USB-2 Serial Converters -* -* Copyright 2000 by Digi International -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* Shamelessly based on Brian Warner's keyspan_pda.c and Greg Kroah-Hartman's -* usb-serial driver. -* -* Peter Berger ([email protected]) -* Al Borchers ([email protected]) -* -* (12/03/2001) gkh -* switched to using port->port.count instead of private version. -* Removed port->active -* -* (04/08/2001) gb -* Identify version on module load. -* -* (11/01/2000) Adam J. Richter -* usb_device_id table support -* -* (11/01/2000) pberger and borchers -* -- Turned off the USB_DISABLE_SPD flag for write bulk urbs--it caused -* USB 4 ports to hang on startup. -* -- Serialized access to write urbs by adding the dp_write_urb_in_use -* flag; otherwise, the driver caused SMP system hangs. Watching the -* urb status is not sufficient. -* -* (10/05/2000) gkh -* -- Fixed bug with urb->dev not being set properly, now that the usb -* core needs it. -* -* (8/8/2000) pberger and borchers -* -- Fixed close so that -* - it can timeout while waiting for transmit idle, if needed; -* - it ignores interrupts when flushing the port, turning -* of modem signalling, and so on; -* - it waits for the flush to really complete before returning. -* -- Read_bulk_callback and write_bulk_callback check for a closed -* port before using the tty struct or writing to the port. -* -- The two changes above fix the oops caused by interrupted closes. -* -- Added interruptible args to write_oob_command and set_modem_signals -* and added a timeout arg to transmit_idle; needed for fixes to -* close. -* -- Added code for rx_throttle and rx_unthrottle so that input flow -* control works. -* -- Added code to set overrun, parity, framing, and break errors -* (untested). -* -- Set USB_DISABLE_SPD flag for write bulk urbs, so no 0 length -* bulk writes are done. These hung the Digi USB device. The -* 0 length bulk writes were a new feature of usb-uhci added in -* the 2.4.0-test6 kernels. -* -- Fixed mod inc race in open; do mod inc before sleeping to wait -* for a close to finish. -* -* (7/31/2000) pberger -* -- Fixed bugs with hardware handshaking: -* - Added code to set/clear tty->hw_stopped in digi_read_oob_callback() -* and digi_set_termios() -* -- Added code in digi_set_termios() to -* - add conditional in code handling transition from B0 to only -* set RTS if RTS/CTS flow control is either not in use or if -* the port is not currently throttled. -* - handle turning off CRTSCTS. -* -* (7/30/2000) borchers -* -- Added support for more than one Digi USB device by moving -* globals to a private structure in the pointed to from the -* usb_serial structure. -* -- Moved the modem change and transmit idle wait queues into -* the port private structure, so each port has its own queue -* rather than sharing global queues. -* -- Added support for break signals. -* -* (7/25/2000) pberger -* -- Added USB-2 support. Note: the USB-2 supports 3 devices: two -* serial and a parallel port. The parallel port is implemented -* as a serial-to-parallel converter. That is, the driver actually -* presents all three USB-2 interfaces as serial ports, but the third -* one physically connects to a parallel device. Thus, for example, -* one could plug a parallel printer into the USB-2's third port, -* but from the kernel's (and userland's) point of view what's -* actually out there is a serial device. -* -* (7/15/2000) borchers -* -- Fixed race in open when a close is in progress. -* -- Keep count of opens and dec the module use count for each -* outstanding open when shutdown is called (on disconnect). -* -- Fixed sanity checks in read_bulk_callback and write_bulk_callback -* so pointers are checked before use. -* -- Split read bulk callback into in band and out of band -* callbacks, and no longer restart read chains if there is -* a status error or a sanity error. This fixed the seg -* faults and other errors we used to get on disconnect. -* -- Port->active is once again a flag as usb-serial intended it -* to be, not a count. Since it was only a char it would -* have been limited to 256 simultaneous opens. Now the open -* count is kept in the port private structure in dp_open_count. -* -- Added code for modularization of the digi_acceleport driver. -* -* (6/27/2000) pberger and borchers -* -- Zeroed out sync field in the wakeup_task before first use; -* otherwise the uninitialized value might prevent the task from -* being scheduled. -* -- Initialized ret value to 0 in write_bulk_callback, otherwise -* the uninitialized value could cause a spurious debugging message. -* -* (6/22/2000) pberger and borchers -* -- Made cond_wait_... inline--apparently on SPARC the flags arg -* to spin_lock_irqsave cannot be passed to another function -* to call spin_unlock_irqrestore. Thanks to Pauline Middelink. -* -- In digi_set_modem_signals the inner nested spin locks use just -* spin_lock() rather than spin_lock_irqsave(). The old code -* mistakenly left interrupts off. Thanks to Pauline Middelink. -* -- copy_from_user (which can sleep) is no longer called while a -* spinlock is held. We copy to a local buffer before getting -* the spinlock--don't like the extra copy but the code is simpler. -* -- Printk and dbg are no longer called while a spin lock is held. -* -* (6/4/2000) pberger and borchers -* -- Replaced separate calls to spin_unlock_irqrestore and -* interruptible_sleep_on_timeout with a new function -* cond_wait_interruptible_timeout_irqrestore. This eliminates -* the race condition where the wake up could happen after -* the unlock and before the sleep. -* -- Close now waits for output to drain. -* -- Open waits until any close in progress is finished. -* -- All out of band responses are now processed, not just the -* first in a USB packet. -* -- Fixed a bug that prevented the driver from working when the -* first Digi port was not the first USB serial port--the driver -* was mistakenly using the external USB serial port number to -* try to index into its internal ports. -* -- Fixed an SMP bug -- write_bulk_callback is called directly from -* an interrupt, so spin_lock_irqsave/spin_unlock_irqrestore are -* needed for locks outside write_bulk_callback that are also -* acquired by write_bulk_callback to prevent deadlocks. -* -- Fixed support for select() by making digi_chars_in_buffer() -* return 256 when -EINPROGRESS is set, as the line discipline -* code in n_tty.c expects. -* -- Fixed an include file ordering problem that prevented debugging -* messages from working. -* -- Fixed an intermittent timeout problem that caused writes to -* sometimes get stuck on some machines on some kernels. It turns -* out in these circumstances write_chan() (in n_tty.c) was -* asleep waiting for our wakeup call. Even though we call -* wake_up_interruptible() in digi_write_bulk_callback(), there is -* a race condition that could cause the wakeup to fail: if our -* wake_up_interruptible() call occurs between the time that our -* driver write routine finishes and write_chan() sets current->state -* to TASK_INTERRUPTIBLE, the effect of our wakeup setting the state -* to TASK_RUNNING will be lost and write_chan's subsequent call to -* schedule() will never return (unless it catches a signal). -* This race condition occurs because write_bulk_callback() (and thus -* the wakeup) are called asynchronously from an interrupt, rather than -* from the scheduler. We can avoid the race by calling the wakeup -* from the scheduler queue and that's our fix: Now, at the end of -* write_bulk_callback() we queue up a wakeup call on the scheduler -* task queue. We still also invoke the wakeup directly since that -* squeezes a bit more performance out of the driver, and any lost -* race conditions will get cleaned up at the next scheduler run. -* -* NOTE: The problem also goes away if you comment out -* the two code lines in write_chan() where current->state -* is set to TASK_RUNNING just before calling driver.write() and to -* TASK_INTERRUPTIBLE immediately afterwards. This is why the -* problem did not show up with the 2.2 kernels -- they do not -* include that code. -* -* (5/16/2000) pberger and borchers -* -- Added timeouts to sleeps, to defend against lost wake ups. -* -- Handle transition to/from B0 baud rate in digi_set_termios. -* -* (5/13/2000) pberger and borchers -* -- All commands now sent on out of band port, using -* digi_write_oob_command. -* -- Get modem control signals whenever they change, support TIOCMGET/ -* SET/BIS/BIC ioctls. -* -- digi_set_termios now supports parity, word size, stop bits, and -* receive enable. -* -- Cleaned up open and close, use digi_set_termios and -* digi_write_oob_command to set port parameters. -* -- Added digi_startup_device to start read chains on all ports. -* -- Write buffer is only used when count==1, to be sure put_char can -* write a char (unless the buffer is full). -* -* (5/10/2000) pberger and borchers -* -- Added MOD_INC_USE_COUNT/MOD_DEC_USE_COUNT calls on open/close. -* -- Fixed problem where the first incoming character is lost on -* port opens after the first close on that port. Now we keep -* the read_urb chain open until shutdown. -* -- Added more port conditioning calls in digi_open and digi_close. -* -- Convert port->active to a use count so that we can deal with multiple -* opens and closes properly. -* -- Fixed some problems with the locking code. -* -* (5/3/2000) pberger and borchers -* -- First alpha version of the driver--many known limitations and bugs. -* -* -* Locking and SMP -* -* - Each port, including the out-of-band port, has a lock used to -* serialize all access to the port's private structure. -* - The port lock is also used to serialize all writes and access to -* the port's URB. -* - The port lock is also used for the port write_wait condition -* variable. Holding the port lock will prevent a wake up on the -* port's write_wait; this can be used with cond_wait_... to be sure -* the wake up is not lost in a race when dropping the lock and -* sleeping waiting for the wakeup. -* - digi_write() does not sleep, since it is sometimes called on -* interrupt time. -* - digi_write_bulk_callback() and digi_read_bulk_callback() are -* called directly from interrupts. Hence spin_lock_irqsave() -* and spin_unlock_irqrestore() are used in the rest of the code -* for any locks they acquire. -* - digi_write_bulk_callback() gets the port lock before waking up -* processes sleeping on the port write_wait. It also schedules -* wake ups so they happen from the scheduler, because the tty -* system can miss wake ups from interrupts. -* - All sleeps use a timeout of DIGI_RETRY_TIMEOUT before looping to -* recheck the condition they are sleeping on. This is defensive, -* in case a wake up is lost. -* - Following Documentation/DocBook/kernel-locking.pdf no spin locks -* are held when calling copy_to/from_user or printk. -* -* $Id: digi_acceleport.c,v 1.80.1.2 2000/11/02 05:45:08 root Exp $ -*/ +* Digi AccelePort USB-4 and USB-2 Serial Converters +* +* Copyright 2000 by Digi International +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* Shamelessly based on Brian Warner's keyspan_pda.c and Greg Kroah-Hartman's +* usb-serial driver. +* +* Peter Berger ([email protected]) +* Al Borchers ([email protected]) +* +* (12/03/2001) gkh +* switched to using port->port.count instead of private version. +* Removed port->active +* +* (04/08/2001) gb +* Identify version on module load. +* +* (11/01/2000) Adam J. Richter +* usb_device_id table support +* +* (11/01/2000) pberger and borchers +* -- Turned off the USB_DISABLE_SPD flag for write bulk urbs--it caused +* USB 4 ports to hang on startup. +* -- Serialized access to write urbs by adding the dp_write_urb_in_use +* flag; otherwise, the driver caused SMP system hangs. Watching the +* urb status is not sufficient. +* +* (10/05/2000) gkh +* -- Fixed bug with urb->dev not being set properly, now that the usb +* core needs it. +* +* (8/8/2000) pberger and borchers +* -- Fixed close so that +* - it can timeout while waiting for transmit idle, if needed; +* - it ignores interrupts when flushing the port, turning +* of modem signalling, and so on; +* - it waits for the flush to really complete before returning. +* -- Read_bulk_callback and write_bulk_callback check for a closed +* port before using the tty struct or writing to the port. +* -- The two changes above fix the oops caused by interrupted closes. +* -- Added interruptible args to write_oob_command and set_modem_signals +* and added a timeout arg to transmit_idle; needed for fixes to +* close. +* -- Added code for rx_throttle and rx_unthrottle so that input flow +* control works. +* -- Added code to set overrun, parity, framing, and break errors +* (untested). +* -- Set USB_DISABLE_SPD flag for write bulk urbs, so no 0 length +* bulk writes are done. These hung the Digi USB device. The +* 0 length bulk writes were a new feature of usb-uhci added in +* the 2.4.0-test6 kernels. +* -- Fixed mod inc race in open; do mod inc before sleeping to wait +* for a close to finish. +* +* (7/31/2000) pberger +* -- Fixed bugs with hardware handshaking: +* - Added code to set/clear tty->hw_stopped in digi_read_oob_callback() +* and digi_set_termios() +* -- Added code in digi_set_termios() to +* - add conditional in code handling transition from B0 to only +* set RTS if RTS/CTS flow control is either not in use or if +* the port is not currently throttled. +* - handle turning off CRTSCTS. +* +* (7/30/2000) borchers +* -- Added support for more than one Digi USB device by moving +* globals to a private structure in the pointed to from the +* usb_serial structure. +* -- Moved the modem change and transmit idle wait queues into +* the port private structure, so each port has its own queue +* rather than sharing global queues. +* -- Added support for break signals. +* +* (7/25/2000) pberger +* -- Added USB-2 support. Note: the USB-2 supports 3 devices: two +* serial and a parallel port. The parallel port is implemented +* as a serial-to-parallel converter. That is, the driver actually +* presents all three USB-2 interfaces as serial ports, but the third +* one physically connects to a parallel device. Thus, for example, +* one could plug a parallel printer into the USB-2's third port, +* but from the kernel's (and userland's) point of view what's +* actually out there is a serial device. +* +* (7/15/2000) borchers +* -- Fixed race in open when a close is in progress. +* -- Keep count of opens and dec the module use count for each +* outstanding open when shutdown is called (on disconnect). +* -- Fixed sanity checks in read_bulk_callback and write_bulk_callback +* so pointers are checked before use. +* -- Split read bulk callback into in band and out of band +* callbacks, and no longer restart read chains if there is +* a status error or a sanity error. This fixed the seg +* faults and other errors we used to get on disconnect. +* -- Port->active is once again a flag as usb-serial intended it +* to be, not a count. Since it was only a char it would +* have been limited to 256 simultaneous opens. Now the open +* count is kept in the port private structure in dp_open_count. +* -- Added code for modularization of the digi_acceleport driver. +* +* (6/27/2000) pberger and borchers +* -- Zeroed out sync field in the wakeup_task before first use; +* otherwise the uninitialized value might prevent the task from +* being scheduled. +* -- Initialized ret value to 0 in write_bulk_callback, otherwise +* the uninitialized value could cause a spurious debugging message. +* +* (6/22/2000) pberger and borchers +* -- Made cond_wait_... inline--apparently on SPARC the flags arg +* to spin_lock_irqsave cannot be passed to another function +* to call spin_unlock_irqrestore. Thanks to Pauline Middelink. +* -- In digi_set_modem_signals the inner nested spin locks use just +* spin_lock() rather than spin_lock_irqsave(). The old code +* mistakenly left interrupts off. Thanks to Pauline Middelink. +* -- copy_from_user (which can sleep) is no longer called while a +* spinlock is held. We copy to a local buffer before getting +* the spinlock--don't like the extra copy but the code is simpler. +* -- Printk and dbg are no longer called while a spin lock is held. +* +* (6/4/2000) pberger and borchers +* -- Replaced separate calls to spin_unlock_irqrestore and +* interruptible_sleep_on_timeout with a new function +* cond_wait_interruptible_timeout_irqrestore. This eliminates +* the race condition where the wake up could happen after +* the unlock and before the sleep. +* -- Close now waits for output to drain. +* -- Open waits until any close in progress is finished. +* -- All out of band responses are now processed, not just the +* first in a USB packet. +* -- Fixed a bug that prevented the driver from working when the +* first Digi port was not the first USB serial port--the driver +* was mistakenly using the external USB serial port number to +* try to index into its internal ports. +* -- Fixed an SMP bug -- write_bulk_callback is called directly from +* an interrupt, so spin_lock_irqsave/spin_unlock_irqrestore are +* needed for locks outside write_bulk_callback that are also +* acquired by write_bulk_callback to prevent deadlocks. +* -- Fixed support for select() by making digi_chars_in_buffer() +* return 256 when -EINPROGRESS is set, as the line discipline +* code in n_tty.c expects. +* -- Fixed an include file ordering problem that prevented debugging +* messages from working. +* -- Fixed an intermittent timeout problem that caused writes to +* sometimes get stuck on some machines on some kernels. It turns +* out in these circumstances write_chan() (in n_tty.c) was +* asleep waiting for our wakeup call. Even though we call +* wake_up_interruptible() in digi_write_bulk_callback(), there is +* a race condition that could cause the wakeup to fail: if our +* wake_up_interruptible() call occurs between the time that our +* driver write routine finishes and write_chan() sets current->state +* to TASK_INTERRUPTIBLE, the effect of our wakeup setting the state +* to TASK_RUNNING will be lost and write_chan's subsequent call to +* schedule() will never return (unless it catches a signal). +* This race condition occurs because write_bulk_callback() (and thus +* the wakeup) are called asynchronously from an interrupt, rather than +* from the scheduler. We can avoid the race by calling the wakeup +* from the scheduler queue and that's our fix: Now, at the end of +* write_bulk_callback() we queue up a wakeup call on the scheduler +* task queue. We still also invoke the wakeup directly since that +* squeezes a bit more performance out of the driver, and any lost +* race conditions will get cleaned up at the next scheduler run. +* +* NOTE: The problem also goes away if you comment out +* the two code lines in write_chan() where current->state +* is set to TASK_RUNNING just before calling driver.write() and to +* TASK_INTERRUPTIBLE immediately afterwards. This is why the +* problem did not show up with the 2.2 kernels -- they do not +* include that code. +* +* (5/16/2000) pberger and borchers +* -- Added timeouts to sleeps, to defend against lost wake ups. +* -- Handle transition to/from B0 baud rate in digi_set_termios. +* +* (5/13/2000) pberger and borchers +* -- All commands now sent on out of band port, using +* digi_write_oob_command. +* -- Get modem control signals whenever they change, support TIOCMGET/ +* SET/BIS/BIC ioctls. +* -- digi_set_termios now supports parity, word size, stop bits, and +* receive enable. +* -- Cleaned up open and close, use digi_set_termios and +* digi_write_oob_command to set port parameters. +* -- Added digi_startup_device to start read chains on all ports. +* -- Write buffer is only used when count==1, to be sure put_char can +* write a char (unless the buffer is full). +* +* (5/10/2000) pberger and borchers +* -- Added MOD_INC_USE_COUNT/MOD_DEC_USE_COUNT calls on open/close. +* -- Fixed problem where the first incoming character is lost on +* port opens after the first close on that port. Now we keep +* the read_urb chain open until shutdown. +* -- Added more port conditioning calls in digi_open and digi_close. +* -- Convert port->active to a use count so that we can deal with multiple +* opens and closes properly. +* -- Fixed some problems with the locking code. +* +* (5/3/2000) pberger and borchers +* -- First alpha version of the driver--many known limitations and bugs. +* +* +* Locking and SMP +* +* - Each port, including the out-of-band port, has a lock used to +* serialize all access to the port's private structure. +* - The port lock is also used to serialize all writes and access to +* the port's URB. +* - The port lock is also used for the port write_wait condition +* variable. Holding the port lock will prevent a wake up on the +* port's write_wait; this can be used with cond_wait_... to be sure +* the wake up is not lost in a race when dropping the lock and +* sleeping waiting for the wakeup. +* - digi_write() does not sleep, since it is sometimes called on +* interrupt time. +* - digi_write_bulk_callback() and digi_read_bulk_callback() are +* called directly from interrupts. Hence spin_lock_irqsave() +* and spin_unlock_irqrestore() are used in the rest of the code +* for any locks they acquire. +* - digi_write_bulk_callback() gets the port lock before waking up +* processes sleeping on the port write_wait. It also schedules +* wake ups so they happen from the scheduler, because the tty +* system can miss wake ups from interrupts. +* - All sleeps use a timeout of DIGI_RETRY_TIMEOUT before looping to +* recheck the condition they are sleeping on. This is defensive, +* in case a wake up is lost. +* - Following Documentation/DocBook/kernel-locking.pdf no spin locks +* are held when calling copy_to/from_user or printk. +* +*/ #include <linux/kernel.h> #include <linux/errno.h>
@@ -243,7 +242,7 @@#include <linux/module.h> #include <linux/spinlock.h> #include <linux/workqueue.h> -#include <asm/uaccess.h> +#include <linux/uaccess.h> #include <linux/usb.h> #include <linux/wait.h> #include <linux/usb/serial.h>
@@ -443,8 +442,8 @@ static int digi_set_modem_signals(struct usb_serial_port *port, unsigned int modem_signals, int interruptible);static int digi_transmit_idle (struct usb_serial_port *port,unsigned long timeout); -static void digi_rx_throttle (struct tty_struct *tty); -static void digi_rx_unthrottle (struct tty_struct *tty); +static void digi_rx_throttle (struct tty_struct *tty); +static void digi_rx_unthrottle (struct tty_struct *tty);static void digi_set_termios (struct tty_struct *tty,struct usb_serial_port *port,struct ktermios *old_termios);static void digi_break_ctl (struct tty_struct *tty,int break_state);
@@ -488,7 +487,7 @@ static struct usb_device_id id_table_4 [] = { { }/* Terminating entry */ }; -MODULE_DEVICE_TABLE (usb, id_table_combined); +MODULE_DEVICE_TABLE (usb, id_table_combined);static struct usb_driver digi_driver = { .name ="digi_acceleport" ,
@@ -593,7 +592,8 @@ static long cond_wait_interruptible_timeout_irqrestore(static void digi_wakeup_write_lock (struct work_struct *work) { - struct digi_port *priv = container_of(work, struct digi_port, dp_wakeup_work); +struct digi_port *priv = + container_of(work, struct digi_port, dp_wakeup_work);struct usb_serial_port *port = priv->dp_port;unsigned long flags;
@@ -632,8 +632,8 @@ static int digi_write_oob_command(struct usb_serial_port *port,dbg ("digi_write_oob_command: TOP: port=%d, count=%d" , oob_priv->dp_port_num, count);spin_lock_irqsave (&oob_priv->dp_port_lock, flags); -while (count >0 ) { -while (oob_port->write_urb->status == -EINPROGRESS +while (count >0 ) { +while (oob_port->write_urb->status == -EINPROGRESS || oob_priv->dp_write_urb_in_use) { cond_wait_interruptible_timeout_irqrestore( &oob_port->write_wait, DIGI_RETRY_TIMEOUT,
@@ -650,7 +650,8 @@ static int digi_write_oob_command(struct usb_serial_port *port,memcpy (oob_port->write_urb->transfer_buffer, buf, len); oob_port->write_urb->transfer_buffer_length = len; oob_port->write_urb->dev = port->serial->dev; -if ((ret =usb_submit_urb (oob_port->write_urb,GFP_ATOMIC )) ==0 ) { + ret =usb_submit_urb (oob_port->write_urb,GFP_ATOMIC ); +if (ret ==0 ) { oob_priv->dp_write_urb_in_use =1 ; count -= len; buf += len;
@@ -694,9 +695,10 @@ static int digi_write_inb_command(struct usb_serial_port *port, timeout =ULONG_MAX ;spin_lock_irqsave (&priv->dp_port_lock, flags); -while (count >0 && ret ==0 ) { -while ((port->write_urb->status == -EINPROGRESS - || priv->dp_write_urb_in_use) &&time_before (jiffies, timeout)) { +while (count >0 && ret ==0 ) { +while ((port->write_urb->status == -EINPROGRESS + || priv->dp_write_urb_in_use) + &&time_before (jiffies, timeout)) {cond_wait_interruptible_timeout_irqrestore ( &port->write_wait,DIGI_RETRY_TIMEOUT , &priv->dp_port_lock, flags);
@@ -727,7 +729,8 @@ static int digi_write_inb_command(struct usb_serial_port *port, } port->write_urb->dev = port->serial->dev; -if ((ret =usb_submit_urb (port->write_urb,GFP_ATOMIC )) ==0 ) { + ret =usb_submit_urb (port->write_urb,GFP_ATOMIC ); +if (ret ==0 ) { priv->dp_write_urb_in_use =1 ; priv->dp_out_buf_len =0 ; count -= len;
@@ -760,7 +763,7 @@ static int digi_set_modem_signals(struct usb_serial_port *port,int ret;struct digi_port *port_priv =usb_get_serial_port_data (port); -struct usb_serial_port *oob_port = (struct usb_serial_port *)((struct digi_serial *)(usb_get_serial_data (port->serial)))->ds_oob_port; +struct usb_serial_port *oob_port = (struct usb_serial_port *) ((struct digi_serial *)(usb_get_serial_data (port->serial)))->ds_oob_port;struct digi_port *oob_priv =usb_get_serial_port_data (oob_port);unsigned char *data = oob_port->write_urb->transfer_buffer;unsigned long flags =0 ;
@@ -772,7 +775,8 @@ static int digi_set_modem_signals(struct usb_serial_port *port,spin_lock_irqsave (&oob_priv->dp_port_lock, flags);spin_lock (&port_priv->dp_port_lock); -while (oob_port->write_urb->status == -EINPROGRESS || oob_priv->dp_write_urb_in_use) { +while (oob_port->write_urb->status == -EINPROGRESS || + oob_priv->dp_write_urb_in_use) {spin_unlock (&port_priv->dp_port_lock); cond_wait_interruptible_timeout_irqrestore( &oob_port->write_wait, DIGI_RETRY_TIMEOUT,
@@ -784,17 +788,20 @@ static int digi_set_modem_signals(struct usb_serial_port *port, } data[0 ] =DIGI_CMD_SET_DTR_SIGNAL ; data[1 ] = port_priv->dp_port_num; - data[2 ] = (modem_signals&TIOCM_DTR ) ?DIGI_DTR_ACTIVE :DIGI_DTR_INACTIVE ; + data[2 ] = (modem_signals &TIOCM_DTR ) ? +DIGI_DTR_ACTIVE :DIGI_DTR_INACTIVE ; data[3 ] =0 ; data[4 ] =DIGI_CMD_SET_RTS_SIGNAL ; data[5 ] = port_priv->dp_port_num; - data[6 ] = (modem_signals&TIOCM_RTS ) ?DIGI_RTS_ACTIVE :DIGI_RTS_INACTIVE ; + data[6 ] = (modem_signals &TIOCM_RTS ) ? +DIGI_RTS_ACTIVE :DIGI_RTS_INACTIVE ; data[7 ] =0 ; oob_port->write_urb->transfer_buffer_length =8 ; oob_port->write_urb->dev = port->serial->dev; -if ((ret =usb_submit_urb (oob_port->write_urb,GFP_ATOMIC )) ==0 ) { + ret =usb_submit_urb (oob_port->write_urb,GFP_ATOMIC ); +if (ret ==0 ) { oob_priv->dp_write_urb_in_use =1 ; port_priv->dp_modem_signals = (port_priv->dp_modem_signals&~(TIOCM_DTR |TIOCM_RTS ))
@@ -836,12 +843,13 @@ static int digi_transmit_idle(struct usb_serial_port *port, timeout += jiffies; -if ((ret =digi_write_inb_command (port, buf,2 , timeout - jiffies)) !=0 ) + ret =digi_write_inb_command (port, buf,2 , timeout - jiffies); +if (ret !=0 )return ret;spin_lock_irqsave (&priv->dp_port_lock, flags); -while (time_before (jiffies, timeout) && !priv->dp_transmit_idle) { +while (time_before (jiffies, timeout) && !priv->dp_transmit_idle) {cond_wait_interruptible_timeout_irqrestore ( &priv->dp_transmit_idle_wait,DIGI_RETRY_TIMEOUT , &priv->dp_port_lock, flags);
@@ -902,7 +910,7 @@ static void digi_rx_unthrottle(struct tty_struct *tty) } -static void digi_set_termios (struct tty_struct *tty, +static void digi_set_termios (struct tty_struct *tty,struct usb_serial_port *port,struct ktermios *old_termios) {struct digi_port *priv =usb_get_serial_port_data (port);
@@ -912,14 +920,15 @@ static void digi_set_termios(struct tty_struct *tty,unsigned int old_cflag = old_termios->c_cflag;unsigned char buf[32 ];unsigned int modem_signals; -int arg,ret; +int arg, ret;int i =0 ;speed_t baud;dbg ("digi_set_termios: TOP: port=%d, iflag=0x%x, old_iflag=0x%x, cflag=0x%x, old_cflag=0x%x" , priv->dp_port_num, iflag, old_iflag, cflag, old_cflag);/* set baud rate */ -if ((baud =tty_get_baud_rate (tty)) !=tty_termios_baud_rate (old_termios)) { + baud =tty_get_baud_rate (tty); +if (baud !=tty_termios_baud_rate (old_termios)) { arg =-1 ;/* reassert DTR and (maybe) RTS on transition from B0 */
@@ -933,30 +942,30 @@ static void digi_set_termios(struct tty_struct *tty,digi_set_modem_signals (port, modem_signals,1 ); }switch (baud) { -/* drop DTR and RTS on transition to B0 */ -case 0 :digi_set_modem_signals (port,0 ,1 );break ; -case 50 : arg =DIGI_BAUD_50 ;break ; -case 75 : arg =DIGI_BAUD_75 ;break ; -case 110 : arg =DIGI_BAUD_110 ;break ; -case 150 : arg =DIGI_BAUD_150 ;break ; -case 200 : arg =DIGI_BAUD_200 ;break ; -case 300 : arg =DIGI_BAUD_300 ;break ; -case 600 : arg =DIGI_BAUD_600 ;break ; -case 1200 : arg =DIGI_BAUD_1200 ;break ; -case 1800 : arg =DIGI_BAUD_1800 ;break ; -case 2400 : arg =DIGI_BAUD_2400 ;break ; -case 4800 : arg =DIGI_BAUD_4800 ;break ; -case 9600 : arg =DIGI_BAUD_9600 ;break ; -case 19200 : arg =DIGI_BAUD_19200 ;break ; -case 38400 : arg =DIGI_BAUD_38400 ;break ; -case 57600 : arg =DIGI_BAUD_57600 ;break ; -case 115200 : arg =DIGI_BAUD_115200 ;break ; -case 230400 : arg =DIGI_BAUD_230400 ;break ; -case 460800 : arg =DIGI_BAUD_460800 ;break ; -default : - arg =DIGI_BAUD_9600 ; - baud =9600 ; -break ; +/* drop DTR and RTS on transition to B0 */ +case 0 :digi_set_modem_signals (port,0 ,1 );break ; +case 50 : arg =DIGI_BAUD_50 ;break ; +case 75 : arg =DIGI_BAUD_75 ;break ; +case 110 : arg =DIGI_BAUD_110 ;break ; +case 150 : arg =DIGI_BAUD_150 ;break ; +case 200 : arg =DIGI_BAUD_200 ;break ; +case 300 : arg =DIGI_BAUD_300 ;break ; +case 600 : arg =DIGI_BAUD_600 ;break ; +case 1200 : arg =DIGI_BAUD_1200 ;break ; +case 1800 : arg =DIGI_BAUD_1800 ;break ; +case 2400 : arg =DIGI_BAUD_2400 ;break ; +case 4800 : arg =DIGI_BAUD_4800 ;break ; +case 9600 : arg =DIGI_BAUD_9600 ;break ; +case 19200 : arg =DIGI_BAUD_19200 ;break ; +case 38400 : arg =DIGI_BAUD_38400 ;break ; +case 57600 : arg =DIGI_BAUD_57600 ;break ; +case 115200 : arg =DIGI_BAUD_115200 ;break ; +case 230400 : arg =DIGI_BAUD_230400 ;break ; +case 460800 : arg =DIGI_BAUD_460800 ;break ; +default : + arg =DIGI_BAUD_9600 ; + baud =9600 ; +break ; }if (arg !=-1 ) { buf[i++] =DIGI_CMD_SET_BAUD_RATE ;
@@ -1082,7 +1091,8 @@ static void digi_set_termios(struct tty_struct *tty, buf[i++] = arg; buf[i++] =0 ; } -if ((ret =digi_write_oob_command (port, buf, i,1 )) !=0 ) + ret =digi_write_oob_command (port, buf, i,1 ); +if (ret !=0 )dbg ("digi_set_termios: write oob failed, ret=%d" , ret);tty_encode_baud_rate (tty, baud, baud); }
@@ -1138,7 +1148,7 @@ static int digi_write(struct tty_struct *tty, struct usb_serial_port *port, const unsigned char *buf, int count) { - int ret,data_len,new_len; + int ret, data_len, new_len;struct digi_port *priv =usb_get_serial_port_data (port);unsigned char *data = port->write_urb->transfer_buffer;unsigned long flags =0 ;
@@ -1156,7 +1166,8 @@ static int digi_write(struct tty_struct *tty, struct usb_serial_port *port,spin_lock_irqsave (&priv->dp_port_lock, flags);/* wait for urb status clear to submit another urb */ -if (port->write_urb->status == -EINPROGRESS || priv->dp_write_urb_in_use) { +if (port->write_urb->status == -EINPROGRESS || + priv->dp_write_urb_in_use) {/* buffer data if count is 1 (probably put_char) if possible */ if (count ==1 && priv->dp_out_buf_len <DIGI_OUT_BUF_SIZE ) { priv->dp_out_buf[priv->dp_out_buf_len++] = *buf;
@@ -1191,7 +1202,8 @@ static int digi_write(struct tty_struct *tty, struct usb_serial_port *port,/* copy in new data */ memcpy (data, buf, new_len); -if ((ret =usb_submit_urb (port->write_urb,GFP_ATOMIC )) ==0 ) { + ret =usb_submit_urb (port->write_urb,GFP_ATOMIC ); +if (ret ==0 ) { priv->dp_write_urb_in_use =1 ; ret = new_len; priv->dp_out_buf_len =0 ;
@@ -1205,7 +1217,7 @@ static int digi_write(struct tty_struct *tty, struct usb_serial_port *port,dbg ("digi_write: returning %d" , ret);return ret; -} +}static void digi_write_bulk_callback (struct urb *urb) {
@@ -1220,13 +1232,13 @@ static void digi_write_bulk_callback(struct urb *urb)dbg ("digi_write_bulk_callback: TOP, urb->status=%d" , status);/* port and serial sanity check */ -if (port ==NULL || (priv=usb_get_serial_port_data (port)) ==NULL ) { +if (port ==NULL || (priv =usb_get_serial_port_data (port)) ==NULL ) {err ("%s: port or port->private is NULL, status=%d" , __func__, status);return ; } serial = port->serial; -if (serial ==NULL || (serial_priv=usb_get_serial_data (serial)) ==NULL ) { +if (serial ==NULL || (serial_priv =usb_get_serial_data (serial)) ==NULL ) {err ("%s: serial or serial->private is NULL, status=%d" , __func__, status);return ;
@@ -1249,13 +1261,15 @@ static void digi_write_bulk_callback(struct urb *urb) && priv->dp_out_buf_len > 0) { *((unsigned char *)(port->write_urb->transfer_buffer)) = (unsigned char )DIGI_CMD_SEND_DATA ; - *((unsigned char *)(port->write_urb->transfer_buffer)+1 ) + *((unsigned char *)(port->write_urb->transfer_buffer) +1 ) = (unsigned char )priv->dp_out_buf_len; - port->write_urb->transfer_buffer_length = priv->dp_out_buf_len+2 ; + port->write_urb->transfer_buffer_length = + priv->dp_out_buf_len +2 ; port->write_urb->dev = serial->dev; -memcpy (port->write_urb->transfer_buffer+2 , priv->dp_out_buf, +memcpy (port->write_urb->transfer_buffer +2 , priv->dp_out_buf, priv->dp_out_buf_len); -if ((ret =usb_submit_urb (port->write_urb,GFP_ATOMIC )) ==0 ) { + ret =usb_submit_urb (port->write_urb,GFP_ATOMIC ); +if (ret ==0 ) { priv->dp_write_urb_in_use =1 ; priv->dp_out_buf_len =0 ; }
@@ -1281,7 +1295,8 @@ static int digi_write_room(struct tty_struct *tty)spin_lock_irqsave (&priv->dp_port_lock, flags); -if (port->write_urb->status == -EINPROGRESS || priv->dp_write_urb_in_use) +if (port->write_urb->status == -EINPROGRESS || + priv->dp_write_urb_in_use) room =0 ;else room = port->bulk_out_size -2 - priv->dp_out_buf_len;
@@ -1337,7 +1352,7 @@ static int digi_open(struct tty_struct *tty, struct usb_serial_port *port, }/* wait for a close in progress to finish */ -while (priv->dp_in_close) { +while (priv->dp_in_close) {cond_wait_interruptible_timeout_irqrestore ( &priv->dp_close_wait,DIGI_RETRY_TIMEOUT , &priv->dp_port_lock, flags);
@@ -1347,7 +1362,7 @@ static int digi_open(struct tty_struct *tty, struct usb_serial_port *port, }spin_unlock_irqrestore (&priv->dp_port_lock, flags); - +/* read modem signals automatically whenever they change */ buf[0 ] =DIGI_CMD_READ_INPUT_SIGNALS ; buf[1 ] = priv->dp_port_num;
@@ -1360,7 +1375,8 @@ static int digi_open(struct tty_struct *tty, struct usb_serial_port *port, buf[6 ] =DIGI_FLUSH_TX |DIGI_FLUSH_RX ; buf[7 ] =0 ; -if ((ret =digi_write_oob_command (port, buf,8 ,1 )) !=0 ) + ret =digi_write_oob_command (port, buf,8 ,1 ); +if (ret !=0 )dbg ("digi_open: write oob failed, ret=%d" , ret);/* set termios settings */
@@ -1411,9 +1427,8 @@ static void digi_close(struct tty_struct *tty, struct usb_serial_port *port,if (port->serial->dev) {/* wait for transmit idle */ -if ((filp->f_flags&(O_NDELAY |O_NONBLOCK )) ==0 ) { +if ((filp->f_flags&(O_NDELAY |O_NONBLOCK )) ==0 )digi_transmit_idle (port,DIGI_CLOSE_TIMEOUT ); - }/* drop DTR and RTS */ digi_set_modem_signals (port,0 ,0 );
@@ -1447,11 +1462,13 @@ static void digi_close(struct tty_struct *tty, struct usb_serial_port *port, buf[18 ] =DIGI_FLUSH_TX |DIGI_FLUSH_RX ; buf[19 ] =0 ; -if ((ret =digi_write_oob_command (port, buf,20 ,0 )) !=0 ) + ret =digi_write_oob_command (port, buf,20 ,0 ); +if (ret !=0 )dbg ("digi_close: write oob failed, ret=%d" , ret);/* wait for final commands on oob port to complete */ -prepare_to_wait (&priv->dp_flush_wait, &wait,TASK_INTERRUPTIBLE ); +prepare_to_wait (&priv->dp_flush_wait, &wait, +TASK_INTERRUPTIBLE );schedule_timeout (DIGI_CLOSE_TIMEOUT );finish_wait (&priv->dp_flush_wait, &wait);
@@ -1479,7 +1496,7 @@ exit:static int digi_startup_device (struct usb_serial *serial) { -int i,ret =0 ; +int i, ret =0 ;struct digi_serial *serial_priv =usb_get_serial_data (serial);struct usb_serial_port *port;
@@ -1497,7 +1514,8 @@ static int digi_startup_device(struct usb_serial *serial)for (i =0 ; i < serial->type->num_ports +1 ; i++) { port = serial->port[i]; port->write_urb->dev = port->serial->dev; -if ((ret =usb_submit_urb (port->read_urb,GFP_KERNEL )) !=0 ) { + ret =usb_submit_urb (port->read_urb,GFP_KERNEL ); +if (ret !=0 ) {err ("%s: usb_submit_urb failed, ret=%d, port=%d" , __func__, ret, i);break ;
@@ -1518,7 +1536,7 @@ static int digi_startup(struct usb_serial *serial)/* allocate the private data structures for all ports */ /* number of regular ports + 1 for the out-of-band port */ -for (i =0 ; i < serial->type->num_ports +1 ; i++) { +for (i =0 ; i < serial->type->num_ports +1 ; i++) {/* allocate port private structure */ priv =kmalloc (sizeof (struct digi_port ),GFP_KERNEL );if (priv ==NULL ) {
@@ -1581,7 +1599,7 @@ static void digi_shutdown(struct usb_serial *serial)/* free the private data structures for all ports */ /* number of regular ports + 1 for the out-of-band port */ -for (i =0 ; i < serial->type->num_ports +1 ; i++) +for (i =0 ; i < serial->type->num_ports +1 ; i++)kfree (usb_get_serial_port_data (serial->port[i]));kfree (usb_get_serial_data (serial)); }
@@ -1604,7 +1622,7 @@ static void digi_read_bulk_callback(struct urb *urb)return ; }if (port->serial ==NULL || - (serial_priv=usb_get_serial_data (port->serial)) ==NULL ) { + (serial_priv =usb_get_serial_data (port->serial)) ==NULL ) {err ("%s: serial is bad or serial->private is NULL, status=%d" , __func__, status);return ;
@@ -1628,22 +1646,23 @@ static void digi_read_bulk_callback(struct urb *urb)/* continue read */ urb->dev = port->serial->dev; -if ((ret =usb_submit_urb (urb,GFP_ATOMIC )) !=0 ) { + ret =usb_submit_urb (urb,GFP_ATOMIC ); +if (ret !=0 ) {err ("%s: failed resubmitting urb, ret=%d, port=%d" , __func__, ret, priv->dp_port_num); } } -/* -* Digi Read INB Callback -* -* Digi Read INB Callback handles reads on the in band ports, sending -* the data on to the tty subsystem. When called we know port and -* port->private are not NULL and port->serial has been validated. -* It returns 0 if successful, 1 if successful but the port is -* throttled, and -1 if the sanity checks failed. -*/ +/* +* Digi Read INB Callback +* +* Digi Read INB Callback handles reads on the in band ports, sending +* the data on to the tty subsystem. When called we know port and +* port->private are not NULL and port->serial has been validated. +* It returns 0 if successful, 1 if successful but the port is +* throttled, and -1 if the sanity checks failed. +*/ static int digi_read_inb_callback (struct urb *urb) {
@@ -1654,8 +1673,8 @@ static int digi_read_inb_callback(struct urb *urb)int opcode = ((unsigned char *)urb->transfer_buffer)[0 ];int len = ((unsigned char *)urb->transfer_buffer)[1 ];int port_status = ((unsigned char *)urb->transfer_buffer)[2 ]; -unsigned char *data = ((unsigned char *)urb->transfer_buffer)+3 ; -int flag,throttled; +unsigned char *data = ((unsigned char *)urb->transfer_buffer) +3 ; +int flag, throttled;int i;int status = urb->status;
@@ -1666,7 +1685,7 @@ static int digi_read_inb_callback(struct urb *urb)/* short/multiple packet check */ if (urb->actual_length != len +2 ) { -err ("%s: INCOMPLETE OR MULTIPLE PACKET, urb->status=%d, " +err ("%s: INCOMPLETE OR MULTIPLE PACKET, urb->status=%d, " "port=%d, opcode=%d, len=%d, actual_length=%d, " "status=%d" , __func__, status, priv->dp_port_num, opcode, len, urb->actual_length, port_status);
@@ -1708,8 +1727,9 @@ static int digi_read_inb_callback(struct urb *urb)if (flag ==TTY_NORMAL )tty_insert_flip_string (tty, data, len);else { -for (i =0 ; i < len; i++) -tty_insert_flip_char (tty, data[i], flag); +for (i =0 ; i < len; i++) +tty_insert_flip_char (tty, + data[i], flag); }tty_flip_buffer_push (tty); }
@@ -1721,19 +1741,19 @@ static int digi_read_inb_callback(struct urb *urb)else if (opcode !=DIGI_CMD_RECEIVE_DATA )dbg ("%s: unknown opcode: %d" , __func__, opcode); -return (throttled ?1 :0 ); +return throttled ?1 :0 ; } -/* -* Digi Read OOB Callback -* -* Digi Read OOB Callback handles reads on the out of band port. -* When called we know port and port->private are not NULL and -* the port->serial is valid. It returns 0 if successful, and -* -1 if the sanity checks failed. -*/ +/* +* Digi Read OOB Callback +* +* Digi Read OOB Callback handles reads on the out of band port. +* When called we know port and port->private are not NULL and +* the port->serial is valid. It returns 0 if successful, and +* -1 if the sanity checks failed. +*/ static int digi_read_oob_callback (struct urb *urb) {
@@ -1743,12 +1763,13 @@ static int digi_read_oob_callback(struct urb *urb)struct digi_port *priv =usb_get_serial_port_data (port);int opcode, line, status, val;int i; +unsigned int rts;dbg ("digi_read_oob_callback: port=%d, len=%d" , priv->dp_port_num, urb->actual_length);/* handle each oob command */ -for (i =0 ; i < urb->actual_length -3 ;) { +for (i =0 ; i < urb->actual_length -3 ;) { opcode = ((unsigned char *)urb->transfer_buffer)[i++]; line = ((unsigned char *)urb->transfer_buffer)[i++]; status = ((unsigned char *)urb->transfer_buffer)[i++];
@@ -1762,27 +1783,29 @@ static int digi_read_oob_callback(struct urb *urb) port = serial->port[line]; -if ((priv=usb_get_serial_port_data (port)) ==NULL ) + priv =usb_get_serial_port_data (port); +if (priv ==NULL )return -1 ; + rts =0 ; +if (port->port.count) + rts = port->port.tty->termios->c_cflag &CRTSCTS ; +if (opcode ==DIGI_CMD_READ_INPUT_SIGNALS ) {spin_lock (&priv->dp_port_lock);/* convert from digi flags to termiox flags */ if (val &DIGI_READ_INPUT_SIGNALS_CTS ) { priv->dp_modem_signals |=TIOCM_CTS ;/* port must be open to use tty struct */ -if (port->port.count - && port->port.tty->termios->c_cflag &CRTSCTS ) { +if (rts) { port->port.tty->hw_stopped =0 ;digi_wakeup_write (port); } }else { priv->dp_modem_signals &= ~TIOCM_CTS ;/* port must be open to use tty struct */ -if (port->port.count - && port->port.tty->termios->c_cflag &CRTSCTS ) { +if (rts) port->port.tty->hw_stopped =1 ; - } }if (val &DIGI_READ_INPUT_SIGNALS_DSR ) priv->dp_modem_signals |=TIOCM_DSR ;
@@ -1819,7 +1842,7 @@ static int __init digi_init(void)if (retval) goto failed_acceleport_2_device; retval =usb_serial_register (&digi_acceleport_4_device); -if (retval) +if (retval) goto failed_acceleport_4_device; retval =usb_register (&digi_driver);if (retval)