[PATCH 1/1] staging: usbip: remove an unnecessary lock in usbip_event_happened. The variable "happened" is local. So I think there is no need to lock here.

2012-11-04 Thread Harvey Yang
From: harvey.yang 


Signed-off-by: harvey.yang 
---
 drivers/staging/usbip/usbip_event.c |2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/usbip/usbip_event.c 
b/drivers/staging/usbip/usbip_event.c
index d332a34..668f8e0 100644
--- a/drivers/staging/usbip/usbip_event.c
+++ b/drivers/staging/usbip/usbip_event.c
@@ -116,10 +116,8 @@ int usbip_event_happened(struct usbip_device *ud)
 {
int happened = 0;
 
-   spin_lock(&ud->lock);
if (ud->event != 0)
happened = 1;
-   spin_unlock(&ud->lock);
 
return happened;
 }
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/1] staging: usbip: remove an unnecessary lock in usbip_event_happened. The variable "happened" is local. So I think there is no need to lock here.

2012-11-04 Thread harvey yang
I think no need to make 'happened' static as we just check 'ud->event'
feild. Maybe making this function inline would make more sense.

inline int usbip_event_happened(struct usbip_device *ud)
{
return ud->event ? 1 : 0;
}

Thanks
Harvey


On Mon, Nov 5, 2012 at 1:34 PM, Prashant Shah  wrote:
> Hi,
>
>> int happened = 0;
>>
>> -   spin_lock(&ud->lock);
>> if (ud->event != 0)
>> happened = 1;
>> -   spin_unlock(&ud->lock);
>>
>> return happened;
>
> I am guessing locking was intended to protect ud->event along with
> happened so that (checking the value of ud->event and setting value of
> happened) was atomic.
>
> return ud->event != 0 ? 1 : 0;
>
> Regards.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1] usb: usbip: userspace: remove the port state file when detaching port.

2012-11-15 Thread Harvey Yang
with the last detached port state file remaining , usbip reports error on 
attaching. So clean up the state files on detaching.

Signed-off-by: Harvey Yang 
---
 drivers/staging/usbip/userspace/src/usbip_detach.c |9 +
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/drivers/staging/usbip/userspace/src/usbip_detach.c 
b/drivers/staging/usbip/userspace/src/usbip_detach.c
index 89bf3c1..312745d 100644
--- a/drivers/staging/usbip/userspace/src/usbip_detach.c
+++ b/drivers/staging/usbip/userspace/src/usbip_detach.c
@@ -19,6 +19,7 @@
 #include 
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -46,6 +47,7 @@ static int detach_port(char *port)
 {
int ret;
uint8_t portnum;
+   char path[PATH_MAX+1];
 
for (unsigned int i=0; i < strlen(port); i++)
if (!isdigit(port[i])) {
@@ -56,6 +58,13 @@ static int detach_port(char *port)
/* check max port */
 
portnum = atoi(port);
+
+   /* remove the port state file */
+
+   snprintf(path, PATH_MAX, VHCI_STATE_PATH"/port%d", portnum);
+
+   remove(path);
+   rmdir(VHCI_STATE_PATH);
 
ret = usbip_vhci_driver_open();
if (ret < 0) {
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1] staging: usbip: put usb_device and kill event handler thread in error cleanups.

2012-11-06 Thread Harvey Yang
From: harvey.yang 

If probe returns with error, the kthread is still alive even when all usbip 
modules unloaded. So do cleanups in error handler.

Signed-off-by: harvey.yang 
---
 drivers/staging/usbip/stub_dev.c |2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/drivers/staging/usbip/stub_dev.c b/drivers/staging/usbip/stub_dev.c
index c8d79a7..16a6868 100644
--- a/drivers/staging/usbip/stub_dev.c
+++ b/drivers/staging/usbip/stub_dev.c
@@ -432,6 +432,8 @@ static int stub_probe(struct usb_interface *interface,
dev_err(&interface->dev, "stub_add_files for %s\n", udev_busid);
usb_set_intfdata(interface, NULL);
usb_put_intf(interface);
+   usb_put_dev(udev);
+   kthread_stop_put(sdev->ud.eh);
 
busid_priv->interf_count = 0;
busid_priv->sdev = NULL;
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1] staging: usbip: make the code consistent using the variable name 'vhci' instead of 'dum'.

2012-11-10 Thread Harvey Yang

Signed-off-by: Harvey Yang 
---
 drivers/staging/usbip/vhci_hcd.c |   80 +++---
 1 files changed, 40 insertions(+), 40 deletions(-)

diff --git a/drivers/staging/usbip/vhci_hcd.c b/drivers/staging/usbip/vhci_hcd.c
index 620d1be..6771668 100644
--- a/drivers/staging/usbip/vhci_hcd.c
+++ b/drivers/staging/usbip/vhci_hcd.c
@@ -244,7 +244,7 @@ static inline void hub_descriptor(struct usb_hub_descriptor 
*desc)
 static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
u16 wIndex, char *buf, u16 wLength)
 {
-   struct vhci_hcd *dum;
+   struct vhci_hcd *vhci;
int retval = 0;
unsigned long   flags;
int rhport;
@@ -264,13 +264,13 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 
typeReq, u16 wValue,
pr_err("invalid port number %d\n", wIndex);
rhport = ((__u8)(wIndex & 0x00ff)) - 1;
 
-   dum = hcd_to_vhci(hcd);
+   vhci = hcd_to_vhci(hcd);
 
-   spin_lock_irqsave(&dum->lock, flags);
+   spin_lock_irqsave(&vhci->lock, flags);
 
/* store old status and compare now and old later */
if (usbip_dbg_flag_vhci_rh) {
-   memcpy(prev_port_status, dum->port_status,
+   memcpy(prev_port_status, vhci->port_status,
sizeof(prev_port_status));
}
 
@@ -281,31 +281,31 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 
typeReq, u16 wValue,
case ClearPortFeature:
switch (wValue) {
case USB_PORT_FEAT_SUSPEND:
-   if (dum->port_status[rhport] & USB_PORT_STAT_SUSPEND) {
+   if (vhci->port_status[rhport] & USB_PORT_STAT_SUSPEND) {
/* 20msec signaling */
-   dum->resuming = 1;
-   dum->re_timeout =
+   vhci->resuming = 1;
+   vhci->re_timeout =
jiffies + msecs_to_jiffies(20);
}
break;
case USB_PORT_FEAT_POWER:
usbip_dbg_vhci_rh(" ClearPortFeature: "
  "USB_PORT_FEAT_POWER\n");
-   dum->port_status[rhport] = 0;
-   /* dum->address = 0; */
-   /* dum->hdev = 0; */
-   dum->resuming = 0;
+   vhci->port_status[rhport] = 0;
+   /* vhci->address = 0; */
+   /* vhci->hdev = 0; */
+   vhci->resuming = 0;
break;
case USB_PORT_FEAT_C_RESET:
usbip_dbg_vhci_rh(" ClearPortFeature: "
  "USB_PORT_FEAT_C_RESET\n");
-   switch (dum->vdev[rhport].speed) {
+   switch (vhci->vdev[rhport].speed) {
case USB_SPEED_HIGH:
-   dum->port_status[rhport] |=
+   vhci->port_status[rhport] |=
USB_PORT_STAT_HIGH_SPEED;
break;
case USB_SPEED_LOW:
-   dum->port_status[rhport] |=
+   vhci->port_status[rhport] |=
USB_PORT_STAT_LOW_SPEED;
break;
default:
@@ -314,7 +314,7 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 
typeReq, u16 wValue,
default:
usbip_dbg_vhci_rh(" ClearPortFeature: default %x\n",
  wValue);
-   dum->port_status[rhport] &= ~(1 << wValue);
+   vhci->port_status[rhport] &= ~(1 << wValue);
break;
}
break;
@@ -338,40 +338,40 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 
typeReq, u16 wValue,
/* whoever resets or resumes must GetPortStatus to
 * complete it!!
 *   */
-   if (dum->resuming && time_after(jiffies, dum->re_timeout)) {
-   dum->port_status[rhport] |=
+   if (vhci->resuming && time_after(jiffies, vhci->re_timeout)) {
+   vhci->port_status[rhport] |=
(1 << USB_PORT_FEAT_C_SUSPEND);
-   dum->port_status[rhport] &=
+   vhci->port_status

[RFC] usb: add 'usb_get_intf()' call into the probe methods of drivers for usb interfaces.

2012-11-18 Thread harvey yang
Hi, all
I checked many usb drivers in the mainline kernel which do not record
this reference in their probe methods. But according to the documents
about this function, we shoud record this reference in our probe
methods, just as the call to 'usb_get_dev()' to reference a usb
device. Are these usb drivers right or we need to fix them?
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH V2 1/1] mwifiex: add tx info to skb when forming mgmt frame

2013-07-01 Thread Harvey Yang
From: Huawei Yang 

In function 'mwifiex_write_data_complete' it need tx info to find
the mwifiex_private to updates statistics and wake up tx queues.
Or we may trigger tx queues timeout when transmitting lots of mgmt
frames.

Signed-off-by: Huawei Yang 
---
 drivers/net/wireless/mwifiex/cfg80211.c |5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/net/wireless/mwifiex/cfg80211.c 
b/drivers/net/wireless/mwifiex/cfg80211.c
index e42b266..b4e2538 100644
--- a/drivers/net/wireless/mwifiex/cfg80211.c
+++ b/drivers/net/wireless/mwifiex/cfg80211.c
@@ -186,6 +186,7 @@ mwifiex_cfg80211_mgmt_tx(struct wiphy *wiphy, struct 
wireless_dev *wdev,
struct sk_buff *skb;
u16 pkt_len;
const struct ieee80211_mgmt *mgmt;
+   struct mwifiex_txinfo *tx_info;
struct mwifiex_private *priv = mwifiex_netdev_get_priv(wdev->netdev);
 
if (!buf || !len) {
@@ -212,6 +213,10 @@ mwifiex_cfg80211_mgmt_tx(struct wiphy *wiphy, struct 
wireless_dev *wdev,
wiphy_err(wiphy, "allocate skb failed for management frame\n");
return -ENOMEM;
}
+   
+   tx_info = MWIFIEX_SKB_TXCB(skb);
+   tx_info->bss_num = priv->bss_num;
+   tx_info->bss_type = priv->bss_type;
 
mwifiex_form_mgmt_frame(skb, buf, len);
mwifiex_queue_tx_pkt(priv, skb);
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1] mwifiex: add tx info to skb when forming mgmt frame

2013-07-01 Thread Harvey Yang
From: Huawei Yang 

In function 'mwifiex_write_data_complete' it need tx info to find the 
mwifiex_private to updates statistics and wake up tx queues. Or we may trigger 
tx queues timeout when transmitting lots of mgmt frames burstly.

Signed-off-by: Huawei Yang 
---
 drivers/net/wireless/mwifiex/cfg80211.c |4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/wireless/mwifiex/cfg80211.c 
b/drivers/net/wireless/mwifiex/cfg80211.c
index e42b266..e8655f9 100644
--- a/drivers/net/wireless/mwifiex/cfg80211.c
+++ b/drivers/net/wireless/mwifiex/cfg80211.c
@@ -166,6 +166,10 @@ mwifiex_form_mgmt_frame(struct sk_buff *skb, const u8 
*buf, size_t len)
memcpy(skb_put(skb, len - sizeof(struct ieee80211_hdr_3addr)),
   buf + sizeof(struct ieee80211_hdr_3addr),
   len - sizeof(struct ieee80211_hdr_3addr));
+   
+   tx_info = MWIFIEX_SKB_TXCB(skb);
+   tx_info->bss_num = priv->bss_num;
+   tx_info->bss_type = priv->bss_type;
 
skb->priority = LOW_PRIO_TID;
do_gettimeofday(&tv);
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [RFC] usb: add 'usb_get_intf()' call into the probe methods of drivers for usb interfaces.

2012-11-20 Thread harvey yang
Thanks for your comments :)

Harvey


On Wed, Nov 21, 2012 at 12:09 AM, Alan Stern  wrote:
> On Mon, 19 Nov 2012, harvey yang wrote:
>
>> Hi, all
>> I checked many usb drivers in the mainline kernel which do not record
>> this reference in their probe methods. But according to the documents
>> about this function, we shoud record this reference in our probe
>> methods, just as the call to 'usb_get_dev()' to reference a usb
>> device. Are these usb drivers right or we need to fix them?
>
> The drivers are right; they do not need to be fixed.  The reason is
> because the drivers will be unbound automatically when the device or
> interface is unregistered.
>
> The only reason for a driver to take a reference would be if it wanted
> to continue using the device after it was unbound.  But drivers aren't
> supposed to do that.
>
> Alan Stern
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH 0/2] staging: usbip: refine the spinlock

2012-11-23 Thread Harvey Yang
This patchset refine some spinlocks which I think not used properly. Maybe my 
'refine' make the code  broken, so any comments will be appreciated. 

patch1: The function 'usbip_event_add()' may be called in interrupt context on 
the stub side: 
'stub_complete'->'stub_enqueue_ret_unlink'->'usbip_event_add'.
In this function it tries to get the lock 'ud->lock', so we shoud disable irq 
when we get this lock in process context.

patch2: On the client side, we have a virtual hcd driver so there actually no 
hardware interrupts. Maybe to achieve a good performance there is no need to 
use the interrupt safe spinlock. Just replace them with a non interrupt safe 
version.


Harvey Yang (2):
  staging: usbip: use interrupt safe spinlock to avoid potential
deadlock.
  staging: usbip: replace the interrupt safe spinlock because no
hardware interrupt exists.

 drivers/staging/usbip/stub_dev.c|   34 
 drivers/staging/usbip/stub_rx.c |4 +-
 drivers/staging/usbip/usbip_event.c |6 ++-
 drivers/staging/usbip/vhci_hcd.c|   75 +++
 drivers/staging/usbip/vhci_rx.c |   10 ++---
 drivers/staging/usbip/vhci_tx.c |   14 +++
 6 files changed, 65 insertions(+), 78 deletions(-)

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1] net: ipv4: refine the logic for determining daddr in ip_queue_xmit.

2013-01-14 Thread Harvey Yang
The destination address daddr is faddr if source route option is set, otherwise 
it is inet_daddr. So use if-else to assign the value.

Signed-off-by: Harvey Yang 
---
 net/ipv4/ip_output.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
index 3e98ed2..22b738c 100644
--- a/net/ipv4/ip_output.c
+++ b/net/ipv4/ip_output.c
@@ -349,10 +349,10 @@ int ip_queue_xmit(struct sk_buff *skb, struct flowi *fl)
__be32 daddr;
 
/* Use correct destination address if we have options. */
-   daddr = inet->inet_daddr;
if (inet_opt && inet_opt->opt.srr)
daddr = inet_opt->opt.faddr;
-
+   else
+   daddr = inet->inet_daddr;
/* If this fails, retransmit mechanism of transport layer will
 * keep trying until route appears or the connection times
 * itself out.
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 0/2] staging: usbip: refine the lock

2013-01-07 Thread Harvey Yang
This patchset refines some spinlocks which maybe not used properly.  

[PATCH 1/2]: The function 'usbip_event_add()' may be called in interrupt 
context on the stub side: 
'stub_complete'->'stub_enqueue_ret_unlink'->'usbip_event_add'.
In this function it tries to get the lock 'ud->lock', so we should disable irq 
when we get this lock in process context.

[PATCH 2/2]: On the client side, we have a virtual hcd driver, there actually 
no hardware interrupts, so we do not need worry about race conditions caused by 
irq. To achieve a good performance there is no need to use the interrupt safe 
spinlock. Just replace them with a non interrupt safe version.


Harvey Yang (2):
  staging: usbip: use interrupt safe spinlock to avoid potential
deadlock.
  staging: usbip: replace the interrupt safe spinlocks with common
ones.

 drivers/staging/usbip/stub_dev.c|   34 
 drivers/staging/usbip/stub_rx.c |4 +-
 drivers/staging/usbip/usbip_event.c |6 ++-
 drivers/staging/usbip/vhci_hcd.c|   76 +++
 drivers/staging/usbip/vhci_rx.c |   10 ++---
 drivers/staging/usbip/vhci_tx.c |   14 +++
 6 files changed, 65 insertions(+), 79 deletions(-)

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/2] staging: usbip: use interrupt safe spinlock to avoid potential deadlock.

2013-01-07 Thread Harvey Yang

Signed-off-by: Harvey Yang 
---
 drivers/staging/usbip/stub_dev.c|   34 +-
 drivers/staging/usbip/stub_rx.c |4 ++--
 drivers/staging/usbip/usbip_event.c |6 --
 3 files changed, 23 insertions(+), 21 deletions(-)

diff --git a/drivers/staging/usbip/stub_dev.c b/drivers/staging/usbip/stub_dev.c
index ee36415..d36c69e 100644
--- a/drivers/staging/usbip/stub_dev.c
+++ b/drivers/staging/usbip/stub_dev.c
@@ -67,9 +67,9 @@ static ssize_t show_status(struct device *dev, struct 
device_attribute *attr,
return -ENODEV;
}
 
-   spin_lock(&sdev->ud.lock);
+   spin_lock_irq(&sdev->ud.lock);
status = sdev->ud.status;
-   spin_unlock(&sdev->ud.lock);
+   spin_unlock_irq(&sdev->ud.lock);
 
return snprintf(buf, PAGE_SIZE, "%d\n", status);
 }
@@ -97,39 +97,39 @@ static ssize_t store_sockfd(struct device *dev, struct 
device_attribute *attr,
if (sockfd != -1) {
dev_info(dev, "stub up\n");
 
-   spin_lock(&sdev->ud.lock);
+   spin_lock_irq(&sdev->ud.lock);
 
if (sdev->ud.status != SDEV_ST_AVAILABLE) {
dev_err(dev, "not ready\n");
-   spin_unlock(&sdev->ud.lock);
+   spin_unlock_irq(&sdev->ud.lock);
return -EINVAL;
}
 
socket = sockfd_to_socket(sockfd);
if (!socket) {
-   spin_unlock(&sdev->ud.lock);
+   spin_unlock_irq(&sdev->ud.lock);
return -EINVAL;
}
sdev->ud.tcp_socket = socket;
 
-   spin_unlock(&sdev->ud.lock);
+   spin_unlock_irq(&sdev->ud.lock);
 
sdev->ud.tcp_rx = kthread_get_run(stub_rx_loop, &sdev->ud, 
"stub_rx");
sdev->ud.tcp_tx = kthread_get_run(stub_tx_loop, &sdev->ud, 
"stub_tx");
 
-   spin_lock(&sdev->ud.lock);
+   spin_lock_irq(&sdev->ud.lock);
sdev->ud.status = SDEV_ST_USED;
-   spin_unlock(&sdev->ud.lock);
+   spin_unlock_irq(&sdev->ud.lock);
 
} else {
dev_info(dev, "stub down\n");
 
-   spin_lock(&sdev->ud.lock);
+   spin_lock_irq(&sdev->ud.lock);
if (sdev->ud.status != SDEV_ST_USED) {
-   spin_unlock(&sdev->ud.lock);
+   spin_unlock_irq(&sdev->ud.lock);
return -EINVAL;
}
-   spin_unlock(&sdev->ud.lock);
+   spin_unlock_irq(&sdev->ud.lock);
 
usbip_event_add(&sdev->ud, SDEV_EVENT_DOWN);
}
@@ -241,9 +241,9 @@ static void stub_device_reset(struct usbip_device *ud)
ret = usb_lock_device_for_reset(udev, sdev->interface);
if (ret < 0) {
dev_err(&udev->dev, "lock for reset\n");
-   spin_lock(&ud->lock);
+   spin_lock_irq(&ud->lock);
ud->status = SDEV_ST_ERROR;
-   spin_unlock(&ud->lock);
+   spin_unlock_irq(&ud->lock);
return;
}
 
@@ -251,7 +251,7 @@ static void stub_device_reset(struct usbip_device *ud)
ret = usb_reset_device(udev);
usb_unlock_device(udev);
 
-   spin_lock(&ud->lock);
+   spin_lock_irq(&ud->lock);
if (ret) {
dev_err(&udev->dev, "device reset\n");
ud->status = SDEV_ST_ERROR;
@@ -259,14 +259,14 @@ static void stub_device_reset(struct usbip_device *ud)
dev_info(&udev->dev, "device reset\n");
ud->status = SDEV_ST_AVAILABLE;
}
-   spin_unlock(&ud->lock);
+   spin_unlock_irq(&ud->lock);
 }
 
 static void stub_device_unusable(struct usbip_device *ud)
 {
-   spin_lock(&ud->lock);
+   spin_lock_irq(&ud->lock);
ud->status = SDEV_ST_ERROR;
-   spin_unlock(&ud->lock);
+   spin_unlock_irq(&ud->lock);
 }
 
 /**
diff --git a/drivers/staging/usbip/stub_rx.c b/drivers/staging/usbip/stub_rx.c
index 0572a15..e7458e1 100644
--- a/drivers/staging/usbip/stub_rx.c
+++ b/drivers/staging/usbip/stub_rx.c
@@ -307,12 +307,12 @@ static int valid_request(struct stub_device *sdev, struct 
usbip_header *pdu)
int valid = 0;
 
if (pdu->base.devid == sdev->devid) {
-   spin_lock(&ud->lock);
+   spin_lock_irq(&ud->lock);
if (ud->status == SDEV_ST_USED) {
/* A r

[PATCH 2/2] staging: usbip: replace the interrupt safe spinlocks with common ones.

2013-01-07 Thread Harvey Yang

Signed-off-by: Harvey Yang 
---
 drivers/staging/usbip/vhci_hcd.c |   76 --
 drivers/staging/usbip/vhci_rx.c  |   10 ++---
 drivers/staging/usbip/vhci_tx.c  |   14 +++
 3 files changed, 42 insertions(+), 58 deletions(-)

diff --git a/drivers/staging/usbip/vhci_hcd.c b/drivers/staging/usbip/vhci_hcd.c
index c3aa219..216648d 100644
--- a/drivers/staging/usbip/vhci_hcd.c
+++ b/drivers/staging/usbip/vhci_hcd.c
@@ -121,11 +121,9 @@ static void dump_port_status_diff(u32 prev_status, u32 
new_status)
 
 void rh_port_connect(int rhport, enum usb_device_speed speed)
 {
-   unsigned long   flags;
-
usbip_dbg_vhci_rh("rh_port_connect %d\n", rhport);
 
-   spin_lock_irqsave(&the_controller->lock, flags);
+   spin_lock(&the_controller->lock);
 
the_controller->port_status[rhport] |= USB_PORT_STAT_CONNECTION
| (1 << USB_PORT_FEAT_C_CONNECTION);
@@ -141,24 +139,22 @@ void rh_port_connect(int rhport, enum usb_device_speed 
speed)
break;
}
 
-   spin_unlock_irqrestore(&the_controller->lock, flags);
+   spin_unlock(&the_controller->lock);
 
usb_hcd_poll_rh_status(vhci_to_hcd(the_controller));
 }
 
 static void rh_port_disconnect(int rhport)
 {
-   unsigned long flags;
-
usbip_dbg_vhci_rh("rh_port_disconnect %d\n", rhport);
 
-   spin_lock_irqsave(&the_controller->lock, flags);
+   spin_lock(&the_controller->lock);
 
the_controller->port_status[rhport] &= ~USB_PORT_STAT_CONNECTION;
the_controller->port_status[rhport] |=
(1 << USB_PORT_FEAT_C_CONNECTION);
 
-   spin_unlock_irqrestore(&the_controller->lock, flags);
+   spin_unlock(&the_controller->lock);
usb_hcd_poll_rh_status(vhci_to_hcd(the_controller));
 }
 
@@ -183,7 +179,6 @@ static void rh_port_disconnect(int rhport)
 static int vhci_hub_status(struct usb_hcd *hcd, char *buf)
 {
struct vhci_hcd *vhci;
-   unsigned long   flags;
int retval;
int rhport;
int changed = 0;
@@ -193,7 +188,7 @@ static int vhci_hub_status(struct usb_hcd *hcd, char *buf)
 
vhci = hcd_to_vhci(hcd);
 
-   spin_lock_irqsave(&vhci->lock, flags);
+   spin_lock(&vhci->lock);
if (!HCD_HW_ACCESSIBLE(hcd)) {
usbip_dbg_vhci_rh("hw accessible flag not on?\n");
goto done;
@@ -216,7 +211,7 @@ static int vhci_hub_status(struct usb_hcd *hcd, char *buf)
usb_hcd_resume_root_hub(hcd);
 
 done:
-   spin_unlock_irqrestore(&vhci->lock, flags);
+   spin_unlock(&vhci->lock);
return changed ? retval : 0;
 }
 
@@ -237,7 +232,6 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 
typeReq, u16 wValue,
 {
struct vhci_hcd *dum;
int retval = 0;
-   unsigned long   flags;
int rhport;
 
u32 prev_port_status[VHCI_NPORTS];
@@ -257,7 +251,7 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 
typeReq, u16 wValue,
 
dum = hcd_to_vhci(hcd);
 
-   spin_lock_irqsave(&dum->lock, flags);
+   spin_lock(&dum->lock);
 
/* store old status and compare now and old later */
if (usbip_dbg_flag_vhci_rh) {
@@ -410,7 +404,7 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 
typeReq, u16 wValue,
}
usbip_dbg_vhci_rh(" bye\n");
 
-   spin_unlock_irqrestore(&dum->lock, flags);
+   spin_unlock(&dum->lock);
 
return retval;
 }
@@ -433,7 +427,6 @@ static void vhci_tx_urb(struct urb *urb)
 {
struct vhci_device *vdev = get_vdev(urb->dev);
struct vhci_priv *priv;
-   unsigned long flag;
 
if (!vdev) {
pr_err("could not get virtual device");
@@ -442,11 +435,11 @@ static void vhci_tx_urb(struct urb *urb)
 
priv = kzalloc(sizeof(struct vhci_priv), GFP_ATOMIC);
 
-   spin_lock_irqsave(&vdev->priv_lock, flag);
+   spin_lock(&vdev->priv_lock);
 
if (!priv) {
dev_err(&urb->dev->dev, "malloc vhci_priv\n");
-   spin_unlock_irqrestore(&vdev->priv_lock, flag);
+   spin_unlock(&vdev->priv_lock);
usbip_event_add(&vdev->ud, VDEV_EVENT_ERROR_MALLOC);
return;
}
@@ -463,7 +456,7 @@ static void vhci_tx_urb(struct urb *urb)
list_add_tail(&priv->list, &vdev->priv_tx);
 
wake_up(&vdev->waitq_tx);
-   spin_unlock_irqrestore(&vdev->priv_lock, flag);
+   spin_unlock(&vdev->priv_lock);
 }
 
 static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb,
@@ -471,7 +464,6 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struc