From patchwork Wed Mar 11 08:44:57 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 24292 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from ozlabs.org (localhost [127.0.0.1]) by ozlabs.org (Postfix) with ESMTP id AD6C6DE3C3 for ; Wed, 11 Mar 2009 19:46:05 +1100 (EST) X-Original-To: linuxppc-dev@ozlabs.org Delivered-To: linuxppc-dev@ozlabs.org Received: from mx2.redhat.com (mx2.redhat.com [66.187.237.31]) by ozlabs.org (Postfix) with ESMTP id A931BDDFAC for ; Wed, 11 Mar 2009 19:45:41 +1100 (EST) Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n2B8j08v004066; Wed, 11 Mar 2009 04:45:00 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n2B8ixmd015205; Wed, 11 Mar 2009 04:45:00 -0400 Received: from warthog.cambridge.redhat.com (kibblesnbits.boston.devel.redhat.com [10.16.60.12]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n2B8iwbi010125; Wed, 11 Mar 2009 04:44:59 -0400 Received: from [127.0.0.1] (helo=warthog.procyon.org.uk) by warthog.cambridge.redhat.com with esmtp (Exim 4.68 #1 (Red Hat Linux)) id 1LhK3d-0002Oi-1D; Wed, 11 Mar 2009 08:44:57 +0000 Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 From: David Howells Subject: [PATCH] eHEA: Don't do memory allocation under lock if not necessary To: raisch@de.ibm.com, themann@de.ibm.com, tklein@de.ibm.com Date: Wed, 11 Mar 2009 08:44:57 +0000 Message-ID: <20090311084456.9190.52805.stgit@warthog.procyon.org.uk> User-Agent: StGIT/0.14.3 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.58 on 172.16.27.26 Cc: linuxppc-dev@ozlabs.org, netdev@vger.kernel.org X-BeenThere: linuxppc-dev@ozlabs.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@ozlabs.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@ozlabs.org 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 --- 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;