diff options
author | Todd Poynter <tpoynter@nvidia.com> | 2013-12-10 11:26:36 -0600 |
---|---|---|
committer | Mandar Padmawar <mpadmawar@nvidia.com> | 2013-12-13 02:40:51 -0800 |
commit | f9b6903890cf41ed8569c48eddf00f349ba12293 (patch) | |
tree | e9afe6b5b42a5a53e231da163de88516a290e6e9 | |
parent | f63a47ec9c5dd9b11fd807ef0624e2d7e09cdc34 (diff) |
staging: ozwpan: Fix an issue with hub_status.
Update ozwpan to the latest drop from ATMEL to
resolve an issue with hub_status() returning the
wrong status. This resulted in the USB stack
trying to read the port status continously.
Bug 1415705.
Change-Id: I433cce1add10b82fbb08b0e3804f02607b809bea
Signed-off-by: Todd Poynter <tpoynter@nvidia.com>
Reviewed-on: http://git-master/r/343739
GVS: Gerrit_Virtual_Submit
Reviewed-by: Mitch Luban <mluban@nvidia.com>
-rw-r--r-- | drivers/staging/ozwpan/Makefile | 25 | ||||
-rw-r--r-- | drivers/staging/ozwpan/ozcdev.c | 39 | ||||
-rw-r--r-- | drivers/staging/ozwpan/ozcdev.h | 2 | ||||
-rw-r--r-- | drivers/staging/ozwpan/ozeltbuf.c | 18 | ||||
-rw-r--r-- | drivers/staging/ozwpan/ozhcd.c | 135 | ||||
-rw-r--r-- | drivers/staging/ozwpan/ozmain.c | 5 | ||||
-rw-r--r-- | drivers/staging/ozwpan/ozpd.c | 99 | ||||
-rw-r--r-- | drivers/staging/ozwpan/ozpd.h | 4 | ||||
-rw-r--r-- | drivers/staging/ozwpan/ozproto.c | 61 | ||||
-rw-r--r-- | drivers/staging/ozwpan/ozproto.h | 2 | ||||
-rw-r--r-- | drivers/staging/ozwpan/ozprotocol.h | 2 | ||||
-rw-r--r-- | drivers/staging/ozwpan/oztrace.c | 7 | ||||
-rw-r--r-- | drivers/staging/ozwpan/oztrace.h | 70 | ||||
-rw-r--r-- | drivers/staging/ozwpan/ozusbif.h | 12 | ||||
-rw-r--r-- | drivers/staging/ozwpan/ozusbsvc.c | 30 | ||||
-rw-r--r-- | drivers/staging/ozwpan/ozusbsvc1.c | 12 |
16 files changed, 298 insertions, 225 deletions
diff --git a/drivers/staging/ozwpan/Makefile b/drivers/staging/ozwpan/Makefile new file mode 100644 index 000000000000..d2fdf8a1b5cf --- /dev/null +++ b/drivers/staging/ozwpan/Makefile @@ -0,0 +1,25 @@ +# ----------------------------------------------------------------------------- +# Copyright .o) 2011 Ozmo I.o +# Released under the GNU General Publ.o L.oense Version 2 (GPLv2). +# ----------------------------------------------------------------------------- +ifneq ($(KERNELRELEASE),) +# If invoked from kbuild. +obj-m := ozwpan.o +ozwpan-y := ozusbsvc.o ozusbsvc1.o ozurbparanoia.o oztrace.o ozproto.o ozpd.o ozmain.o ozkobject.o ozhcd.o ozeltbuf.o ozcdev.o + +else +# If invoked dir.otly. +KDIR := /lib/modules/$(shell uname -r)/build +PWD := $(shell pwd) + +default: + $(MAKE) -C $(KDIR) M=$(PWD) modules EXTRA_CFLAGS="-I$(PWD)" + +debug: OZ_CFLAGS=-DWANT_TRACE_DATA_FLOW +debug: + $(MAKE) -C $(KDIR) M=$(PWD) modules EXTRA_CFLAGS="$(OZ_CFLAGS) -I$(PWD)" +less_debug: + $(MAKE) -C $(KDIR) M=$(PWD) modules EXTRA_CFLAGS="-DDEBUG -I$(PWD)" + +endif + diff --git a/drivers/staging/ozwpan/ozcdev.c b/drivers/staging/ozwpan/ozcdev.c index f3238229b5b3..fa7f7d0d3467 100644 --- a/drivers/staging/ozwpan/ozcdev.c +++ b/drivers/staging/ozwpan/ozcdev.c @@ -8,6 +8,7 @@ #include <linux/cdev.h> #include <linux/uaccess.h> #include <linux/netdevice.h> +#include <linux/etherdevice.h> #include <linux/poll.h> #include <linux/sched.h> #include "ozprotocol.h" @@ -16,6 +17,7 @@ #include "ozeltbuf.h" #include "ozpd.h" #include "ozproto.h" +#include "ozcdev.h" #include "ozkobject.h" /*------------------------------------------------------------------------------ */ @@ -122,7 +124,7 @@ ssize_t oz_cdev_read(struct file *filp, char __user *buf, size_t count, int ix; int is_tftp; struct oz_pd *pd; - struct oz_serial_ctx *ctx = 0; + struct oz_serial_ctx *ctx; spin_lock_bh(&g_cdev.lock); pd = g_cdev.active_pd; @@ -130,10 +132,10 @@ ssize_t oz_cdev_read(struct file *filp, char __user *buf, size_t count, oz_pd_get(pd); is_tftp = (g_cdev.mode & OZ_MODE_TFTP) ? 1 : 0; spin_unlock_bh(&g_cdev.lock); - if (pd == 0) + if (pd == NULL) return -1; ctx = oz_cdev_claim_ctx(pd); - if (ctx == 0) + if (ctx == NULL) goto out2; spin_lock_bh(&ctx->rd_lock); @@ -229,7 +231,7 @@ ssize_t oz_cdev_write(struct file *filp, const char __user *buf, size_t count, { struct oz_pd *pd; struct oz_elt_buf *eb; - struct oz_elt_info *ei = 0; + struct oz_elt_info *ei; struct oz_elt *elt; struct oz_ext_elt *ext_elt; struct oz_app_hdr *app_hdr; @@ -240,13 +242,13 @@ ssize_t oz_cdev_write(struct file *filp, const char __user *buf, size_t count, if (pd) oz_pd_get(pd); spin_unlock_bh(&g_cdev.lock); - if (pd == 0) + if (pd == NULL) return -1; if (!(pd->state & OZ_PD_S_CONNECTED)) return -ENXIO; eb = &pd->elt_buff; ei = oz_elt_info_alloc(eb); - if (ei == 0) { + if (ei == NULL) { count = 0; goto out; } @@ -284,7 +286,7 @@ ssize_t oz_cdev_write(struct file *filp, const char __user *buf, size_t count, ei->context = ctx->tx_seq_num; spin_lock(&eb->lock); if (oz_queue_elt_info(eb, 0, 0, ei) == 0) - ei = 0; + ei = NULL; spin_unlock(&eb->lock); } spin_unlock_bh(&pd->app_lock[OZ_APPID_SERIAL-1]); @@ -301,7 +303,7 @@ out: /*------------------------------------------------------------------------------ * Context: process */ -int oz_set_active_pd(u8 *addr) +int oz_set_active_pd(const u8 *addr) { int rc = 0; struct oz_pd *pd; @@ -334,10 +336,10 @@ int oz_set_active_pd(u8 *addr) if (old_pd) oz_pd_put(old_pd); } else { - if (!memcmp(addr, "\0\0\0\0\0\0", ETH_ALEN)) { + if (is_zero_ether_addr(addr)) { spin_lock_bh(&g_cdev.lock); pd = g_cdev.active_pd; - g_cdev.active_pd = 0; + g_cdev.active_pd = NULL; memset(g_cdev.active_addr, 0, sizeof(g_cdev.active_addr)); spin_unlock_bh(&g_cdev.lock); @@ -416,6 +418,7 @@ long oz_cdev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) switch (cmd) { case OZ_IOCTL_GET_PD_LIST: { struct oz_pd_list list; + memset(&list, 0, sizeof(list)); list.count = oz_get_pd_list(list.addr, OZ_MAX_PDS); if (copy_to_user((void __user *)arg, &list, sizeof(list))) @@ -518,12 +521,14 @@ int oz_cdev_register(void) g_oz_class = class_create(THIS_MODULE, "ozmo_wpan"); if (IS_ERR(g_oz_class)) { oz_trace("Failed to register ozmo_wpan class\n"); + err = PTR_ERR(g_oz_class); goto out1; } g_oz_wpan_dev = device_create(g_oz_class, NULL, g_cdev.devnum, NULL, "ozwpan"); if (IS_ERR(g_oz_wpan_dev)) { oz_trace("Failed to create sysfs entry for cdev\n"); + err = PTR_ERR(g_oz_wpan_dev); goto out1; } oz_create_sys_entry(); @@ -570,13 +575,13 @@ void oz_cdev_term(void) int oz_cdev_start(struct oz_pd *pd, int resume) { struct oz_serial_ctx *ctx; - struct oz_serial_ctx *old_ctx = 0; + struct oz_serial_ctx *old_ctx; if (resume) { oz_trace("Serial service resumed.\n"); return 0; } ctx = kzalloc(sizeof(struct oz_serial_ctx), GFP_ATOMIC); - if (ctx == 0) + if (ctx == NULL) return -ENOMEM; atomic_set(&ctx->ref_count, 1); ctx->tx_seq_num = 1; @@ -591,7 +596,7 @@ int oz_cdev_start(struct oz_pd *pd, int resume) spin_unlock_bh(&pd->app_lock[OZ_APPID_SERIAL-1]); } spin_lock(&g_cdev.lock); - if ((g_cdev.active_pd == 0) && + if ((g_cdev.active_pd == NULL) && (memcmp(pd->mac_addr, g_cdev.active_addr, ETH_ALEN) == 0)) { oz_pd_get(pd); g_cdev.active_pd = pd; @@ -612,15 +617,15 @@ void oz_cdev_stop(struct oz_pd *pd, int pause) } spin_lock_bh(&pd->app_lock[OZ_APPID_SERIAL-1]); ctx = (struct oz_serial_ctx *)pd->app_ctx[OZ_APPID_SERIAL-1]; - pd->app_ctx[OZ_APPID_SERIAL-1] = 0; + pd->app_ctx[OZ_APPID_SERIAL-1] = NULL; spin_unlock_bh(&pd->app_lock[OZ_APPID_SERIAL-1]); if (ctx) oz_cdev_release_ctx(ctx); spin_lock(&g_cdev.lock); if (pd == g_cdev.active_pd) - g_cdev.active_pd = 0; + g_cdev.active_pd = NULL; else - pd = 0; + pd = NULL; spin_unlock(&g_cdev.lock); if (pd) { oz_pd_put(pd); @@ -646,7 +651,7 @@ void oz_cdev_rx(struct oz_pd *pd, struct oz_elt *elt) spin_unlock_bh(&g_cdev.lock); ctx = oz_cdev_claim_ctx(pd); - if (ctx == 0) { + if (ctx == NULL) { oz_trace("Cannot claim serial context.\n"); return; } diff --git a/drivers/staging/ozwpan/ozcdev.h b/drivers/staging/ozwpan/ozcdev.h index 0e4071782448..d0dc3dc5d5f1 100644 --- a/drivers/staging/ozwpan/ozcdev.h +++ b/drivers/staging/ozwpan/ozcdev.h @@ -15,7 +15,7 @@ int oz_cdev_start(struct oz_pd *pd, int resume); void oz_cdev_stop(struct oz_pd *pd, int pause); void oz_cdev_rx(struct oz_pd *pd, struct oz_elt *elt); void oz_cdev_heartbeat(struct oz_pd *pd); -int oz_set_active_pd(u8 *addr); +int oz_set_active_pd(const u8 *addr); void oz_get_active_pd(u8 *addr); #endif /* _OZCDEV_H */ diff --git a/drivers/staging/ozwpan/ozeltbuf.c b/drivers/staging/ozwpan/ozeltbuf.c index e86f28b8dfa5..a52fecef85fb 100644 --- a/drivers/staging/ozwpan/ozeltbuf.c +++ b/drivers/staging/ozwpan/ozeltbuf.c @@ -63,7 +63,7 @@ void oz_elt_buf_term(struct oz_elt_buf *buf) */ struct oz_elt_info *oz_elt_info_alloc(struct oz_elt_buf *buf) { - struct oz_elt_info *ei = 0; + struct oz_elt_info *ei = NULL; spin_lock_bh(&buf->lock); if (buf->free_elts && buf->elt_pool) { ei = container_of(buf->elt_pool, struct oz_elt_info, link); @@ -81,9 +81,9 @@ struct oz_elt_info *oz_elt_info_alloc(struct oz_elt_buf *buf) if (ei) { ei->flags = 0; ei->app_id = 0; - ei->callback = 0; + ei->callback = NULL; ei->context = 0; - ei->stream = 0; + ei->stream = NULL; ei->magic = OZ_ELT_INFO_MAGIC_USED; INIT_LIST_HEAD(&ei->link); INIT_LIST_HEAD(&ei->link_order); @@ -132,7 +132,7 @@ int oz_elt_stream_create(struct oz_elt_buf *buf, u8 id, int max_buf_count) struct oz_elt_stream *st; st = kzalloc(sizeof(struct oz_elt_stream), GFP_ATOMIC | __GFP_ZERO); - if (st == 0) + if (st == NULL) return -ENOMEM; atomic_set(&st->ref_count, 1); st->id = id; @@ -148,7 +148,7 @@ int oz_elt_stream_create(struct oz_elt_buf *buf, u8 id, int max_buf_count) int oz_elt_stream_delete(struct oz_elt_buf *buf, u8 id) { struct list_head *e; - struct oz_elt_stream *st; + struct oz_elt_stream *st = NULL; spin_lock_bh(&buf->lock); e = buf->stream_list.next; @@ -158,7 +158,7 @@ int oz_elt_stream_delete(struct oz_elt_buf *buf, u8 id) list_del(e); break; } - st = 0; + st = NULL; } if (!st) { spin_unlock_bh(&buf->lock); @@ -202,7 +202,7 @@ void oz_elt_stream_put(struct oz_elt_stream *st) int oz_queue_elt_info(struct oz_elt_buf *buf, u8 isoc, u8 id, struct oz_elt_info *ei) { - struct oz_elt_stream *st = 0; + struct oz_elt_stream *st = NULL; struct list_head *e; if (id) { list_for_each(e, &buf->stream_list) { @@ -290,7 +290,7 @@ int oz_select_elts_for_tx(struct oz_elt_buf *buf, u8 isoc, unsigned *len, if (ei->stream) { ei->stream->buf_count -= ei->length; oz_elt_stream_put(ei->stream); - ei->stream = 0; + ei->stream = NULL; } INIT_LIST_HEAD(&ei->link_order); list_add_tail(&ei->link, list); @@ -312,7 +312,7 @@ int oz_are_elts_available(struct oz_elt_buf *buf) */ void oz_trim_elt_pool(struct oz_elt_buf *buf) { - struct list_head *free = 0; + struct list_head *free = NULL; struct list_head *e; spin_lock_bh(&buf->lock); while (buf->free_elts > buf->max_free_elts) { diff --git a/drivers/staging/ozwpan/ozhcd.c b/drivers/staging/ozwpan/ozhcd.c index c26547b4e553..42c8a0880740 100644 --- a/drivers/staging/ozwpan/ozhcd.c +++ b/drivers/staging/ozwpan/ozhcd.c @@ -33,6 +33,7 @@ #include "ozusbif.h" #include "oztrace.h" #include "ozurbparanoia.h" +#include "ozhcd.h" #define OZ_HUB_DEBOUNCE_TIMEOUT 1500 @@ -261,7 +262,7 @@ static int oz_get_port_from_addr(struct oz_hcd *ozhcd, u8 bus_addr) */ static struct oz_urb_link *oz_alloc_urb_link(void) { - struct oz_urb_link *urbl = 0; + struct oz_urb_link *urbl = NULL; unsigned long irq_state; spin_lock_irqsave(&g_link_lock, irq_state); if (g_link_pool) { @@ -270,7 +271,7 @@ static struct oz_urb_link *oz_alloc_urb_link(void) --g_link_pool_size; } spin_unlock_irqrestore(&g_link_lock, irq_state); - if (urbl == 0) + if (urbl == NULL) urbl = kmalloc(sizeof(struct oz_urb_link), GFP_ATOMIC); return urbl; } @@ -287,7 +288,7 @@ static void oz_free_urb_link(struct oz_urb_link *urbl) if (g_link_pool_size < OZ_MAX_LINK_POOL_SIZE) { urbl->link.next = g_link_pool; g_link_pool = &urbl->link; - urbl = 0; + urbl = NULL; g_link_pool_size++; } spin_unlock_irqrestore(&g_link_lock, irq_state); @@ -305,7 +306,7 @@ static void oz_empty_link_pool(void) unsigned long irq_state; spin_lock_irqsave(&g_link_lock, irq_state); e = g_link_pool; - g_link_pool = 0; + g_link_pool = NULL; g_link_pool_size = 0; spin_unlock_irqrestore(&g_link_lock, irq_state); while (e) { @@ -351,7 +352,7 @@ struct oz_urb_link *oz_uncancel_urb(struct oz_hcd *ozhcd, struct urb *urb) return urbl; } } - return 0; + return NULL; } /*------------------------------------------------------------------------------ * This is called when we have finished processing an urb. It unlinks it from @@ -363,7 +364,7 @@ static void oz_complete_urb(struct usb_hcd *hcd, struct urb *urb, { struct oz_hcd *ozhcd = oz_hcd_private(hcd); unsigned long irq_state; - struct oz_urb_link *cancel_urbl = 0; + struct oz_urb_link *cancel_urbl = NULL; spin_lock_irqsave(&g_tasklet_lock, irq_state); if (usb_pipeisoc(urb->pipe)) { @@ -384,7 +385,7 @@ static void oz_complete_urb(struct usb_hcd *hcd, struct urb *urb, /* Clear hcpriv which will prevent it being put in the cancel list * in the event that an attempt is made to cancel it. */ - urb->hcpriv = 0; + urb->hcpriv = NULL; /* Walk the cancel list in case the urb is already sitting there. * Since we process the cancel list in a tasklet rather than in * the dequeue function this could happen. @@ -553,7 +554,7 @@ out: static int oz_dequeue_ep_urb(struct oz_port *port, u8 ep_addr, int in_dir, struct urb *urb) { - struct oz_urb_link *urbl = 0; + struct oz_urb_link *urbl = NULL; struct oz_endpoint *ep; spin_lock_bh(&port->ozhcd->hcd_lock); if (in_dir) @@ -568,7 +569,7 @@ static int oz_dequeue_ep_urb(struct oz_port *port, u8 ep_addr, int in_dir, list_del_init(e); break; } - urbl = 0; + urbl = NULL; } } spin_unlock_bh(&port->ozhcd->hcd_lock); @@ -584,8 +585,8 @@ static struct urb *oz_find_urb_by_id(struct oz_port *port, int ep_ix, u8 req_id) { struct oz_hcd *ozhcd = port->ozhcd; - struct urb *urb = 0; - struct oz_urb_link *urbl = 0; + struct urb *urb = NULL; + struct oz_urb_link *urbl = NULL; struct oz_endpoint *ep; spin_lock_bh(&ozhcd->hcd_lock); @@ -687,14 +688,14 @@ static inline void oz_hcd_put(struct oz_hcd *ozhcd) void *oz_hcd_pd_arrived(void *hpd) { int i; - void *hport = 0; - struct oz_hcd *ozhcd = 0; + void *hport = NULL; + struct oz_hcd *ozhcd = NULL; struct oz_endpoint *ep; static int n = OZ_NB_PORTS; int j; ozhcd = oz_hcd_claim(); - if (ozhcd == 0) - return 0; + if (ozhcd == NULL) + return NULL; /* Allocate an endpoint object in advance (before holding hcd lock) to * use for out endpoint 0. */ @@ -725,7 +726,7 @@ void *oz_hcd_pd_arrived(void *hpd) /* Attach out endpoint 0. */ ozhcd->ports[j].out_ep[0] = ep; - ep = 0; + ep = NULL; hport = &ozhcd->ports[j]; spin_unlock_bh(&ozhcd->hcd_lock); if (ozhcd->flags & OZ_HDC_F_SUSPENDED) { @@ -740,7 +741,7 @@ void *oz_hcd_pd_arrived(void *hpd) } out: if (ep) /* ep is non-null if not used. */ - oz_ep_free(0, ep); + oz_ep_free(NULL, ep); oz_hcd_put(ozhcd); return hport; } @@ -755,15 +756,15 @@ void oz_hcd_pd_departed(void *hport) struct oz_port *port = (struct oz_port *)hport; struct oz_hcd *ozhcd; void *hpd; - struct oz_endpoint *ep = 0; + struct oz_endpoint *ep = NULL; oz_trace("%s:\n", __func__); - if (port == 0) { + if (port == NULL) { oz_trace("%s: port = 0\n", __func__); return; } ozhcd = port->ozhcd; - if (ozhcd == 0) + if (ozhcd == NULL) return; /* Check if this is the connection port - if so clear it. */ @@ -780,7 +781,7 @@ void oz_hcd_pd_departed(void *hport) oz_clean_endpoints_for_config(ozhcd->hcd, port); spin_lock_bh(&port->port_lock); hpd = port->hpd; - port->hpd = 0; + port->hpd = NULL; port->bus_addr = 0xff; port->config_num = 0; port->flags &= ~(OZ_PORT_F_PRESENT | OZ_PORT_F_DYING); @@ -792,7 +793,7 @@ void oz_hcd_pd_departed(void *hport) */ if (port->out_ep[0]) { ep = port->out_ep[0]; - port->out_ep[0] = 0; + port->out_ep[0] = NULL; } spin_unlock_bh(&port->port_lock); if (ep) @@ -822,7 +823,7 @@ void oz_hcd_pd_reset(void *hpd, void *hport) /*------------------------------------------------------------------------------ * Context: softirq */ -void oz_hcd_get_desc_cnf(void *hport, u8 req_id, int status, u8 *desc, +void oz_hcd_get_desc_cnf(void *hport, u8 req_id, int status, const u8 *desc, int length, int offset, int total_size) { struct oz_port *port = (struct oz_port *)hport; @@ -913,7 +914,7 @@ static void oz_hcd_complete_set_interface(struct oz_port *port, struct urb *urb, /*------------------------------------------------------------------------------ * Context: softirq */ -void oz_hcd_control_cnf(void *hport, u8 req_id, u8 rcode, u8 *data, +void oz_hcd_control_cnf(void *hport, u8 req_id, u8 rcode, const u8 *data, int data_len) { struct oz_port *port = (struct oz_port *)hport; @@ -962,7 +963,8 @@ void oz_hcd_control_cnf(void *hport, u8 req_id, u8 rcode, u8 *data, /*------------------------------------------------------------------------------ * Context: softirq-serialized */ -static int oz_hcd_buffer_data(struct oz_endpoint *ep, u8 *data, int data_len) +static int oz_hcd_buffer_data(struct oz_endpoint *ep, const u8 *data, + int data_len) { int space; int copy_len; @@ -1000,14 +1002,14 @@ static int oz_hcd_buffer_data(struct oz_endpoint *ep, u8 *data, int data_len) /*------------------------------------------------------------------------------ * Context: softirq-serialized */ -void oz_hcd_data_ind(void *hport, u8 endpoint, u8 *data, int data_len) +void oz_hcd_data_ind(void *hport, u8 endpoint, const u8 *data, int data_len) { struct oz_port *port = (struct oz_port *)hport; struct oz_endpoint *ep; struct oz_hcd *ozhcd = port->ozhcd; spin_lock_bh(&ozhcd->hcd_lock); ep = port->in_ep[endpoint & USB_ENDPOINT_NUMBER_MASK]; - if (ep == 0) + if (ep == NULL) goto done; switch (ep->attrib & USB_ENDPOINT_XFERTYPE_MASK) { case USB_ENDPOINT_XFER_INT: @@ -1107,8 +1109,7 @@ int oz_hcd_heartbeat(void *hport) ep->credit -= urb->number_of_packets; if (ep->credit < 0) ep->credit = 0; - list_del(&urbl->link); - list_add_tail(&urbl->link, &xfr_list); + list_move_tail(&urbl->link, &xfr_list); } } spin_unlock_bh(&ozhcd->hcd_lock); @@ -1181,8 +1182,7 @@ int oz_hcd_heartbeat(void *hport) urb->error_count = 0; urb->start_frame = ep->start_frame; ep->start_frame += urb->number_of_packets; - list_del(&urbl->link); - list_add_tail(&urbl->link, &xfr_list); + list_move_tail(&urbl->link, &xfr_list); ep->credit -= urb->number_of_packets; ep->credit2 += urb->number_of_packets; } @@ -1235,8 +1235,7 @@ int oz_hcd_heartbeat(void *hport) oz_trace_msg(M, "URB:%08X timeout %02X\n", (unsigned int)((uintptr_t)urbl->urb), urbl->req_id); - list_del(e); - list_add_tail(e, &xfr_list); + list_move_tail(e, &xfr_list); urbl->submit_counter = 0; } else if (urbl->submit_counter) { urbl->submit_counter++; @@ -1364,19 +1363,17 @@ static void oz_clean_endpoints_for_interface(struct usb_hcd *hcd, */ if ((mask & (1<<i)) && port->out_ep[i]) { e = &port->out_ep[i]->link; - port->out_ep[i] = 0; + port->out_ep[i] = NULL; /* Remove from isoc list if present. */ - list_del(e); - list_add_tail(e, &ep_list); + list_move_tail(e, &ep_list); } /* Gather IN endpoints. */ if ((mask & (1<<(i+OZ_NB_ENDPOINTS))) && port->in_ep[i]) { e = &port->in_ep[i]->link; - port->in_ep[i] = 0; - list_del(e); - list_add_tail(e, &ep_list); + port->in_ep[i] = NULL; + list_move_tail(e, &ep_list); } } spin_unlock_bh(&ozhcd->hcd_lock); @@ -1435,7 +1432,7 @@ static void oz_clean_endpoints_for_config(struct usb_hcd *hcd, spin_lock_bh(&ozhcd->hcd_lock); if (port->iface) { kfree(port->iface); - port->iface = 0; + port->iface = NULL; } port->num_iface = 0; spin_unlock_bh(&ozhcd->hcd_lock); @@ -1445,7 +1442,7 @@ static void oz_clean_endpoints_for_config(struct usb_hcd *hcd, */ static void *oz_claim_hpd(struct oz_port *port) { - void *hpd = 0; + void *hpd = NULL; struct oz_hcd *ozhcd = port->ozhcd; spin_lock_bh(&ozhcd->hcd_lock); hpd = port->hpd; @@ -1464,13 +1461,13 @@ static void oz_process_ep0_urb(struct oz_hcd *ozhcd, struct urb *urb, unsigned windex; unsigned wvalue; unsigned wlength; - void *hpd = 0; + void *hpd = NULL; u8 req_id; int rc = 0; unsigned complete = 0; int port_ix = -1; - struct oz_port *port = 0; + struct oz_port *port = NULL; port_ix = oz_get_port_from_addr(ozhcd, (usb_pipedevice(urb->pipe))); if (port_ix < 0) { @@ -1495,7 +1492,7 @@ static void oz_process_ep0_urb(struct oz_hcd *ozhcd, struct urb *urb, req_id = port->next_req_id++; hpd = oz_claim_hpd(port); - if (hpd == 0) { + if (hpd == NULL) { rc = -EPIPE; goto out; } @@ -1622,7 +1619,7 @@ static void oz_urb_process_tasklet(unsigned long unused) struct urb *urb; struct oz_hcd *ozhcd = oz_hcd_claim(); int rc = 0; - if (ozhcd == 0) + if (ozhcd == NULL) return; /* This is called from a tasklet so is in softirq context but the urb * list is filled from any context so we need to lock @@ -1656,17 +1653,17 @@ static void oz_urb_process_tasklet(unsigned long unused) */ static void oz_urb_cancel(struct oz_port *port, u8 ep_num, struct urb *urb) { - struct oz_urb_link *urbl = 0; + struct oz_urb_link *urbl = NULL; struct list_head *e; struct oz_hcd *ozhcd; unsigned long irq_state; u8 ix; - if (port == 0) { + if (port == NULL) { oz_trace("%s: urb=%p port is null\n", __func__, urb); return; } ozhcd = port->ozhcd; - if (ozhcd == 0) { + if (ozhcd == NULL) { oz_trace("%s: urb=%p ozhcd is null\n", __func__, urb); return; } @@ -1683,7 +1680,7 @@ static void oz_urb_cancel(struct oz_port *port, u8 ep_num, struct urb *urb) } } spin_unlock_irqrestore(&g_tasklet_lock, irq_state); - urbl = 0; + urbl = NULL; /* Look in the orphanage. */ @@ -1697,7 +1694,7 @@ static void oz_urb_cancel(struct oz_port *port, u8 ep_num, struct urb *urb) } } ix = (ep_num & 0xf); - urbl = 0; + urbl = NULL; if ((ep_num & USB_DIR_IN) && ix) urbl = oz_remove_urb(port->in_ep[ix], urb); else @@ -1719,7 +1716,7 @@ static void oz_urb_cancel_tasklet(unsigned long unused) unsigned long irq_state; struct urb *urb; struct oz_hcd *ozhcd = oz_hcd_claim(); - if (ozhcd == 0) + if (ozhcd == NULL) return; spin_lock_irqsave(&g_tasklet_lock, irq_state); while (!list_empty(&ozhcd->urb_cancel_list)) { @@ -1792,7 +1789,7 @@ static int oz_hcd_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, struct oz_port *port; unsigned long irq_state; struct oz_urb_link *urbl; - if (unlikely(ozhcd == 0)) { + if (unlikely(ozhcd == NULL)) { oz_trace("Refused urb(%p) not ozhcd.\n", urb); return -ENODEV; } @@ -1804,7 +1801,7 @@ static int oz_hcd_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, if (port_ix < 0) return -ENODEV; port = &ozhcd->ports[port_ix]; - if (port == 0) + if (port == NULL) return -ENODEV; if ((port->flags & OZ_PORT_F_PRESENT) == 0) { oz_trace("Refusing URB port_ix = %d devnum = %d\n", @@ -1815,7 +1812,7 @@ static int oz_hcd_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, /* Put request in queue for processing by tasklet. */ urbl = oz_alloc_urb_link(); - if (unlikely(urbl == 0)) + if (unlikely(urbl == NULL)) return -ENOMEM; urbl->urb = urb; spin_lock_irqsave(&g_tasklet_lock, irq_state); @@ -1838,9 +1835,9 @@ static int oz_hcd_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, static struct oz_urb_link *oz_remove_urb(struct oz_endpoint *ep, struct urb *urb) { - struct oz_urb_link *urbl = 0; + struct oz_urb_link *urbl = NULL; struct list_head *e; - if (unlikely(ep == 0)) + if (unlikely(ep == NULL)) return 0; list_for_each(e, &ep->urb_list) { urbl = container_of(e, struct oz_urb_link, link); @@ -1864,12 +1861,12 @@ static struct oz_urb_link *oz_remove_urb(struct oz_endpoint *ep, static int oz_hcd_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) { struct oz_hcd *ozhcd = oz_hcd_private(hcd); - struct oz_urb_link *urbl = 0; + struct oz_urb_link *urbl = NULL; int rc; unsigned long irq_state; urbl = oz_alloc_urb_link(); - if (unlikely(urbl == 0)) + if (unlikely(urbl == NULL)) return -ENOMEM; spin_lock_irqsave(&g_tasklet_lock, irq_state); /* The following function checks the urb is still in the queue @@ -1942,12 +1939,12 @@ static int oz_hcd_hub_status_data(struct usb_hcd *hcd, char *buf) } } oz_trace_msg(H, "HUBSTS : %02X%02X\n", - buf[1], buf[0]); + (unsigned char)(buf[1]), (unsigned char)(buf[0])); spin_unlock_bh(&ozhcd->hcd_lock); if (buf[1] != 0 || buf[0] != 0) return 2; else - return 1; + return 0; } /*------------------------------------------------------------------------------ * Context: process @@ -1973,6 +1970,7 @@ static int oz_set_port_feature(struct usb_hcd *hcd, u16 wvalue, u16 windex) struct oz_hcd *ozhcd = oz_hcd_private(hcd); unsigned set_bits = 0; unsigned clear_bits = 0; + void *hpd; if ((port_id < 1) || (port_id > OZ_NB_PORTS)) return -ENODEV; @@ -1995,6 +1993,11 @@ static int oz_set_port_feature(struct usb_hcd *hcd, u16 wvalue, u16 windex) set_bits = USB_PORT_STAT_ENABLE | (USB_PORT_STAT_C_RESET<<16); clear_bits = USB_PORT_STAT_RESET; ozhcd->ports[port_id-1].bus_addr = 0; + hpd = oz_claim_hpd(&ozhcd->ports[port_id-1]); + if (hpd != NULL) { + oz_usb_reset_device(hpd); + oz_usb_put(hpd); + } break; case USB_PORT_FEAT_POWER: oz_trace("USB_PORT_FEAT_POWER\n"); @@ -2217,7 +2220,7 @@ static int oz_plat_probe(struct platform_device *dev) struct oz_hcd *ozhcd; hcd = usb_create_hcd(&g_oz_hc_drv, &dev->dev, dev_name(&dev->dev)); - if (hcd == 0) { + if (hcd == NULL) { oz_trace("Failed to created hcd object\n"); return -ENOMEM; } @@ -2256,12 +2259,12 @@ static int oz_plat_remove(struct platform_device *dev) struct usb_hcd *hcd = platform_get_drvdata(dev); struct oz_hcd *ozhcd; - if (hcd == 0) + if (hcd == NULL) return -1; ozhcd = oz_hcd_private(hcd); spin_lock_bh(&g_hcdlock); if (ozhcd == g_ozhcd) - g_ozhcd = 0; + g_ozhcd = NULL; spin_unlock_bh(&g_hcdlock); oz_hcd_clear_orphanage(ozhcd, -ENODEV); usb_remove_hcd(hcd); @@ -2300,7 +2303,7 @@ int oz_hcd_init(void) if (err) goto error; g_plat_dev = platform_device_alloc(OZ_PLAT_DEV_NAME, -1); - if (g_plat_dev == 0) { + if (g_plat_dev == NULL) { err = -ENOMEM; goto error1; } @@ -2324,8 +2327,8 @@ error: void oz_hcd_term(void) { msleep(OZ_HUB_DEBOUNCE_TIMEOUT); - tasklet_disable(&g_urb_process_tasklet); - tasklet_disable(&g_urb_cancel_tasklet); + tasklet_kill(&g_urb_process_tasklet); + tasklet_kill(&g_urb_cancel_tasklet); platform_device_unregister(g_plat_dev); platform_driver_unregister(&g_oz_plat_drv); oz_trace("Pending urbs:%d\n", atomic_read(&g_pending_urbs)); diff --git a/drivers/staging/ozwpan/ozmain.c b/drivers/staging/ozwpan/ozmain.c index 0b48cc8508ff..61b83f86ef63 100644 --- a/drivers/staging/ozwpan/ozmain.c +++ b/drivers/staging/ozwpan/ozmain.c @@ -26,8 +26,9 @@ char *g_net_dev = ""; */ static int __init ozwpan_init(void) { + if (oz_protocol_init(g_net_dev)) + return -1; oz_cdev_register(); - oz_protocol_init(g_net_dev); oz_app_enable(OZ_APPID_USB, 1); oz_apps_init(); printk(KERN_DEBUG "p->oz_protocol_init = 0x%p\n", oz_protocol_init); @@ -50,6 +51,6 @@ module_exit(ozwpan_exit); MODULE_AUTHOR("Chris Kelly"); MODULE_DESCRIPTION("Ozmo Devices USB over WiFi hcd driver"); -MODULE_VERSION("1.2.3-rc2"); +MODULE_VERSION("1.2.3-rc9"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/ozwpan/ozpd.c b/drivers/staging/ozwpan/ozpd.c index e3bf27b6bee8..e9a3de041b8c 100644 --- a/drivers/staging/ozwpan/ozpd.c +++ b/drivers/staging/ozwpan/ozpd.c @@ -45,7 +45,7 @@ static void oz_def_app_rx(struct oz_pd *pd, struct oz_elt *elt); static atomic_t g_submitted_isoc = ATOMIC_INIT(0); /* Application handler functions. */ -static struct oz_app_if g_app_if[OZ_APPID_MAX] = { +static const struct oz_app_if g_app_if[OZ_APPID_MAX] = { {oz_usb_init, oz_usb_term, oz_usb_start, @@ -60,8 +60,8 @@ static struct oz_app_if g_app_if[OZ_APPID_MAX] = { oz_def_app_start, oz_def_app_stop, oz_def_app_rx, - 0, - 0, + NULL, + NULL, OZ_APPID_UNUSED1}, {oz_def_app_init, @@ -69,8 +69,8 @@ static struct oz_app_if g_app_if[OZ_APPID_MAX] = { oz_def_app_start, oz_def_app_stop, oz_def_app_rx, - 0, - 0, + NULL, + NULL, OZ_APPID_UNUSED2}, {oz_cdev_init, @@ -78,8 +78,8 @@ static struct oz_app_if g_app_if[OZ_APPID_MAX] = { oz_cdev_start, oz_cdev_stop, oz_cdev_rx, - 0, - 0, + NULL, + NULL, OZ_APPID_SERIAL}, {oz_def_app_init, @@ -87,8 +87,8 @@ static struct oz_app_if g_app_if[OZ_APPID_MAX] = { oz_def_app_start, oz_def_app_stop, oz_def_app_rx, - 0, - 0, + NULL, + NULL, OZ_APPID_UNUSED3}, {oz_def_app_init, @@ -96,17 +96,17 @@ static struct oz_app_if g_app_if[OZ_APPID_MAX] = { oz_def_app_start, oz_def_app_stop, oz_def_app_rx, - 0, - 0, + NULL, + NULL, OZ_APPID_UNUSED4}, - {0, - 0, - 0, - 0, + {NULL, + NULL, + NULL, + NULL, oz_cdev_rx, - 0, - 0, + NULL, + NULL, OZ_APPID_TFTP}, }; /*------------------------------------------------------------------------------ @@ -166,7 +166,7 @@ void oz_pd_put(struct oz_pd *pd) /*------------------------------------------------------------------------------ * Context: softirq-serialized */ -struct oz_pd *oz_pd_alloc(u8 *mac_addr) +struct oz_pd *oz_pd_alloc(const u8 *mac_addr) { struct oz_pd *pd = kzalloc(sizeof(struct oz_pd), GFP_ATOMIC); if (pd) { @@ -181,7 +181,7 @@ struct oz_pd *oz_pd_alloc(u8 *mac_addr) memcpy(pd->mac_addr, mac_addr, ETH_ALEN); if (0 != oz_elt_buf_init(&pd->elt_buff)) { kfree(pd); - pd = 0; + pd = NULL; } spin_lock_init(&pd->tx_frame_lock); INIT_LIST_HEAD(&pd->tx_queue); @@ -276,7 +276,7 @@ void oz_pd_destroy(struct oz_pd *pd) */ int oz_services_start(struct oz_pd *pd, u16 apps, int resume) { - struct oz_app_if *ai; + const struct oz_app_if *ai; int rc = 0; oz_trace("oz_services_start(0x%x) resume(%d)\n", apps, resume); if (apps & (1<<OZ_APPID_TFTP)) @@ -301,7 +301,7 @@ int oz_services_start(struct oz_pd *pd, u16 apps, int resume) */ void oz_services_stop(struct oz_pd *pd, u16 apps, int pause) { - struct oz_app_if *ai; + const struct oz_app_if *ai; oz_trace("oz_stop_services(0x%x) pause(%d)\n", apps, pause); if (apps & (1<<OZ_APPID_TFTP)) apps |= 1<<OZ_APPID_SERIAL; @@ -325,7 +325,7 @@ void oz_services_stop(struct oz_pd *pd, u16 apps, int pause) */ void oz_pd_heartbeat(struct oz_pd *pd, u16 apps) { - struct oz_app_if *ai; + const struct oz_app_if *ai; int more = 0; for (ai = g_app_if; ai < &g_app_if[OZ_APPID_MAX]; ai++) { if (ai->heartbeat && (apps & (1<<ai->app_id))) { @@ -377,6 +377,8 @@ int oz_pd_sleep(struct oz_pd *pd) return 0; } if (pd->keep_alive && pd->session_id) { + if (pd->keep_alive >= OZ_KALIVE_INFINITE) + oz_pd_indicate_farewells(pd); oz_pd_set_state(pd, OZ_PD_S_SLEEP); } else { do_stop = 1; @@ -396,7 +398,7 @@ int oz_pd_sleep(struct oz_pd *pd) */ static struct oz_tx_frame *oz_tx_frame_alloc(struct oz_pd *pd) { - struct oz_tx_frame *f = 0; + struct oz_tx_frame *f = NULL; spin_lock_bh(&pd->tx_frame_lock); if (pd->tx_pool) { f = container_of(pd->tx_pool, struct oz_tx_frame, link); @@ -404,7 +406,7 @@ static struct oz_tx_frame *oz_tx_frame_alloc(struct oz_pd *pd) pd->tx_pool_count--; } spin_unlock_bh(&pd->tx_frame_lock); - if (f == 0) + if (f == NULL) f = kmalloc(sizeof(struct oz_tx_frame), GFP_ATOMIC); if (f) { f->total_size = sizeof(struct oz_hdr); @@ -438,7 +440,7 @@ static void oz_tx_frame_free(struct oz_pd *pd, struct oz_tx_frame *f) f->link.next = pd->tx_pool; pd->tx_pool = &f->link; pd->tx_pool_count++; - f = 0; + f = NULL; } spin_unlock_bh(&pd->tx_frame_lock); if (f) @@ -473,7 +475,7 @@ int oz_prepare_frame(struct oz_pd *pd, int empty) if (!empty && !oz_are_elts_available(&pd->elt_buff)) return -1; f = oz_tx_frame_alloc(pd); - if (f == 0) + if (f == NULL) return -1; f->skb = NULL; f->hdr.control = @@ -495,7 +497,7 @@ int oz_prepare_frame(struct oz_pd *pd, int empty) */ static struct sk_buff *oz_build_frame(struct oz_pd *pd, struct oz_tx_frame *f) { - struct sk_buff *skb = 0; + struct sk_buff *skb; struct net_device *dev = pd->net_dev; struct oz_hdr *oz_hdr; struct oz_elt *elt; @@ -504,8 +506,8 @@ static struct sk_buff *oz_build_frame(struct oz_pd *pd, struct oz_tx_frame *f) * as the space we need. */ skb = alloc_skb(f->total_size + OZ_ALLOCATED_SPACE(dev), GFP_ATOMIC); - if (skb == 0) - return 0; + if (skb == NULL) + return NULL; /* Reserve the head room for lower layers. */ skb_reserve(skb, LL_RESERVED_SPACE(dev)); @@ -533,7 +535,7 @@ static struct sk_buff *oz_build_frame(struct oz_pd *pd, struct oz_tx_frame *f) return skb; fail: kfree_skb(skb); - return 0; + return NULL; } /*------------------------------------------------------------------------------ * Context: softirq or process @@ -650,7 +652,7 @@ out: oz_prepare_frame(pd, 1); */ static int oz_send_isoc_frame(struct oz_pd *pd) { - struct sk_buff *skb = 0; + struct sk_buff *skb; struct net_device *dev = pd->net_dev; struct oz_hdr *oz_hdr; struct oz_elt *elt; @@ -664,7 +666,7 @@ static int oz_send_isoc_frame(struct oz_pd *pd) if (list.next == &list) return 0; skb = alloc_skb(total_size + OZ_ALLOCATED_SPACE(dev), GFP_ATOMIC); - if (skb == 0) { + if (skb == NULL) { oz_elt_info_free_chain(&pd->elt_buff, &list); return -1; } @@ -700,8 +702,8 @@ void oz_retire_tx_frames(struct oz_pd *pd, u8 lpn) { struct list_head *e; struct oz_tx_frame *f; - struct list_head *first = 0; - struct list_head *last = 0; + struct list_head *first = NULL; + struct list_head *last = NULL; u8 diff; u32 pkt_num; @@ -713,7 +715,7 @@ void oz_retire_tx_frames(struct oz_pd *pd, u8 lpn) diff = (lpn - (pkt_num & OZ_LAST_PN_MASK)) & OZ_LAST_PN_MASK; if ((diff > OZ_LAST_PN_HALF_CYCLE) || (pkt_num == 0)) break; - if (first == 0) + if (first == NULL) first = e; last = e; e = e->next; @@ -722,7 +724,7 @@ void oz_retire_tx_frames(struct oz_pd *pd, u8 lpn) if (first) { last->next->prev = &pd->tx_queue; pd->tx_queue.next = last->next; - last->next = 0; + last->next = NULL; } pd->last_sent_frame = &pd->tx_queue; spin_unlock(&pd->tx_frame_lock); @@ -745,7 +747,7 @@ static struct oz_isoc_stream *pd_stream_find(struct oz_pd *pd, u8 ep_num) if (st->ep_num == ep_num) return st; } - return 0; + return NULL; } /*------------------------------------------------------------------------------ * Context: softirq @@ -760,7 +762,7 @@ int oz_isoc_stream_create(struct oz_pd *pd, u8 ep_num) spin_lock_bh(&pd->stream_lock); if (!pd_stream_find(pd, ep_num)) { list_add(&st->link, &pd->stream_list); - st = 0; + st = NULL; } spin_unlock_bh(&pd->stream_lock); if (st) @@ -801,19 +803,19 @@ static void oz_isoc_destructor(struct sk_buff *skb) /*------------------------------------------------------------------------------ * Context: softirq */ -int oz_send_isoc_unit(struct oz_pd *pd, u8 ep_num, u8 *data, int len) +int oz_send_isoc_unit(struct oz_pd *pd, u8 ep_num, const u8 *data, int len) { struct net_device *dev = pd->net_dev; struct oz_isoc_stream *st; u8 nb_units = 0; - struct sk_buff *skb = 0; - struct oz_hdr *oz_hdr = 0; + struct sk_buff *skb = NULL; + struct oz_hdr *oz_hdr = NULL; int size = 0; spin_lock_bh(&pd->stream_lock); st = pd_stream_find(pd, ep_num); if (st) { skb = st->skb; - st->skb = 0; + st->skb = NULL; nb_units = st->nb_units; st->nb_units = 0; oz_hdr = st->oz_hdr; @@ -826,7 +828,7 @@ int oz_send_isoc_unit(struct oz_pd *pd, u8 ep_num, u8 *data, int len) /* Allocate enough space for max size frame. */ skb = alloc_skb(pd->max_tx_size + OZ_ALLOCATED_SPACE(dev), GFP_ATOMIC); - if (skb == 0) + if (skb == NULL) return 0; /* Reserve the head room for lower layers. */ skb_reserve(skb, LL_RESERVED_SPACE(dev)); @@ -840,7 +842,8 @@ int oz_send_isoc_unit(struct oz_pd *pd, u8 ep_num, u8 *data, int len) } memcpy(skb_put(skb, len), data, len); size += len; - if (++nb_units < pd->ms_per_isoc) { + if ((++nb_units < pd->ms_per_isoc) + && ((pd->max_tx_size - size) > len)) { spin_lock_bh(&pd->stream_lock); st->skb = skb; st->nb_units = nb_units; @@ -939,7 +942,7 @@ void oz_apps_term(void) */ void oz_handle_app_elt(struct oz_pd *pd, u8 app_id, struct oz_elt *elt) { - struct oz_app_if *ai; + const struct oz_app_if *ai; if (app_id == 0 || app_id > OZ_APPID_MAX) return; ai = &g_app_if[app_id-1]; @@ -951,10 +954,8 @@ void oz_handle_app_elt(struct oz_pd *pd, u8 app_id, struct oz_elt *elt) void oz_pd_indicate_farewells(struct oz_pd *pd) { struct oz_farewell *f; - struct oz_app_if *ai = &g_app_if[OZ_APPID_USB-1]; - if (!(list_empty(&pd->farewell_list))) { - f = list_first_entry(&pd->farewell_list, - struct oz_farewell, link); + const struct oz_app_if *ai = &g_app_if[OZ_APPID_USB-1]; + list_for_each_entry(f, &pd->farewell_list, link) { if (ai->farewell) ai->farewell(pd, f->ep_num, f->report, f->len); } diff --git a/drivers/staging/ozwpan/ozpd.h b/drivers/staging/ozwpan/ozpd.h index 355f637e72c5..d75f0afa20ed 100644 --- a/drivers/staging/ozwpan/ozpd.h +++ b/drivers/staging/ozwpan/ozpd.h @@ -106,7 +106,7 @@ struct oz_pd { #define OZ_MAX_QUEUED_FRAMES 4 -struct oz_pd *oz_pd_alloc(u8 *mac_addr); +struct oz_pd *oz_pd_alloc(const u8 *mac_addr); void oz_pd_destroy(struct oz_pd *pd); void oz_pd_get(struct oz_pd *pd); void oz_pd_put(struct oz_pd *pd); @@ -122,7 +122,7 @@ void oz_send_queued_frames(struct oz_pd *pd, int backlog); void oz_retire_tx_frames(struct oz_pd *pd, u8 lpn); int oz_isoc_stream_create(struct oz_pd *pd, u8 ep_num); int oz_isoc_stream_delete(struct oz_pd *pd, u8 ep_num); -int oz_send_isoc_unit(struct oz_pd *pd, u8 ep_num, u8 *data, int len); +int oz_send_isoc_unit(struct oz_pd *pd, u8 ep_num, const u8 *data, int len); void oz_handle_app_elt(struct oz_pd *pd, u8 app_id, struct oz_elt *elt); void oz_apps_init(void); void oz_apps_term(void); diff --git a/drivers/staging/ozwpan/ozproto.c b/drivers/staging/ozwpan/ozproto.c index e222d0831f8f..c116e5250f6b 100644 --- a/drivers/staging/ozwpan/ozproto.c +++ b/drivers/staging/ozwpan/ozproto.c @@ -80,7 +80,7 @@ static void oz_send_conn_rsp(struct oz_pd *pd, u8 status) int sz = sizeof(struct oz_hdr) + sizeof(struct oz_elt) + sizeof(struct oz_elt_connect_rsp); skb = alloc_skb(sz + OZ_ALLOCATED_SPACE(dev), GFP_ATOMIC); - if (skb == 0) + if (skb == NULL) return; skb_reserve(skb, LL_RESERVED_SPACE(dev)); skb_reset_network_header(skb); @@ -96,7 +96,7 @@ static void oz_send_conn_rsp(struct oz_pd *pd, u8 status) return; } oz_hdr->control = (OZ_PROTOCOL_VERSION<<OZ_VERSION_SHIFT); - oz_hdr->last_pkt_num = 0; + oz_hdr->last_pkt_num = pd->trigger_pkt_num & OZ_LAST_PN_MASK; put_unaligned(0, &oz_hdr->pkt_num); elt->type = OZ_ELT_CONNECT_RSP; elt->length = sizeof(struct oz_elt_connect_rsp); @@ -120,7 +120,7 @@ static void pd_set_keepalive(struct oz_pd *pd, u8 kalive) switch (kalive & OZ_KALIVE_TYPE_MASK) { case OZ_KALIVE_SPECIAL: - pd->keep_alive = (keep_alive*1000*60*60*24*20); + pd->keep_alive = (keep_alive * OZ_KALIVE_INFINITE); break; case OZ_KALIVE_SECS: pd->keep_alive = (keep_alive*1000); @@ -154,7 +154,7 @@ static void pd_set_presleep(struct oz_pd *pd, u8 presleep, u8 start_timer) * Context: softirq-serialized */ static struct oz_pd *oz_connect_req(struct oz_pd *cur_pd, struct oz_elt *elt, - u8 *pd_addr, struct net_device *net_dev) + const u8 *pd_addr, struct net_device *net_dev, u32 pkt_num) { struct oz_pd *pd; struct oz_elt_connect_req *body = @@ -162,17 +162,17 @@ static struct oz_pd *oz_connect_req(struct oz_pd *cur_pd, struct oz_elt *elt, u8 rsp_status = OZ_STATUS_SUCCESS; u8 stop_needed = 0; u16 new_apps = g_apps; - struct net_device *old_net_dev = 0; - struct oz_pd *free_pd = 0; + struct net_device *old_net_dev = NULL; + struct oz_pd *free_pd = NULL; if (cur_pd) { pd = cur_pd; spin_lock_bh(&g_polling_lock); } else { - struct oz_pd *pd2 = 0; + struct oz_pd *pd2 = NULL; struct list_head *e; pd = oz_pd_alloc(pd_addr); - if (pd == 0) - return 0; + if (pd == NULL) + return NULL; getnstimeofday(&pd->last_rx_timestamp); spin_lock_bh(&g_polling_lock); list_for_each(e, &g_pd_list) { @@ -186,9 +186,9 @@ static struct oz_pd *oz_connect_req(struct oz_pd *cur_pd, struct oz_elt *elt, if (pd != pd2) list_add_tail(&pd->link, &g_pd_list); } - if (pd == 0) { + if (pd == NULL) { spin_unlock_bh(&g_polling_lock); - return 0; + return NULL; } if (pd->net_dev != net_dev) { old_net_dev = pd->net_dev; @@ -268,12 +268,17 @@ done: } else { spin_unlock_bh(&g_polling_lock); } + + /* CONNECT_REQ was sent without AR bit, + but firmware does check LPN field to identify correcponding + CONNECT_RSP field. */ + pd->trigger_pkt_num = pkt_num; oz_send_conn_rsp(pd, rsp_status); if (rsp_status != OZ_STATUS_SUCCESS) { if (stop_needed) oz_pd_stop(pd); oz_pd_put(pd); - pd = 0; + pd = NULL; } if (old_net_dev) dev_put(old_net_dev); @@ -285,7 +290,7 @@ done: * Context: softirq-serialized */ static void oz_add_farewell(struct oz_pd *pd, u8 ep_num, u8 index, - u8 *report, u8 len) + const u8 *report, u8 len) { struct oz_farewell *f; struct oz_farewell *f2; @@ -320,7 +325,7 @@ static void oz_rx_frame(struct sk_buff *skb) u8 *src_addr; struct oz_elt *elt; int length; - struct oz_pd *pd = 0; + struct oz_pd *pd = NULL; struct oz_hdr *oz_hdr = (struct oz_hdr *)skb_network_header(skb); struct timespec current_time; int dup = 0; @@ -382,7 +387,8 @@ static void oz_rx_frame(struct sk_buff *skb) break; switch (elt->type) { case OZ_ELT_CONNECT_REQ: - pd = oz_connect_req(pd, elt, src_addr, skb->dev); + pd = oz_connect_req(pd, elt, src_addr, skb->dev, + pkt_num); break; case OZ_ELT_DISCONNECT: if (pd) @@ -569,7 +575,7 @@ void oz_pd_request_heartbeat(struct oz_pd *pd) /*------------------------------------------------------------------------------ * Context: softirq or process */ -struct oz_pd *oz_pd_find(u8 *mac_addr) +struct oz_pd *oz_pd_find(const u8 *mac_addr) { struct oz_pd *pd; struct list_head *e; @@ -606,7 +612,7 @@ static int oz_pkt_recv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt, struct net_device *orig_dev) { skb = skb_share_check(skb, GFP_ATOMIC); - if (skb == 0) + if (skb == NULL) return 0; spin_lock_bh(&g_rx_queue.lock); if (g_processing_rx) { @@ -646,17 +652,18 @@ void oz_binding_add(const char *net_dev) binding->ptype.func = oz_pkt_recv; memcpy(binding->name, net_dev, OZ_MAX_BINDING_LEN); if (net_dev && *net_dev) { - oz_trace("Adding binding: %s\n", net_dev); + oz_trace_msg(M, "Adding binding: '%s'\n", net_dev); binding->ptype.dev = dev_get_by_name(&init_net, net_dev); - if (binding->ptype.dev == 0) { - oz_trace("Netdev %s not found\n", net_dev); + if (binding->ptype.dev == NULL) { + oz_trace_msg(M, "Netdev '%s' not found\n", + net_dev); kfree(binding); - binding = 0; + binding = NULL; } } else { - oz_trace("Binding to all netcards\n"); - binding->ptype.dev = 0; + oz_trace_msg(M, "Binding to all netcards\n"); + binding->ptype.dev = NULL; } if (binding) { dev_add_pack(&binding->ptype); @@ -709,14 +716,14 @@ static void pd_stop_all_for_device(struct net_device *net_dev) */ void oz_binding_remove(const char *net_dev) { - struct oz_binding *binding = NULL; + struct oz_binding *binding; int found = 0; - oz_trace("Removing binding: %s\n", net_dev); + oz_trace_msg(M, "Removing binding: '%s'\n", net_dev); spin_lock_bh(&g_binding_lock); list_for_each_entry(binding, &g_binding, link) { if (compare_binding_name(binding->name, net_dev)) { - oz_trace("Binding '%s' found\n", net_dev); + oz_trace_msg(M, "Binding '%s' found\n", net_dev); found = 1; break; } @@ -771,7 +778,7 @@ int oz_protocol_init(char *devs) { skb_queue_head_init(&g_rx_queue); if (devs && (devs[0] == '*')) { - oz_binding_add(0); + return -1; } else { char d[32]; while (*devs) { diff --git a/drivers/staging/ozwpan/ozproto.h b/drivers/staging/ozwpan/ozproto.h index 9b100a5b479c..64ac30c7fb54 100644 --- a/drivers/staging/ozwpan/ozproto.h +++ b/drivers/staging/ozwpan/ozproto.h @@ -53,7 +53,7 @@ int oz_protocol_init(char *devs); void oz_protocol_term(void); int oz_get_pd_list(struct oz_mac_addr *addr, int max_count); void oz_app_enable(int app_id, int enable); -struct oz_pd *oz_pd_find(u8 *mac_addr); +struct oz_pd *oz_pd_find(const u8 *mac_addr); void oz_binding_add(const char *net_dev); void oz_binding_remove(const char *net_dev); void oz_timer_add(struct oz_pd *pd, int type, unsigned long due_time); diff --git a/drivers/staging/ozwpan/ozprotocol.h b/drivers/staging/ozwpan/ozprotocol.h index ee76c2e2e308..5cb989c90a58 100644 --- a/drivers/staging/ozwpan/ozprotocol.h +++ b/drivers/staging/ozwpan/ozprotocol.h @@ -139,6 +139,8 @@ struct oz_elt_connect_req { #define OZ_KALIVE_MINS 0x80 #define OZ_KALIVE_HOURS 0xc0 +#define OZ_KALIVE_INFINITE (1000*60*60*24*20) + /* Connect response data structure. */ struct oz_elt_connect_rsp { diff --git a/drivers/staging/ozwpan/oztrace.c b/drivers/staging/ozwpan/oztrace.c index 6bb22572dd2a..4503c5dfa091 100644 --- a/drivers/staging/ozwpan/oztrace.c +++ b/drivers/staging/ozwpan/oztrace.c @@ -12,7 +12,8 @@ u32 g_debug = #ifdef WANT_TRACE_DATA_FLOW - TRC_M|TRC_R|TRC_T|TRC_S|TRC_E|TRC_C; + TRC_FLG(M)|TRC_FLG(R)|TRC_FLG(T)| + TRC_FLG(S)|TRC_FLG(E)|TRC_FLG(C); #else 0; #endif @@ -136,14 +137,14 @@ void trace_dbg_msg(int c, char *fmt, ...) va_end(arg); } -void trace_debug_log(char *log_type, ...) +void trace_debug_log(char log_type, ...) { va_list arg; char *fmt; va_start(arg, log_type); fmt = va_arg(arg, char *); - switch (*log_type) { + switch (log_type) { case 'H': trace_hcd_msg_evt(fmt, arg); break; diff --git a/drivers/staging/ozwpan/oztrace.h b/drivers/staging/ozwpan/oztrace.h index fe1322104c49..ab1d5cb96c1c 100644 --- a/drivers/staging/ozwpan/oztrace.h +++ b/drivers/staging/ozwpan/oztrace.h @@ -19,48 +19,50 @@ void oz_trace_f_urb_in(struct urb *urb); void oz_trace_f_skb(struct sk_buff *skb, char dir); void oz_trace_f_dbg(void); void trace_dbg_msg(int c, char *fmt, ...); -void trace_debug_log(char *log_type, ...); +void trace_debug_log(char log_type, ...); extern u32 g_debug; -#define TRC_A 0x00000001 -#define TRC_B 0x00000002 -#define TRC_C 0x00000004 /* urb Completion */ -#define TRC_D 0x00000008 /* Debug */ -#define TRC_E 0x00000010 /* urb Error */ -#define TRC_F 0x00000020 -#define TRC_G 0x00000040 -#define TRC_H 0x00000080 /* Hcd message */ -#define TRC_I 0x00000100 /* Isoc buffer depth */ -#define TRC_J 0x00000200 -#define TRC_K 0x00000400 -#define TRC_L 0x00000800 -#define TRC_M 0x00001000 /* Message */ -#define TRC_N 0x00002000 -#define TRC_O 0x00004000 -#define TRC_P 0x00008000 -#define TRC_Q 0x00010000 -#define TRC_R 0x00020000 /* Rx Ozmo frame */ -#define TRC_S 0x00040000 /* urb Submission */ -#define TRC_T 0x00080000 /* Tx ozmo frame */ -#define TRC_U 0x00100000 -#define TRC_V 0x00200000 -#define TRC_W 0x00400000 -#define TRC_X 0x00800000 -#define TRC_Y 0x01000000 -#define TRC_Z 0x02000000 - +#define TRC_A 'A' +#define TRC_B 'B' +#define TRC_C 'C' /* urb Completion */ +#define TRC_D 'D' /* Debug */ +#define TRC_E 'E' /* urb Error */ +#define TRC_F 'F' +#define TRC_G 'G' +#define TRC_H 'H' /* Hcd message */ +#define TRC_I 'I' /* Isoc buffer depth */ +#define TRC_J 'J' +#define TRC_K 'K' +#define TRC_L 'L' +#define TRC_M 'M' /* Message */ +#define TRC_N 'N' +#define TRC_O 'O' +#define TRC_P 'P' +#define TRC_Q 'Q' +#define TRC_R 'R' /* Rx Ozmo frame */ +#define TRC_S 'S' /* urb Submission */ +#define TRC_T 'T' /* Tx ozmo frame */ +#define TRC_U 'U' +#define TRC_V 'V' +#define TRC_W 'W' +#define TRC_X 'X' +#define TRC_Y 'Y' +#define TRC_Z 'Z' + +#define TRC_FLG(f) (1<<((TRC_##f)-'A')) #define oz_trace_urb_out(u, s) \ do { if (!g_debug) \ trace_urb_out(u, s); \ - else if ((g_debug & TRC_C) || ((g_debug & TRC_E) && (u->status != 0))) \ + else if ((g_debug & TRC_FLG(C)) ||\ + ((g_debug & TRC_FLG(E)) && (s != 0))) \ oz_trace_f_urb_out(u, s); } while (0) #define oz_trace_urb_in(u) \ do { if (!g_debug) \ trace_urb_in(u); \ - else if (g_debug & TRC_S) \ + else if (g_debug & TRC_FLG(S)) \ oz_trace_f_urb_in(u); } while (0) #define oz_trace_skb(u, d) \ @@ -68,14 +70,14 @@ extern u32 g_debug; trace_tx_frame(u); \ else if ((!g_debug) && ('R' == d)) \ trace_rx_frame(u); \ - else if ((('T' == d) && (g_debug & TRC_T)) || \ - (('R' == d) && (g_debug & TRC_R))) \ + else if ((('T' == d) && (g_debug & TRC_FLG(T))) || \ + (('R' == d) && (g_debug & TRC_FLG(R)))) \ oz_trace_f_skb(u, d); } while(0) #define oz_trace_msg(f, ...) \ do { if (!g_debug) \ - trace_debug_log(#f, __VA_ARGS__); \ - else if (g_debug & TRC_##f) \ + trace_debug_log(TRC_##f, __VA_ARGS__); \ + else if (g_debug & TRC_FLG(f)) \ printk("OZ " #f " " __VA_ARGS__); } while(0) enum { diff --git a/drivers/staging/ozwpan/ozusbif.h b/drivers/staging/ozwpan/ozusbif.h index 7c59b22f8b9f..b1d58e16992a 100644 --- a/drivers/staging/ozwpan/ozusbif.h +++ b/drivers/staging/ozwpan/ozusbif.h @@ -13,6 +13,10 @@ void oz_usb_get(void *hpd); void oz_usb_put(void *hpd); +/* Reset device. +*/ +void oz_usb_reset_device(void *hpd); + /* Stream functions. */ int oz_usb_stream_create(void *hpd, u8 ep_num); @@ -21,7 +25,7 @@ int oz_usb_stream_delete(void *hpd, u8 ep_num); /* Request functions. */ int oz_usb_control_req(void *hpd, u8 req_id, struct usb_ctrlrequest *setup, - u8 *data, int data_len); + const u8 *data, int data_len); int oz_usb_get_desc_req(void *hpd, u8 req_id, u8 req_type, u8 desc_type, u8 index, u16 windex, int offset, int len); int oz_usb_send_isoc(void *hpd, u8 ep_num, struct urb *urb); @@ -30,15 +34,15 @@ void oz_usb_request_heartbeat(void *hpd); /* Confirmation functions. */ void oz_hcd_get_desc_cnf(void *hport, u8 req_id, int status, - u8 *desc, int length, int offset, int total_size); + const u8 *desc, int length, int offset, int total_size); void oz_hcd_control_cnf(void *hport, u8 req_id, u8 rcode, - u8 *data, int data_len); + const u8 *data, int data_len); void oz_hcd_mark_urb_submitted(void *hport, int ep_ix, u8 req_id); /* Indication functions. */ -void oz_hcd_data_ind(void *hport, u8 endpoint, u8 *data, int data_len); +void oz_hcd_data_ind(void *hport, u8 endpoint, const u8 *data, int data_len); int oz_hcd_heartbeat(void *hport); diff --git a/drivers/staging/ozwpan/ozusbsvc.c b/drivers/staging/ozwpan/ozusbsvc.c index 3dae52f0af18..c763c089ebc9 100644 --- a/drivers/staging/ozwpan/ozusbsvc.c +++ b/drivers/staging/ozwpan/ozusbsvc.c @@ -43,6 +43,22 @@ void oz_usb_term(void) oz_hcd_term(); } /*------------------------------------------------------------------------------ + * This is called when HCD received FEAT_RESET request from hub. + * If PD is in sleep, it then removes PD as it is unable to respond any host + * action. + */ +void oz_usb_reset_device(void *hpd) +{ + struct oz_usb_ctx *usb_ctx = (struct oz_usb_ctx *)hpd; + struct oz_pd *pd = usb_ctx->pd; + oz_pd_get(pd); + if (pd && (!(pd->state & OZ_PD_S_CONNECTED))) { + oz_trace_msg(M, "Remove device\n"); + oz_pd_stop(pd); + } + oz_pd_put(pd); +} +/*------------------------------------------------------------------------------ * This is called when the USB service is started or resumed for a PD. * Context: softirq */ @@ -50,7 +66,7 @@ int oz_usb_start(struct oz_pd *pd, int resume) { int rc = 0; struct oz_usb_ctx *usb_ctx; - struct oz_usb_ctx *old_ctx = 0; + struct oz_usb_ctx *old_ctx; if (resume) { oz_trace("USB service resumed.\n"); return 0; @@ -60,7 +76,7 @@ int oz_usb_start(struct oz_pd *pd, int resume) * has a USB context then we will destroy it. */ usb_ctx = kzalloc(sizeof(struct oz_usb_ctx), GFP_ATOMIC); - if (usb_ctx == 0) + if (usb_ctx == NULL) return -ENOMEM; atomic_set(&usb_ctx->ref_count, 1); usb_ctx->pd = pd; @@ -71,7 +87,7 @@ int oz_usb_start(struct oz_pd *pd, int resume) */ spin_lock_bh(&pd->app_lock[OZ_APPID_USB-1]); old_ctx = pd->app_ctx[OZ_APPID_USB-1]; - if (old_ctx == 0) + if (old_ctx == NULL) pd->app_ctx[OZ_APPID_USB-1] = usb_ctx; oz_usb_get(pd->app_ctx[OZ_APPID_USB-1]); spin_unlock_bh(&pd->app_lock[OZ_APPID_USB-1]); @@ -92,9 +108,9 @@ int oz_usb_start(struct oz_pd *pd, int resume) oz_hcd_pd_reset(usb_ctx, usb_ctx->hport); } else { usb_ctx->hport = oz_hcd_pd_arrived(usb_ctx); - if (usb_ctx->hport == 0) { + if (usb_ctx->hport == NULL) { spin_lock_bh(&pd->app_lock[OZ_APPID_USB-1]); - pd->app_ctx[OZ_APPID_USB-1] = 0; + pd->app_ctx[OZ_APPID_USB-1] = NULL; spin_unlock_bh(&pd->app_lock[OZ_APPID_USB-1]); oz_usb_put(usb_ctx); rc = -1; @@ -116,7 +132,7 @@ void oz_usb_stop(struct oz_pd *pd, int pause) } spin_lock_bh(&pd->app_lock[OZ_APPID_USB-1]); usb_ctx = (struct oz_usb_ctx *)pd->app_ctx[OZ_APPID_USB-1]; - pd->app_ctx[OZ_APPID_USB-1] = 0; + pd->app_ctx[OZ_APPID_USB-1] = NULL; spin_unlock_bh(&pd->app_lock[OZ_APPID_USB-1]); if (usb_ctx) { struct timespec ts, now; @@ -177,7 +193,7 @@ int oz_usb_heartbeat(struct oz_pd *pd) if (usb_ctx) oz_usb_get(usb_ctx); spin_unlock_bh(&pd->app_lock[OZ_APPID_USB-1]); - if (usb_ctx == 0) + if (usb_ctx == NULL) return rc; if (usb_ctx->stopped) goto done; diff --git a/drivers/staging/ozwpan/ozusbsvc1.c b/drivers/staging/ozwpan/ozusbsvc1.c index a66d2adca434..609d7119051a 100644 --- a/drivers/staging/ozwpan/ozusbsvc1.c +++ b/drivers/staging/ozwpan/ozusbsvc1.c @@ -172,7 +172,7 @@ static int oz_usb_set_clear_feature_req(void *hpd, u8 req_id, u8 type, * Context: tasklet */ static int oz_usb_vendor_class_req(void *hpd, u8 req_id, u8 req_type, - u8 request, __le16 value, __le16 index, u8 *data, int data_len) + u8 request, __le16 value, __le16 index, const u8 *data, int data_len) { struct oz_usb_ctx *usb_ctx = (struct oz_usb_ctx *)hpd; struct oz_pd *pd = usb_ctx->pd; @@ -201,7 +201,7 @@ static int oz_usb_vendor_class_req(void *hpd, u8 req_id, u8 req_type, * Context: tasklet */ int oz_usb_control_req(void *hpd, u8 req_id, struct usb_ctrlrequest *setup, - u8 *data, int data_len) + const u8 *data, int data_len) { unsigned wvalue = le16_to_cpu(setup->wValue); unsigned windex = le16_to_cpu(setup->wIndex); @@ -259,10 +259,14 @@ int oz_usb_send_isoc(void *hpd, u8 ep_num, struct urb *urb) struct usb_iso_packet_descriptor *desc; if (pd->mode & OZ_F_ISOC_NO_ELTS) { + urb->actual_length = 0; for (i = 0; i < urb->number_of_packets; i++) { u8 *data; desc = &urb->iso_frame_desc[i]; data = ((u8 *)urb->transfer_buffer)+desc->offset; + desc->status = 0; + desc->actual_length = desc->length; + urb->actual_length += desc->length; oz_send_isoc_unit(pd, ep_num, data, desc->length); } return 0; @@ -383,7 +387,9 @@ void oz_usb_rx(struct oz_pd *pd, struct oz_elt *elt) if (usb_hdr->elt_seq_num != 0) { if (((usb_ctx->rx_seq_num - usb_hdr->elt_seq_num) & 0x80) == 0) /* Reject duplicate element. */ - goto done; + oz_trace_msg(M, "USB seq overlap %02X %02X\n", + usb_ctx->rx_seq_num, + usb_hdr->elt_seq_num); } usb_ctx->rx_seq_num = usb_hdr->elt_seq_num; switch (usb_hdr->type) { |