Skip to contentSkip to conversation

staging: usbip: remove an unnecessary lock in usbip_event_happened.

PATCH In review harvey.yang 2 participants 2 messages Nov 5, 2012 Staging

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 staging: usbip: remove an unnecessary lock in usbip_event_happened.

From: Harvey.Yang <[email protected]>

---
 drivers/staging/usbip/usbip_common.h |    2 +-
 drivers/staging/usbip/usbip_event.c  |   11 ++---------
 2 files changed, 3 insertions(+), 10 deletions(-)
drivers/staging/usbip/usbip_common.h +1 -1
index 5d89c0f..b6d7add 100644
@@ -330,7 +330,7 @@ int usbip_recv_xbuff(struct usbip_device *ud, struct urb *urb);
 int usbip_start_eh(struct usbip_device *ud);
 void usbip_stop_eh(struct usbip_device *ud);
 void usbip_event_add(struct usbip_device *ud, unsigned long event);
-int usbip_event_happened(struct usbip_device *ud);
+inline int usbip_event_happened(struct usbip_device *ud);
 
 static inline int interface_to_busnum(struct usb_interface *interface)
 {
drivers/staging/usbip/usbip_event.c +2 -9
index d332a34..15871f0 100644
@@ -112,15 +112,8 @@ void usbip_event_add(struct usbip_device *ud, unsigned long event)
 }
 EXPORT_SYMBOL_GPL(usbip_event_add);
 
-int usbip_event_happened(struct usbip_device *ud)
+inline 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;
+	return ud->event ? 1 : 0;
 }
 EXPORT_SYMBOL_GPL(usbip_event_happened);
Signature · 1 line
1.7.1
#1 lore raw
Quoted 32 lines · harvey.yang

From: Harvey.Yang <[email protected]>

---
 drivers/staging/usbip/usbip_common.h |    2 +-
 drivers/staging/usbip/usbip_event.c  |   11 ++---------
 2 files changed, 3 insertions(+), 10 deletions(-)
drivers/staging/usbip/usbip_common.h +1 -1
index 5d89c0f..b6d7add 100644
@@ -330,7 +330,7 @@ int usbip_recv_xbuff(struct usbip_device *ud, struct urb *urb);
 int usbip_start_eh(struct usbip_device *ud);
 void usbip_stop_eh(struct usbip_device *ud);
 void usbip_event_add(struct usbip_device *ud, unsigned long event);
-int usbip_event_happened(struct usbip_device *ud);
+inline int usbip_event_happened(struct usbip_device *ud);
 
 static inline int interface_to_busnum(struct usb_interface *interface)
 {
drivers/staging/usbip/usbip_event.c +1 -1
index d332a34..15871f0 100644
@@ -112,15 +112,8 @@ void usbip_event_add(struct usbip_device *ud, unsigned long event)
 }
 EXPORT_SYMBOL_GPL(usbip_event_add);
 
-int usbip_event_happened(struct usbip_device *ud)
+inline int usbip_event_happened(struct usbip_device *ud)

drivers/staging/usbip/usbip_event.c void usbip_event_add(struct usbip_device *ud, unsigned long event) · line 117

Quoted 10 lines
drivers/staging/usbip/usbip_event.c +1 -8
 {
-	int happened = 0;
-
-	spin_lock(&ud->lock);
-	if (ud->event != 0)
-		happened = 1;
-	spin_unlock(&ud->lock);
-
-	return happened;
+	return ud->event ? 1 : 0;

No, you aren't locking to see if something changed with ud->event here.

Actually, that's pretty broken anyway, what is to say that event doesn't change right after this call? What exactly is this call supposed to be doing? Who is calling it?

drivers/staging/usbip/usbip_event.c void usbip_event_add(struct usbip_device *ud, unsigned long event) · line 119

Quoted 2 lines
drivers/staging/usbip/usbip_event.c +0 -0
 }
 EXPORT_SYMBOL_GPL(usbip_event_happened);

You can't inline an exported symbol, how would that work?

greg k-h