serial: sh-sci: Codestyle cleanup patch.
Trivial coding style cleanups. Signed-off-by: Michael Trimarchi <trimarchimichael@yahoo.it> Signed-off-by: Paul Mundt <lethal@linux-sh.org>
This commit is contained in:
parent
af505b1eab
commit
e7c98dc76d
|
@ -101,6 +101,12 @@ static void sci_stop_tx(struct uart_port *port);
|
||||||
static struct sci_port sci_ports[SCI_NPORTS];
|
static struct sci_port sci_ports[SCI_NPORTS];
|
||||||
static struct uart_driver sci_uart_driver;
|
static struct uart_driver sci_uart_driver;
|
||||||
|
|
||||||
|
static inline struct sci_port *
|
||||||
|
to_sci_port(struct uart_port *uart)
|
||||||
|
{
|
||||||
|
return container_of(uart, struct sci_port, port);
|
||||||
|
}
|
||||||
|
|
||||||
#if defined(CONFIG_SERIAL_SH_SCI_CONSOLE) && \
|
#if defined(CONFIG_SERIAL_SH_SCI_CONSOLE) && \
|
||||||
defined(CONFIG_SH_STANDARD_BIOS) || defined(CONFIG_SH_KGDB)
|
defined(CONFIG_SH_STANDARD_BIOS) || defined(CONFIG_SH_KGDB)
|
||||||
static inline void handle_error(struct uart_port *port)
|
static inline void handle_error(struct uart_port *port)
|
||||||
|
@ -124,7 +130,8 @@ static int get_char(struct uart_port *port)
|
||||||
}
|
}
|
||||||
} while (!(status & SCxSR_RDxF(port)));
|
} while (!(status & SCxSR_RDxF(port)));
|
||||||
c = sci_in(port, SCxRDR);
|
c = sci_in(port, SCxRDR);
|
||||||
sci_in(port, SCxSR); /* Dummy read */
|
/* Dummy read */
|
||||||
|
sci_in(port, SCxSR);
|
||||||
sci_out(port, SCxSR, SCxSR_RDxF_CLEAR(port));
|
sci_out(port, SCxSR, SCxSR_RDxF_CLEAR(port));
|
||||||
spin_unlock_irqrestore(&port->lock, flags);
|
spin_unlock_irqrestore(&port->lock, flags);
|
||||||
|
|
||||||
|
@ -161,7 +168,7 @@ static void put_string(struct sci_port *sci_port, const char *buffer, int count)
|
||||||
|
|
||||||
#if defined(CONFIG_SH_STANDARD_BIOS) || defined(CONFIG_SH_KGDB)
|
#if defined(CONFIG_SH_STANDARD_BIOS) || defined(CONFIG_SH_KGDB)
|
||||||
int checksum;
|
int checksum;
|
||||||
int usegdb=0;
|
int usegdb = 0;
|
||||||
|
|
||||||
#ifdef CONFIG_SH_STANDARD_BIOS
|
#ifdef CONFIG_SH_STANDARD_BIOS
|
||||||
/* This call only does a trap the first time it is
|
/* This call only does a trap the first time it is
|
||||||
|
@ -181,7 +188,8 @@ static void put_string(struct sci_port *sci_port, const char *buffer, int count)
|
||||||
put_char(port, 'O'); /* 'O'utput to console */
|
put_char(port, 'O'); /* 'O'utput to console */
|
||||||
checksum = 'O';
|
checksum = 'O';
|
||||||
|
|
||||||
for (i=0; i<count; i++) { /* Don't use run length encoding */
|
/* Don't use run length encoding */
|
||||||
|
for (i = 0; i < count; i++) {
|
||||||
int h, l;
|
int h, l;
|
||||||
|
|
||||||
c = *p++;
|
c = *p++;
|
||||||
|
@ -197,7 +205,7 @@ static void put_string(struct sci_port *sci_port, const char *buffer, int count)
|
||||||
} while (get_char(port) != '+');
|
} while (get_char(port) != '+');
|
||||||
} else
|
} else
|
||||||
#endif /* CONFIG_SH_STANDARD_BIOS || CONFIG_SH_KGDB */
|
#endif /* CONFIG_SH_STANDARD_BIOS || CONFIG_SH_KGDB */
|
||||||
for (i=0; i<count; i++) {
|
for (i = 0; i < count; i++) {
|
||||||
if (*p == 10)
|
if (*p == 10)
|
||||||
put_char(port, '\r');
|
put_char(port, '\r');
|
||||||
put_char(port, *p++);
|
put_char(port, *p++);
|
||||||
|
@ -208,35 +216,34 @@ static void put_string(struct sci_port *sci_port, const char *buffer, int count)
|
||||||
#ifdef CONFIG_SH_KGDB
|
#ifdef CONFIG_SH_KGDB
|
||||||
static int kgdb_sci_getchar(void)
|
static int kgdb_sci_getchar(void)
|
||||||
{
|
{
|
||||||
int c;
|
int c;
|
||||||
|
|
||||||
/* Keep trying to read a character, this could be neater */
|
/* Keep trying to read a character, this could be neater */
|
||||||
while ((c = get_char(&kgdb_sci_port->port)) < 0)
|
while ((c = get_char(&kgdb_sci_port->port)) < 0)
|
||||||
cpu_relax();
|
cpu_relax();
|
||||||
|
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void kgdb_sci_putchar(int c)
|
static inline void kgdb_sci_putchar(int c)
|
||||||
{
|
{
|
||||||
put_char(&kgdb_sci_port->port, c);
|
put_char(&kgdb_sci_port->port, c);
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_SH_KGDB */
|
#endif /* CONFIG_SH_KGDB */
|
||||||
|
|
||||||
#if defined(__H8300S__)
|
#if defined(__H8300S__)
|
||||||
enum { sci_disable, sci_enable };
|
enum { sci_disable, sci_enable };
|
||||||
|
|
||||||
static void h8300_sci_config(struct uart_port* port, unsigned int ctrl)
|
static void h8300_sci_config(struct uart_port *port, unsigned int ctrl)
|
||||||
{
|
{
|
||||||
volatile unsigned char *mstpcrl=(volatile unsigned char *)MSTPCRL;
|
volatile unsigned char *mstpcrl = (volatile unsigned char *)MSTPCRL;
|
||||||
int ch = (port->mapbase - SMR0) >> 3;
|
int ch = (port->mapbase - SMR0) >> 3;
|
||||||
unsigned char mask = 1 << (ch+1);
|
unsigned char mask = 1 << (ch+1);
|
||||||
|
|
||||||
if (ctrl == sci_disable) {
|
if (ctrl == sci_disable)
|
||||||
*mstpcrl |= mask;
|
*mstpcrl |= mask;
|
||||||
} else {
|
else
|
||||||
*mstpcrl &= ~mask;
|
*mstpcrl &= ~mask;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void h8300_sci_enable(struct uart_port *port)
|
static inline void h8300_sci_enable(struct uart_port *port)
|
||||||
|
@ -251,7 +258,7 @@ static inline void h8300_sci_disable(struct uart_port *port)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__H8300H__) || defined(__H8300S__)
|
#if defined(__H8300H__) || defined(__H8300S__)
|
||||||
static void sci_init_pins_sci(struct uart_port* port, unsigned int cflag)
|
static void sci_init_pins_sci(struct uart_port *port, unsigned int cflag)
|
||||||
{
|
{
|
||||||
int ch = (port->mapbase - SMR0) >> 3;
|
int ch = (port->mapbase - SMR0) >> 3;
|
||||||
|
|
||||||
|
@ -285,14 +292,13 @@ static void sci_init_pins_irda(struct uart_port *port, unsigned int cflag)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(CONFIG_CPU_SUBTYPE_SH7710) || defined(CONFIG_CPU_SUBTYPE_SH7712)
|
#if defined(CONFIG_CPU_SUBTYPE_SH7710) || defined(CONFIG_CPU_SUBTYPE_SH7712)
|
||||||
static void sci_init_pins_scif(struct uart_port* port, unsigned int cflag)
|
static void sci_init_pins_scif(struct uart_port *port, unsigned int cflag)
|
||||||
{
|
{
|
||||||
unsigned int fcr_val = 0;
|
unsigned int fcr_val = 0;
|
||||||
|
|
||||||
set_sh771x_scif_pfc(port);
|
set_sh771x_scif_pfc(port);
|
||||||
if (cflag & CRTSCTS) {
|
if (cflag & CRTSCTS)
|
||||||
fcr_val |= SCFCR_MCE;
|
fcr_val |= SCFCR_MCE;
|
||||||
}
|
|
||||||
sci_out(port, SCFCR, fcr_val);
|
sci_out(port, SCFCR, fcr_val);
|
||||||
}
|
}
|
||||||
#elif defined(CONFIG_CPU_SUBTYPE_SH7720) || defined(CONFIG_CPU_SUBTYPE_SH7721)
|
#elif defined(CONFIG_CPU_SUBTYPE_SH7720) || defined(CONFIG_CPU_SUBTYPE_SH7721)
|
||||||
|
@ -419,18 +425,26 @@ static inline int scif_rxroom(struct uart_port *port)
|
||||||
#elif defined(CONFIG_CPU_SUBTYPE_SH7763)
|
#elif defined(CONFIG_CPU_SUBTYPE_SH7763)
|
||||||
static inline int scif_txroom(struct uart_port *port)
|
static inline int scif_txroom(struct uart_port *port)
|
||||||
{
|
{
|
||||||
if((port->mapbase == 0xffe00000) || (port->mapbase == 0xffe08000)) /* SCIF0/1*/
|
if ((port->mapbase == 0xffe00000) ||
|
||||||
|
(port->mapbase == 0xffe08000)) {
|
||||||
|
/* SCIF0/1*/
|
||||||
return SCIF_TXROOM_MAX - (sci_in(port, SCTFDR) & 0xff);
|
return SCIF_TXROOM_MAX - (sci_in(port, SCTFDR) & 0xff);
|
||||||
else /* SCIF2 */
|
} else {
|
||||||
|
/* SCIF2 */
|
||||||
return SCIF2_TXROOM_MAX - (sci_in(port, SCFDR) >> 8);
|
return SCIF2_TXROOM_MAX - (sci_in(port, SCFDR) >> 8);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int scif_rxroom(struct uart_port *port)
|
static inline int scif_rxroom(struct uart_port *port)
|
||||||
{
|
{
|
||||||
if((port->mapbase == 0xffe00000) || (port->mapbase == 0xffe08000)) /* SCIF0/1*/
|
if ((port->mapbase == 0xffe00000) ||
|
||||||
|
(port->mapbase == 0xffe08000)) {
|
||||||
|
/* SCIF0/1*/
|
||||||
return sci_in(port, SCRFDR) & 0xff;
|
return sci_in(port, SCRFDR) & 0xff;
|
||||||
else /* SCIF2 */
|
} else {
|
||||||
|
/* SCIF2 */
|
||||||
return sci_in(port, SCFDR) & SCIF2_RFDC_MASK;
|
return sci_in(port, SCFDR) & SCIF2_RFDC_MASK;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
static inline int scif_txroom(struct uart_port *port)
|
static inline int scif_txroom(struct uart_port *port)
|
||||||
|
@ -446,12 +460,12 @@ static inline int scif_rxroom(struct uart_port *port)
|
||||||
|
|
||||||
static inline int sci_txroom(struct uart_port *port)
|
static inline int sci_txroom(struct uart_port *port)
|
||||||
{
|
{
|
||||||
return ((sci_in(port, SCxSR) & SCI_TDRE) != 0);
|
return (sci_in(port, SCxSR) & SCI_TDRE) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int sci_rxroom(struct uart_port *port)
|
static inline int sci_rxroom(struct uart_port *port)
|
||||||
{
|
{
|
||||||
return ((sci_in(port, SCxSR) & SCxSR_RDxF(port)) != 0);
|
return (sci_in(port, SCxSR) & SCxSR_RDxF(port)) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ********************************************************************** *
|
/* ********************************************************************** *
|
||||||
|
@ -469,11 +483,10 @@ static void sci_transmit_chars(struct uart_port *port)
|
||||||
status = sci_in(port, SCxSR);
|
status = sci_in(port, SCxSR);
|
||||||
if (!(status & SCxSR_TDxE(port))) {
|
if (!(status & SCxSR_TDxE(port))) {
|
||||||
ctrl = sci_in(port, SCSCR);
|
ctrl = sci_in(port, SCSCR);
|
||||||
if (uart_circ_empty(xmit)) {
|
if (uart_circ_empty(xmit))
|
||||||
ctrl &= ~SCI_CTRL_FLAGS_TIE;
|
ctrl &= ~SCI_CTRL_FLAGS_TIE;
|
||||||
} else {
|
else
|
||||||
ctrl |= SCI_CTRL_FLAGS_TIE;
|
ctrl |= SCI_CTRL_FLAGS_TIE;
|
||||||
}
|
|
||||||
sci_out(port, SCSCR, ctrl);
|
sci_out(port, SCSCR, ctrl);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -521,11 +534,11 @@ static void sci_transmit_chars(struct uart_port *port)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* On SH3, SCIF may read end-of-break as a space->mark char */
|
/* On SH3, SCIF may read end-of-break as a space->mark char */
|
||||||
#define STEPFN(c) ({int __c=(c); (((__c-1)|(__c)) == -1); })
|
#define STEPFN(c) ({int __c = (c); (((__c-1)|(__c)) == -1); })
|
||||||
|
|
||||||
static inline void sci_receive_chars(struct uart_port *port)
|
static inline void sci_receive_chars(struct uart_port *port)
|
||||||
{
|
{
|
||||||
struct sci_port *sci_port = (struct sci_port *)port;
|
struct sci_port *sci_port = to_sci_port(port);
|
||||||
struct tty_struct *tty = port->info->port.tty;
|
struct tty_struct *tty = port->info->port.tty;
|
||||||
int i, count, copied = 0;
|
int i, count, copied = 0;
|
||||||
unsigned short status;
|
unsigned short status;
|
||||||
|
@ -550,13 +563,13 @@ static inline void sci_receive_chars(struct uart_port *port)
|
||||||
|
|
||||||
if (port->type == PORT_SCI) {
|
if (port->type == PORT_SCI) {
|
||||||
char c = sci_in(port, SCxRDR);
|
char c = sci_in(port, SCxRDR);
|
||||||
if (uart_handle_sysrq_char(port, c) || sci_port->break_flag)
|
if (uart_handle_sysrq_char(port, c) ||
|
||||||
|
sci_port->break_flag)
|
||||||
count = 0;
|
count = 0;
|
||||||
else {
|
else
|
||||||
tty_insert_flip_char(tty, c, TTY_NORMAL);
|
tty_insert_flip_char(tty, c, TTY_NORMAL);
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
for (i=0; i<count; i++) {
|
for (i = 0; i < count; i++) {
|
||||||
char c = sci_in(port, SCxRDR);
|
char c = sci_in(port, SCxRDR);
|
||||||
status = sci_in(port, SCxSR);
|
status = sci_in(port, SCxSR);
|
||||||
#if defined(CONFIG_CPU_SH3)
|
#if defined(CONFIG_CPU_SH3)
|
||||||
|
@ -657,7 +670,7 @@ static inline int sci_handle_errors(struct uart_port *port)
|
||||||
if (status & SCxSR_FER(port)) {
|
if (status & SCxSR_FER(port)) {
|
||||||
if (sci_rxd_in(port) == 0) {
|
if (sci_rxd_in(port) == 0) {
|
||||||
/* Notify of BREAK */
|
/* Notify of BREAK */
|
||||||
struct sci_port *sci_port = (struct sci_port *)port;
|
struct sci_port *sci_port = to_sci_port(port);
|
||||||
|
|
||||||
if (!sci_port->break_flag) {
|
if (!sci_port->break_flag) {
|
||||||
sci_port->break_flag = 1;
|
sci_port->break_flag = 1;
|
||||||
|
@ -666,10 +679,11 @@ static inline int sci_handle_errors(struct uart_port *port)
|
||||||
/* Do sysrq handling. */
|
/* Do sysrq handling. */
|
||||||
if (uart_handle_break(port))
|
if (uart_handle_break(port))
|
||||||
return 0;
|
return 0;
|
||||||
pr_debug("sci: BREAK detected\n");
|
pr_debug("sci: BREAK detected\n");
|
||||||
if (tty_insert_flip_char(tty, 0, TTY_BREAK))
|
if (tty_insert_flip_char(tty, 0, TTY_BREAK))
|
||||||
copied++;
|
copied++;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
/* frame error */
|
/* frame error */
|
||||||
if (tty_insert_flip_char(tty, 0, TTY_FRAME))
|
if (tty_insert_flip_char(tty, 0, TTY_FRAME))
|
||||||
|
@ -764,7 +778,7 @@ static irqreturn_t sci_er_interrupt(int irq, void *ptr)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
#if defined(SCIF_ORER)
|
#if defined(SCIF_ORER)
|
||||||
if((sci_in(port, SCLSR) & SCIF_ORER) != 0) {
|
if ((sci_in(port, SCLSR) & SCIF_ORER) != 0) {
|
||||||
struct tty_struct *tty = port->info->port.tty;
|
struct tty_struct *tty = port->info->port.tty;
|
||||||
|
|
||||||
sci_out(port, SCLSR, 0);
|
sci_out(port, SCLSR, 0);
|
||||||
|
@ -801,8 +815,8 @@ static irqreturn_t sci_mpxed_interrupt(int irq, void *ptr)
|
||||||
struct uart_port *port = ptr;
|
struct uart_port *port = ptr;
|
||||||
irqreturn_t ret = IRQ_NONE;
|
irqreturn_t ret = IRQ_NONE;
|
||||||
|
|
||||||
ssr_status = sci_in(port,SCxSR);
|
ssr_status = sci_in(port, SCxSR);
|
||||||
scr_status = sci_in(port,SCSCR);
|
scr_status = sci_in(port, SCSCR);
|
||||||
|
|
||||||
/* Tx Interrupt */
|
/* Tx Interrupt */
|
||||||
if ((ssr_status & 0x0020) && (scr_status & SCI_CTRL_FLAGS_TIE))
|
if ((ssr_status & 0x0020) && (scr_status & SCI_CTRL_FLAGS_TIE))
|
||||||
|
@ -832,7 +846,7 @@ static int sci_notifier(struct notifier_block *self,
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if ((phase == CPUFREQ_POSTCHANGE) ||
|
if ((phase == CPUFREQ_POSTCHANGE) ||
|
||||||
(phase == CPUFREQ_RESUMECHANGE)){
|
(phase == CPUFREQ_RESUMECHANGE)) {
|
||||||
for (i = 0; i < SCI_NPORTS; i++) {
|
for (i = 0; i < SCI_NPORTS; i++) {
|
||||||
struct uart_port *port = &sci_ports[i].port;
|
struct uart_port *port = &sci_ports[i].port;
|
||||||
struct clk *clk;
|
struct clk *clk;
|
||||||
|
@ -904,12 +918,12 @@ static void sci_free_irq(struct sci_port *port)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (port->irqs[0] == port->irqs[1]) {
|
if (port->irqs[0] == port->irqs[1]) {
|
||||||
if (!port->irqs[0])
|
if (!port->irqs[0])
|
||||||
printk("sci: sci_free_irq error\n");
|
printk(KERN_ERR "sci: sci_free_irq error\n");
|
||||||
else
|
else
|
||||||
free_irq(port->irqs[0], port);
|
free_irq(port->irqs[0], port);
|
||||||
} else {
|
} else {
|
||||||
for (i = 0; i < ARRAY_SIZE(port->irqs); i++) {
|
for (i = 0; i < ARRAY_SIZE(port->irqs); i++) {
|
||||||
if (!port->irqs[i])
|
if (!port->irqs[i])
|
||||||
continue;
|
continue;
|
||||||
|
@ -1060,12 +1074,12 @@ static void sci_set_termios(struct uart_port *port, struct ktermios *termios,
|
||||||
sci_out(port, SCSMR, smr_val);
|
sci_out(port, SCSMR, smr_val);
|
||||||
|
|
||||||
if (t > 0) {
|
if (t > 0) {
|
||||||
if(t >= 256) {
|
if (t >= 256) {
|
||||||
sci_out(port, SCSMR, (sci_in(port, SCSMR) & ~3) | 1);
|
sci_out(port, SCSMR, (sci_in(port, SCSMR) & ~3) | 1);
|
||||||
t >>= 2;
|
t >>= 2;
|
||||||
} else {
|
} else
|
||||||
sci_out(port, SCSMR, sci_in(port, SCSMR) & ~3);
|
sci_out(port, SCSMR, sci_in(port, SCSMR) & ~3);
|
||||||
}
|
|
||||||
sci_out(port, SCBRR, t);
|
sci_out(port, SCBRR, t);
|
||||||
udelay((1000000+(baud-1)) / baud); /* Wait one bit interval */
|
udelay((1000000+(baud-1)) / baud); /* Wait one bit interval */
|
||||||
}
|
}
|
||||||
|
@ -1076,16 +1090,20 @@ static void sci_set_termios(struct uart_port *port, struct ktermios *termios,
|
||||||
sci_out(port, SCSCR, SCSCR_INIT(port));
|
sci_out(port, SCSCR, SCSCR_INIT(port));
|
||||||
|
|
||||||
if ((termios->c_cflag & CREAD) != 0)
|
if ((termios->c_cflag & CREAD) != 0)
|
||||||
sci_start_rx(port,0);
|
sci_start_rx(port, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *sci_type(struct uart_port *port)
|
static const char *sci_type(struct uart_port *port)
|
||||||
{
|
{
|
||||||
switch (port->type) {
|
switch (port->type) {
|
||||||
case PORT_SCI: return "sci";
|
case PORT_IRDA:
|
||||||
case PORT_SCIF: return "scif";
|
return "irda";
|
||||||
case PORT_IRDA: return "irda";
|
case PORT_SCI:
|
||||||
case PORT_SCIFA: return "scifa";
|
return "sci";
|
||||||
|
case PORT_SCIF:
|
||||||
|
return "scif";
|
||||||
|
case PORT_SCIFA:
|
||||||
|
return "scifa";
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -1387,9 +1405,9 @@ console_initcall(kgdb_console_init);
|
||||||
#endif /* CONFIG_SH_KGDB_CONSOLE */
|
#endif /* CONFIG_SH_KGDB_CONSOLE */
|
||||||
|
|
||||||
#if defined(CONFIG_SH_KGDB_CONSOLE)
|
#if defined(CONFIG_SH_KGDB_CONSOLE)
|
||||||
#define SCI_CONSOLE &kgdb_console
|
#define SCI_CONSOLE (&kgdb_console)
|
||||||
#elif defined(CONFIG_SERIAL_SH_SCI_CONSOLE)
|
#elif defined(CONFIG_SERIAL_SH_SCI_CONSOLE)
|
||||||
#define SCI_CONSOLE &serial_console
|
#define SCI_CONSOLE (&serial_console)
|
||||||
#else
|
#else
|
||||||
#define SCI_CONSOLE 0
|
#define SCI_CONSOLE 0
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue