diff options
Diffstat (limited to 'drivers/staging/ozwpan')
| -rw-r--r-- | drivers/staging/ozwpan/TODO | 2 | ||||
| -rw-r--r-- | drivers/staging/ozwpan/ozcdev.c | 4 | ||||
| -rw-r--r-- | drivers/staging/ozwpan/ozhcd.c | 29 | ||||
| -rw-r--r-- | drivers/staging/ozwpan/ozpd.c | 31 | ||||
| -rw-r--r-- | drivers/staging/ozwpan/ozpd.h | 5 | ||||
| -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 | 6 | ||||
| -rw-r--r-- | drivers/staging/ozwpan/ozusbif.h | 2 | ||||
| -rw-r--r-- | drivers/staging/ozwpan/ozusbsvc1.c | 2 |
10 files changed, 75 insertions, 69 deletions
diff --git a/drivers/staging/ozwpan/TODO b/drivers/staging/ozwpan/TODO index b4febd79a68..f32c1c0bc87 100644 --- a/drivers/staging/ozwpan/TODO +++ b/drivers/staging/ozwpan/TODO @@ -10,5 +10,5 @@ TODO: - testing with as many devices as possible. Please send any patches for this driver to -Rupesh Gujare <rupesh.gujare@atmel.com> +Shigekatsu Tateno <shigekatsu.tateno@atmel.com> and Greg Kroah-Hartman <gregkh@linuxfoundation.org>. diff --git a/drivers/staging/ozwpan/ozcdev.c b/drivers/staging/ozwpan/ozcdev.c index 5de5981b3bb..10c0a96ce8b 100644 --- a/drivers/staging/ozwpan/ozcdev.c +++ b/drivers/staging/ozwpan/ozcdev.c @@ -217,7 +217,7 @@ static int oz_set_active_pd(const u8 *addr) pd = oz_pd_find(addr); if (pd) { spin_lock_bh(&g_cdev.lock); - memcpy(g_cdev.active_addr, addr, ETH_ALEN); + ether_addr_copy(g_cdev.active_addr, addr); old_pd = g_cdev.active_pd; g_cdev.active_pd = pd; spin_unlock_bh(&g_cdev.lock); @@ -283,7 +283,7 @@ static long oz_cdev_ioctl(struct file *filp, unsigned int cmd, u8 addr[ETH_ALEN]; oz_dbg(ON, "OZ_IOCTL_GET_ACTIVE_PD\n"); spin_lock_bh(&g_cdev.lock); - memcpy(addr, g_cdev.active_addr, ETH_ALEN); + ether_addr_copy(addr, g_cdev.active_addr); spin_unlock_bh(&g_cdev.lock); if (copy_to_user((void __user *)arg, addr, ETH_ALEN)) return -EFAULT; diff --git a/drivers/staging/ozwpan/ozhcd.c b/drivers/staging/ozwpan/ozhcd.c index efaf26f734c..30bd9286d47 100644 --- a/drivers/staging/ozwpan/ozhcd.c +++ b/drivers/staging/ozwpan/ozhcd.c @@ -294,6 +294,7 @@ static void oz_free_urb_link(struct oz_urb_link *urbl) { if (urbl) { unsigned long irq_state; + spin_lock_irqsave(&g_link_lock, irq_state); if (g_link_pool_size < OZ_MAX_LINK_POOL_SIZE) { urbl->link.next = g_link_pool; @@ -354,7 +355,8 @@ static struct oz_endpoint *oz_ep_alloc(int buffer_size, gfp_t mem_flags) * disabled. * Context: softirq or process */ -static struct oz_urb_link *oz_uncancel_urb(struct oz_hcd *ozhcd, struct urb *urb) +static struct oz_urb_link *oz_uncancel_urb(struct oz_hcd *ozhcd, + struct urb *urb) { struct oz_urb_link *urbl; struct list_head *e; @@ -423,6 +425,7 @@ static void oz_ep_free(struct oz_port *port, struct oz_endpoint *ep) if (port) { struct list_head list; struct oz_hcd *ozhcd = port->ozhcd; + INIT_LIST_HEAD(&list); if (ep->flags & OZ_F_EP_HAVE_STREAM) oz_usb_stream_delete(port->hpd, ep->ep_num); @@ -567,6 +570,7 @@ static int oz_dequeue_ep_urb(struct oz_port *port, u8 ep_addr, int in_dir, ep = port->out_ep[ep_addr]; if (ep) { struct list_head *e; + list_for_each(e, &ep->urb_list) { urbl = container_of(e, struct oz_urb_link, link); if (urbl->urb == urb) { @@ -598,6 +602,7 @@ static struct urb *oz_find_urb_by_id(struct oz_port *port, int ep_ix, ep = port->out_ep[ep_ix]; if (ep) { struct list_head *e; + list_for_each(e, &ep->urb_list) { urbl = container_of(e, struct oz_urb_link, link); if (urbl->req_id == req_id) { @@ -814,6 +819,7 @@ void oz_hcd_get_desc_cnf(void *hport, u8 req_id, int status, const u8 *desc, if (status == 0) { int copy_len; int required_size = urb->transfer_buffer_length; + if (required_size > total_size) required_size = total_size; copy_len = required_size-offset; @@ -825,6 +831,7 @@ void oz_hcd_get_desc_cnf(void *hport, u8 req_id, int status, const u8 *desc, struct usb_ctrlrequest *setup = (struct usb_ctrlrequest *)urb->setup_packet; unsigned wvalue = le16_to_cpu(setup->wValue); + if (oz_enqueue_ep_urb(port, 0, 0, urb, req_id)) err = -ENOMEM; else if (oz_usb_get_desc_req(port->hpd, req_id, @@ -918,6 +925,7 @@ static void oz_hcd_complete_set_interface(struct oz_port *port, struct urb *urb, if ((rcode == 0) && (port->config_num > 0)) { struct usb_host_config *config; struct usb_host_interface *intf; + oz_dbg(ON, "Set interface %d alt %d\n", if_num, alt); oz_clean_endpoints_for_interface(hcd, port, if_num); config = &urb->dev->config[port->config_num-1]; @@ -973,6 +981,7 @@ void oz_hcd_control_cnf(void *hport, u8 req_id, u8 rcode, const u8 *data, } else { int copy_len; + oz_dbg(ON, "VENDOR-CLASS - cnf\n"); if (data_len) { if (data_len <= urb->transfer_buffer_length) @@ -1046,6 +1055,7 @@ void oz_hcd_data_ind(void *hport, u8 endpoint, const u8 *data, int data_len) struct oz_urb_link, link); struct urb *urb; int copy_len; + list_del_init(&urbl->link); spin_unlock_bh(&ozhcd->hcd_lock); urb = urbl->urb; @@ -1139,6 +1149,7 @@ int oz_hcd_heartbeat(void *hport) spin_lock_bh(&ozhcd->hcd_lock); list_for_each(e, &port->isoc_in_ep) { struct oz_endpoint *ep = ep_from_link(e); + if (ep->flags & OZ_F_EP_BUFFERING) { if (ep->buffered_units >= OZ_IN_BUFFERING_UNITS) { ep->flags &= ~OZ_F_EP_BUFFERING; @@ -1159,6 +1170,7 @@ int oz_hcd_heartbeat(void *hport) int len = 0; int copy_len; int i; + if (ep->credit < urb->number_of_packets) break; if (ep->buffered_units < urb->number_of_packets) @@ -1214,6 +1226,7 @@ int oz_hcd_heartbeat(void *hport) if (ep) { struct list_head *e; struct list_head *n; + spin_lock_bh(&ozhcd->hcd_lock); list_for_each_safe(e, n, &ep->urb_list) { urbl = container_of(e, struct oz_urb_link, link); @@ -1556,6 +1569,7 @@ static void oz_process_ep0_urb(struct oz_hcd *ozhcd, struct urb *urb, } if (!rc && !complete) { int data_len = 0; + if ((setup->bRequestType & USB_DIR_IN) == 0) data_len = wlength; urb->actual_length = data_len; @@ -1760,6 +1774,7 @@ static void oz_hcd_clear_orphanage(struct oz_hcd *ozhcd, int status) { if (ozhcd) { struct oz_urb_link *urbl; + while (!list_empty(&ozhcd->orphanage)) { urbl = list_first_entry(&ozhcd->orphanage, struct oz_urb_link, link); @@ -1986,8 +2001,7 @@ static void oz_get_hub_descriptor(struct usb_hcd *hcd, memset(desc, 0, sizeof(*desc)); desc->bDescriptorType = 0x29; desc->bDescLength = 9; - desc->wHubCharacteristics = (__force __u16) - __constant_cpu_to_le16(0x0001); + desc->wHubCharacteristics = (__force __u16)cpu_to_le16(0x0001); desc->bNbrPorts = OZ_NB_PORTS; } @@ -1997,7 +2011,6 @@ static void oz_get_hub_descriptor(struct usb_hcd *hcd, static int oz_set_port_feature(struct usb_hcd *hcd, u16 wvalue, u16 windex) { struct oz_port *port; - int err = 0; u8 port_id = (u8)windex; struct oz_hcd *ozhcd = oz_hcd_private(hcd); unsigned set_bits = 0; @@ -2064,7 +2077,7 @@ static int oz_set_port_feature(struct usb_hcd *hcd, u16 wvalue, u16 windex) spin_unlock_bh(&port->port_lock); } oz_dbg(HUB, "Port[%d] status = 0x%x\n", port_id, port->status); - return err; + return 0; } /* @@ -2073,7 +2086,6 @@ static int oz_set_port_feature(struct usb_hcd *hcd, u16 wvalue, u16 windex) static int oz_clear_port_feature(struct usb_hcd *hcd, u16 wvalue, u16 windex) { struct oz_port *port; - int err = 0; u8 port_id = (u8)windex; struct oz_hcd *ozhcd = oz_hcd_private(hcd); unsigned clear_bits = 0; @@ -2140,7 +2152,7 @@ static int oz_clear_port_feature(struct usb_hcd *hcd, u16 wvalue, u16 windex) } oz_dbg(HUB, "Port[%d] status = 0x%x\n", port_id, ozhcd->ports[port_id-1].status); - return err; + return 0; } /* @@ -2181,7 +2193,7 @@ static int oz_hcd_hub_control(struct usb_hcd *hcd, u16 req_type, u16 wvalue, break; case GetHubStatus: oz_dbg(HUB, "GetHubStatus: req_type = 0x%x\n", req_type); - put_unaligned(__constant_cpu_to_le32(0), (__le32 *)buf); + put_unaligned(cpu_to_le32(0), (__le32 *)buf); break; case GetPortStatus: err = oz_get_port_status(hcd, windex, buf); @@ -2258,6 +2270,7 @@ static int oz_plat_probe(struct platform_device *dev) spin_lock_init(&ozhcd->hcd_lock); for (i = 0; i < OZ_NB_PORTS; i++) { struct oz_port *port = &ozhcd->ports[i]; + port->ozhcd = ozhcd; port->flags = 0; port->status = 0; diff --git a/drivers/staging/ozwpan/ozpd.c b/drivers/staging/ozwpan/ozpd.c index 74369507734..10f1b3ac883 100644 --- a/drivers/staging/ozwpan/ozpd.c +++ b/drivers/staging/ozwpan/ozpd.c @@ -8,6 +8,7 @@ #include <linux/timer.h> #include <linux/sched.h> #include <linux/netdevice.h> +#include <linux/etherdevice.h> #include <linux/errno.h> #include "ozdbg.h" #include "ozprotocol.h" @@ -173,7 +174,7 @@ struct oz_pd *oz_pd_alloc(const u8 *mac_addr) pd->last_rx_pkt_num = 0xffffffff; oz_pd_set_state(pd, OZ_PD_S_IDLE); pd->max_tx_size = OZ_MAX_TX_SIZE; - memcpy(pd->mac_addr, mac_addr, ETH_ALEN); + ether_addr_copy(pd->mac_addr, mac_addr); if (0 != oz_elt_buf_init(&pd->elt_buff)) { kfree(pd); pd = NULL; @@ -284,11 +285,11 @@ int oz_services_start(struct oz_pd *pd, u16 apps, int resume) ai->app_id); break; } - oz_polling_lock_bh(); + spin_lock_bh(&g_polling_lock); pd->total_apps |= (1<<ai->app_id); if (resume) pd->paused_apps &= ~(1<<ai->app_id); - oz_polling_unlock_bh(); + spin_unlock_bh(&g_polling_lock); } } return rc; @@ -304,14 +305,14 @@ void oz_services_stop(struct oz_pd *pd, u16 apps, int pause) oz_pd_dbg(pd, ON, "%s: (0x%x) pause(%d)\n", __func__, apps, pause); for (ai = g_app_if; ai < &g_app_if[OZ_APPID_MAX]; ai++) { if (apps & (1<<ai->app_id)) { - oz_polling_lock_bh(); + spin_lock_bh(&g_polling_lock); if (pause) { pd->paused_apps |= (1<<ai->app_id); } else { pd->total_apps &= ~(1<<ai->app_id); pd->paused_apps &= ~(1<<ai->app_id); } - oz_polling_unlock_bh(); + spin_unlock_bh(&g_polling_lock); ai->stop(pd, pause); } } @@ -349,17 +350,17 @@ void oz_pd_stop(struct oz_pd *pd) oz_dbg(ON, "oz_pd_stop() State = 0x%x\n", pd->state); oz_pd_indicate_farewells(pd); - oz_polling_lock_bh(); + spin_lock_bh(&g_polling_lock); stop_apps = pd->total_apps; pd->total_apps = 0; pd->paused_apps = 0; - oz_polling_unlock_bh(); + spin_unlock_bh(&g_polling_lock); oz_services_stop(pd, stop_apps, 0); - oz_polling_lock_bh(); + spin_lock_bh(&g_polling_lock); oz_pd_set_state(pd, OZ_PD_S_STOPPED); /* Remove from PD list.*/ list_del(&pd->link); - oz_polling_unlock_bh(); + spin_unlock_bh(&g_polling_lock); oz_dbg(ON, "pd ref count = %d\n", atomic_read(&pd->ref_count)); oz_pd_put(pd); } @@ -372,9 +373,9 @@ int oz_pd_sleep(struct oz_pd *pd) int do_stop = 0; u16 stop_apps; - oz_polling_lock_bh(); + spin_lock_bh(&g_polling_lock); if (pd->state & (OZ_PD_S_SLEEP | OZ_PD_S_STOPPED)) { - oz_polling_unlock_bh(); + spin_unlock_bh(&g_polling_lock); return 0; } if (pd->keep_alive && pd->session_id) @@ -383,7 +384,7 @@ int oz_pd_sleep(struct oz_pd *pd) do_stop = 1; stop_apps = pd->total_apps; - oz_polling_unlock_bh(); + spin_unlock_bh(&g_polling_lock); if (do_stop) { oz_pd_stop(pd); } else { @@ -999,15 +1000,15 @@ void oz_pd_indicate_farewells(struct oz_pd *pd) const struct oz_app_if *ai = &g_app_if[OZ_APPID_USB-1]; while (1) { - oz_polling_lock_bh(); + spin_lock_bh(&g_polling_lock); if (list_empty(&pd->farewell_list)) { - oz_polling_unlock_bh(); + spin_unlock_bh(&g_polling_lock); break; } f = list_first_entry(&pd->farewell_list, struct oz_farewell, link); list_del(&f->link); - oz_polling_unlock_bh(); + spin_unlock_bh(&g_polling_lock); if (ai->farewell) ai->farewell(pd, f->ep_num, f->report, f->len); kfree(f); diff --git a/drivers/staging/ozwpan/ozpd.h b/drivers/staging/ozwpan/ozpd.h index 12c71295688..ad5fe7a6e61 100644 --- a/drivers/staging/ozwpan/ozpd.h +++ b/drivers/staging/ozwpan/ozpd.h @@ -22,6 +22,11 @@ #define OZ_TIMER_HEARTBEAT 2 #define OZ_TIMER_STOP 3 +/* + *External spinlock variable + */ +extern spinlock_t g_polling_lock; + /* Data structure that hold information on a frame for transmisson. This is * built when the frame is first transmitted and is used to rebuild the frame * if a re-transmission is required. diff --git a/drivers/staging/ozwpan/ozproto.c b/drivers/staging/ozwpan/ozproto.c index 5d965cf06d5..11020559919 100644 --- a/drivers/staging/ozwpan/ozproto.c +++ b/drivers/staging/ozwpan/ozproto.c @@ -38,9 +38,13 @@ struct oz_binding { }; /* + * External variable + */ + +DEFINE_SPINLOCK(g_polling_lock); +/* * Static external variables. */ -static DEFINE_SPINLOCK(g_polling_lock); static LIST_HEAD(g_pd_list); static LIST_HEAD(g_binding); static DEFINE_SPINLOCK(g_binding_lock); @@ -664,32 +668,26 @@ void oz_binding_add(const char *net_dev) { struct oz_binding *binding; - binding = kmalloc(sizeof(struct oz_binding), GFP_KERNEL); - if (binding) { - binding->ptype.type = __constant_htons(OZ_ETHERTYPE); - binding->ptype.func = oz_pkt_recv; - if (net_dev && *net_dev) { - memcpy(binding->name, net_dev, OZ_MAX_BINDING_LEN); - oz_dbg(ON, "Adding binding: %s\n", net_dev); - binding->ptype.dev = - dev_get_by_name(&init_net, net_dev); - if (binding->ptype.dev == NULL) { - oz_dbg(ON, "Netdev %s not found\n", net_dev); - kfree(binding); - binding = NULL; - } - } else { - oz_dbg(ON, "Binding to all netcards\n"); - memset(binding->name, 0, OZ_MAX_BINDING_LEN); - binding->ptype.dev = NULL; - } - if (binding) { - dev_add_pack(&binding->ptype); - spin_lock_bh(&g_binding_lock); - list_add_tail(&binding->link, &g_binding); - spin_unlock_bh(&g_binding_lock); + binding = kzalloc(sizeof(struct oz_binding), GFP_KERNEL); + if (!binding) + return; + + binding->ptype.type = htons(OZ_ETHERTYPE); + binding->ptype.func = oz_pkt_recv; + if (net_dev && *net_dev) { + memcpy(binding->name, net_dev, OZ_MAX_BINDING_LEN); + oz_dbg(ON, "Adding binding: %s\n", net_dev); + binding->ptype.dev = dev_get_by_name(&init_net, net_dev); + if (binding->ptype.dev == NULL) { + oz_dbg(ON, "Netdev %s not found\n", net_dev); + kfree(binding); + return; } } + dev_add_pack(&binding->ptype); + spin_lock_bh(&g_binding_lock); + list_add_tail(&binding->link, &g_binding); + spin_unlock_bh(&g_binding_lock); } /* @@ -767,7 +765,7 @@ static char *oz_get_next_device_name(char *s, char *dname, int max_size) int oz_protocol_init(char *devs) { skb_queue_head_init(&g_rx_queue); - if (devs && (devs[0] == '*')) { + if (devs[0] == '*') { oz_binding_add(NULL); } else { char d[32]; @@ -794,18 +792,9 @@ int oz_get_pd_list(struct oz_mac_addr *addr, int max_count) if (count >= max_count) break; pd = container_of(e, struct oz_pd, link); - memcpy(&addr[count++], pd->mac_addr, ETH_ALEN); + ether_addr_copy((u8 *)&addr[count++], pd->mac_addr); } spin_unlock_bh(&g_polling_lock); return count; } -void oz_polling_lock_bh(void) -{ - spin_lock_bh(&g_polling_lock); -} - -void oz_polling_unlock_bh(void) -{ - spin_unlock_bh(&g_polling_lock); -} diff --git a/drivers/staging/ozwpan/ozproto.h b/drivers/staging/ozwpan/ozproto.h index 0c49c8a0e81..cb38e02c968 100644 --- a/drivers/staging/ozwpan/ozproto.h +++ b/drivers/staging/ozwpan/ozproto.h @@ -59,8 +59,6 @@ void oz_binding_remove(const char *net_dev); void oz_timer_add(struct oz_pd *pd, int type, unsigned long due_time); void oz_timer_delete(struct oz_pd *pd, int type); void oz_pd_request_heartbeat(struct oz_pd *pd); -void oz_polling_lock_bh(void); -void oz_polling_unlock_bh(void); void oz_pd_heartbeat_handler(unsigned long data); void oz_pd_timeout_handler(unsigned long data); enum hrtimer_restart oz_pd_heartbeat_event(struct hrtimer *timer); diff --git a/drivers/staging/ozwpan/ozprotocol.h b/drivers/staging/ozwpan/ozprotocol.h index 17b09b9a5b0..9bbb182f277 100644 --- a/drivers/staging/ozwpan/ozprotocol.h +++ b/drivers/staging/ozwpan/ozprotocol.h @@ -192,7 +192,7 @@ struct oz_get_desc_req { u16 size; u8 req_type; u8 desc_type; - u16 w_index; + __le16 w_index; u8 index; } PACKED; @@ -219,8 +219,8 @@ struct oz_get_desc_rsp { u8 elt_seq_num; u8 type; u8 req_id; - u16 offset; - u16 total_size; + __le16 offset; + __le16 total_size; u8 rcode; u8 data[1]; } PACKED; diff --git a/drivers/staging/ozwpan/ozusbif.h b/drivers/staging/ozwpan/ozusbif.h index 8531438d758..4249fa37401 100644 --- a/drivers/staging/ozwpan/ozusbif.h +++ b/drivers/staging/ozwpan/ozusbif.h @@ -23,7 +23,7 @@ int oz_usb_stream_delete(void *hpd, u8 ep_num); int oz_usb_control_req(void *hpd, u8 req_id, struct usb_ctrlrequest *setup, 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); + u8 index, __le16 windex, int offset, int len); int oz_usb_send_isoc(void *hpd, u8 ep_num, struct urb *urb); void oz_usb_request_heartbeat(void *hpd); diff --git a/drivers/staging/ozwpan/ozusbsvc1.c b/drivers/staging/ozwpan/ozusbsvc1.c index 617f51cdaea..f32d01427f7 100644 --- a/drivers/staging/ozwpan/ozusbsvc1.c +++ b/drivers/staging/ozwpan/ozusbsvc1.c @@ -54,7 +54,7 @@ static int oz_usb_submit_elt(struct oz_elt_buf *eb, struct oz_elt_info *ei, * Context: softirq */ 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) + u8 index, __le16 windex, int offset, int len) { struct oz_usb_ctx *usb_ctx = (struct oz_usb_ctx *)hpd; struct oz_pd *pd = usb_ctx->pd; |
