From: "Németh Márton" <nm127@freemail.hu>
To: Greg Kroah-Hartman <gregkh@suse.de>,
Matt Mooney <mfm@muteddisk.com>,
"(commit_signer:4/10=40%) Endre Kollar" <taxy443@gmail.com>,
Arjan Mels <arjan.mels@gmx.net>, Max Vozeler <max@vozeler.com>
Cc: devel@driverdev.osuosl.org, usbip-devel@lists.sourceforge.net,
linux-kernel@vger.kernel.org
Subject: [PATCH] usbip: simplify lock handling in valid_request()
Date: Tue, 24 May 2011 23:19:18 +0200 [thread overview]
Message-ID: <4DDC20D6.9050102@freemail.hu> (raw)
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,
reply other threads:[~2011-05-24 21:19 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4DDC20D6.9050102@freemail.hu \
--to=nm127@freemail.hu \
--cc=arjan.mels@gmx.net \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@suse.de \
--cc=linux-kernel@vger.kernel.org \
--cc=max@vozeler.com \
--cc=mfm@muteddisk.com \
--cc=taxy443@gmail.com \
--cc=usbip-devel@lists.sourceforge.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox