Commit 285b4e90 authored by Andrei Emeltchenko's avatar Andrei Emeltchenko Committed by Gustavo F. Padovan

Bluetooth: clean up rfcomm code

Remove extra spaces, assignments in if statement, zeroing static
variables, extra braces. Fix includes.
Signed-off-by: default avatarAndrei Emeltchenko <andrei.emeltchenko@nokia.com>
Signed-off-by: default avatarGustavo F. Padovan <padovan@profusion.mobi>
parent 735cbc47
...@@ -105,7 +105,7 @@ ...@@ -105,7 +105,7 @@
struct rfcomm_hdr { struct rfcomm_hdr {
u8 addr; u8 addr;
u8 ctrl; u8 ctrl;
u8 len; // Actual size can be 2 bytes u8 len; /* Actual size can be 2 bytes */
} __packed; } __packed;
struct rfcomm_cmd { struct rfcomm_cmd {
......
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
#include <linux/slab.h> #include <linux/slab.h>
#include <net/sock.h> #include <net/sock.h>
#include <asm/uaccess.h> #include <linux/uaccess.h>
#include <asm/unaligned.h> #include <asm/unaligned.h>
#include <net/bluetooth/bluetooth.h> #include <net/bluetooth/bluetooth.h>
...@@ -51,10 +51,10 @@ ...@@ -51,10 +51,10 @@
#define VERSION "1.11" #define VERSION "1.11"
static int disable_cfc = 0; static int disable_cfc;
static int l2cap_ertm;
static int channel_mtu = -1; static int channel_mtu = -1;
static unsigned int l2cap_mtu = RFCOMM_MAX_L2CAP_MTU; static unsigned int l2cap_mtu = RFCOMM_MAX_L2CAP_MTU;
static int l2cap_ertm = 0;
static struct task_struct *rfcomm_thread; static struct task_struct *rfcomm_thread;
...@@ -1901,7 +1901,7 @@ static inline void rfcomm_check_connection(struct rfcomm_session *s) ...@@ -1901,7 +1901,7 @@ static inline void rfcomm_check_connection(struct rfcomm_session *s)
BT_DBG("%p state %ld", s, s->state); BT_DBG("%p state %ld", s, s->state);
switch(sk->sk_state) { switch (sk->sk_state) {
case BT_CONNECTED: case BT_CONNECTED:
s->state = BT_CONNECT; s->state = BT_CONNECT;
......
...@@ -45,7 +45,7 @@ ...@@ -45,7 +45,7 @@
#include <net/sock.h> #include <net/sock.h>
#include <asm/system.h> #include <asm/system.h>
#include <asm/uaccess.h> #include <linux/uaccess.h>
#include <net/bluetooth/bluetooth.h> #include <net/bluetooth/bluetooth.h>
#include <net/bluetooth/hci_core.h> #include <net/bluetooth/hci_core.h>
...@@ -888,7 +888,8 @@ static int rfcomm_sock_shutdown(struct socket *sock, int how) ...@@ -888,7 +888,8 @@ static int rfcomm_sock_shutdown(struct socket *sock, int how)
BT_DBG("sock %p, sk %p", sock, sk); BT_DBG("sock %p, sk %p", sock, sk);
if (!sk) return 0; if (!sk)
return 0;
lock_sock(sk); lock_sock(sk);
if (!sk->sk_shutdown) { if (!sk->sk_shutdown) {
......
...@@ -431,7 +431,8 @@ static int rfcomm_release_dev(void __user *arg) ...@@ -431,7 +431,8 @@ static int rfcomm_release_dev(void __user *arg)
BT_DBG("dev_id %d flags 0x%x", req.dev_id, req.flags); BT_DBG("dev_id %d flags 0x%x", req.dev_id, req.flags);
if (!(dev = rfcomm_dev_get(req.dev_id))) dev = rfcomm_dev_get(req.dev_id);
if (!dev)
return -ENODEV; return -ENODEV;
if (dev->flags != NOCAP_FLAGS && !capable(CAP_NET_ADMIN)) { if (dev->flags != NOCAP_FLAGS && !capable(CAP_NET_ADMIN)) {
...@@ -470,7 +471,8 @@ static int rfcomm_get_dev_list(void __user *arg) ...@@ -470,7 +471,8 @@ static int rfcomm_get_dev_list(void __user *arg)
size = sizeof(*dl) + dev_num * sizeof(*di); size = sizeof(*dl) + dev_num * sizeof(*di);
if (!(dl = kmalloc(size, GFP_KERNEL))) dl = kmalloc(size, GFP_KERNEL);
if (!dl)
return -ENOMEM; return -ENOMEM;
di = dl->dev_info; di = dl->dev_info;
...@@ -513,7 +515,8 @@ static int rfcomm_get_dev_info(void __user *arg) ...@@ -513,7 +515,8 @@ static int rfcomm_get_dev_info(void __user *arg)
if (copy_from_user(&di, arg, sizeof(di))) if (copy_from_user(&di, arg, sizeof(di)))
return -EFAULT; return -EFAULT;
if (!(dev = rfcomm_dev_get(di.id))) dev = rfcomm_dev_get(di.id);
if (!dev)
return -ENODEV; return -ENODEV;
di.flags = dev->flags; di.flags = dev->flags;
...@@ -561,7 +564,8 @@ static void rfcomm_dev_data_ready(struct rfcomm_dlc *dlc, struct sk_buff *skb) ...@@ -561,7 +564,8 @@ static void rfcomm_dev_data_ready(struct rfcomm_dlc *dlc, struct sk_buff *skb)
return; return;
} }
if (!(tty = dev->tty) || !skb_queue_empty(&dev->pending)) { tty = dev->tty;
if (!tty || !skb_queue_empty(&dev->pending)) {
skb_queue_tail(&dev->pending, skb); skb_queue_tail(&dev->pending, skb);
return; return;
} }
...@@ -796,7 +800,8 @@ static int rfcomm_tty_write(struct tty_struct *tty, const unsigned char *buf, in ...@@ -796,7 +800,8 @@ static int rfcomm_tty_write(struct tty_struct *tty, const unsigned char *buf, in
memcpy(skb_put(skb, size), buf + sent, size); memcpy(skb_put(skb, size), buf + sent, size);
if ((err = rfcomm_dlc_send(dlc, skb)) < 0) { err = rfcomm_dlc_send(dlc, skb);
if (err < 0) {
kfree_skb(skb); kfree_skb(skb);
break; break;
} }
...@@ -892,7 +897,7 @@ static void rfcomm_tty_set_termios(struct tty_struct *tty, struct ktermios *old) ...@@ -892,7 +897,7 @@ static void rfcomm_tty_set_termios(struct tty_struct *tty, struct ktermios *old)
/* Parity on/off and when on, odd/even */ /* Parity on/off and when on, odd/even */
if (((old->c_cflag & PARENB) != (new->c_cflag & PARENB)) || if (((old->c_cflag & PARENB) != (new->c_cflag & PARENB)) ||
((old->c_cflag & PARODD) != (new->c_cflag & PARODD)) ) { ((old->c_cflag & PARODD) != (new->c_cflag & PARODD))) {
changes |= RFCOMM_RPN_PM_PARITY; changes |= RFCOMM_RPN_PM_PARITY;
BT_DBG("Parity change detected."); BT_DBG("Parity change detected.");
} }
...@@ -937,11 +942,10 @@ static void rfcomm_tty_set_termios(struct tty_struct *tty, struct ktermios *old) ...@@ -937,11 +942,10 @@ static void rfcomm_tty_set_termios(struct tty_struct *tty, struct ktermios *old)
/* POSIX does not support 1.5 stop bits and RFCOMM does not /* POSIX does not support 1.5 stop bits and RFCOMM does not
* support 2 stop bits. So a request for 2 stop bits gets * support 2 stop bits. So a request for 2 stop bits gets
* translated to 1.5 stop bits */ * translated to 1.5 stop bits */
if (new->c_cflag & CSTOPB) { if (new->c_cflag & CSTOPB)
stop_bits = RFCOMM_RPN_STOP_15; stop_bits = RFCOMM_RPN_STOP_15;
} else { else
stop_bits = RFCOMM_RPN_STOP_1; stop_bits = RFCOMM_RPN_STOP_1;
}
/* Handle number of data bits [5-8] */ /* Handle number of data bits [5-8] */
if ((old->c_cflag & CSIZE) != (new->c_cflag & CSIZE)) if ((old->c_cflag & CSIZE) != (new->c_cflag & CSIZE))
......
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