Skip to contentSkip to conversation

Bluetooth: bfusb: Fixed some coding style issues

PATCH In review mahendra singh meena 2 participants 2 messages Jan 15, 2012 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Bluetooth: bfusb: Fixed some coding style issues

Fixed some coding style issues shown by scripts/checkpatch.pl

---
 drivers/bluetooth/bfusb.c |   52 ++++++++++++++++++++++++++++++--------------
 1 files changed, 35 insertions(+), 17 deletions(-)
drivers/bluetooth/bfusb.c +35 -17
index a323bae..e74062a 100644
@@ -127,11 +127,13 @@ static int bfusb_send_bulk(struct bfusb_data *data, struct sk_buff *skb)
 {
 	struct bfusb_data_scb *scb = (void *) skb->cb;
 	struct urb *urb = bfusb_get_completed(data);
+	struct urb *urb_chk = urb;
 	int err, pipe;
 
 	BT_DBG("bfusb %p skb %p len %d", data, skb, skb->len);
+	urb = usb_alloc_urb(0, GFP_ATOMIC);
 
-	if (!urb && !(urb = usb_alloc_urb(0, GFP_ATOMIC)))
+	if (!urb_chk && !urb)
 		return -ENOMEM;
 
 	pipe = usb_sndbulkpipe(data->udev, data->bulk_out_ep);
@@ -145,7 +147,7 @@ static int bfusb_send_bulk(struct bfusb_data *data, struct sk_buff *skb)
 
 	err = usb_submit_urb(urb, GFP_ATOMIC);
 	if (err) {
-		BT_ERR("%s bulk tx submit failed urb %p err %d",
+		BT_ERR("%s bulk tx submit failed urb %p err %d",
 					data->hdev->name, urb, err);
 		skb_unlink(skb, &data->pending_q);
 		usb_free_urb(urb);
@@ -214,11 +216,13 @@ static int bfusb_rx_submit(struct bfusb_data *data, struct urb *urb)
 {
 	struct bfusb_data_scb *scb;
 	struct sk_buff *skb;
+	struct urb *urb_chk = urb;
 	int err, pipe, size = HCI_MAX_FRAME_SIZE + 32;
 
 	BT_DBG("bfusb %p urb %p", data, urb);
+	urb = usb_alloc_urb(0, GFP_ATOMIC);
 
-	if (!urb && !(urb = usb_alloc_urb(0, GFP_ATOMIC)))
+	if (!urb && !urb_chk)
 		return -ENOMEM;
 
 	skb = bt_skb_alloc(size, GFP_ATOMIC);
@@ -251,7 +255,8 @@ static int bfusb_rx_submit(struct bfusb_data *data, struct urb *urb)
 	return err;
 }
 
-static inline int bfusb_recv_block(struct bfusb_data *data, int hdr, unsigned char *buf, int len)
+static inline int bfusb_recv_block(struct bfusb_data *data, int hdr,
+						 unsigned char *buf, int len)
 {
 	BT_DBG("bfusb %p hdr 0x%02x data %p len %d", data, hdr, buf, len);
 
@@ -283,30 +288,37 @@ static inline int bfusb_recv_block(struct bfusb_data *data, int hdr, unsigned ch
 		switch (pkt_type) {
 		case HCI_EVENT_PKT:
 			if (len >= HCI_EVENT_HDR_SIZE) {
-				struct hci_event_hdr *hdr = (struct hci_event_hdr *) buf;
+				struct hci_event_hdr *hdr;
+				hdr = (struct hci_event_hdr *) buf;
 				pkt_len = HCI_EVENT_HDR_SIZE + hdr->plen;
 			} else {
-				BT_ERR("%s event block is too short", data->hdev->name);
+				BT_ERR("%s event block is too short",
+							 data->hdev->name);
 				return -EILSEQ;
 			}
 			break;
 
 		case HCI_ACLDATA_PKT:
 			if (len >= HCI_ACL_HDR_SIZE) {
-				struct hci_acl_hdr *hdr = (struct hci_acl_hdr *) buf;
-				pkt_len = HCI_ACL_HDR_SIZE + __le16_to_cpu(hdr->dlen);
+				struct hci_acl_hdr *hdr;
+				hdr = (struct hci_acl_hdr *) buf;
+				pkt_len = HCI_ACL_HDR_SIZE;
+				pkt_len = pkt_len + __le16_to_cpu(hdr->dlen);
 			} else {
-				BT_ERR("%s data block is too short", data->hdev->name);
+				BT_ERR("%s data block is too short",
+							 data->hdev->name);
 				return -EILSEQ;
 			}
 			break;
 
 		case HCI_SCODATA_PKT:
 			if (len >= HCI_SCO_HDR_SIZE) {
-				struct hci_sco_hdr *hdr = (struct hci_sco_hdr *) buf;
+				struct hci_sco_hdr *hdr;
+				hdr = (struct hci_sco_hdr *) buf;
 				pkt_len = HCI_SCO_HDR_SIZE + hdr->dlen;
 			} else {
-				BT_ERR("%s audio block is too short", data->hdev->name);
+				BT_ERR("%s audio block is too short",
+							 data->hdev->name);
 				return -EILSEQ;
 			}
 			break;
@@ -324,7 +336,8 @@ static inline int bfusb_recv_block(struct bfusb_data *data, int hdr, unsigned ch
 		data->reassembly = skb;
 	} else {
 		if (!data->reassembly) {
-			BT_ERR("%s unexpected continuation block", data->hdev->name);
+			BT_ERR("%s unexpected continuation block",
+							 data->hdev->name);
 			return -EIO;
 		}
 	}
@@ -473,7 +486,8 @@ static int bfusb_send_frame(struct sk_buff *skb)
 	unsigned char buf[3];
 	int sent = 0, size, count;
 
-	BT_DBG("hdev %p skb %p type %d len %d", hdev, skb, bt_cb(skb)->pkt_type, skb->len);
+	BT_DBG("hdev %p skb %p type %d len %d",
+				 hdev, skb, bt_cb(skb)->pkt_type, skb->len);
 
 	if (!hdev) {
 		BT_ERR("Frame for unknown HCI device (hdev=NULL)");
@@ -514,12 +528,14 @@ static int bfusb_send_frame(struct sk_buff *skb)
 	while (count) {
 		size = min_t(uint, count, BFUSB_MAX_BLOCK_SIZE);
 
-		buf[0] = 0xc1 | ((sent == 0) ? 0x04 : 0) | ((count == size) ? 0x08 : 0);
+		buf[0] = 0xc1 | ((sent == 0) ? 0x04 : 0) |
+						((count == size) ? 0x08 : 0);
 		buf[1] = 0x00;
 		buf[2] = (size == BFUSB_MAX_BLOCK_SIZE) ? 0 : size;
 
 		memcpy(skb_put(nskb, 3), buf, 3);
-		skb_copy_from_linear_data_offset(skb, sent, skb_put(nskb, size), size);
+		skb_copy_from_linear_data_offset(skb, sent,
+						 skb_put(nskb, size), size);
 
 		sent  += size;
 		count -= size;
@@ -553,7 +569,8 @@ static void bfusb_destruct(struct hci_dev *hdev)
 	kfree(data);
 }
 
-static int bfusb_ioctl(struct hci_dev *hdev, unsigned int cmd, unsigned long arg)
+static int bfusb_ioctl(struct hci_dev *hdev, unsigned int cmd,
+							 unsigned long arg)
 {
 	return -ENOIOCTLCMD;
 }
@@ -638,7 +655,8 @@ error:
 	return err;
 }
 
-static int bfusb_probe(struct usb_interface *intf, const struct usb_device_id *id)
+static int bfusb_probe(struct usb_interface *intf,
+						 const struct usb_device_id *id)
 {
 	const struct firmware *firmware;
 	struct usb_device *udev = interface_to_usbdev(intf);
Signature · 1 line
1.7.0.4
#1 lore raw
Quoted 1 line · mahendra singh meena

Fixed some coding style issues shown by scripts/checkpatch.pl

[]

drivers/bluetooth/bfusb.c

Quoted 1 line
drivers/bluetooth/bfusb.c +0 -0

[]

drivers/bluetooth/bfusb.c static int bfusb_send_bulk(struct bfusb_data *data, struct sk_buff *skb) · line 136

Quoted 12 lines
drivers/bluetooth/bfusb.c +3 -1
@@ -127,11 +127,13 @@ static int bfusb_send_bulk(struct bfusb_data *data, struct sk_buff *skb)
 {
 	struct bfusb_data_scb *scb = (void *) skb->cb;
 	struct urb *urb = bfusb_get_completed(data);
+	struct urb *urb_chk = urb;
 	int err, pipe;
 
 	BT_DBG("bfusb %p skb %p len %d", data, skb, skb->len);
+	urb = usb_alloc_urb(0, GFP_ATOMIC);
 
-	if (!urb && !(urb = usb_alloc_urb(0, GFP_ATOMIC)))
+	if (!urb_chk && !urb)

Broken patch.

You are now always calling usb_alloc_urb and
overwriting the original urb that is returned
from bfusb_get_completed().

Not everything that checkpatch flags needs to be
modified.

The original is better than even a correct
proposed patch because it's more readable and it
uses fewer variables.

If you _really_ want to avoid checkpatch warnings, then don't use the additional automatic.

	if (!urb) {
		urb = usb_alloc_urb(0, GFP_ATOMIC);
		if (!urb)
			return -ENOMEM;
	}

drivers/bluetooth/bfusb.c static int bfusb_send_bulk(struct bfusb_data *data, struct sk_buff *skb) · line 150

Quoted 6 lines
drivers/bluetooth/bfusb.c +1 -1
@@ -145,7 +147,7 @@ static int bfusb_send_bulk(struct bfusb_data *data, struct sk_buff *skb)
 
 	err = usb_submit_urb(urb, GFP_ATOMIC);
 	if (err) {
-		BT_ERR("%s bulk tx submit failed urb %p err %d",
+		BT_ERR("%s bulk tx submit failed urb %p err %d",

? What does checkpatch complain about this?

Quoted 6 lines
drivers/bluetooth/bfusb.c +0 -0
 					data->hdev->name, urb, err);
 		skb_unlink(skb, &data->pending_q);
 		usb_free_urb(urb);
@@ -214,11 +216,13 @@ static int bfusb_rx_submit(struct bfusb_data *data, struct urb *urb)
 {
 	struct bfusb_data_scb *scb;

drivers/bluetooth/bfusb.c static int bfusb_rx_submit(struct bfusb_data *data, struct urb *urb) · line 226

Quoted 10 lines
drivers/bluetooth/bfusb.c +3 -1
 	struct sk_buff *skb;
+	struct urb *urb_chk = urb;
 	int err, pipe, size = HCI_MAX_FRAME_SIZE + 32;
 
 	BT_DBG("bfusb %p urb %p", data, urb);
+	urb = usb_alloc_urb(0, GFP_ATOMIC);
 
-	if (!urb && !(urb = usb_alloc_urb(0, GFP_ATOMIC)))
+	if (!urb && !urb_chk)
 		return -ENOMEM;

Same broken change.

drivers/bluetooth/bfusb.c static inline int bfusb_recv_block(struct bfusb_data *data, int hdr, unsigned ch · line 292

Quoted 7 lines
drivers/bluetooth/bfusb.c +2 -1
@@ -283,30 +288,37 @@ static inline int bfusb_recv_block(struct bfusb_data *data, int hdr, unsigned ch
 		switch (pkt_type) {
 		case HCI_EVENT_PKT:
 			if (len >= HCI_EVENT_HDR_SIZE) {
-				struct hci_event_hdr *hdr = (struct hci_event_hdr *) buf;
+				struct hci_event_hdr *hdr;
+				hdr = (struct hci_event_hdr *) buf;

It'd probably be better to change the type of "buf" to void * and avoid all the casts.

drivers/bluetooth/bfusb.c static int bfusb_send_frame(struct sk_buff *skb) · line 532

Quoted 7 lines
drivers/bluetooth/bfusb.c +2 -1
@@ -514,12 +528,14 @@ static int bfusb_send_frame(struct sk_buff *skb)
 	while (count) {
 		size = min_t(uint, count, BFUSB_MAX_BLOCK_SIZE);
 
-		buf[0] = 0xc1 | ((sent == 0) ? 0x04 : 0) | ((count == size) ? 0x08 : 0);
+		buf[0] = 0xc1 | ((sent == 0) ? 0x04 : 0) |
+						((count == size) ? 0x08 : 0);

When wrapping just for 80 columns, please try to use alignments that are a bit more readable and perhaps remove unnecessary parentheses like:

		buf[0] = 0xc1 |
			 (sent == 0 ? 0x04 : 0) |
			 (count == size ? 0x08 : 0);