[PATCH] staging: ozwpan: Fix coding style warnings
The warnings addressed: 1. Missing a blank line after declarations. 2. else is not generally useful after a break or return Signed-off-by: Adrian Nicoara --- Patch submitted as part of the Eudyptula challenge. drivers/staging/ozwpan/ozpd.c | 16 ++-- 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/drivers/staging/ozwpan/ozpd.c b/drivers/staging/ozwpan/ozpd.c index 7726410..852c288 100644 --- a/drivers/staging/ozwpan/ozpd.c +++ b/drivers/staging/ozwpan/ozpd.c @@ -106,6 +106,7 @@ struct oz_pd *oz_pd_alloc(const u8 *mac_addr) if (pd) { int i; + atomic_set(&pd->ref_count, 2); for (i = 0; i < OZ_NB_APPS; i++) spin_lock_init(&pd->app_lock[i]); @@ -153,6 +154,7 @@ static void oz_pd_free(struct work_struct *work) list_for_each_safe(e, n, &pd->tx_queue) { struct oz_tx_frame *f = list_entry(e, struct oz_tx_frame, link); + if (f->skb != NULL) kfree_skb(f->skb); oz_retire_frame(pd, f); @@ -249,6 +251,7 @@ void oz_pd_heartbeat(struct oz_pd *pd, u16 apps) hrtimer_cancel(&pd->heartbeat); if (pd->mode & OZ_F_ISOC_ANYTIME) { int count = 8; + while (count-- && (oz_send_isoc_frame(pd) >= 0)) ; } @@ -493,11 +496,10 @@ static int oz_send_next_queued_frame(struct oz_pd *pd, int more_data) oz_dbg(TX_FRAMES, "Sending ISOC Frame, nb_isoc= %d\n", pd->nb_queued_isoc_frames); return 0; - } else { - kfree_skb(skb); - oz_dbg(TX_FRAMES, "Dropping ISOC Frame>\n"); - return -1; } + kfree_skb(skb); + oz_dbg(TX_FRAMES, "Dropping ISOC Frame>\n"); + return -1; } pd->last_sent_frame = e; @@ -752,6 +754,7 @@ int oz_send_isoc_unit(struct oz_pd *pd, u8 ep_num, const u8 *data, int len) } else { struct oz_hdr oz; struct oz_isoc_large iso; + spin_lock_bh(&pd->stream_lock); iso.frame_number = st->frame_num; st->frame_num += nb_units; @@ -774,8 +777,10 @@ int oz_send_isoc_unit(struct oz_pd *pd, u8 ep_num, const u8 *data, int len) if (!(pd->mode & OZ_F_ISOC_ANYTIME)) { struct oz_tx_frame *isoc_unit = NULL; int nb = pd->nb_queued_isoc_frames; + if (nb >= pd->isoc_latency) { struct oz_tx_frame *f; + oz_dbg(TX_FRAMES, "Dropping ISOC Unit nb= %d\n", nb); spin_lock(&pd->tx_frame_lock); @@ -807,8 +812,7 @@ int oz_send_isoc_unit(struct oz_pd *pd, u8 ep_num, const u8 *data, int len) atomic_inc(&g_submitted_isoc); if (dev_queue_xmit(skb) < 0) return -1; - else - return 0; + return 0; } out: kfree_skb(skb); -- 2.0.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 1/4] staging: ozwpan: fix missing blank line after declaration
Signed-off-by: Adrian Nicoara --- Patch submitted as part of the Eudyptula challenge. drivers/staging/ozwpan/ozcdev.c| 5 + drivers/staging/ozwpan/ozeltbuf.c | 1 + drivers/staging/ozwpan/ozpd.c | 6 ++ drivers/staging/ozwpan/ozproto.c | 4 drivers/staging/ozwpan/ozusbsvc.c | 2 ++ drivers/staging/ozwpan/ozusbsvc1.c | 4 6 files changed, 22 insertions(+) diff --git a/drivers/staging/ozwpan/ozcdev.c b/drivers/staging/ozwpan/ozcdev.c index c73d396..da0e1fd 100644 --- a/drivers/staging/ozwpan/ozcdev.c +++ b/drivers/staging/ozwpan/ozcdev.c @@ -263,6 +263,7 @@ static long oz_cdev_ioctl(struct file *filp, unsigned int cmd, switch (cmd) { case OZ_IOCTL_GET_PD_LIST: { struct oz_pd_list list; + oz_dbg(ON, "OZ_IOCTL_GET_PD_LIST\n"); memset(&list, 0, sizeof(list)); list.count = oz_get_pd_list(list.addr, OZ_MAX_PDS); @@ -273,6 +274,7 @@ static long oz_cdev_ioctl(struct file *filp, unsigned int cmd, break; case OZ_IOCTL_SET_ACTIVE_PD: { u8 addr[ETH_ALEN]; + oz_dbg(ON, "OZ_IOCTL_SET_ACTIVE_PD\n"); if (copy_from_user(addr, (void __user *)arg, ETH_ALEN)) return -EFAULT; @@ -281,6 +283,7 @@ static long oz_cdev_ioctl(struct file *filp, unsigned int cmd, break; case OZ_IOCTL_GET_ACTIVE_PD: { u8 addr[ETH_ALEN]; + oz_dbg(ON, "OZ_IOCTL_GET_ACTIVE_PD\n"); spin_lock_bh(&g_cdev.lock); ether_addr_copy(addr, g_cdev.active_addr); @@ -292,6 +295,7 @@ static long oz_cdev_ioctl(struct file *filp, unsigned int cmd, case OZ_IOCTL_ADD_BINDING: case OZ_IOCTL_REMOVE_BINDING: { struct oz_binding_info b; + if (copy_from_user(&b, (void __user *)arg, sizeof(struct oz_binding_info))) { return -EFAULT; @@ -320,6 +324,7 @@ static unsigned int oz_cdev_poll(struct file *filp, poll_table *wait) spin_lock_bh(&dev->lock); if (dev->active_pd) { struct oz_serial_ctx *ctx = oz_cdev_claim_ctx(dev->active_pd); + if (ctx) { if (ctx->rd_in != ctx->rd_out) ret |= POLLIN | POLLRDNORM; diff --git a/drivers/staging/ozwpan/ozeltbuf.c b/drivers/staging/ozwpan/ozeltbuf.c index 400cc75..01b25da 100644 --- a/drivers/staging/ozwpan/ozeltbuf.c +++ b/drivers/staging/ozwpan/ozeltbuf.c @@ -174,6 +174,7 @@ int oz_queue_elt_info(struct oz_elt_buf *buf, u8 isoc, u8 id, == OZ_USB_ENDPOINT_DATA) && (body->format == OZ_DATA_F_ISOC_FIXED)) { u8 unit_count = body->frame_number; + body->frame_number = st->frame_number; st->frame_number += unit_count; } diff --git a/drivers/staging/ozwpan/ozpd.c b/drivers/staging/ozwpan/ozpd.c index 7726410..26c1049 100644 --- a/drivers/staging/ozwpan/ozpd.c +++ b/drivers/staging/ozwpan/ozpd.c @@ -106,6 +106,7 @@ struct oz_pd *oz_pd_alloc(const u8 *mac_addr) if (pd) { int i; + atomic_set(&pd->ref_count, 2); for (i = 0; i < OZ_NB_APPS; i++) spin_lock_init(&pd->app_lock[i]); @@ -153,6 +154,7 @@ static void oz_pd_free(struct work_struct *work) list_for_each_safe(e, n, &pd->tx_queue) { struct oz_tx_frame *f = list_entry(e, struct oz_tx_frame, link); + if (f->skb != NULL) kfree_skb(f->skb); oz_retire_frame(pd, f); @@ -249,6 +251,7 @@ void oz_pd_heartbeat(struct oz_pd *pd, u16 apps) hrtimer_cancel(&pd->heartbeat); if (pd->mode & OZ_F_ISOC_ANYTIME) { int count = 8; + while (count-- && (oz_send_isoc_frame(pd) >= 0)) ; } @@ -752,6 +755,7 @@ int oz_send_isoc_unit(struct oz_pd *pd, u8 ep_num, const u8 *data, int len) } else { struct oz_hdr oz; struct oz_isoc_large iso; + spin_lock_bh(&pd->stream_lock); iso.frame_number = st->frame_num; st->frame_num += nb_units; @@ -774,8 +778,10 @@ int oz_send_isoc_unit(struct oz_pd *pd, u8 ep_num, const u8 *data, int len) if (!(pd->mode & OZ_F_ISOC_ANYTIME)) { struct oz_tx_frame *isoc_unit = NULL; int nb = pd->nb_queued_isoc_frames; + if (nb >= pd->isoc_latency) { struct oz_tx_frame *f; + oz_dbg(TX_FRAMES, "Dropping ISOC Unit nb= %d\n", nb);
[PATCH 2/4] staging: ozwpan: fix redundant else after break or return
Signed-off-by: Adrian Nicoara --- Patch submitted as part of the Eudyptula challenge. drivers/staging/ozwpan/ozhcd.c | 8 +++- drivers/staging/ozwpan/ozpd.c | 10 -- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/drivers/staging/ozwpan/ozhcd.c b/drivers/staging/ozwpan/ozhcd.c index b30c4d87..ba2168f 100644 --- a/drivers/staging/ozwpan/ozhcd.c +++ b/drivers/staging/ozwpan/ozhcd.c @@ -1010,10 +1010,9 @@ void oz_hcd_data_ind(void *hport, u8 endpoint, const u8 *data, int data_len) urb->actual_length = copy_len; oz_complete_urb(port->ozhcd->hcd, urb, 0); return; - } else { - oz_dbg(ON, "buffering frame as URB is not available\n"); - oz_hcd_buffer_data(ep, data, data_len); } + oz_dbg(ON, "buffering frame as URB is not available\n"); + oz_hcd_buffer_data(ep, data, data_len); break; case USB_ENDPOINT_XFER_ISOC: oz_hcd_buffer_data(ep, data, data_len); @@ -1903,8 +1902,7 @@ static int oz_hcd_hub_status_data(struct usb_hcd *hcd, char *buf) spin_unlock_bh(&ozhcd->hcd_lock); if (buf[0] != 0 || buf[1] != 0) return 2; - else - return 0; + return 0; } /* diff --git a/drivers/staging/ozwpan/ozpd.c b/drivers/staging/ozwpan/ozpd.c index 26c1049..852c288 100644 --- a/drivers/staging/ozwpan/ozpd.c +++ b/drivers/staging/ozwpan/ozpd.c @@ -496,11 +496,10 @@ static int oz_send_next_queued_frame(struct oz_pd *pd, int more_data) oz_dbg(TX_FRAMES, "Sending ISOC Frame, nb_isoc= %d\n", pd->nb_queued_isoc_frames); return 0; - } else { - kfree_skb(skb); - oz_dbg(TX_FRAMES, "Dropping ISOC Frame>\n"); - return -1; } + kfree_skb(skb); + oz_dbg(TX_FRAMES, "Dropping ISOC Frame>\n"); + return -1; } pd->last_sent_frame = e; @@ -813,8 +812,7 @@ int oz_send_isoc_unit(struct oz_pd *pd, u8 ep_num, const u8 *data, int len) atomic_inc(&g_submitted_isoc); if (dev_queue_xmit(skb) < 0) return -1; - else - return 0; + return 0; } out: kfree_skb(skb); -- 2.0.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 3/4] staging: ozwpan: fix redundant return in void function
Signed-off-by: Adrian Nicoara --- Patch submitted as part of the Eudyptula challenge. drivers/staging/ozwpan/ozproto.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/ozwpan/ozproto.c b/drivers/staging/ozwpan/ozproto.c index cae0e6f..3d3a3a8 100644 --- a/drivers/staging/ozwpan/ozproto.c +++ b/drivers/staging/ozwpan/ozproto.c @@ -112,7 +112,6 @@ static void oz_send_conn_rsp(struct oz_pd *pd, u8 status) } oz_dbg(ON, "TX: OZ_ELT_CONNECT_RSP %d", status); dev_queue_xmit(skb); - return; } /* -- 2.0.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 4/4] staging: ozwpan: use kmalloc_array over kmalloc with multiply
Signed-off-by: Adrian Nicoara --- Patch submitted as part of the Eudyptula challenge. drivers/staging/ozwpan/ozhcd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/ozwpan/ozhcd.c b/drivers/staging/ozwpan/ozhcd.c index ba2168f..4cfe56e 100644 --- a/drivers/staging/ozwpan/ozhcd.c +++ b/drivers/staging/ozwpan/ozhcd.c @@ -1315,7 +1315,7 @@ static int oz_build_endpoints_for_config(struct usb_hcd *hcd, if (num_iface) { struct oz_interface *iface; - iface = kmalloc(num_iface*sizeof(struct oz_interface), + iface = kmalloc_array(num_iface, sizeof(struct oz_interface), mem_flags | __GFP_ZERO); if (!iface) return -ENOMEM; -- 2.0.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel