Commit b7d752fb authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] console cleanup (1/2)

	Preparation to console->device() cleanup: serial drivers converted
to common helper for their ->device() methods.
parent b8f652d5
......@@ -414,11 +414,6 @@ serial21285_console_write(struct console *co, const char *s,
}
}
static kdev_t serial21285_console_device(struct console *c)
{
return mk_kdev(SERIAL_21285_MAJOR, SERIAL_21285_MINOR);
}
static void __init
serial21285_get_options(struct uart_port *port, int *baud,
int *parity, int *bits)
......@@ -479,15 +474,17 @@ static int __init serial21285_console_setup(struct console *co, char *options)
return uart_set_options(port, co, baud, parity, bits, flow);
}
extern struct uart_driver serial21285_reg;
#ifdef CONFIG_SERIAL_21285_OLD
static struct console serial21285_old_cons =
{
.name = SERIAL_21285_OLD_NAME,
.write = serial21285_console_write,
.device = serial21285_console_device,
.device = uart_console_device,
.setup = serial21285_console_setup,
.flags = CON_PRINTBUFFER,
.index = -1,
.data = &serial21285_reg,
};
#endif
......@@ -495,10 +492,11 @@ static struct console serial21285_console =
{
.name = SERIAL_21285_NAME,
.write = serial21285_console_write,
.device = serial21285_console_device,
.device = uart_console_device,
.setup = serial21285_console_setup,
.flags = CON_PRINTBUFFER,
.index = -1,
.data = &serial21285_reg,
};
static int __init rs285_console_init(void)
......
......@@ -1944,11 +1944,6 @@ serial8250_console_write(struct console *co, const char *s, unsigned int count)
serial_out(up, UART_IER, ier);
}
static kdev_t serial8250_console_device(struct console *co)
{
return mk_kdev(TTY_MAJOR, 64 + co->index);
}
static int __init serial8250_console_setup(struct console *co, char *options)
{
struct uart_port *port;
......@@ -1977,13 +1972,15 @@ static int __init serial8250_console_setup(struct console *co, char *options)
return uart_set_options(port, co, baud, parity, bits, flow);
}
extern struct uart_driver serial8250_reg;
static struct console serial8250_console = {
.name = "ttyS",
.write = serial8250_console_write,
.device = serial8250_console_device,
.device = uart_console_device,
.setup = serial8250_console_setup,
.flags = CON_PRINTBUFFER,
.index = -1,
.data = &serial8250_reg,
};
static int __init serial8250_console_init(void)
......
......@@ -640,11 +640,6 @@ ambauart_console_write(struct console *co, const char *s, unsigned int count)
UART_PUT_CR(port, old_cr);
}
static kdev_t ambauart_console_device(struct console *co)
{
return mk_kdev(SERIAL_AMBA_MAJOR, SERIAL_AMBA_MINOR + co->index);
}
static void __init
ambauart_console_get_options(struct uart_port *port, int *baud,
int *parity, int *bits)
......@@ -696,13 +691,15 @@ static int __init ambauart_console_setup(struct console *co, char *options)
return uart_set_options(port, co, baud, parity, bits, flow);
}
extern struct uart_driver amba_reg;
static struct console amba_console = {
.name = "ttyAM",
.write = ambauart_console_write,
.device = ambauart_console_device,
.device = uart_console_device,
.setup = ambauart_console_setup,
.flags = CON_PRINTBUFFER,
.index = -1,
.data = &amba_reg,
};
static int __init ambauart_console_init(void)
......
......@@ -444,12 +444,6 @@ anakin_console_write(struct console *co, const char *s, unsigned int count)
}
}
static kdev_t
anakin_console_device(struct console *co)
{
return mk_kdev(SERIAL_ANAKIN_MAJOR, SERIAL_ANAKIN_MINOR + co->index);
}
/*
* Read the current UART setup.
*/
......@@ -493,10 +487,11 @@ anakin_console_setup(struct console *co, char *options)
return uart_set_options(port, co, baud, parity, bits);
}
extern struct uart_driver anakin_reg;
static struct console anakin_console = {
.name = SERIAL_ANAKIN_NAME,
.write = anakin_console_write,
.device = anakin_console_device,
.device = uart_console_device,
.setup = anakin_console_setup,
.flags = CON_PRINTBUFFER,
.index = -1,
......@@ -514,7 +509,7 @@ console_initcall(anakin_console_init);
#define ANAKIN_CONSOLE NULL
#endif
static struct uart_register anakin_reg = {
static struct uart_driver anakin_reg = {
.driver_name = SERIAL_ANAKIN_NAME,
.dev_name = SERIAL_ANAKIN_NAME,
.major = SERIAL_ANAKIN_MAJOR,
......
......@@ -503,11 +503,6 @@ clps711xuart_console_write(struct console *co, const char *s,
clps_writel(syscon, SYSCON(port));
}
static kdev_t clps711xuart_console_device(struct console *co)
{
return mk_kdev(SERIAL_CLPS711X_MAJOR, SERIAL_CLPS711X_MINOR + co->index);
}
static void __init
clps711xuart_console_get_options(struct uart_port *port, int *baud,
int *parity, int *bits)
......@@ -558,13 +553,15 @@ static int __init clps711xuart_console_setup(struct console *co, char *options)
return uart_set_options(port, co, baud, parity, bits, flow);
}
extern struct uart_driver clps711x_reg;
static struct console clps711x_console = {
.name = "ttyCL",
.write = clps711xuart_console_write,
.device = clps711xuart_console_device,
.device = uart_console_device,
.setup = clps711xuart_console_setup,
.flags = CON_PRINTBUFFER,
.index = -1,
.data = &clps711x_reg,
};
static int __init clps711xuart_console_init(void)
......
......@@ -2194,6 +2194,12 @@ void uart_unregister_driver(struct uart_driver *drv)
kfree(drv->tty_driver);
}
kdev_t uart_console_device(struct console *co)
{
struct uart_driver *p = co->data;
return mk_kdev(p->major, p->minor + co->index);
}
/**
* uart_add_one_port - attach a driver-defined port structure
* @drv: pointer to the uart low level driver structure for this port
......
......@@ -272,19 +272,16 @@ static void nb85e_uart_cons_write (struct console *co,
}
}
static kdev_t nb85e_uart_cons_device (struct console *c)
{
return mk_kdev (TTY_MAJOR, NB85E_UART_MINOR_BASE + c->index);
}
extern struct uart_driver nb85e_uart_driver;
static struct console nb85e_uart_cons =
{
.name = "ttyS",
.write = nb85e_uart_cons_write,
.device = nb85e_uart_cons_device,
.device = uart_console_device,
.flags = CON_PRINTBUFFER,
.cflag = NB85E_UART_INIT_CFLAGS,
.index = -1,
.data = &nb85e_uart_driver,
};
void nb85e_uart_cons_init (unsigned chan)
......
......@@ -760,11 +760,6 @@ sa1100_console_write(struct console *co, const char *s, unsigned int count)
UART_PUT_UTCR3(sport, old_utcr3);
}
static kdev_t sa1100_console_device(struct console *co)
{
return mk_kdev(SERIAL_SA1100_MAJOR, MINOR_START + co->index);
}
/*
* If the port was already initialised (eg, by a boot loader),
* try to determine the current setup.
......@@ -827,13 +822,15 @@ sa1100_console_setup(struct console *co, char *options)
return uart_set_options(&sport->port, co, baud, parity, bits, flow);
}
extern struct uart_driver sa1100_reg;
static struct console sa1100_console = {
.name = "ttySA",
.write = sa1100_console_write,
.device = sa1100_console_device,
.device = uart_console_device,
.setup = sa1100_console_setup,
.flags = CON_PRINTBUFFER,
.index = -1,
.data = sa1100_reg,
};
static int __init sa1100_rs_console_init(void)
......
......@@ -136,16 +136,17 @@ struct serial98_port {
#ifdef CONFIG_SERIAL98_CONSOLE
static void
serial98_console_write(struct console *co, const char *s, unsigned int count);
static kdev_t serial98_console_device(struct console *co);
static int __init serial98_console_setup(struct console *co, char *options);
extern struct uart_driver serial98_reg;
static struct console serial98_console = {
.name = "ttyS",
.write = serial98_console_write,
.device = serial98_console_device,
.device = uart_console_device,
.setup = serial98_console_setup,
.flags = CON_PRINTBUFFER,
.index = -1,
.data = &serial98_reg,
};
#define SERIAL98_CONSOLE &serial98_console
......@@ -994,11 +995,6 @@ serial98_console_write(struct console *co, const char *s, unsigned int count)
outb(ier2, IER2_8251F);
}
static kdev_t serial98_console_device(struct console *co)
{
return mk_kdev(TTY_MAJOR, 64 + co->index);
}
static int __init serial98_console_setup(struct console *co, char *options)
{
struct uart_port *port;
......
......@@ -863,11 +863,6 @@ static void sunsab_console_write(struct console *con, const char *s, unsigned n)
sunsab_tec_wait(up);
}
static kdev_t sunsab_console_device(struct console *con)
{
return mk_kdev(sunsab_reg.major, sunsab_reg.minor + con->index);
}
static int sunsab_console_setup(struct console *con, char *options)
{
struct uart_sunsab_port *up = &sunsab_ports[con->index];
......@@ -928,10 +923,11 @@ static int sunsab_console_setup(struct console *con, char *options)
static struct console sunsab_console = {
.name = "ttyS",
.write = sunsab_console_write,
.device = sunsab_console_device,
.device = uart_console_device,
.setup = sunsab_console_setup,
.flags = CON_PRINTBUFFER,
.index = -1,
.data = &sunsab_reg,
};
static void __init sunsab_console_init(void)
......
......@@ -1422,11 +1422,6 @@ static void sunsu_console_write(struct console *co, const char *s,
serial_out(up, UART_IER, ier);
}
static kdev_t sunsu_console_device(struct console *co)
{
return mk_kdev(sunsu_reg.major, sunsu_reg.minor + co->index);
}
/*
* Setup initial baud/bits/parity. We do two things here:
* - construct a cflag setting for the first su_open()
......@@ -1467,10 +1462,11 @@ static int __init sunsu_console_setup(struct console *co, char *options)
static struct console sunsu_cons = {
.name = "ttyS",
.write = sunsu_console_write,
.device = sunsu_console_device,
.device = uart_console_device,
.setup = sunsu_console_setup,
.flags = CON_PRINTBUFFER,
.index = -1,
.data = &sunsu_reg,
};
/*
......
......@@ -1352,11 +1352,6 @@ sunzilog_console_write(struct console *con, const char *s, unsigned int count)
spin_unlock_irqrestore(&up->port.lock, flags);
}
static kdev_t sunzilog_console_device(struct console *con)
{
return mk_kdev(sunzilog_reg.major, sunzilog_reg.minor + con->index);
}
static int __init sunzilog_console_setup(struct console *con, char *options)
{
struct uart_sunzilog_port *up = &sunzilog_port_table[con->index];
......@@ -1402,10 +1397,11 @@ static int __init sunzilog_console_setup(struct console *con, char *options)
static struct console sunzilog_console = {
.name = "ttyS",
.write = sunzilog_console_write,
.device = sunzilog_console_device,
.device = uart_console_device,
.setup = sunzilog_console_setup,
.flags = CON_PRINTBUFFER,
.index = -1,
.data = &sunzilog_reg,
};
static int __init sunzilog_console_init(void)
......
......@@ -576,11 +576,6 @@ static void uart00_console_write(struct console *co, const char *s, unsigned cou
#endif
}
static kdev_t uart00_console_device(struct console *co)
{
return mk_kdev(SERIAL_UART00_MAJOR, SERIAL_UART00_MINOR + co->index);
}
static void __init
uart00_console_get_options(struct uart_port *port, int *baud,
int *parity, int *bits)
......@@ -636,13 +631,15 @@ static int __init uart00_console_setup(struct console *co, char *options)
return uart_set_options(port, co, baud, parity, bits, flow);
}
extern struct uart_driver uart00_reg;
static struct console uart00_console = {
.name = SERIAL_UART00_NAME,
.write = uart00_console_write,
.device = uart00_console_device,
.device = uart_console_device,
.setup = uart00_console_setup,
.flags = CON_PRINTBUFFER,
.index = 0,
.data = &uart00_reg;
};
static int __init uart00_console_init(void)
......
......@@ -103,6 +103,7 @@ struct console
short flags;
short index;
int cflag;
void *data;
struct console *next;
};
......
......@@ -300,6 +300,7 @@ void uart_parse_options(char *options, int *baud, int *parity, int *bits,
int *flow);
int uart_set_options(struct uart_port *port, struct console *co, int baud,
int parity, int bits, int flow);
kdev_t uart_console_device(struct console *co);
/*
* Port/driver registration/removal
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment