From patchwork Fri Sep 7 06:45:55 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yongjun X-Patchwork-Id: 182329 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from ozlabs.org (localhost [IPv6:::1]) by ozlabs.org (Postfix) with ESMTP id C32EB2C03EC for ; Fri, 7 Sep 2012 16:51:18 +1000 (EST) Received: from mail-qc0-f179.google.com (mail-qc0-f179.google.com [209.85.216.179]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 4D6722C008C; Fri, 7 Sep 2012 16:45:58 +1000 (EST) Received: by qcse14 with SMTP id e14so1177365qcs.38 for ; Thu, 06 Sep 2012 23:45:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:cc:content-type; bh=FX80W496uJE1w32Tt341wm+eI68nsjpJsdpJUGOkSaM=; b=Fk0yiRlpaP7HmicxBLG/1TJIqjx9SQPLRpn1XxBUSSxwFSrXoqo9PeoQzJFCDMhijp lAVdcZKRpKkLgfbWh9f+cgzDxyGUkwWAzn4s9a9CM1A7kQEgfb4cLUoBm7fseEldhK4Y FQLBl1SRJChTCTvBKGs8jqp224/6CcZXH7rcMdmkSQtCl9fXovbhbSSRqklMzRuuDzGv V372lCSpNp4A7myUHPfgRm5y6X5P2h6ceUFlrnDeP7fGCMJNFkLVwhE3YqVD22gdryvt 0uBhMJd7j4dCZPzHF7dATo79LpxRq3zzEjRYkL/DeSW3jUGkNLK041zCiFvBL/viJNYW Y2LQ== MIME-Version: 1.0 Received: by 10.224.193.132 with SMTP id du4mr6327439qab.75.1347000355478; Thu, 06 Sep 2012 23:45:55 -0700 (PDT) Received: by 10.229.146.194 with HTTP; Thu, 6 Sep 2012 23:45:55 -0700 (PDT) Date: Fri, 7 Sep 2012 14:45:55 +0800 Message-ID: Subject: [PATCH] powerpc/powernv: move the dereference below the NULL test From: Wei Yongjun To: benh@kernel.crashing.org, paulus@samba.org, grant.likely@secretlab.ca, rob.herring@calxeda.com X-Mailman-Approved-At: Fri, 07 Sep 2012 16:50:52 +1000 Cc: yongjun_wei@trendmicro.com.cn, linuxppc-dev@lists.ozlabs.org, devicetree-discuss@lists.ozlabs.org, linux-kernel@vger.kernel.org X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" From: Wei Yongjun The dereference should be moved below the NULL test. spatch with a semantic match is used to found this. (http://coccinelle.lip6.fr/) Signed-off-by: Wei Yongjun --- arch/powerpc/platforms/powernv/pci.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/platforms/powernv/pci.c b/arch/powerpc/platforms/powernv/pci.c index be3cfc5..4ba89c1 100644 --- a/arch/powerpc/platforms/powernv/pci.c +++ b/arch/powerpc/platforms/powernv/pci.c @@ -287,13 +287,15 @@ static int pnv_pci_read_config(struct pci_bus *bus, int where, int size, u32 *val) { struct pci_controller *hose = pci_bus_to_host(bus); - struct pnv_phb *phb = hose->private_data; + struct pnv_phb *phb; u32 bdfn = (((uint64_t)bus->number) << 8) | devfn; s64 rc; if (hose == NULL) return PCIBIOS_DEVICE_NOT_FOUND; + phb = hose->private_data; + switch (size) { case 1: { u8 v8; @@ -331,12 +333,14 @@ static int pnv_pci_write_config(struct pci_bus *bus, int where, int size, u32 val) { struct pci_controller *hose = pci_bus_to_host(bus); - struct pnv_phb *phb = hose->private_data; + struct pnv_phb *phb; u32 bdfn = (((uint64_t)bus->number) << 8) | devfn; if (hose == NULL) return PCIBIOS_DEVICE_NOT_FOUND; + phb = hose->private_data; + cfg_dbg("pnv_pci_write_config bus: %x devfn: %x +%x/%x -> %08x\n", bus->number, devfn, where, size, val); switch (size) {