linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: David Howells <dhowells@redhat.com>
To: raisch@de.ibm.com, themann@de.ibm.com, tklein@de.ibm.com
Cc: linuxppc-dev@ozlabs.org
Subject: [PATCH] eHEA: Don't do memory allocation under lock if not necessary
Date: Mon, 09 Mar 2009 16:36:28 +0000	[thread overview]
Message-ID: <20090309163628.2570.8408.stgit@warthog.procyon.org.uk> (raw)

In ehea_probe_adapter() the initial memory allocation and initialisation does
not need to be done with the ehea_fw_handles.lock semaphore held.  Doing so
extends the amount of time the lock is held unnecessarily.

Signed-off-by: David Howells <dhowells@redhat.com>
---

 drivers/net/ehea/ehea_main.c |   13 ++++++-------
 1 files changed, 6 insertions(+), 7 deletions(-)


diff --git a/drivers/net/ehea/ehea_main.c b/drivers/net/ehea/ehea_main.c
index dfe9226..34480ae 100644
--- a/drivers/net/ehea/ehea_main.c
+++ b/drivers/net/ehea/ehea_main.c
@@ -3370,18 +3370,19 @@ static int __devinit ehea_probe_adapter(struct of_device *dev,
 		ehea_error("Invalid ibmebus device probed");
 		return -EINVAL;
 	}
-	mutex_lock(&ehea_fw_handles.lock);
 
 	adapter = kzalloc(sizeof(*adapter), GFP_KERNEL);
 	if (!adapter) {
-		ret = -ENOMEM;
 		dev_err(&dev->dev, "no mem for ehea_adapter\n");
-		goto out;
+		return -ENOMEM;
 	}
 
-	list_add(&adapter->list, &adapter_list);
-
 	adapter->ofdev = dev;
+	adapter->pd = EHEA_PD_ID;
+
+	mutex_lock(&ehea_fw_handles.lock);
+
+	list_add(&adapter->list, &adapter_list);
 
 	adapter_handle = of_get_property(dev->node, "ibm,hea-handle",
 					 NULL);
@@ -3395,8 +3396,6 @@ static int __devinit ehea_probe_adapter(struct of_device *dev,
 		goto out_free_ad;
 	}
 
-	adapter->pd = EHEA_PD_ID;
-
 	dev->dev.driver_data = adapter;
 
 

             reply	other threads:[~2009-03-09 16:36 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-09 16:36 David Howells [this message]
2009-03-11  4:10 ` [PATCH] eHEA: Don't do memory allocation under lock if not necessary Benjamin Herrenschmidt
2009-03-11  8:44 David Howells
2009-03-11  9:37 ` Jan-Bernd Themann

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=20090309163628.2570.8408.stgit@warthog.procyon.org.uk \
    --to=dhowells@redhat.com \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=raisch@de.ibm.com \
    --cc=themann@de.ibm.com \
    --cc=tklein@de.ibm.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;
as well as URLs for NNTP newsgroup(s).