All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] usbip: simplify lock handling in valid_request()
@ 2011-05-24 21:19 Németh Márton
  0 siblings, 0 replies; only message in thread
From: Németh Márton @ 2011-05-24 21:19 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Matt Mooney,
	(commit_signer:4/10=40%) Endre Kollar, Arjan Mels, Max Vozeler
  Cc: devel, usbip-devel, linux-kernel

From: Márton Németh <nm127@freemail.hu>

The function calls spin_lock() and spin_unlock() should be in pair. This patch makes
this pairing more clear for the reader of the code.

Signed-off-by: Márton Németh <nm127@freemail.hu>
---
diff --git a/drivers/staging/usbip/stub_rx.c b/drivers/staging/usbip/stub_rx.c
index a5c1fa1..e2cfedb 100644
--- a/drivers/staging/usbip/stub_rx.c
+++ b/drivers/staging/usbip/stub_rx.c
@@ -304,18 +304,18 @@ static int stub_recv_cmd_unlink(struct stub_device *sdev,
 static int valid_request(struct stub_device *sdev, struct usbip_header *pdu)
 {
 	struct usbip_device *ud = &sdev->ud;
+	int valid = 0;

 	if (pdu->base.devid == sdev->devid) {
 		spin_lock(&ud->lock);
 		if (ud->status == SDEV_ST_USED) {
 			/* A request is valid. */
-			spin_unlock(&ud->lock);
-			return 1;
+			valid = 1;
 		}
 		spin_unlock(&ud->lock);
 	}

-	return 0;
+	return valid;
 }

 static struct stub_priv *stub_priv_alloc(struct stub_device *sdev,

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2011-05-24 21:19 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-24 21:19 [PATCH] usbip: simplify lock handling in valid_request() Németh Márton

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.