In order to prepare the submission of other functional
patches, the checkpatch script has been applied and the
reported issues have been solved.

Signed-off-by: Gwenn Bourree <[email protected]>
---
 drivers/tty/n_gsm.c | 56 +++++++++++++++++++++++++++++++++++++++++------------
 1 file changed, 44 insertions(+), 12 deletions(-)

diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
index 382d3fc..2983ae2 100644
--- a/drivers/tty/n_gsm.c
+++ b/drivers/tty/n_gsm.c
@@ -486,10 +486,11 @@ static void gsm_print_packet(const char *hdr, int addr, 
int cr,
                pr_cont("UIH");
                break;
        default:
-               if (!(control & 0x01)) {
+               if (!(control & 0x01))
                        pr_cont("I N(S)%d N(R)%d",
                                (control & 0x0E) >> 1, (control & 0xE0) >> 5);
-               } else switch (control & 0x0F) {
+               else
+                       switch (control & 0x0F) {
                        case RR:
                                pr_cont("RR(%d)", (control & 0xE0) >> 5);
                                break;
@@ -501,7 +502,7 @@ static void gsm_print_packet(const char *hdr, int addr, int 
cr,
                                break;
                        default:
                                pr_cont("[%02X]", control);
-               }
+                       }
        }
 
        if (control & PF)
@@ -511,6 +512,7 @@ static void gsm_print_packet(const char *hdr, int addr, int 
cr,
 
        if (dlen) {
                int ct = 0;
+
                while (dlen--) {
                        if (ct % 8 == 0) {
                                pr_cont("\n");
@@ -542,6 +544,7 @@ static void gsm_print_packet(const char *hdr, int addr, int 
cr,
 static int gsm_stuff_frame(const u8 *input, u8 *output, int len)
 {
        int olen = 0;
+
        while (len--) {
                if (*input == GSM1_SOF || *input == GSM1_ESCAPE
                    || *input == XON || *input == XOFF) {
@@ -695,7 +698,7 @@ static void gsm_data_kick(struct gsm_mux *gsm)
                        len += 2;
                } else {
                        gsm->txframe[0] = GSM0_SOF;
-                       memcpy(gsm->txframe + 1 , msg->data, msg->len);
+                       memcpy(gsm->txframe + 1, msg->data, msg->len);
                        gsm->txframe[msg->len + 1] = GSM0_SOF;
                        len = msg->len + 2;
                }
@@ -750,7 +753,7 @@ static void __gsm_data_queue(struct gsm_dlci *dlci, struct 
gsm_msg *msg)
                *--dp = (msg->addr << 2) | 2 | EA;
        else
                *--dp = (msg->addr << 2) | EA;
-       *fcs = gsm_fcs_add_block(INIT_FCS, dp , msg->data - dp);
+       *fcs = gsm_fcs_add_block(INIT_FCS, dp, msg->data - dp);
        /* Ugly protocol layering violation */
        if (msg->ctrl == UI || msg->ctrl == (UI|PF))
                *fcs = gsm_fcs_add_block(*fcs, msg->data, msg->len);
@@ -783,6 +786,7 @@ static void __gsm_data_queue(struct gsm_dlci *dlci, struct 
gsm_msg *msg)
 static void gsm_data_queue(struct gsm_dlci *dlci, struct gsm_msg *msg)
 {
        unsigned long flags;
+
        spin_lock_irqsave(&dlci->gsm->tx_lock, flags);
        __gsm_data_queue(dlci, msg);
        spin_unlock_irqrestore(&dlci->gsm->tx_lock, flags);
@@ -833,7 +837,8 @@ static int gsm_dlci_data_output(struct gsm_mux *gsm, struct 
gsm_dlci *dlci)
                        *dp++ = gsm_encode_modem(dlci);
                        break;
                }
-               WARN_ON(kfifo_out_locked(dlci->fifo, dp , len, &dlci->lock) != 
len);
+               WARN_ON(kfifo_out_locked(dlci->fifo, dp, len,
+                               &dlci->lock) != len);
                __gsm_data_queue(dlci, msg);
                total_size += size;
        }
@@ -1005,6 +1010,7 @@ static void gsm_control_reply(struct gsm_mux *gsm, int 
cmd, u8 *data,
                                        int dlen)
 {
        struct gsm_msg *msg;
+
        msg = gsm_data_alloc(gsm, 0, dlen + 2, gsm->ftype);
        if (msg == NULL)
                return;
@@ -1308,6 +1314,7 @@ static void gsm_control_response(struct gsm_mux *gsm, 
unsigned int command,
 static void gsm_control_transmit(struct gsm_mux *gsm, struct gsm_control *ctrl)
 {
        struct gsm_msg *msg = gsm_data_alloc(gsm, 0, ctrl->len + 1, gsm->ftype);
+
        if (msg == NULL)
                return;
        msg->data[0] = (ctrl->cmd << 1) | 2 | EA;       /* command */
@@ -1331,6 +1338,7 @@ static void gsm_control_retransmit(unsigned long data)
        struct gsm_mux *gsm = (struct gsm_mux *)data;
        struct gsm_control *ctrl;
        unsigned long flags;
+
        spin_lock_irqsave(&gsm->control_lock, flags);
        ctrl = gsm->pending_cmd;
        if (ctrl) {
@@ -1367,6 +1375,7 @@ static struct gsm_control *gsm_control_send(struct 
gsm_mux *gsm,
        struct gsm_control *ctrl = kzalloc(sizeof(struct gsm_control),
                                                GFP_KERNEL);
        unsigned long flags;
+
        if (ctrl == NULL)
                return NULL;
 retry:
@@ -1400,6 +1409,7 @@ retry:
 static int gsm_control_wait(struct gsm_mux *gsm, struct gsm_control *control)
 {
        int err;
+
        wait_event(gsm->event, control->done == 1);
        err = control->error;
        kfree(control);
@@ -1507,6 +1517,7 @@ static void gsm_dlci_t1(unsigned long data)
 static void gsm_dlci_begin_open(struct gsm_dlci *dlci)
 {
        struct gsm_mux *gsm = dlci->gsm;
+
        if (dlci->state == DLCI_OPEN || dlci->state == DLCI_OPENING)
                return;
        dlci->retries = gsm->n2;
@@ -1529,6 +1540,7 @@ static void gsm_dlci_begin_open(struct gsm_dlci *dlci)
 static void gsm_dlci_begin_close(struct gsm_dlci *dlci)
 {
        struct gsm_mux *gsm = dlci->gsm;
+
        if (dlci->state == DLCI_CLOSED || dlci->state == DLCI_CLOSING)
                return;
        dlci->retries = gsm->n2;
@@ -1602,9 +1614,11 @@ static void gsm_dlci_command(struct gsm_dlci *dlci, u8 
*data, int len)
 {
        /* See what command is involved */
        unsigned int command = 0;
+
        while (len-- > 0) {
                if (gsm_read_ea(&command, *data++) == 1) {
                        int clen = *data++;
+
                        len--;
                        /* FIXME: this is properly an EA */
                        clen >>= 1;
@@ -1639,6 +1653,7 @@ static void gsm_dlci_command(struct gsm_dlci *dlci, u8 
*data, int len)
 static struct gsm_dlci *gsm_dlci_alloc(struct gsm_mux *gsm, int addr)
 {
        struct gsm_dlci *dlci = kzalloc(sizeof(struct gsm_dlci), GFP_ATOMIC);
+
        if (dlci == NULL)
                return NULL;
        spin_lock_init(&dlci->lock);
@@ -1711,6 +1726,7 @@ static void gsm_destroy_network(struct gsm_dlci *dlci);
 static void gsm_dlci_release(struct gsm_dlci *dlci)
 {
        struct tty_struct *tty = tty_port_tty_get(&dlci->port);
+
        if (tty) {
                mutex_lock(&dlci->mutex);
                gsm_destroy_network(dlci);
@@ -1840,7 +1856,6 @@ static void gsm_queue(struct gsm_mux *gsm)
        return;
 invalid:
        gsm->malformed++;
-       return;
 }
 
 
@@ -2140,6 +2155,7 @@ static void gsm_free_mux(struct gsm_mux *gsm)
 static void gsm_free_muxr(struct kref *ref)
 {
        struct gsm_mux *gsm = container_of(ref, struct gsm_mux, ref);
+
        gsm_free_mux(gsm);
 }
 
@@ -2162,6 +2178,7 @@ static inline void mux_put(struct gsm_mux *gsm)
 static struct gsm_mux *gsm_alloc_mux(void)
 {
        struct gsm_mux *gsm = kzalloc(sizeof(struct gsm_mux), GFP_KERNEL);
+
        if (gsm == NULL)
                return NULL;
        gsm->buf = kmalloc(MAX_MRU + 1, GFP_KERNEL);
@@ -2407,9 +2424,8 @@ static void gsmld_write_wakeup(struct tty_struct *tty)
        clear_bit(TTY_DO_WRITE_WAKEUP, &tty->flags);
        spin_lock_irqsave(&gsm->tx_lock, flags);
        gsm_data_kick(gsm);
-       if (gsm->tx_bytes < TX_THRESH_LO) {
+       if (gsm->tx_bytes < TX_THRESH_LO)
                gsm_dlci_data_sweep(gsm);
-       }
        spin_unlock_irqrestore(&gsm->tx_lock, flags);
 }
 
@@ -2452,6 +2468,7 @@ static ssize_t gsmld_write(struct tty_struct *tty, struct 
file *file,
                           const unsigned char *buf, size_t nr)
 {
        int space = tty_write_room(tty);
+
        if (space >= nr)
                return tty->ops->write(tty, buf, nr);
        set_bit(TTY_DO_WRITE_WAKEUP, &tty->flags);
@@ -2670,6 +2687,7 @@ static int gsm_mux_net_start_xmit(struct sk_buff *skb,
 {
        struct gsm_mux_net *mux_net = netdev_priv(net);
        struct gsm_dlci *dlci = mux_net->dlci;
+
        muxnet_get(mux_net);
 
        skb_queue_head(&dlci->skb_list, skb);
@@ -2698,6 +2716,7 @@ static void gsm_mux_rx_netchar(struct gsm_dlci *dlci,
        struct net_device *net = dlci->net;
        struct sk_buff *skb;
        struct gsm_mux_net *mux_net = netdev_priv(net);
+
        muxnet_get(mux_net);
 
        /* Allocate an sk_buff */
@@ -2712,7 +2731,7 @@ static void gsm_mux_rx_netchar(struct gsm_dlci *dlci,
        memcpy(skb_put(skb, size), in_buf, size);
 
        skb->dev = net;
-       skb->protocol = __constant_htons(ETH_P_IP);
+       skb->protocol = htons(ETH_P_IP);
 
        /* Ship it off to the kernel */
        netif_rx(skb);
@@ -2721,12 +2740,12 @@ static void gsm_mux_rx_netchar(struct gsm_dlci *dlci,
        STATS(net).rx_packets++;
        STATS(net).rx_bytes += size;
        muxnet_put(mux_net);
-       return;
 }
 
 static int gsm_change_mtu(struct net_device *net, int new_mtu)
 {
        struct gsm_mux_net *mux_net = netdev_priv(net);
+
        if ((new_mtu < 8) || (new_mtu > mux_net->dlci->gsm->mtu))
                return -EINVAL;
        net->mtu = new_mtu;
@@ -2868,6 +2887,7 @@ static int gsmtty_modem_update(struct gsm_dlci *dlci, u8 
brk)
 static int gsm_carrier_raised(struct tty_port *port)
 {
        struct gsm_dlci *dlci = container_of(port, struct gsm_dlci, port);
+
        /* Not yet open so no carrier info */
        if (dlci->state != DLCI_OPEN)
                return 0;
@@ -2880,6 +2900,7 @@ static void gsm_dtr_rts(struct tty_port *port, int onoff)
 {
        struct gsm_dlci *dlci = container_of(port, struct gsm_dlci, port);
        unsigned int modem_tx = dlci->modem_tx;
+
        if (onoff)
                modem_tx |= TIOCM_DTR | TIOCM_RTS;
        else
@@ -2992,12 +3013,12 @@ static void gsmtty_close(struct tty_struct *tty, struct 
file *filp)
        }
        tty_port_close_end(&dlci->port, tty);
        tty_port_tty_set(&dlci->port, NULL);
-       return;
 }
 
 static void gsmtty_hangup(struct tty_struct *tty)
 {
        struct gsm_dlci *dlci = tty->driver_data;
+
        if (dlci->state == DLCI_CLOSED)
                return;
        tty_port_hangup(&dlci->port);
@@ -3009,6 +3030,7 @@ static int gsmtty_write(struct tty_struct *tty, const 
unsigned char *buf,
 {
        int sent;
        struct gsm_dlci *dlci = tty->driver_data;
+
        if (dlci->state == DLCI_CLOSED)
                return -EINVAL;
        /* Stuff the bytes into the fifo queue */
@@ -3021,6 +3043,7 @@ static int gsmtty_write(struct tty_struct *tty, const 
unsigned char *buf,
 static int gsmtty_write_room(struct tty_struct *tty)
 {
        struct gsm_dlci *dlci = tty->driver_data;
+
        if (dlci->state == DLCI_CLOSED)
                return -EINVAL;
        return TX_SIZE - kfifo_len(dlci->fifo);
@@ -3029,6 +3052,7 @@ static int gsmtty_write_room(struct tty_struct *tty)
 static int gsmtty_chars_in_buffer(struct tty_struct *tty)
 {
        struct gsm_dlci *dlci = tty->driver_data;
+
        if (dlci->state == DLCI_CLOSED)
                return -EINVAL;
        return kfifo_len(dlci->fifo);
@@ -3037,6 +3061,7 @@ static int gsmtty_chars_in_buffer(struct tty_struct *tty)
 static void gsmtty_flush_buffer(struct tty_struct *tty)
 {
        struct gsm_dlci *dlci = tty->driver_data;
+
        if (dlci->state == DLCI_CLOSED)
                return;
        /* Caution needed: If we implement reliable transport classes
@@ -3057,6 +3082,7 @@ static void gsmtty_wait_until_sent(struct tty_struct 
*tty, int timeout)
 static int gsmtty_tiocmget(struct tty_struct *tty)
 {
        struct gsm_dlci *dlci = tty->driver_data;
+
        if (dlci->state == DLCI_CLOSED)
                return -EINVAL;
        return dlci->modem_rx;
@@ -3117,6 +3143,7 @@ static int gsmtty_ioctl(struct tty_struct *tty,
 static void gsmtty_set_termios(struct tty_struct *tty, struct ktermios *old)
 {
        struct gsm_dlci *dlci = tty->driver_data;
+
        if (dlci->state == DLCI_CLOSED)
                return;
        /* For the moment its fixed. In actual fact the speed information
@@ -3130,6 +3157,7 @@ static void gsmtty_set_termios(struct tty_struct *tty, 
struct ktermios *old)
 static void gsmtty_throttle(struct tty_struct *tty)
 {
        struct gsm_dlci *dlci = tty->driver_data;
+
        if (dlci->state == DLCI_CLOSED)
                return;
        if (tty->termios.c_cflag & CRTSCTS)
@@ -3142,6 +3170,7 @@ static void gsmtty_throttle(struct tty_struct *tty)
 static void gsmtty_unthrottle(struct tty_struct *tty)
 {
        struct gsm_dlci *dlci = tty->driver_data;
+
        if (dlci->state == DLCI_CLOSED)
                return;
        if (tty->termios.c_cflag & CRTSCTS)
@@ -3155,6 +3184,7 @@ static int gsmtty_break_ctl(struct tty_struct *tty, int 
state)
 {
        struct gsm_dlci *dlci = tty->driver_data;
        int encode = 0; /* Off */
+
        if (dlci->state == DLCI_CLOSED)
                return -EINVAL;
 
@@ -3206,6 +3236,7 @@ static int __init gsm_init(void)
 {
        /* Fill in our line protocol discipline, and register it */
        int status = tty_register_ldisc(N_GSM0710, &tty_ldisc_packet);
+
        if (status != 0) {
                pr_err("n_gsm: can't register line discipline (err = %d)\n",
                                                                status);
@@ -3247,6 +3278,7 @@ static int __init gsm_init(void)
 static void __exit gsm_exit(void)
 {
        int status = tty_unregister_ldisc(N_GSM0710);
+
        if (status != 0)
                pr_err("n_gsm: can't unregister line discipline (err = %d)\n",
                                                                status);
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to