diff options
Diffstat (limited to 'drivers/staging/ozwpan')
-rw-r--r-- | drivers/staging/ozwpan/ozcdev.c | 4 | ||||
-rw-r--r-- | drivers/staging/ozwpan/ozhcd.c | 8 | ||||
-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 | 54 | ||||
-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 |
9 files changed, 54 insertions, 60 deletions
diff --git a/drivers/staging/ozwpan/ozcdev.c b/drivers/staging/ozwpan/ozcdev.c index 5de5981b3bba..10c0a96ce8bb 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 efaf26f734c3..b3d401ae41b4 100644 --- a/drivers/staging/ozwpan/ozhcd.c +++ b/drivers/staging/ozwpan/ozhcd.c @@ -354,7 +354,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; @@ -1986,8 +1987,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; } @@ -2181,7 +2181,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); diff --git a/drivers/staging/ozwpan/ozpd.c b/drivers/staging/ozwpan/ozpd.c index 743695077346..10f1b3ac8832 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 12c712956888..ad5fe7a6e619 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 cb060364dfe7..f09acd0bb013 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,31 +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; + 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); - if (net_dev && *net_dev) { - 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"); - 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); + 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); } /* @@ -799,12 +798,3 @@ int oz_get_pd_list(struct oz_mac_addr *addr, int max_count) 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 0c49c8a0e815..cb38e02c968e 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 17b09b9a5b08..9bbb182f2776 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 8531438d7586..4249fa374012 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 617f51cdaea7..f32d01427f77 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; |