I ran over the entire code and fixed coding style warnings and errors
according to the /scripts/checkpatch.pl script. These changes include
fixing whitespaces, improving the readability of the code as well as
fixing evil typedefs. The code is still very bad, but now hopefully
easier to read.

Signed-off-by: Valentin Rothberg <[email protected]>

--- a/staging/drivers/staging/serial/68360serial.c      2011-11-25
16:28:50.000000000 +0100
+++ b/staging/drivers/staging/serial/68360serial.c      2011-11-26
10:30:09.313492822 +0100
@@ -29,7 +29,7 @@
 #include <linux/tty.h>
 #include <linux/tty_flip.h>
 #include <linux/serial.h>
-#include <linux/serialP.h>
+#include <linux/serialP.h>
 #include <linux/major.h>
 #include <linux/string.h>
 #include <linux/fcntl.h>
@@ -41,7 +41,7 @@
 #include <asm/m68360.h>
 #include <asm/commproc.h>

-
+
 #ifdef CONFIG_KGDB
 extern void breakpoint(void);
 extern void set_debug_traps(void);
@@ -91,7 +91,7 @@ int serial_console_setup(struct console
 #undef SERIAL_DEBUG_RS_WAIT_UNTIL_SENT

 #define _INLINE_ inline
-
+
 #define DBG_CNT(s)

 /* We overload some of the items in the data structure to meet our
@@ -161,7 +161,7 @@ struct serial_state {
         u16     iomem_reg_shift;
         unsigned short  close_delay;
         unsigned short  closing_wait; /* time to wait before closing */
-        struct async_icount_24     icount;
+        struct async_icount_24     icount;
         int     io_type;
         struct async_struct *info;
 };
@@ -229,14 +229,14 @@ char *console_fifos[CONSOLE_NUM_FIFO * C
 /* The async_struct in serial.h does not really give us what we
  * need, so define our own here.
  */
-typedef struct serial_info {
+struct serial_info {
        int                     magic;
        int                     flags;

        struct serial_state     *state;
        /* struct serial_struct *state; */
        /* struct async_struct  *state; */
-       
+
        struct tty_struct       *tty;
        int                     read_status_mask;
        int                     ignore_status_mask;
@@ -251,10 +251,10 @@ typedef struct serial_info {
        int                     blocked_open; /* # of blocked opens */
        struct work_struct      tqueue;
        struct work_struct      tqueue_hangup;
-       wait_queue_head_t       open_wait;
-       wait_queue_head_t       close_wait;
+       wait_queue_head_t       open_wait;
+       wait_queue_head_t       close_wait;
+

-       
 /* CPM Buffer Descriptor pointers.
        */
        QUICC_BD                        *rx_bd_base;
@@ -332,7 +332,7 @@ static void rs_360_stop(struct tty_struc

        if (serial_paranoia_check(info, tty->name, "rs_stop"))
                return;
-       
+
        local_irq_save(flags);
        idx = PORT_NUM(info->state->smc_scc_num);
        if (info->state->smc_scc_num & NUM_IS_SCC) {
@@ -357,7 +357,7 @@ static void rs_360_start(struct tty_stru

        if (serial_paranoia_check(info, tty->name, "rs_stop"))
                return;
-       
+
        local_irq_save(flags);
        idx = PORT_NUM(info->state->smc_scc_num);
        if (info->state->smc_scc_num & NUM_IS_SCC) {
@@ -382,7 +382,7 @@ static void rs_360_start(struct tty_stru
  * rs_interrupt() should try to keep the interrupt handler as fast as
  * possible.  After you are done making modifications, it is not a bad
  * idea to do:
- *
+ *
  * gcc -S -DKERNEL -Wall -Wstrict-prototypes -O6 -fomit-frame-pointer serial.c
  *
  * and look at the resulting assemble code in serial.s.
@@ -398,7 +398,7 @@ static _INLINE_ void receive_chars(ser_i
        /*int   ignored = 0;*/
        int     i;
        ushort  status;
-        struct async_icount *icount;
+        struct async_icount *icount;
        /* struct       async_icount_24 *icount; */
        volatile QUICC_BD       *bdp;

@@ -472,7 +472,7 @@ static _INLINE_ void receive_chars(ser_i
                                }
                                 */
                                status &= info->read_status_mask;
-               
+
                                if (status & (BD_SC_BR)) {
 #ifdef SERIAL_DEBUG_INTR
                                        printk("handling break....");
@@ -545,7 +545,7 @@ static _INLINE_ void check_modem_status(
        int     status;
        /* struct       async_icount *icount; */
        struct  async_icount_24 *icount;
-       
+
        status = serial_in(info, UART_MSR);

        if (status & UART_MSR_ANY_DELTA) {
@@ -572,7 +572,7 @@ static _INLINE_ void check_modem_status(
 #if (defined(SERIAL_DEBUG_OPEN) || defined(SERIAL_DEBUG_INTR))
                printk("ttys%d CD now %s...", info->line,
                       (status & UART_MSR_DCD) ? "on" : "off");
-#endif         
+#endif
                if (status & UART_MSR_DCD)
                        wake_up_interruptible(&info->open_wait);
                else {
@@ -620,7 +620,7 @@ static void rs_360_interrupt(int vec, vo
        ser_info_t *info;
        volatile struct smc_regs *smcp;
        volatile struct scc_regs *sccp;
-       
+
        info = dev_id;

        idx = PORT_NUM(info->state->smc_scc_num);
@@ -643,7 +643,7 @@ static void rs_360_interrupt(int vec, vo
                        transmit_chars(info);
                smcp->smc_smce = events;
        }
-       
+
 #ifdef SERIAL_DEBUG_INTR
        printk("rs_interrupt_single(%d, %x)...",
                                        info->state->smc_scc_num, events);
@@ -669,7 +669,7 @@ static void do_softint(void *private_)
 {
        ser_info_t      *info = (ser_info_t *) private_;
        struct tty_struct       *tty;
-       
+
        tty = info->port.tty;
        if (!tty)
                return;
@@ -686,13 +686,13 @@ static void do_softint(void *private_)
  *
  *     serial interrupt routine -> (scheduler tqueue) ->
  *     do_serial_hangup() -> tty->hangup() -> rs_hangup()
- *
+ *
  */
 static void do_serial_hangup(void *private_)
 {
        struct async_struct     *info = (struct async_struct *) private_;
        struct tty_struct       *tty;
-       
+
        tty = info->port.tty;
        if (!tty)
                return;
@@ -737,7 +737,7 @@ static int startup(ser_info_t *info)
        if (info->port.tty->termios->c_cflag & CBAUD)
                info->MCR = UART_MCR_DTR | UART_MCR_RTS;
 #endif
-       
+
        if (info->port.tty)
                clear_bit(TTY_IO_ERROR, &info->port.tty->flags);

@@ -786,7 +786,7 @@ static int startup(ser_info_t *info)
        info->flags |= ASYNC_INITIALIZED;
        local_irq_restore(flags);
        return 0;
-       
+
 errout:
        local_irq_restore(flags);
        return retval;
@@ -813,7 +813,7 @@ static void shutdown(ser_info_t *info)
        printk("Shutting down serial port %d (irq %d)....", info->line,
               state->irq);
 #endif
-       
+
        local_irq_save(flags);

        idx = PORT_NUM(state->smc_scc_num);
@@ -841,7 +841,7 @@ static void shutdown(ser_info_t *info)
 #endif
                        smcp->smc_smcmr &= ~(SMCMR_REN | SMCMR_TEN);
        }
-       
+
        if (info->port.tty)
                set_bit(TTY_IO_ERROR, &info->port.tty->flags);

@@ -940,7 +940,7 @@ static void change_speed(ser_info_t *inf
                info->read_status_mask |= BD_SC_FR | BD_SC_PR;
        if (I_BRKINT(info->port.tty) || I_PARMRK(info->port.tty))
                info->read_status_mask |= BD_SC_BR;
-       
+
        /*
         * Characters to ignore
         */
@@ -950,7 +950,7 @@ static void change_speed(ser_info_t *inf
        if (I_IGNBRK(info->port.tty)) {
                info->ignore_status_mask |= BD_SC_BR;
                /*
-                * If we're ignore parity and break indicators, ignore
+                * If we're ignore parity and break indicators, ignore
                 * overruns too.  (For real raw support).
                 */
                if (I_IGNPAR(info->port.tty))
@@ -1028,7 +1028,7 @@ static int rs_360_write(struct tty_struc
        volatile QUICC_BD *bdp;

 #ifdef CONFIG_KGDB
-       /* Try to let stub handle output. Returns true if it did. */
+       /* Try to let stub handle output. Returns true if it did. */
        if (kgdb_output_string(buf, count))
                return ret;
 #endif
@@ -1036,7 +1036,7 @@ static int rs_360_write(struct tty_struc
        if (serial_paranoia_check(info, tty->name, "rs_write"))
                return 0;

-       if (!tty)
+       if (!tty)
                return 0;

        bdp = info->tx_cur;
@@ -1097,7 +1097,7 @@ static int rs_360_write_room(struct tty_
 static int rs_360_chars_in_buffer(struct tty_struct *tty)
 {
        ser_info_t *info = (ser_info_t *)tty->driver_data;
-                               
+
        if (serial_paranoia_check(info, tty->name, "rs_chars_in_buffer"))
                return 0;
        return 0;
@@ -1106,7 +1106,7 @@ static int rs_360_chars_in_buffer(struct
 static void rs_360_flush_buffer(struct tty_struct *tty)
 {
        ser_info_t *info = (ser_info_t *)tty->driver_data;
-                               
+
        if (serial_paranoia_check(info, tty->name, "rs_flush_buffer"))
                return;

@@ -1151,7 +1151,7 @@ static void rs_360_send_xchar(struct tty
 /*
  * ------------------------------------------------------------
  * rs_throttle()
- *
+ *
  * This routine is called by the upper-layer tty layer to signal that
  * incoming characters should be throttled.
  * ------------------------------------------------------------
@@ -1161,14 +1161,14 @@ static void rs_360_throttle(struct tty_s
        ser_info_t *info = (ser_info_t *)tty->driver_data;
 #ifdef SERIAL_DEBUG_THROTTLE
        char    buf[64];
-       
+
        printk("throttle %s: %d....\n", _tty_name(tty, buf),
               tty->ldisc.chars_in_buffer(tty));
 #endif

        if (serial_paranoia_check(info, tty->name, "rs_throttle"))
                return;
-       
+
        if (I_IXOFF(tty))
                rs_360_send_xchar(tty, STOP_CHAR(tty));

@@ -1187,14 +1187,14 @@ static void rs_360_unthrottle(struct tty
        ser_info_t *info = (ser_info_t *)tty->driver_data;
 #ifdef SERIAL_DEBUG_THROTTLE
        char    buf[64];
-       
+
        printk("unthrottle %s: %d....\n", _tty_name(tty, buf),
               tty->ldisc.chars_in_buffer(tty));
 #endif

        if (serial_paranoia_check(info, tty->name, "rs_unthrottle"))
                return;
-       
+
        if (I_IXOFF(tty)) {
                if (info->x_char)
                        info->x_char = 0;
@@ -1225,7 +1225,7 @@ static void rs_360_unthrottle(struct tty
  *         release the bus after transmitting. This must be done when
  *         the transmit shift register is empty, not be done when the
  *         transmit holding register is empty.  This functionality
- *         allows an RS485 driver to be written in user space.
+ *         allows an RS485 driver to be written in user space.
  */
 static int get_lsr_info(struct async_struct * info, unsigned int *value)
 {
@@ -1411,7 +1411,7 @@ static int rs_360_ioctl(struct tty_struc
        int error;
        ser_info_t *info = (ser_info_t *)tty->driver_data;
        int retval;
-       struct async_icount cnow;
+       struct async_icount cnow;
        /* struct async_icount_24 cnow;*/       /* kernel counter temps */
        struct serial_icounter_struct *p_cuser; /* user space */

@@ -1422,7 +1422,7 @@ static int rs_360_ioctl(struct tty_struc
                if (tty->flags & (1 << TTY_IO_ERROR))
                    return -EIO;
        }
-       
+
        switch (cmd) {
                case TCSBRK:    /* SVID version: non-zero arg --> no break */
                        retval = tty_check_change(tty);
@@ -1485,7 +1485,7 @@ static int rs_360_ioctl(struct tty_struc
                                local_irq_disable();
                                cnow = info->state->icount; /* atomic copy */
                                local_irq_enable();
-                               if (cnow.rng == cprev.rng && cnow.dsr == 
cprev.dsr &&
+                               if (cnow.rng == cprev.rng && cnow.dsr == 
cprev.dsr &&
                                    cnow.dcd == cprev.dcd && cnow.cts == 
cprev.cts)
                                        return -EIO; /* no change => error */
                                if ( ((arg & TIOCM_RNG) && (cnow.rng != 
cprev.rng)) ||
@@ -1525,7 +1525,7 @@ static void rs_360_set_termios(struct tt
                serial_out(info, UART_MCR, info->MCR);
                local_irq_enable();
        }
-       
+
        /* Handle transition away from B0 status */
        if (!(old_termios->c_cflag & CBAUD) &&
            (tty->termios->c_cflag & CBAUD)) {
@@ -1538,7 +1538,7 @@ static void rs_360_set_termios(struct tt
                serial_out(info, UART_MCR, info->MCR);
                local_irq_enable();
        }
-       
+
        /* Handle turning off CRTSCTS */
        if ((old_termios->c_cflag & CRTSCTS) &&
            !(tty->termios->c_cflag & CRTSCTS)) {
@@ -1563,7 +1563,7 @@ static void rs_360_set_termios(struct tt
 /*
  * ------------------------------------------------------------
  * rs_close()
- *
+ *
  * This routine is called when the serial port gets closed.  First, we
  * wait for the last remaining data to be sent.  Then, we unlink its
  * async structure from the interrupt chain if necessary, and we free
@@ -1584,15 +1584,15 @@ static void rs_360_close(struct tty_stru
                return;

        state = info->state;
-       
+
        local_irq_save(flags);
-       
+
        if (tty_hung_up_p(filp)) {
                DBG_CNT("before DEC-hung");
                local_irq_restore(flags);
                return;
        }
-       
+
 #ifdef SERIAL_DEBUG_OPEN
        printk("rs_close ttys%d, count = %d\n", info->line, state->count);
 #endif
@@ -1620,7 +1620,7 @@ static void rs_360_close(struct tty_stru
        }
        info->flags |= ASYNC_CLOSING;
        /*
-        * Now we wait for the transmit buffer to clear; and we notify
+        * Now we wait for the transmit buffer to clear; and we notify
         * the line discipline to only process XON/XOFF characters.
         */
        tty->closing = 1;
@@ -1654,7 +1654,7 @@ static void rs_360_close(struct tty_stru
        }
        shutdown(info);
        rs_360_flush_buffer(tty);
-       tty_ldisc_flush(tty);           
+       tty_ldisc_flush(tty);
        tty->closing = 0;
        info->event = 0;
        info->port.tty = NULL;
@@ -1678,7 +1678,7 @@ static void rs_360_wait_until_sent(struc
        unsigned long orig_jiffies, char_time;
        /*int lsr;*/
        volatile QUICC_BD *bdp;
-       
+
        if (serial_paranoia_check(info, tty->name, "rs_wait_until_sent"))
                return;

@@ -1692,7 +1692,7 @@ static void rs_360_wait_until_sent(struc
         * Set the check interval to be 1/5 of the estimated time to
         * send a single character, and make it at least 1.  The check
         * interval should also be less than the timeout.
-        *
+        *
         * Note: we have to use pretty tight timings here to satisfy
         * the NIST-PCTS.
         */
@@ -1744,12 +1744,12 @@ static void rs_360_hangup(struct tty_str
 {
        ser_info_t *info = (ser_info_t *)tty->driver_data;
        struct serial_state *state = info->state;
-       
+
        if (serial_paranoia_check(info, tty->name, "rs_hangup"))
                return;

        state = info->state;
-       
+
        rs_360_flush_buffer(tty);
        shutdown(info);
        info->event = 0;
@@ -1807,7 +1807,7 @@ static int block_til_ready(struct tty_st

        if (tty->termios->c_cflag & CLOCAL)
                do_clocal = 1;
-       
+
        /*
         * Block waiting for the carrier detect and the line to become
         * free (i.e., not in use by the callout).  While we are in
@@ -1823,7 +1823,7 @@ static int block_til_ready(struct tty_st
               state->line, state->count);
 #endif
        local_irq_disable();
-       if (!tty_hung_up_p(filp))
+       if (!tty_hung_up_p(filp))
                state->count--;
        local_irq_enable();
        info->blocked_open++;
@@ -1841,7 +1841,7 @@ static int block_til_ready(struct tty_st
                        if (info->flags & ASYNC_HUP_NOTIFY)
                                retval = -EAGAIN;
                        else
-                               retval = -ERESTARTSYS;  
+                               retval = -ERESTARTSYS;
 #else
                        retval = -EAGAIN;
 #endif
@@ -1981,7 +1981,7 @@ static inline int line_info(char *buf, s
        status = serial_in(info, UART_MSR);
        control = info ? info->MCR : serial_in(info, UART_MCR);
        local_irq_enable();
-       
+
        stat_buf[0] = 0;
        stat_buf[1] = 0;
        if (control & UART_MCR_RTS)
@@ -2007,12 +2007,12 @@ static inline int line_info(char *buf, s

        if (state->icount.frame)
                ret += sprintf(buf+ret, " fe:%d", state->icount.frame);
-       
+
        if (state->icount.parity)
                ret += sprintf(buf+ret, " pe:%d", state->icount.parity);
-       
+
        if (state->icount.brk)
-               ret += sprintf(buf+ret, " brk:%d", state->icount.brk);  
+               ret += sprintf(buf+ret, " brk:%d", state->icount.brk);

        if (state->icount.overrun)
                ret += sprintf(buf+ret, " oe:%d", state->icount.overrun);
@@ -2135,7 +2135,7 @@ static void my_console_write(int idx, co
                 */
                cp = bdp->buf;
                *cp = *s;
-               
+
                bdp->length = 1;
                bdp->status |= BD_SC_READY;

@@ -2176,7 +2176,7 @@ static void serial_console_write(struct
                                unsigned count)
 {
 #ifdef CONFIG_KGDB
-       /* Try to let stub handle output. Returns true if it did. */
+       /* Try to let stub handle output. Returns true if it did. */
        if (kgdb_output_string(s, count))
                return;
 #endif
@@ -2385,7 +2385,7 @@ struct console sercons = {
        .wait_key       = serial_console_wait_key,
        .setup          = serial_console_setup,
        .flags          = CON_PRINTBUFFER,
-       .index          = CONFIG_SERIAL_CONSOLE_PORT,
+       .index          = CONFIG_SERIAL_CONSOLE_PORT,
 };


@@ -2446,7 +2446,7 @@ static int __init rs_360_init(void)
        volatile        struct scc_regs *scp;
        volatile        struct uart_pram        *sup;
        /* volatile     immap_t         *immap; */
-       
+
        serial_driver = alloc_tty_driver(NR_PORTS);
        if (!serial_driver)
                return -1;
@@ -2463,7 +2463,7 @@ static int __init rs_360_init(void)
                baud_idx | CS8 | CREAD | HUPCL | CLOCAL;
        serial_driver->flags = TTY_DRIVER_REAL_RAW;
        tty_set_operations(serial_driver, &rs_360_ops);
-       
+
        if (tty_register_driver(serial_driver))
                panic("Couldn't register serial driver\n");

@@ -2487,7 +2487,7 @@ static int __init rs_360_init(void)
         * as general purpose I/O.  This will assert CTS and CD for the
         * SCC ports.
         */
-       /* FIXME: see 360um p.7-365 and 860um p.34-12
+       /* FIXME: see 360um p.7-365 and 860um p.34-12
         * I can't make sense of these bits - mleslie*/
 /*     immap->im_ioport.iop_pcdir |= 0x03c6; */
 /*     immap->im_ioport.iop_pcpar &= ~0x03c6; */
@@ -2524,7 +2524,7 @@ static int __init rs_360_init(void)
                state->custom_divisor = 0;
                state->close_delay = 5*HZ/10;
                state->closing_wait = 30*HZ;
-               state->icount.cts = state->icount.dsr =
+               state->icount.cts = state->icount.dsr =
                        state->icount.rng = state->icount.dcd = 0;
                state->icount.rx = state->icount.tx = 0;
                state->icount.frame = state->icount.parity = 0;
@@ -2681,7 +2681,7 @@ static int __init rs_360_init(void)
                                 * Enable receive and transmit.
                                 */
                                scp->scc_gsmr.w.high = 0;
-                               scp->scc_gsmr.w.low =
+                               scp->scc_gsmr.w.low =
                                        (SCC_GSMRL_MODE_UART | 
SCC_GSMRL_TDCR_16 | SCC_GSMRL_RDCR_16);

                                /* Disable all interrupts and clear all pending
@@ -2823,7 +2823,7 @@ int serial_console_setup( struct console
        if (ser->smc_scc_num & NUM_IS_SCC) {

                /* TODO: need to set up SCC pin assignment etc. here */
-               
+
        }
        else {
                iobits = 0xc0 << (idx * 4);
@@ -2917,7 +2917,7 @@ int serial_console_setup( struct console
                 * Enable receive and transmit.
                 */
                scp->scc_gsmr.w.high = 0;
-               scp->scc_gsmr.w.low =
+               scp->scc_gsmr.w.low =
                        (SCC_GSMRL_MODE_UART | SCC_GSMRL_TDCR_16 | 
SCC_GSMRL_RDCR_16);

                /* Disable all interrupts and clear all pending
_______________________________________________
devel mailing list
[email protected]
http://driverdev.linuxdriverproject.org/mailman/listinfo/devel

Reply via email to