* [PATCH] Bluetooth: bfusb: Fixed some coding style issues
@ 2012-01-15 19:47 mahendra singh meena
2012-01-15 20:33 ` Joe Perches
0 siblings, 1 reply; 2+ messages in thread
From: mahendra singh meena @ 2012-01-15 19:47 UTC (permalink / raw)
To: marcel; +Cc: padovan, linux-bluetooth, linux-kernel
Fixed some coding style issues shown by scripts/checkpatch.pl
Signed-off-by: Mahendra Singh Meena <mahendra.devel@gmail.com>
---
drivers/bluetooth/bfusb.c | 52 ++++++++++++++++++++++++++++++--------------
1 files changed, 35 insertions(+), 17 deletions(-)
diff --git a/drivers/bluetooth/bfusb.c b/drivers/bluetooth/bfusb.c
index a323bae..e74062a 100644
--- a/drivers/bluetooth/bfusb.c
+++ b/drivers/bluetooth/bfusb.c
@@ -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);
--
1.7.0.4
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] Bluetooth: bfusb: Fixed some coding style issues
2012-01-15 19:47 [PATCH] Bluetooth: bfusb: Fixed some coding style issues mahendra singh meena
@ 2012-01-15 20:33 ` Joe Perches
0 siblings, 0 replies; 2+ messages in thread
From: Joe Perches @ 2012-01-15 20:33 UTC (permalink / raw)
To: mahendra singh meena; +Cc: marcel, padovan, linux-bluetooth, linux-kernel
On Mon, 2012-01-16 at 01:17 +0530, mahendra singh meena wrote:
> Fixed some coding style issues shown by scripts/checkpatch.pl
[]
> diff --git a/drivers/bluetooth/bfusb.c b/drivers/bluetooth/bfusb.c
[]
> @@ -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;
}
> @@ -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?
> 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;
Same broken change.
> @@ -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.
> @@ -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);
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-01-15 20:33 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-15 19:47 [PATCH] Bluetooth: bfusb: Fixed some coding style issues mahendra singh meena
2012-01-15 20:33 ` Joe Perches
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).