mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Eduardo Silva <edsiper@gmail.com>
To: Mike Miller <mike.miller@hp.com>
Cc: iss_storagedev@hp.com, linux-kernel@vger.kernel.org
Subject: [PATCH] block: reduce spin_lock critical region
Date: Thu, 19 May 2011 22:43:09 -0400	[thread overview]
Message-ID: <1305859389.1763.1.camel@monotop> (raw)

the critical region is originally composed by a conditional plus
a memory copy, the memory copy routine don't need protection.
Moving the memcpy() outside the conditional also help to fix the
16 compiler warning messages generated in __u8 sn[16] def.

Signed-off-by: Eduardo Silva <edsiper@gmail.com>
---
 drivers/block/cciss.c |   19 +++++++++----------
 1 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
index 9bf1398..199b35e 100644
--- a/drivers/block/cciss.c
+++ b/drivers/block/cciss.c
@@ -621,20 +621,19 @@ static ssize_t dev_show_unique_id(struct device *dev,
 	spin_lock_irqsave(&h->lock, flags);
 	if (h->busy_configuring)
 		ret = -EBUSY;
-	else
-		memcpy(sn, drv->serial_no, sizeof(sn));
 	spin_unlock_irqrestore(&h->lock, flags);
 
 	if (ret)
 		return ret;
-	else
-		return snprintf(buf, 16 * 2 + 2,
-				"%02X%02X%02X%02X%02X%02X%02X%02X"
-				"%02X%02X%02X%02X%02X%02X%02X%02X\n",
-				sn[0], sn[1], sn[2], sn[3],
-				sn[4], sn[5], sn[6], sn[7],
-				sn[8], sn[9], sn[10], sn[11],
-				sn[12], sn[13], sn[14], sn[15]);
+
+	memcpy(sn, drv->serial_no, sizeof(sn));
+	return snprintf(buf, 16 * 2 + 2,
+			"%02X%02X%02X%02X%02X%02X%02X%02X"
+			"%02X%02X%02X%02X%02X%02X%02X%02X\n",
+			sn[0], sn[1], sn[2], sn[3],
+			sn[4], sn[5], sn[6], sn[7],
+			sn[8], sn[9], sn[10], sn[11],
+			sn[12], sn[13], sn[14], sn[15]);
 }
 static DEVICE_ATTR(unique_id, S_IRUGO, dev_show_unique_id, NULL);
 
-- 
1.7.4.1




                 reply	other threads:[~2011-05-20  2:43 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=1305859389.1763.1.camel@monotop \
    --to=edsiper@gmail.com \
    --cc=iss_storagedev@hp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mike.miller@hp.com \
    /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

all inboxes | Powered by JetHome®