From patchwork Mon Mar 9 16:36:28 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 24205 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 7CD4DDE6A1 for ; Tue, 10 Mar 2009 03:38:39 +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 E6174DE147 for ; Tue, 10 Mar 2009 03:36:44 +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 n29GaUc6002974; Mon, 9 Mar 2009 12:36:30 -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 n29GaUqN009962; Mon, 9 Mar 2009 12:36:30 -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 n29GaTxu001630; Mon, 9 Mar 2009 12:36:30 -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 1LgiSq-0000g7-Fd; Mon, 09 Mar 2009 16:36:28 +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: Mon, 09 Mar 2009 16:36:28 +0000 Message-ID: <20090309163628.2570.8408.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 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;