mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 01/15] alpha: srmcons: localize spin_lock section
@ 2010-07-16 16:12 Kulikov Vasiliy
  2010-07-16 20:30 ` Marcin Slusarz
  0 siblings, 1 reply; 2+ messages in thread
From: Kulikov Vasiliy @ 2010-07-16 16:12 UTC (permalink / raw)
  To: kernel-janitors
  Cc: Richard Henderson, Ivan Kokshaysky, Matt Turner, linux-alpha,
	linux-kernel

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-07-16 20:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-07-16 16:12 [PATCH 01/15] alpha: srmcons: localize spin_lock section Kulikov Vasiliy
2010-07-16 20:30 ` Marcin Slusarz

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