mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Kulikov Vasiliy <segooon@gmail.com>
To: kernel-janitors@vger.kernel.org
Cc: Richard Henderson <rth@twiddle.net>,
	Ivan Kokshaysky <ink@jurassic.park.msu.ru>,
	Matt Turner <mattst88@gmail.com>,
	linux-alpha@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 01/15] alpha: srmcons: localize spin_lock section
Date: Fri, 16 Jul 2010 20:12:27 +0400	[thread overview]
Message-ID: <1279296747-24783-1-git-send-email-segooon@gmail.com> (raw)

Scale down spin_lock_irqsave/spin_unlock_irqrestore exactly to area
where it is needed. Also it makes static checkers happy as code checks
kmalloc() result value exactly after call.

Signed-off-by: Kulikov Vasiliy <segooon@gmail.com>
---
 arch/alpha/kernel/srmcons.c |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/arch/alpha/kernel/srmcons.c b/arch/alpha/kernel/srmcons.c
index 783f4e5..6b04005 100644
--- a/arch/alpha/kernel/srmcons.c
+++ b/arch/alpha/kernel/srmcons.c
@@ -165,17 +165,15 @@ srmcons_get_private_struct(struct srmcons_private **ps)
 
 	if (srmconsp == NULL) {
 		srmconsp = kmalloc(sizeof(*srmconsp), GFP_KERNEL);
-		spin_lock_irqsave(&srmconsp_lock, flags);
-
 		if (srmconsp == NULL)
 			retval = -ENOMEM;
 		else {
+			spin_lock_irqsave(&srmconsp_lock, flags);
 			srmconsp->tty = NULL;
 			spin_lock_init(&srmconsp->lock);
 			init_timer(&srmconsp->timer);
+			spin_unlock_irqrestore(&srmconsp_lock, flags);
 		}
-
-		spin_unlock_irqrestore(&srmconsp_lock, flags);
 	}
 
 	*ps = srmconsp;
-- 
1.7.0.4


             reply	other threads:[~2010-07-16 16:12 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-16 16:12 Kulikov Vasiliy [this message]
2010-07-16 20:30 ` Marcin Slusarz

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=1279296747-24783-1-git-send-email-segooon@gmail.com \
    --to=segooon@gmail.com \
    --cc=ink@jurassic.park.msu.ru \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-alpha@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mattst88@gmail.com \
    --cc=rth@twiddle.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

Powered by JetHome