Skip to content

Commit 285b4e9

Browse files
Andrei EmeltchenkoGustavo F. Padovan
authored andcommitted
Bluetooth: clean up rfcomm code
Remove extra spaces, assignments in if statement, zeroing static variables, extra braces. Fix includes. Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@nokia.com> Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
1 parent 735cbc4 commit 285b4e9

4 files changed

Lines changed: 25 additions & 20 deletions

File tree

‎include/net/bluetooth/rfcomm.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@
105105
struct rfcomm_hdr {
106106
u8 addr;
107107
u8 ctrl;
108-
u8 len; // Actual size can be 2 bytes
108+
u8 len; /* Actual size can be 2 bytes */
109109
} __packed;
110110

111111
struct rfcomm_cmd {
@@ -228,7 +228,7 @@ struct rfcomm_dlc {
228228
/* ---- RFCOMM SEND RPN ---- */
229229
int rfcomm_send_rpn(struct rfcomm_session *s, int cr, u8 dlci,
230230
u8 bit_rate, u8 data_bits, u8 stop_bits,
231-
u8 parity, u8 flow_ctrl_settings,
231+
u8 parity, u8 flow_ctrl_settings,
232232
u8 xon_char, u8 xoff_char, u16 param_mask);
233233

234234
/* ---- RFCOMM DLCs (channels) ---- */

‎net/bluetooth/rfcomm/core.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
#include <linux/slab.h>
4242

4343
#include <net/sock.h>
44-
#include <asm/uaccess.h>
44+
#include <linux/uaccess.h>
4545
#include <asm/unaligned.h>
4646

4747
#include <net/bluetooth/bluetooth.h>
@@ -51,10 +51,10 @@
5151

5252
#define VERSION "1.11"
5353

54-
static int disable_cfc = 0;
54+
static int disable_cfc;
55+
static int l2cap_ertm;
5556
static int channel_mtu = -1;
5657
static unsigned int l2cap_mtu = RFCOMM_MAX_L2CAP_MTU;
57-
static int l2cap_ertm = 0;
5858

5959
static struct task_struct *rfcomm_thread;
6060

@@ -1901,7 +1901,7 @@ static inline void rfcomm_check_connection(struct rfcomm_session *s)
19011901

19021902
BT_DBG("%p state %ld", s, s->state);
19031903

1904-
switch(sk->sk_state) {
1904+
switch (sk->sk_state) {
19051905
case BT_CONNECTED:
19061906
s->state = BT_CONNECT;
19071907

‎net/bluetooth/rfcomm/sock.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
#include <net/sock.h>
4646

4747
#include <asm/system.h>
48-
#include <asm/uaccess.h>
48+
#include <linux/uaccess.h>
4949

5050
#include <net/bluetooth/bluetooth.h>
5151
#include <net/bluetooth/hci_core.h>
@@ -888,7 +888,8 @@ static int rfcomm_sock_shutdown(struct socket *sock, int how)
888888

889889
BT_DBG("sock %p, sk %p", sock, sk);
890890

891-
if (!sk) return 0;
891+
if (!sk)
892+
return 0;
892893

893894
lock_sock(sk);
894895
if (!sk->sk_shutdown) {

‎net/bluetooth/rfcomm/tty.c‎

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ struct rfcomm_dev {
5858

5959
bdaddr_t src;
6060
bdaddr_t dst;
61-
u8 channel;
61+
u8 channel;
6262

63-
uint modem_status;
63+
uint modem_status;
6464

6565
struct rfcomm_dlc *dlc;
6666
struct tty_struct *tty;
@@ -69,7 +69,7 @@ struct rfcomm_dev {
6969

7070
struct device *tty_dev;
7171

72-
atomic_t wmem_alloc;
72+
atomic_t wmem_alloc;
7373

7474
struct sk_buff_head pending;
7575
};
@@ -431,7 +431,8 @@ static int rfcomm_release_dev(void __user *arg)
431431

432432
BT_DBG("dev_id %d flags 0x%x", req.dev_id, req.flags);
433433

434-
if (!(dev = rfcomm_dev_get(req.dev_id)))
434+
dev = rfcomm_dev_get(req.dev_id);
435+
if (!dev)
435436
return -ENODEV;
436437

437438
if (dev->flags != NOCAP_FLAGS && !capable(CAP_NET_ADMIN)) {
@@ -470,7 +471,8 @@ static int rfcomm_get_dev_list(void __user *arg)
470471

471472
size = sizeof(*dl) + dev_num * sizeof(*di);
472473

473-
if (!(dl = kmalloc(size, GFP_KERNEL)))
474+
dl = kmalloc(size, GFP_KERNEL);
475+
if (!dl)
474476
return -ENOMEM;
475477

476478
di = dl->dev_info;
@@ -513,7 +515,8 @@ static int rfcomm_get_dev_info(void __user *arg)
513515
if (copy_from_user(&di, arg, sizeof(di)))
514516
return -EFAULT;
515517

516-
if (!(dev = rfcomm_dev_get(di.id)))
518+
dev = rfcomm_dev_get(di.id);
519+
if (!dev)
517520
return -ENODEV;
518521

519522
di.flags = dev->flags;
@@ -561,7 +564,8 @@ static void rfcomm_dev_data_ready(struct rfcomm_dlc *dlc, struct sk_buff *skb)
561564
return;
562565
}
563566

564-
if (!(tty = dev->tty) || !skb_queue_empty(&dev->pending)) {
567+
tty = dev->tty;
568+
if (!tty || !skb_queue_empty(&dev->pending)) {
565569
skb_queue_tail(&dev->pending, skb);
566570
return;
567571
}
@@ -796,7 +800,8 @@ static int rfcomm_tty_write(struct tty_struct *tty, const unsigned char *buf, in
796800

797801
memcpy(skb_put(skb, size), buf + sent, size);
798802

799-
if ((err = rfcomm_dlc_send(dlc, skb)) < 0) {
803+
err = rfcomm_dlc_send(dlc, skb);
804+
if (err < 0) {
800805
kfree_skb(skb);
801806
break;
802807
}
@@ -892,7 +897,7 @@ static void rfcomm_tty_set_termios(struct tty_struct *tty, struct ktermios *old)
892897

893898
/* Parity on/off and when on, odd/even */
894899
if (((old->c_cflag & PARENB) != (new->c_cflag & PARENB)) ||
895-
((old->c_cflag & PARODD) != (new->c_cflag & PARODD)) ) {
900+
((old->c_cflag & PARODD) != (new->c_cflag & PARODD))) {
896901
changes |= RFCOMM_RPN_PM_PARITY;
897902
BT_DBG("Parity change detected.");
898903
}
@@ -937,11 +942,10 @@ static void rfcomm_tty_set_termios(struct tty_struct *tty, struct ktermios *old)
937942
/* POSIX does not support 1.5 stop bits and RFCOMM does not
938943
* support 2 stop bits. So a request for 2 stop bits gets
939944
* translated to 1.5 stop bits */
940-
if (new->c_cflag & CSTOPB) {
945+
if (new->c_cflag & CSTOPB)
941946
stop_bits = RFCOMM_RPN_STOP_15;
942-
} else {
947+
else
943948
stop_bits = RFCOMM_RPN_STOP_1;
944-
}
945949

946950
/* Handle number of data bits [5-8] */
947951
if ((old->c_cflag & CSIZE) != (new->c_cflag & CSIZE))

0 commit comments

Comments
 (0)