Bluetooth: Remove assignments in if-statements
authorValentin Ilie <valentin.ilie@gmail.com>
Mon, 12 Aug 2013 15:46:00 +0000 (18:46 +0300)
committerJohan Hedberg <johan.hedberg@intel.com>
Wed, 5 Mar 2014 18:52:17 +0000 (20:52 +0200)
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>
drivers/bluetooth/ath3k.c
drivers/bluetooth/bfusb.c
drivers/bluetooth/bluecard_cs.c
drivers/bluetooth/bt3c_cs.c
drivers/bluetooth/btuart_cs.c
drivers/bluetooth/dtl1_cs.c
drivers/bluetooth/hci_bcsp.c
drivers/bluetooth/hci_h5.c
drivers/bluetooth/hci_ldisc.c

index 4f78a9d39dc8fe960e194b1dc3e8b0bf703733e3..59b2e6a4091315680b3a05b94c375bcc8c10cc84 100644 (file)
@@ -180,10 +180,9 @@ static int ath3k_load_firmware(struct usb_device *udev,
        }
 
        memcpy(send_buf, firmware->data, 20);
-       if ((err = usb_control_msg(udev, pipe,
-                               USB_REQ_DFU_DNLOAD,
-                               USB_TYPE_VENDOR, 0, 0,
-                               send_buf, 20, USB_CTRL_SET_TIMEOUT)) < 0) {
+       err = usb_control_msg(udev, pipe, USB_REQ_DFU_DNLOAD, USB_TYPE_VENDOR,
+                             0, 0, send_buf, 20, USB_CTRL_SET_TIMEOUT);
+       if (err < 0) {
                BT_ERR("Can't change to loading configuration err");
                goto error;
        }
index 31386998c9a7b4159f04194f2125ee10d73cc920..b2e7e94a67719945e9d9ef277aed9b694d3601d1 100644 (file)
@@ -131,8 +131,11 @@ static int bfusb_send_bulk(struct bfusb_data *data, struct sk_buff *skb)
 
        BT_DBG("bfusb %p skb %p len %d", data, skb, skb->len);
 
-       if (!urb && !(urb = usb_alloc_urb(0, GFP_ATOMIC)))
-               return -ENOMEM;
+       if (!urb) {
+               urb = usb_alloc_urb(0, GFP_ATOMIC);
+               if (!urb)
+                       return -ENOMEM;
+       }
 
        pipe = usb_sndbulkpipe(data->udev, data->bulk_out_ep);
 
@@ -218,8 +221,11 @@ static int bfusb_rx_submit(struct bfusb_data *data, struct urb *urb)
 
        BT_DBG("bfusb %p urb %p", data, urb);
 
-       if (!urb && !(urb = usb_alloc_urb(0, GFP_ATOMIC)))
-               return -ENOMEM;
+       if (!urb) {
+               urb = usb_alloc_urb(0, GFP_ATOMIC);
+               if (!urb)
+                       return -ENOMEM;
+       }
 
        skb = bt_skb_alloc(size, GFP_ATOMIC);
        if (!skb) {
index 57427de864a657530ec92f1a54fe9e0d5c52938e..a9a989e5ee88036a186cb7b4d88d73a7aafb563d 100644 (file)
@@ -257,7 +257,8 @@ static void bluecard_write_wakeup(bluecard_info_t *info)
                        ready_bit = XMIT_BUF_ONE_READY;
                }
 
-               if (!(skb = skb_dequeue(&(info->txq))))
+               skb = skb_dequeue(&(info->txq));
+               if (!skb)
                        break;
 
                if (bt_cb(skb)->pkt_type & 0x80) {
@@ -391,7 +392,8 @@ static void bluecard_receive(bluecard_info_t *info, unsigned int offset)
                if (info->rx_skb == NULL) {
                        info->rx_state = RECV_WAIT_PACKET_TYPE;
                        info->rx_count = 0;
-                       if (!(info->rx_skb = bt_skb_alloc(HCI_MAX_FRAME_SIZE, GFP_ATOMIC))) {
+                       info->rx_skb = bt_skb_alloc(HCI_MAX_FRAME_SIZE, GFP_ATOMIC);
+                       if (!info->rx_skb) {
                                BT_ERR("Can't allocate mem for new packet");
                                return;
                        }
@@ -566,7 +568,8 @@ static int bluecard_hci_set_baud_rate(struct hci_dev *hdev, int baud)
        /* Ericsson baud rate command */
        unsigned char cmd[] = { HCI_COMMAND_PKT, 0x09, 0xfc, 0x01, 0x03 };
 
-       if (!(skb = bt_skb_alloc(HCI_MAX_FRAME_SIZE, GFP_ATOMIC))) {
+       skb = bt_skb_alloc(HCI_MAX_FRAME_SIZE, GFP_ATOMIC);
+       if (!skb) {
                BT_ERR("Can't allocate mem for new packet");
                return -1;
        }
index 73d87994d028ad3e64397a61e05a2e8c15f78321..1d82721cf9c67e05653f00f6ae93e20d482c9ff4 100644 (file)
@@ -193,8 +193,8 @@ static void bt3c_write_wakeup(bt3c_info_t *info)
                if (!pcmcia_dev_present(info->p_dev))
                        break;
 
-
-               if (!(skb = skb_dequeue(&(info->txq)))) {
+               skb = skb_dequeue(&(info->txq));
+               if (!skb) {
                        clear_bit(XMIT_SENDING, &(info->tx_state));
                        break;
                }
@@ -238,7 +238,8 @@ static void bt3c_receive(bt3c_info_t *info)
                if (info->rx_skb == NULL) {
                        info->rx_state = RECV_WAIT_PACKET_TYPE;
                        info->rx_count = 0;
-                       if (!(info->rx_skb = bt_skb_alloc(HCI_MAX_FRAME_SIZE, GFP_ATOMIC))) {
+                       info->rx_skb = bt_skb_alloc(HCI_MAX_FRAME_SIZE, GFP_ATOMIC);
+                       if (!info->rx_skb) {
                                BT_ERR("Can't allocate mem for new packet");
                                return;
                        }
index a03ecc22a561caf4c3d1bdc53489a5b9612745d8..fb948f02eda5b1747a7ca7604133daf88a719ef1 100644 (file)
@@ -149,7 +149,8 @@ static void btuart_write_wakeup(btuart_info_t *info)
                if (!pcmcia_dev_present(info->p_dev))
                        return;
 
-               if (!(skb = skb_dequeue(&(info->txq))))
+               skb = skb_dequeue(&(info->txq));
+               if (!skb)
                        break;
 
                /* Send frame */
@@ -190,7 +191,8 @@ static void btuart_receive(btuart_info_t *info)
                if (info->rx_skb == NULL) {
                        info->rx_state = RECV_WAIT_PACKET_TYPE;
                        info->rx_count = 0;
-                       if (!(info->rx_skb = bt_skb_alloc(HCI_MAX_FRAME_SIZE, GFP_ATOMIC))) {
+                       info->rx_skb = bt_skb_alloc(HCI_MAX_FRAME_SIZE, GFP_ATOMIC);
+                       if (!info->rx_skb) {
                                BT_ERR("Can't allocate mem for new packet");
                                return;
                        }
index 52eed1f3565dbf5868c094d246cf7dee4dcc86a4..2bd8fad172064af8f2211536fe8903e363ef33f1 100644 (file)
@@ -153,7 +153,8 @@ static void dtl1_write_wakeup(dtl1_info_t *info)
                if (!pcmcia_dev_present(info->p_dev))
                        return;
 
-               if (!(skb = skb_dequeue(&(info->txq))))
+               skb = skb_dequeue(&(info->txq));
+               if (!skb)
                        break;
 
                /* Send frame */
@@ -215,13 +216,15 @@ static void dtl1_receive(dtl1_info_t *info)
                info->hdev->stat.byte_rx++;
 
                /* Allocate packet */
-               if (info->rx_skb == NULL)
-                       if (!(info->rx_skb = bt_skb_alloc(HCI_MAX_FRAME_SIZE, GFP_ATOMIC))) {
+               if (info->rx_skb == NULL) {
+                       info->rx_skb = bt_skb_alloc(HCI_MAX_FRAME_SIZE, GFP_ATOMIC);
+                       if (!info->rx_skb) {
                                BT_ERR("Can't allocate mem for new packet");
                                info->rx_state = RECV_WAIT_NSH;
                                info->rx_count = NSHL;
                                return;
                        }
+               }
 
                *skb_put(info->rx_skb, 1) = inb(iobase + UART_RX);
                nsh = (nsh_t *)info->rx_skb->data;
index eee2fb23b3bfe032343a48ae1d4fad459486799b..21cc45b34f134fe8028606e2595d381a125e0926 100644 (file)
@@ -291,7 +291,8 @@ static struct sk_buff *bcsp_dequeue(struct hci_uart *hu)
        /* First of all, check for unreliable messages in the queue,
           since they have priority */
 
-       if ((skb = skb_dequeue(&bcsp->unrel)) != NULL) {
+       skb = skb_dequeue(&bcsp->unrel);
+       if (skb != NULL) {
                struct sk_buff *nskb = bcsp_prepare_pkt(bcsp, skb->data, skb->len, bt_cb(skb)->pkt_type);
                if (nskb) {
                        kfree_skb(skb);
@@ -308,16 +309,20 @@ static struct sk_buff *bcsp_dequeue(struct hci_uart *hu)
 
        spin_lock_irqsave_nested(&bcsp->unack.lock, flags, SINGLE_DEPTH_NESTING);
 
-       if (bcsp->unack.qlen < BCSP_TXWINSIZE && (skb = skb_dequeue(&bcsp->rel)) != NULL) {
-               struct sk_buff *nskb = bcsp_prepare_pkt(bcsp, skb->data, skb->len, bt_cb(skb)->pkt_type);
-               if (nskb) {
-                       __skb_queue_tail(&bcsp->unack, skb);
-                       mod_timer(&bcsp->tbcsp, jiffies + HZ / 4);
-                       spin_unlock_irqrestore(&bcsp->unack.lock, flags);
-                       return nskb;
-               } else {
-                       skb_queue_head(&bcsp->rel, skb);
-                       BT_ERR("Could not dequeue pkt because alloc_skb failed");
+       if (bcsp->unack.qlen < BCSP_TXWINSIZE) {
+               skb = skb_dequeue(&bcsp->rel);
+               if (skb != NULL) {
+                       struct sk_buff *nskb = bcsp_prepare_pkt(bcsp, skb->data, skb->len,
+                                                               bt_cb(skb)->pkt_type);
+                       if (nskb) {
+                               __skb_queue_tail(&bcsp->unack, skb);
+                               mod_timer(&bcsp->tbcsp, jiffies + HZ / 4);
+                               spin_unlock_irqrestore(&bcsp->unack.lock, flags);
+                               return nskb;
+                       } else {
+                               skb_queue_head(&bcsp->rel, skb);
+                               BT_ERR("Could not dequeue pkt because alloc_skb failed");
+                       }
                }
        }
 
index afd759eaa704482afcea287796b782a2c442bd90..04680ead9275c20566aeb8268a06e9393fc3107a 100644 (file)
@@ -673,7 +673,8 @@ static struct sk_buff *h5_dequeue(struct hci_uart *hu)
                return h5_prepare_pkt(hu, HCI_3WIRE_LINK_PKT, wakeup_req, 2);
        }
 
-       if ((skb = skb_dequeue(&h5->unrel)) != NULL) {
+       skb = skb_dequeue(&h5->unrel);
+       if (skb != NULL) {
                nskb = h5_prepare_pkt(hu, bt_cb(skb)->pkt_type,
                                      skb->data, skb->len);
                if (nskb) {
@@ -690,7 +691,8 @@ static struct sk_buff *h5_dequeue(struct hci_uart *hu)
        if (h5->unack.qlen >= h5->tx_win)
                goto unlock;
 
-       if ((skb = skb_dequeue(&h5->rel)) != NULL) {
+       skb = skb_dequeue(&h5->rel);
+       if (skb != NULL) {
                nskb = h5_prepare_pkt(hu, bt_cb(skb)->pkt_type,
                                      skb->data, skb->len);
                if (nskb) {
index 6e06f6f6915296ad08d7da394175da19250364db..f1fbf4f1e5bec2e5b3104462c76d0556ddcb8f45 100644 (file)
@@ -271,7 +271,8 @@ static int hci_uart_tty_open(struct tty_struct *tty)
        if (tty->ops->write == NULL)
                return -EOPNOTSUPP;
 
-       if (!(hu = kzalloc(sizeof(struct hci_uart), GFP_KERNEL))) {
+       hu = kzalloc(sizeof(struct hci_uart), GFP_KERNEL);
+       if (!hu) {
                BT_ERR("Can't allocate control structure");
                return -ENFILE;
        }
@@ -569,7 +570,8 @@ static int __init hci_uart_init(void)
        hci_uart_ldisc.write_wakeup     = hci_uart_tty_wakeup;
        hci_uart_ldisc.owner            = THIS_MODULE;
 
-       if ((err = tty_register_ldisc(N_HCI, &hci_uart_ldisc))) {
+       err = tty_register_ldisc(N_HCI, &hci_uart_ldisc);
+       if (err) {
                BT_ERR("HCI line discipline registration failed. (%d)", err);
                return err;
        }
@@ -614,7 +616,8 @@ static void __exit hci_uart_exit(void)
 #endif
 
        /* Release tty registration of line discipline */
-       if ((err = tty_unregister_ldisc(N_HCI)))
+       err = tty_unregister_ldisc(N_HCI);
+       if (err)
                BT_ERR("Can't unregister HCI line discipline (%d)", err);
 }