Skip to content

Commit

Permalink
[PATCH] tty: switch to ktermios
Browse files Browse the repository at this point in the history
This is the grungy swap all the occurrences in the right places patch that
goes with the updates.  At this point we have the same functionality as
before (except that sgttyb() returns speeds not zero) and are ready to
begin turning new stuff on providing nobody reports lots of bugs

If you are a tty driver author converting an out of tree driver the only
impact should be termios->ktermios name changes for the speed/property
setting functions from your upper layers.

If you are implementing your own TCGETS function before then your driver
was broken already and its about to get a whole lot more painful for you so
please fix it 8)

Also fill in c_ispeed/ospeed on init for most devices, although the current
code will do this for you anyway but I'd like eventually to lose that extra
paranoia

[akpm@osdl.org: bluetooth fix]
[mp3@de.ibm.com: sclp fix]
[mp3@de.ibm.com: warning fix for tty3270]
[hugh@veritas.com: fix tty_ioctl powerpc build]
[jdike@addtoit.com: uml: fix ->set_termios declaration]
Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Martin Peschke <mp3@de.ibm.com>
Acked-by: Peter Oberparleiter <oberpar@de.ibm.com>
Cc: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: Hugh Dickins <hugh@veritas.com>
Signed-off-by: Jeff Dike <jdike@addtoit.com>
Cc: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
  • Loading branch information
Alan-Cox authored and Linus Torvalds committed Dec 8, 2006
1 parent edc6afc commit 606d099
Show file tree
Hide file tree
Showing 113 changed files with 301 additions and 253 deletions.
2 changes: 1 addition & 1 deletion arch/um/drivers/line.c
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ int line_write(struct tty_struct *tty, const unsigned char *buf, int len)
return ret;
}

void line_set_termios(struct tty_struct *tty, struct termios * old)
void line_set_termios(struct tty_struct *tty, struct ktermios * old)
{
/* nothing */
}
Expand Down
2 changes: 1 addition & 1 deletion arch/um/include/line.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ extern int line_setup(struct line *lines, unsigned int sizeof_lines,
extern int line_write(struct tty_struct *tty, const unsigned char *buf,
int len);
extern void line_put_char(struct tty_struct *tty, unsigned char ch);
extern void line_set_termios(struct tty_struct *tty, struct termios * old);
extern void line_set_termios(struct tty_struct *tty, struct ktermios * old);
extern int line_chars_in_buffer(struct tty_struct *tty);
extern void line_flush_buffer(struct tty_struct *tty);
extern void line_flush_chars(struct tty_struct *tty);
Expand Down
6 changes: 3 additions & 3 deletions drivers/char/amiserial.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ static struct async_struct *IRQ_ports;

static unsigned char current_ctl_bits;

static void change_speed(struct async_struct *info, struct termios *old);
static void change_speed(struct async_struct *info, struct ktermios *old);
static void rs_wait_until_sent(struct tty_struct *tty, int timeout);


Expand Down Expand Up @@ -694,7 +694,7 @@ static void shutdown(struct async_struct * info)
* the specified baud rate for a serial port.
*/
static void change_speed(struct async_struct *info,
struct termios *old_termios)
struct ktermios *old_termios)
{
int quot = 0, baud_base, baud;
unsigned cflag, cval = 0;
Expand Down Expand Up @@ -1365,7 +1365,7 @@ static int rs_ioctl(struct tty_struct *tty, struct file * file,
return 0;
}

static void rs_set_termios(struct tty_struct *tty, struct termios *old_termios)
static void rs_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
{
struct async_struct *info = (struct async_struct *)tty->driver_data;
unsigned long flags;
Expand Down
2 changes: 1 addition & 1 deletion drivers/char/cyclades.c
Original file line number Diff line number Diff line change
Expand Up @@ -4101,7 +4101,7 @@ cy_ioctl(struct tty_struct *tty, struct file * file,
* where old == NULL, and try to do something rational.
*/
static void
cy_set_termios(struct tty_struct *tty, struct termios * old_termios)
cy_set_termios(struct tty_struct *tty, struct ktermios * old_termios)
{
struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;

Expand Down
16 changes: 11 additions & 5 deletions drivers/char/epca.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ static int pc_ioctl(struct tty_struct *, struct file *,
unsigned int, unsigned long);
static int info_ioctl(struct tty_struct *, struct file *,
unsigned int, unsigned long);
static void pc_set_termios(struct tty_struct *, struct termios *);
static void pc_set_termios(struct tty_struct *, struct ktermios *);
static void do_softint(struct work_struct *work);
static void pc_stop(struct tty_struct *);
static void pc_start(struct tty_struct *);
Expand Down Expand Up @@ -1236,6 +1236,8 @@ static int __init pc_init(void)
pc_driver->init_termios.c_oflag = 0;
pc_driver->init_termios.c_cflag = B9600 | CS8 | CREAD | CLOCAL | HUPCL;
pc_driver->init_termios.c_lflag = 0;
pc_driver->init_termios.c_ispeed = 9600;
pc_driver->init_termios.c_ospeed = 9600;
pc_driver->flags = TTY_DRIVER_REAL_RAW;
tty_set_operations(pc_driver, &pc_ops);

Expand All @@ -1250,6 +1252,8 @@ static int __init pc_init(void)
pc_info->init_termios.c_oflag = 0;
pc_info->init_termios.c_lflag = 0;
pc_info->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL;
pc_info->init_termios.c_ispeed = 9600;
pc_info->init_termios.c_ospeed = 9600;
pc_info->flags = TTY_DRIVER_REAL_RAW;
tty_set_operations(pc_info, &info_ops);

Expand Down Expand Up @@ -1999,7 +2003,7 @@ static void epcaparam(struct tty_struct *tty, struct channel *ch)
{ /* Begin epcaparam */

unsigned int cmdHead;
struct termios *ts;
struct ktermios *ts;
struct board_chan __iomem *bc;
unsigned mval, hflow, cflag, iflag;

Expand Down Expand Up @@ -2114,7 +2118,7 @@ static void receive_data(struct channel *ch)
{ /* Begin receive_data */

unchar *rptr;
struct termios *ts = NULL;
struct ktermios *ts = NULL;
struct tty_struct *tty;
struct board_chan __iomem *bc;
int dataToRead, wrapgap, bytesAvailable;
Expand Down Expand Up @@ -2362,12 +2366,14 @@ static int pc_ioctl(struct tty_struct *tty, struct file * file,
switch (cmd)
{ /* Begin switch cmd */

#if 0 /* Handled by calling layer properly */
case TCGETS:
if (copy_to_user(argp, tty->termios, sizeof(struct termios)))
if (copy_to_user(argp, tty->termios, sizeof(struct ktermios)))
return -EFAULT;
return 0;
case TCGETA:
return get_termio(tty, argp);
#endif
case TCSBRK: /* SVID version: non-zero arg --> no break */
retval = tty_check_change(tty);
if (retval)
Expand Down Expand Up @@ -2536,7 +2542,7 @@ static int pc_ioctl(struct tty_struct *tty, struct file * file,

/* --------------------- Begin pc_set_termios ----------------------- */

static void pc_set_termios(struct tty_struct *tty, struct termios *old_termios)
static void pc_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
{ /* Begin pc_set_termios */

struct channel *ch;
Expand Down
2 changes: 1 addition & 1 deletion drivers/char/esp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1915,7 +1915,7 @@ static int rs_ioctl(struct tty_struct *tty, struct file * file,
return 0;
}

static void rs_set_termios(struct tty_struct *tty, struct termios *old_termios)
static void rs_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
{
struct esp_struct *info = (struct esp_struct *)tty->driver_data;
unsigned long flags;
Expand Down
4 changes: 2 additions & 2 deletions drivers/char/generic_serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -718,11 +718,11 @@ static unsigned int gs_baudrates[] = {


void gs_set_termios (struct tty_struct * tty,
struct termios * old_termios)
struct ktermios * old_termios)
{
struct gs_port *port;
int baudrate, tmp, rv;
struct termios *tiosp;
struct ktermios *tiosp;

func_enter();

Expand Down
6 changes: 4 additions & 2 deletions drivers/char/hvcs.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,13 @@ MODULE_VERSION(HVCS_DRIVER_VERSION);
* that will cause echoing or we'll go into recursive loop echoing chars back
* and forth with the console drivers.
*/
static struct termios hvcs_tty_termios = {
static struct ktermios hvcs_tty_termios = {
.c_iflag = IGNBRK | IGNPAR,
.c_oflag = OPOST,
.c_cflag = B38400 | CS8 | CREAD | HUPCL,
.c_cc = INIT_C_CC
.c_cc = INIT_C_CC,
.c_ispeed = 38400,
.c_ospeed = 38400
};

/*
Expand Down
2 changes: 2 additions & 0 deletions drivers/char/hvsi.c
Original file line number Diff line number Diff line change
Expand Up @@ -1161,6 +1161,8 @@ static int __init hvsi_init(void)
hvsi_driver->type = TTY_DRIVER_TYPE_SYSTEM;
hvsi_driver->init_termios = tty_std_termios;
hvsi_driver->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL;
hvsi_driver->init_termios.c_ispeed = 9600;
hvsi_driver->init_termios.c_ospeed = 9600;
hvsi_driver->flags = TTY_DRIVER_REAL_RAW;
tty_set_operations(hvsi_driver, &hvsi_ops);

Expand Down
10 changes: 5 additions & 5 deletions drivers/char/ip2/ip2main.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ static int ip2_write_room(PTTY);
static int ip2_chars_in_buf(PTTY);
static void ip2_flush_buffer(PTTY);
static int ip2_ioctl(PTTY, struct file *, UINT, ULONG);
static void ip2_set_termios(PTTY, struct termios *);
static void ip2_set_termios(PTTY, struct ktermios *);
static void ip2_set_line_discipline(PTTY);
static void ip2_throttle(PTTY);
static void ip2_unthrottle(PTTY);
Expand All @@ -198,7 +198,7 @@ static void do_status(struct work_struct *);

static void ip2_wait_until_sent(PTTY,int);

static void set_params (i2ChanStrPtr, struct termios *);
static void set_params (i2ChanStrPtr, struct ktermios *);
static int get_serial_info(i2ChanStrPtr, struct serial_struct __user *);
static int set_serial_info(i2ChanStrPtr, struct serial_struct __user *);

Expand Down Expand Up @@ -2398,7 +2398,7 @@ set_serial_info( i2ChanStrPtr pCh, struct serial_struct __user *new_info )
/* */
/******************************************************************************/
static void
ip2_set_termios( PTTY tty, struct termios *old_termios )
ip2_set_termios( PTTY tty, struct ktermios *old_termios )
{
i2ChanStrPtr pCh = (i2ChanStrPtr)tty->driver_data;

Expand Down Expand Up @@ -2440,11 +2440,11 @@ ip2_set_line_discipline ( PTTY tty )
/* change. */
/******************************************************************************/
static void
set_params( i2ChanStrPtr pCh, struct termios *o_tios )
set_params( i2ChanStrPtr pCh, struct ktermios *o_tios )
{
tcflag_t cflag, iflag, lflag;
char stop_char, start_char;
struct termios dummy;
struct ktermios dummy;

lflag = pCh->pTTY->termios->c_lflag;
cflag = pCh->pTTY->termios->c_cflag;
Expand Down
2 changes: 1 addition & 1 deletion drivers/char/isicom.c
Original file line number Diff line number Diff line change
Expand Up @@ -1399,7 +1399,7 @@ static int isicom_ioctl(struct tty_struct *tty, struct file *filp,

/* set_termios et all */
static void isicom_set_termios(struct tty_struct *tty,
struct termios *old_termios)
struct ktermios *old_termios)
{
struct isi_port *port = tty->driver_data;

Expand Down
14 changes: 8 additions & 6 deletions drivers/char/istallion.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,11 @@ static struct tty_struct *stli_txcooktty;
* with this termios initially. Basically all it defines is a raw port
* at 9600 baud, 8 data bits, no parity, 1 stop bit.
*/
static struct termios stli_deftermios = {
static struct ktermios stli_deftermios = {
.c_cflag = (B9600 | CS8 | CREAD | HUPCL | CLOCAL),
.c_cc = INIT_C_CC,
.c_ispeed = 9600,
.c_ospeed = 9600,
};

/*
Expand Down Expand Up @@ -639,7 +641,7 @@ static void stli_flushchars(struct tty_struct *tty);
static int stli_writeroom(struct tty_struct *tty);
static int stli_charsinbuffer(struct tty_struct *tty);
static int stli_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg);
static void stli_settermios(struct tty_struct *tty, struct termios *old);
static void stli_settermios(struct tty_struct *tty, struct ktermios *old);
static void stli_throttle(struct tty_struct *tty);
static void stli_unthrottle(struct tty_struct *tty);
static void stli_stop(struct tty_struct *tty);
Expand Down Expand Up @@ -669,7 +671,7 @@ static int stli_cmdwait(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd, v
static void stli_sendcmd(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd, void *arg, int size, int copyback);
static void __stli_sendcmd(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd, void *arg, int size, int copyback);
static void stli_dodelaycmd(stliport_t *portp, cdkctrl_t __iomem *cp);
static void stli_mkasyport(stliport_t *portp, asyport_t *pp, struct termios *tiosp);
static void stli_mkasyport(stliport_t *portp, asyport_t *pp, struct ktermios *tiosp);
static void stli_mkasysigs(asysigs_t *sp, int dtr, int rts);
static long stli_mktiocm(unsigned long sigvalue);
static void stli_read(stlibrd_t *brdp, stliport_t *portp);
Expand Down Expand Up @@ -1889,11 +1891,11 @@ static int stli_ioctl(struct tty_struct *tty, struct file *file, unsigned int cm
* Looks like it is true for the current ttys implementation..!!
*/

static void stli_settermios(struct tty_struct *tty, struct termios *old)
static void stli_settermios(struct tty_struct *tty, struct ktermios *old)
{
stliport_t *portp;
stlibrd_t *brdp;
struct termios *tiosp;
struct ktermios *tiosp;
asyport_t aport;

if (tty == NULL)
Expand Down Expand Up @@ -2730,7 +2732,7 @@ static void stli_poll(unsigned long arg)
* the slave.
*/

static void stli_mkasyport(stliport_t *portp, asyport_t *pp, struct termios *tiosp)
static void stli_mkasyport(stliport_t *portp, asyport_t *pp, struct ktermios *tiosp)
{
memset(pp, 0, sizeof(asyport_t));

Expand Down
18 changes: 10 additions & 8 deletions drivers/char/moxa.c
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ static void moxa_put_char(struct tty_struct *, unsigned char);
static int moxa_ioctl(struct tty_struct *, struct file *, unsigned int, unsigned long);
static void moxa_throttle(struct tty_struct *);
static void moxa_unthrottle(struct tty_struct *);
static void moxa_set_termios(struct tty_struct *, struct termios *);
static void moxa_set_termios(struct tty_struct *, struct ktermios *);
static void moxa_stop(struct tty_struct *);
static void moxa_start(struct tty_struct *);
static void moxa_hangup(struct tty_struct *);
Expand All @@ -261,7 +261,7 @@ static void MoxaPortEnable(int);
static void MoxaPortDisable(int);
static long MoxaPortGetMaxBaud(int);
static long MoxaPortSetBaud(int, long);
static int MoxaPortSetTermio(int, struct termios *, speed_t);
static int MoxaPortSetTermio(int, struct ktermios *, speed_t);
static int MoxaPortGetLineOut(int, int *, int *);
static void MoxaPortLineCtrl(int, int, int);
static void MoxaPortFlowCtrl(int, int, int, int, int, int);
Expand Down Expand Up @@ -355,6 +355,8 @@ static int __init moxa_init(void)
moxaDriver->init_termios.c_oflag = 0;
moxaDriver->init_termios.c_cflag = B9600 | CS8 | CREAD | CLOCAL | HUPCL;
moxaDriver->init_termios.c_lflag = 0;
moxaDriver->init_termios.c_ispeed = 9600;
moxaDriver->init_termios.c_ospeed = 9600;
moxaDriver->flags = TTY_DRIVER_REAL_RAW;
tty_set_operations(moxaDriver, &moxa_ops);

Expand Down Expand Up @@ -864,7 +866,7 @@ static void moxa_unthrottle(struct tty_struct *tty)
}

static void moxa_set_termios(struct tty_struct *tty,
struct termios *old_termios)
struct ktermios *old_termios)
{
struct moxa_str *ch = (struct moxa_str *) tty->driver_data;

Expand Down Expand Up @@ -978,7 +980,7 @@ static void moxa_poll(unsigned long ignored)

static void set_tty_param(struct tty_struct *tty)
{
register struct termios *ts;
register struct ktermios *ts;
struct moxa_str *ch;
int rts, cts, txflow, rxflow, xany;

Expand Down Expand Up @@ -1149,7 +1151,7 @@ static void shut_down(struct moxa_str *ch)
static void receive_data(struct moxa_str *ch)
{
struct tty_struct *tp;
struct termios *ts;
struct ktermios *ts;
unsigned long flags;

ts = NULL;
Expand Down Expand Up @@ -1912,9 +1914,9 @@ int MoxaPortsOfCard(int cardno)
*
* Function 12: Configure the port.
* Syntax:
* int MoxaPortSetTermio(int port, struct termios *termio, speed_t baud);
* int MoxaPortSetTermio(int port, struct ktermios *termio, speed_t baud);
* int port : port number (0 - 127)
* struct termios * termio : termio structure pointer
* struct ktermios * termio : termio structure pointer
* speed_t baud : baud rate
*
* return: -1 : this port is invalid or termio == NULL
Expand Down Expand Up @@ -2195,7 +2197,7 @@ long MoxaPortSetBaud(int port, long baud)
return (baud);
}

int MoxaPortSetTermio(int port, struct termios *termio, speed_t baud)
int MoxaPortSetTermio(int port, struct ktermios *termio, speed_t baud)
{
void __iomem *ofsAddr;
tcflag_t cflag;
Expand Down
Loading

0 comments on commit 606d099

Please sign in to comment.