Skip to content

Commit a08b15e

Browse files
viliejhedberg
authored andcommitted
Bluetooth: Remove assignments in if-statements
Remove assignment in if-statements to be consistent with the coding style. Signed-off-by: Valentin Ilie <valentin.ilie@gmail.com> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
1 parent 5981a88 commit a08b15e

9 files changed

Lines changed: 59 additions & 35 deletions

File tree

‎drivers/bluetooth/ath3k.c‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -180,10 +180,9 @@ static int ath3k_load_firmware(struct usb_device *udev,
180180
}
181181

182182
memcpy(send_buf, firmware->data, 20);
183-
if ((err = usb_control_msg(udev, pipe,
184-
USB_REQ_DFU_DNLOAD,
185-
USB_TYPE_VENDOR, 0, 0,
186-
send_buf, 20, USB_CTRL_SET_TIMEOUT)) < 0) {
183+
err = usb_control_msg(udev, pipe, USB_REQ_DFU_DNLOAD, USB_TYPE_VENDOR,
184+
0, 0, send_buf, 20, USB_CTRL_SET_TIMEOUT);
185+
if (err < 0) {
187186
BT_ERR("Can't change to loading configuration err");
188187
goto error;
189188
}

‎drivers/bluetooth/bfusb.c‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,11 @@ static int bfusb_send_bulk(struct bfusb_data *data, struct sk_buff *skb)
131131

132132
BT_DBG("bfusb %p skb %p len %d", data, skb, skb->len);
133133

134-
if (!urb && !(urb = usb_alloc_urb(0, GFP_ATOMIC)))
135-
return -ENOMEM;
134+
if (!urb) {
135+
urb = usb_alloc_urb(0, GFP_ATOMIC);
136+
if (!urb)
137+
return -ENOMEM;
138+
}
136139

137140
pipe = usb_sndbulkpipe(data->udev, data->bulk_out_ep);
138141

@@ -218,8 +221,11 @@ static int bfusb_rx_submit(struct bfusb_data *data, struct urb *urb)
218221

219222
BT_DBG("bfusb %p urb %p", data, urb);
220223

221-
if (!urb && !(urb = usb_alloc_urb(0, GFP_ATOMIC)))
222-
return -ENOMEM;
224+
if (!urb) {
225+
urb = usb_alloc_urb(0, GFP_ATOMIC);
226+
if (!urb)
227+
return -ENOMEM;
228+
}
223229

224230
skb = bt_skb_alloc(size, GFP_ATOMIC);
225231
if (!skb) {

‎drivers/bluetooth/bluecard_cs.c‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,8 @@ static void bluecard_write_wakeup(bluecard_info_t *info)
257257
ready_bit = XMIT_BUF_ONE_READY;
258258
}
259259

260-
if (!(skb = skb_dequeue(&(info->txq))))
260+
skb = skb_dequeue(&(info->txq));
261+
if (!skb)
261262
break;
262263

263264
if (bt_cb(skb)->pkt_type & 0x80) {
@@ -391,7 +392,8 @@ static void bluecard_receive(bluecard_info_t *info, unsigned int offset)
391392
if (info->rx_skb == NULL) {
392393
info->rx_state = RECV_WAIT_PACKET_TYPE;
393394
info->rx_count = 0;
394-
if (!(info->rx_skb = bt_skb_alloc(HCI_MAX_FRAME_SIZE, GFP_ATOMIC))) {
395+
info->rx_skb = bt_skb_alloc(HCI_MAX_FRAME_SIZE, GFP_ATOMIC);
396+
if (!info->rx_skb) {
395397
BT_ERR("Can't allocate mem for new packet");
396398
return;
397399
}
@@ -566,7 +568,8 @@ static int bluecard_hci_set_baud_rate(struct hci_dev *hdev, int baud)
566568
/* Ericsson baud rate command */
567569
unsigned char cmd[] = { HCI_COMMAND_PKT, 0x09, 0xfc, 0x01, 0x03 };
568570

569-
if (!(skb = bt_skb_alloc(HCI_MAX_FRAME_SIZE, GFP_ATOMIC))) {
571+
skb = bt_skb_alloc(HCI_MAX_FRAME_SIZE, GFP_ATOMIC);
572+
if (!skb) {
570573
BT_ERR("Can't allocate mem for new packet");
571574
return -1;
572575
}

‎drivers/bluetooth/bt3c_cs.c‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,8 @@ static void bt3c_write_wakeup(bt3c_info_t *info)
193193
if (!pcmcia_dev_present(info->p_dev))
194194
break;
195195

196-
197-
if (!(skb = skb_dequeue(&(info->txq)))) {
196+
skb = skb_dequeue(&(info->txq));
197+
if (!skb) {
198198
clear_bit(XMIT_SENDING, &(info->tx_state));
199199
break;
200200
}
@@ -238,7 +238,8 @@ static void bt3c_receive(bt3c_info_t *info)
238238
if (info->rx_skb == NULL) {
239239
info->rx_state = RECV_WAIT_PACKET_TYPE;
240240
info->rx_count = 0;
241-
if (!(info->rx_skb = bt_skb_alloc(HCI_MAX_FRAME_SIZE, GFP_ATOMIC))) {
241+
info->rx_skb = bt_skb_alloc(HCI_MAX_FRAME_SIZE, GFP_ATOMIC);
242+
if (!info->rx_skb) {
242243
BT_ERR("Can't allocate mem for new packet");
243244
return;
244245
}

‎drivers/bluetooth/btuart_cs.c‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,8 @@ static void btuart_write_wakeup(btuart_info_t *info)
149149
if (!pcmcia_dev_present(info->p_dev))
150150
return;
151151

152-
if (!(skb = skb_dequeue(&(info->txq))))
152+
skb = skb_dequeue(&(info->txq));
153+
if (!skb)
153154
break;
154155

155156
/* Send frame */
@@ -190,7 +191,8 @@ static void btuart_receive(btuart_info_t *info)
190191
if (info->rx_skb == NULL) {
191192
info->rx_state = RECV_WAIT_PACKET_TYPE;
192193
info->rx_count = 0;
193-
if (!(info->rx_skb = bt_skb_alloc(HCI_MAX_FRAME_SIZE, GFP_ATOMIC))) {
194+
info->rx_skb = bt_skb_alloc(HCI_MAX_FRAME_SIZE, GFP_ATOMIC);
195+
if (!info->rx_skb) {
194196
BT_ERR("Can't allocate mem for new packet");
195197
return;
196198
}

‎drivers/bluetooth/dtl1_cs.c‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,8 @@ static void dtl1_write_wakeup(dtl1_info_t *info)
153153
if (!pcmcia_dev_present(info->p_dev))
154154
return;
155155

156-
if (!(skb = skb_dequeue(&(info->txq))))
156+
skb = skb_dequeue(&(info->txq));
157+
if (!skb)
157158
break;
158159

159160
/* Send frame */
@@ -215,13 +216,15 @@ static void dtl1_receive(dtl1_info_t *info)
215216
info->hdev->stat.byte_rx++;
216217

217218
/* Allocate packet */
218-
if (info->rx_skb == NULL)
219-
if (!(info->rx_skb = bt_skb_alloc(HCI_MAX_FRAME_SIZE, GFP_ATOMIC))) {
219+
if (info->rx_skb == NULL) {
220+
info->rx_skb = bt_skb_alloc(HCI_MAX_FRAME_SIZE, GFP_ATOMIC);
221+
if (!info->rx_skb) {
220222
BT_ERR("Can't allocate mem for new packet");
221223
info->rx_state = RECV_WAIT_NSH;
222224
info->rx_count = NSHL;
223225
return;
224226
}
227+
}
225228

226229
*skb_put(info->rx_skb, 1) = inb(iobase + UART_RX);
227230
nsh = (nsh_t *)info->rx_skb->data;

‎drivers/bluetooth/hci_bcsp.c‎

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,8 @@ static struct sk_buff *bcsp_dequeue(struct hci_uart *hu)
291291
/* First of all, check for unreliable messages in the queue,
292292
since they have priority */
293293

294-
if ((skb = skb_dequeue(&bcsp->unrel)) != NULL) {
294+
skb = skb_dequeue(&bcsp->unrel);
295+
if (skb != NULL) {
295296
struct sk_buff *nskb = bcsp_prepare_pkt(bcsp, skb->data, skb->len, bt_cb(skb)->pkt_type);
296297
if (nskb) {
297298
kfree_skb(skb);
@@ -308,16 +309,20 @@ static struct sk_buff *bcsp_dequeue(struct hci_uart *hu)
308309

309310
spin_lock_irqsave_nested(&bcsp->unack.lock, flags, SINGLE_DEPTH_NESTING);
310311

311-
if (bcsp->unack.qlen < BCSP_TXWINSIZE && (skb = skb_dequeue(&bcsp->rel)) != NULL) {
312-
struct sk_buff *nskb = bcsp_prepare_pkt(bcsp, skb->data, skb->len, bt_cb(skb)->pkt_type);
313-
if (nskb) {
314-
__skb_queue_tail(&bcsp->unack, skb);
315-
mod_timer(&bcsp->tbcsp, jiffies + HZ / 4);
316-
spin_unlock_irqrestore(&bcsp->unack.lock, flags);
317-
return nskb;
318-
} else {
319-
skb_queue_head(&bcsp->rel, skb);
320-
BT_ERR("Could not dequeue pkt because alloc_skb failed");
312+
if (bcsp->unack.qlen < BCSP_TXWINSIZE) {
313+
skb = skb_dequeue(&bcsp->rel);
314+
if (skb != NULL) {
315+
struct sk_buff *nskb = bcsp_prepare_pkt(bcsp, skb->data, skb->len,
316+
bt_cb(skb)->pkt_type);
317+
if (nskb) {
318+
__skb_queue_tail(&bcsp->unack, skb);
319+
mod_timer(&bcsp->tbcsp, jiffies + HZ / 4);
320+
spin_unlock_irqrestore(&bcsp->unack.lock, flags);
321+
return nskb;
322+
} else {
323+
skb_queue_head(&bcsp->rel, skb);
324+
BT_ERR("Could not dequeue pkt because alloc_skb failed");
325+
}
321326
}
322327
}
323328

‎drivers/bluetooth/hci_h5.c‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -673,7 +673,8 @@ static struct sk_buff *h5_dequeue(struct hci_uart *hu)
673673
return h5_prepare_pkt(hu, HCI_3WIRE_LINK_PKT, wakeup_req, 2);
674674
}
675675

676-
if ((skb = skb_dequeue(&h5->unrel)) != NULL) {
676+
skb = skb_dequeue(&h5->unrel);
677+
if (skb != NULL) {
677678
nskb = h5_prepare_pkt(hu, bt_cb(skb)->pkt_type,
678679
skb->data, skb->len);
679680
if (nskb) {
@@ -690,7 +691,8 @@ static struct sk_buff *h5_dequeue(struct hci_uart *hu)
690691
if (h5->unack.qlen >= h5->tx_win)
691692
goto unlock;
692693

693-
if ((skb = skb_dequeue(&h5->rel)) != NULL) {
694+
skb = skb_dequeue(&h5->rel);
695+
if (skb != NULL) {
694696
nskb = h5_prepare_pkt(hu, bt_cb(skb)->pkt_type,
695697
skb->data, skb->len);
696698
if (nskb) {

‎drivers/bluetooth/hci_ldisc.c‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,8 @@ static int hci_uart_tty_open(struct tty_struct *tty)
271271
if (tty->ops->write == NULL)
272272
return -EOPNOTSUPP;
273273

274-
if (!(hu = kzalloc(sizeof(struct hci_uart), GFP_KERNEL))) {
274+
hu = kzalloc(sizeof(struct hci_uart), GFP_KERNEL);
275+
if (!hu) {
275276
BT_ERR("Can't allocate control structure");
276277
return -ENFILE;
277278
}
@@ -569,7 +570,8 @@ static int __init hci_uart_init(void)
569570
hci_uart_ldisc.write_wakeup = hci_uart_tty_wakeup;
570571
hci_uart_ldisc.owner = THIS_MODULE;
571572

572-
if ((err = tty_register_ldisc(N_HCI, &hci_uart_ldisc))) {
573+
err = tty_register_ldisc(N_HCI, &hci_uart_ldisc);
574+
if (err) {
573575
BT_ERR("HCI line discipline registration failed. (%d)", err);
574576
return err;
575577
}
@@ -614,7 +616,8 @@ static void __exit hci_uart_exit(void)
614616
#endif
615617

616618
/* Release tty registration of line discipline */
617-
if ((err = tty_unregister_ldisc(N_HCI)))
619+
err = tty_unregister_ldisc(N_HCI);
620+
if (err)
618621
BT_ERR("Can't unregister HCI line discipline (%d)", err);
619622
}
620623

0 commit comments

Comments
 (0)