Re: [PATCH 51/69] TTY: 68328serial, remove serial_state and friends

From: Geert Uytterhoeven
Date: Tue Apr 03 2012 - 08:48:18 EST


[ Added Greg as this is m68knommu territory, but I guess he go all 12 patches
through linux-m68k anyway ]

On Mon, Apr 2, 2012 at 13:54, Jiri Slaby <jslaby@xxxxxxx> wrote:
> serial_state in 68328serial.h is a duplicated structure. One is
> defined in linux/serial.h. So let us use that instead. And since the
> serial flags are identical, use ones from there too.
>
> Signed-off-by: Jiri Slaby <jslaby@xxxxxxx>
> Cc: Geert Uytterhoeven <geert@xxxxxxxxxxxxxx>
> Cc: linux-m68k@xxxxxxxxxxxxxxxxxxxx
> ---
> Âdrivers/tty/serial/68328serial.c | Â 55 +++++++++++----------------
> Âdrivers/tty/serial/68328serial.h | Â 76 --------------------------------------
> Â2 files changed, 22 insertions(+), 109 deletions(-)
>
> diff --git a/drivers/tty/serial/68328serial.c b/drivers/tty/serial/68328serial.c
> index 5ce7825..bf5f811 100644
> --- a/drivers/tty/serial/68328serial.c
> +++ b/drivers/tty/serial/68328serial.c
> @@ -17,6 +17,7 @@
> Â#include <asm/dbg.h>
> Â#include <linux/module.h>
> Â#include <linux/errno.h>
> +#include <linux/serial.h>
> Â#include <linux/signal.h>
> Â#include <linux/sched.h>
> Â#include <linux/timer.h>
> @@ -79,18 +80,6 @@ struct m68k_serial *m68k_consinfo = 0;
>
> Âstruct tty_driver *serial_driver;
>
> -/* number of characters left in xmit buffer before we ask for more */
> -#define WAKEUP_CHARS 256
> -
> -/* Debugging... DEBUG_INTR is bad to use when one of the zs
> - * lines is your console ;(
> - */
> -#undef SERIAL_DEBUG_INTR
> -#undef SERIAL_DEBUG_OPEN
> -#undef SERIAL_DEBUG_FLOW
> -
> -#define RS_ISR_PASS_LIMIT 256
> -
> Âstatic void change_speed(struct m68k_serial *info);
>
> Â/*
> @@ -363,7 +352,7 @@ static int startup(struct m68k_serial * info)
> Â Â Â Âm68328_uart *uart = &uart_addr[info->line];
> Â Â Â Âunsigned long flags;
>
> - Â Â Â if (info->flags & S_INITIALIZED)
> + Â Â Â if (info->flags & ASYNC_INITIALIZED)
> Â Â Â Â Â Â Â Âreturn 0;
>
> Â Â Â Âif (!info->xmit_buf) {
> @@ -404,7 +393,7 @@ static int startup(struct m68k_serial * info)
>
> Â Â Â Âchange_speed(info);
>
> - Â Â Â info->flags |= S_INITIALIZED;
> + Â Â Â info->flags |= ASYNC_INITIALIZED;
> Â Â Â Âlocal_irq_restore(flags);
> Â Â Â Âreturn 0;
> Â}
> @@ -419,7 +408,7 @@ static void shutdown(struct m68k_serial * info)
>    Âunsigned long  flags;
>
> Â Â Â Âuart->ustcnt = 0; /* All off! */
> - Â Â Â if (!(info->flags & S_INITIALIZED))
> + Â Â Â if (!(info->flags & ASYNC_INITIALIZED))
> Â Â Â Â Â Â Â Âreturn;
>
> Â Â Â Âlocal_irq_save(flags);
> @@ -432,7 +421,7 @@ static void shutdown(struct m68k_serial * info)
> Â Â Â Âif (info->tty)
> Â Â Â Â Â Â Â Âset_bit(TTY_IO_ERROR, &info->tty->flags);
>
> - Â Â Â info->flags &= ~S_INITIALIZED;
> + Â Â Â info->flags &= ~ASYNC_INITIALIZED;
> Â Â Â Âlocal_irq_restore(flags);
> Â}
>
> @@ -835,11 +824,11 @@ static int set_serial_info(struct m68k_serial * info,
> Â Â Â Â Â Â Â Âif ((new_serial.baud_base != info->baud_base) ||
> Â Â Â Â Â Â Â Â Â Â(new_serial.type != info->type) ||
> Â Â Â Â Â Â Â Â Â Â(new_serial.close_delay != info->close_delay) ||
> - Â Â Â Â Â Â Â Â Â ((new_serial.flags & ~S_USR_MASK) !=
> - Â Â Â Â Â Â Â Â Â Â(info->flags & ~S_USR_MASK)))
> + Â Â Â Â Â Â Â Â Â ((new_serial.flags & ~ASYNC_USR_MASK) !=
> + Â Â Â Â Â Â Â Â Â Â(info->flags & ~ASYNC_USR_MASK)))
> Â Â Â Â Â Â Â Â Â Â Â Âreturn -EPERM;
> - Â Â Â Â Â Â Â info->flags = ((info->flags & ~S_USR_MASK) |
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â(new_serial.flags & S_USR_MASK));
> + Â Â Â Â Â Â Â info->flags = ((info->flags & ~ASYNC_USR_MASK) |
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â(new_serial.flags & ASYNC_USR_MASK));
> Â Â Â Â Â Â Â Âinfo->custom_divisor = new_serial.custom_divisor;
> Â Â Â Â Â Â Â Âgoto check_and_exit;
> Â Â Â Â}
> @@ -853,8 +842,8 @@ static int set_serial_info(struct m68k_serial * info,
> Â Â Â Â */
>
> Â Â Â Âinfo->baud_base = new_serial.baud_base;
> - Â Â Â info->flags = ((info->flags & ~S_FLAGS) |
> - Â Â Â Â Â Â Â Â Â Â Â (new_serial.flags & S_FLAGS));
> + Â Â Â info->flags = ((info->flags & ~ASYNC_FLAGS) |
> + Â Â Â Â Â Â Â Â Â Â Â (new_serial.flags & ASYNC_FLAGS));
> Â Â Â Âinfo->type = new_serial.type;
> Â Â Â Âinfo->close_delay = new_serial.close_delay;
> Â Â Â Âinfo->closing_wait = new_serial.closing_wait;
> @@ -1022,13 +1011,13 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
> Â Â Â Â Â Â Â Âlocal_irq_restore(flags);
> Â Â Â Â Â Â Â Âreturn;
> Â Â Â Â}
> - Â Â Â info->flags |= S_CLOSING;
> + Â Â Â info->flags |= ASYNC_CLOSING;
> Â Â Â Â/*
> Â Â Â Â * Now we wait for the transmit buffer to clear; and we notify
> Â Â Â Â * the line discipline to only process XON/XOFF characters.
> Â Â Â Â */
> Â Â Â Âtty->closing = 1;
> - Â Â Â if (info->closing_wait != S_CLOSING_WAIT_NONE)
> + Â Â Â if (info->closing_wait != ASYNC_CLOSING_WAIT_NONE)
> Â Â Â Â Â Â Â Âtty_wait_until_sent(tty, info->closing_wait);
> Â Â Â Â/*
> Â Â Â Â * At this point we stop accepting input. ÂTo do this, we
> @@ -1064,7 +1053,7 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
> Â Â Â Â Â Â Â Â}
> Â Â Â Â Â Â Â Âwake_up_interruptible(&info->open_wait);
> Â Â Â Â}
> - Â Â Â info->flags &= ~(S_NORMAL_ACTIVE|S_CLOSING);
> + Â Â Â info->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
> Â Â Â Âwake_up_interruptible(&info->close_wait);
> Â Â Â Âlocal_irq_restore(flags);
> Â}
> @@ -1083,7 +1072,7 @@ void rs_hangup(struct tty_struct *tty)
> Â Â Â Âshutdown(info);
> Â Â Â Âinfo->event = 0;
> Â Â Â Âinfo->count = 0;
> - Â Â Â info->flags &= ~S_NORMAL_ACTIVE;
> + Â Â Â info->flags &= ~ASYNC_NORMAL_ACTIVE;
> Â Â Â Âinfo->tty = NULL;
> Â Â Â Âwake_up_interruptible(&info->open_wait);
> Â}
> @@ -1104,10 +1093,10 @@ 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 (info->flags & S_CLOSING) {
> + Â Â Â if (info->flags & ASYNC_CLOSING) {
> Â Â Â Â Â Â Â Âinterruptible_sleep_on(&info->close_wait);
> Â#ifdef SERIAL_DO_RESTART
> - Â Â Â Â Â Â Â if (info->flags & S_HUP_NOTIFY)
> + Â Â Â Â Â Â Â if (info->flags & ASYNC_HUP_NOTIFY)
> Â Â Â Â Â Â Â Â Â Â Â Âreturn -EAGAIN;
> Â Â Â Â Â Â Â Âelse
> Â Â Â Â Â Â Â Â Â Â Â Âreturn -ERESTARTSYS;
> @@ -1122,7 +1111,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 |= S_NORMAL_ACTIVE;
> + Â Â Â Â Â Â Â info->flags |= ASYNC_NORMAL_ACTIVE;
> Â Â Â Â Â Â Â Âreturn 0;
> Â Â Â Â}
>
> @@ -1147,9 +1136,9 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
> Â Â Â Â Â Â Â Âlocal_irq_enable();
> Â Â Â Â Â Â Â Âcurrent->state = TASK_INTERRUPTIBLE;
> Â Â Â Â Â Â Â Âif (tty_hung_up_p(filp) ||
> - Â Â Â Â Â Â Â Â Â !(info->flags & S_INITIALIZED)) {
> + Â Â Â Â Â Â Â Â Â !(info->flags & ASYNC_INITIALIZED)) {
> Â#ifdef SERIAL_DO_RESTART
> - Â Â Â Â Â Â Â Â Â Â Â if (info->flags & S_HUP_NOTIFY)
> + Â Â Â Â Â Â Â Â Â Â Â if (info->flags & ASYNC_HUP_NOTIFY)
> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Âretval = -EAGAIN;
> Â Â Â Â Â Â Â Â Â Â Â Âelse
> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Âretval = -ERESTARTSYS;
> @@ -1158,7 +1147,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
> Â#endif
> Â Â Â Â Â Â Â Â Â Â Â Âbreak;
> Â Â Â Â Â Â Â Â}
> - Â Â Â Â Â Â Â if (!(info->flags & S_CLOSING) && do_clocal)
> + Â Â Â Â Â Â Â if (!(info->flags & ASYNC_CLOSING) && do_clocal)
> Â Â Â Â Â Â Â Â Â Â Â Âbreak;
> Â Â Â Â Â Â Â Â if (signal_pending(current)) {
> Â Â Â Â Â Â Â Â Â Â Â Âretval = -ERESTARTSYS;
> @@ -1176,7 +1165,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
>
> Â Â Â Âif (retval)
> Â Â Â Â Â Â Â Âreturn retval;
> - Â Â Â info->flags |= S_NORMAL_ACTIVE;
> + Â Â Â info->flags |= ASYNC_NORMAL_ACTIVE;
> Â Â Â Âreturn 0;
> Â}
>
> diff --git a/drivers/tty/serial/68328serial.h b/drivers/tty/serial/68328serial.h
> index 3d2faab..a804ea5 100644
> --- a/drivers/tty/serial/68328serial.h
> +++ b/drivers/tty/serial/68328serial.h
> @@ -11,69 +11,6 @@
> Â#ifndef _MC683XX_SERIAL_H
> Â#define _MC683XX_SERIAL_H
>
> -
> -struct serial_struct {
> -    int   type;
> -    int   line;
> -    int   port;
> -    int   irq;
> -    int   flags;
> -    int   xmit_fifo_size;
> -    int   custom_divisor;
> -    int   baud_base;
> - Â Â Â unsigned short Âclose_delay;
> -    char  Âreserved_char[2];
> -    int   hub6; Â/* FIXME: We don't have AT&T Hub6 boards! */
> - Â Â Â unsigned short Âclosing_wait; /* time to wait before closing */
> - Â Â Â unsigned short Âclosing_wait2; /* no longer used... */
> -    int   reserved[4];
> -};
> -
> -/*
> - * For the close wait times, 0 means wait forever for serial port to
> - * flush its output. Â65535 means don't wait at all.
> - */
> -#define S_CLOSING_WAIT_INF Â Â 0
> -#define S_CLOSING_WAIT_NONE Â Â65535
> -
> -/*
> - * Definitions for S_struct (and serial_struct) flags field
> - */
> -#define S_HUP_NOTIFY 0x0001 /* Notify getty on hangups and closes
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Âon the callout port */
> -#define S_FOURPORT Â0x0002 Â Â /* Set OU1, OUT2 per AST Fourport settings */
> -#define S_SAK Â0x0004 Â/* Secure Attention Key (Orange book) */
> -#define S_SPLIT_TERMIOS 0x0008 /* Separate termios for dialin/callout */
> -
> -#define S_SPD_MASK Â Â 0x0030
> -#define S_SPD_HI Â Â Â 0x0010 Â/* Use 56000 instead of 38400 bps */
> -
> -#define S_SPD_VHI Â Â Â0x0020 Â/* Use 115200 instead of 38400 bps */
> -#define S_SPD_CUST Â Â 0x0030 Â/* Use user-specified divisor */
> -
> -#define S_SKIP_TEST Â Â0x0040 /* Skip UART test during autoconfiguration */
> -#define S_AUTO_IRQ Â0x0080 /* Do automatic IRQ during autoconfiguration */
> -#define S_SESSION_LOCKOUT 0x0100 /* Lock out cua opens based on session */
> -#define S_PGRP_LOCKOUT Â Â0x0200 /* Lock out cua opens based on pgrp */
> -#define S_CALLOUT_NOHUP Â 0x0400 /* Don't do hangups for cua device */
> -
> -#define S_FLAGS Â Â Â Â0x0FFF Â/* Possible legal S flags */
> -#define S_USR_MASK 0x0430 Â Â Â/* Legal flags that non-privileged
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â* users can set or reset */
> -
> -/* Internal flags used only by kernel/chr_drv/serial.c */
> -#define S_INITIALIZED Â0x80000000 /* Serial port was initialized */
> -#define S_CALLOUT_ACTIVE Â Â Â 0x40000000 /* Call out device is active */
> -#define S_NORMAL_ACTIVE Â Â Â Â0x20000000 /* Normal device is active */
> -#define S_BOOT_AUTOCONF Â Â Â Â0x10000000 /* Autoconfigure port on bootup */
> -#define S_CLOSING Â Â Â Â Â Â Â0x08000000 /* Serial port is closing */
> -#define S_CTS_FLOW Â Â Â Â Â Â 0x04000000 /* Do CTS flow control */
> -#define S_CHECK_CD Â Â Â Â Â Â 0x02000000 /* i.e., CLOCAL */
> -
> -/* Software state per channel */
> -
> -#ifdef __KERNEL__
> -
> Â/*
> Â* I believe this is the optimal setting that reduces the number of interrupts.
> Â* At high speeds the output might become a little "bursted" (use USTCNT_TXHE
> @@ -162,25 +99,12 @@ struct m68k_serial {
>    Âwait_queue_head_t    close_wait;
> Â};
>
> -
> Â#define SERIAL_MAGIC 0x5301
>
> -/*
> - * The size of the serial xmit buffer is 1 page, or 4096 bytes
> - */
> -#define SERIAL_XMIT_SIZE 4096
> -
> -/*
> - * Events are used to schedule things to happen at timer-interrupt
> - * time, instead of at rs interrupt time.
> - */
> -#define RS_EVENT_WRITE_WAKEUP Â0
> -
> Â/*
> Â* Define the number of ports supported and their irqs.
> Â*/
> Â#define NR_PORTS 1
> Â#define UART_IRQ_DEFNS {UART_IRQ_NUM}
>
> -#endif /* __KERNEL__ */
> Â#endif /* !(_MC683XX_SERIAL_H) */
> --
> 1.7.9.2

Gr{oetje,eeting}s,

            Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
             Â Â -- Linus Torvalds
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/