From patchwork Wed Nov 27 01:59:18 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jingoo Han X-Patchwork-Id: 3245341 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id D4B64C045B for ; Wed, 27 Nov 2013 02:00:00 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 06F4E20204 for ; Wed, 27 Nov 2013 02:00:00 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A2C31201B3 for ; Wed, 27 Nov 2013 01:59:58 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VlUPz-00083w-HE; Wed, 27 Nov 2013 01:59:55 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VlUPw-00063Y-TW; Wed, 27 Nov 2013 01:59:52 +0000 Received: from mailout1.samsung.com ([203.254.224.24]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VlUPt-000621-4K for linux-arm-kernel@lists.infradead.org; Wed, 27 Nov 2013 01:59:51 +0000 Received: from epcpsbgr2.samsung.com (u142.gpu120.samsung.co.kr [203.254.230.142]) by mailout1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MWW000B1G6U4G80@mailout1.samsung.com> for linux-arm-kernel@lists.infradead.org; Wed, 27 Nov 2013 10:59:18 +0900 (KST) Received: from epcpsbgm1.samsung.com ( [203.254.230.50]) by epcpsbgr2.samsung.com (EPCPMTA) with SMTP id FE.2D.18301.6F155925; Wed, 27 Nov 2013 10:59:18 +0900 (KST) X-AuditID: cbfee68e-b7f7e6d00000477d-5a-529551f67953 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 40.10.32308.6F155925; Wed, 27 Nov 2013 10:59:18 +0900 (KST) Received: from DOJG1HAN03 ([12.23.120.99]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MWW00EFBG6UAX80@mmp1.samsung.com>; Wed, 27 Nov 2013 10:59:18 +0900 (KST) From: Jingoo Han To: 'Christopher Li' , linux-sparse@vger.kernel.org, 'Joe Perches' , 'Dan Carpenter' References: <001001ceb816$5d1aecc0$1750c640$%han@samsung.com> <20131125200256.GA7316@obsidianresearch.com> <001101ceea68$cb486220$61d92660$%han@samsung.com> <20131126180930.GC19852@obsidianresearch.com> In-reply-to: <20131126180930.GC19852@obsidianresearch.com> Subject: Re: PCI: mvebu: return NULL instead of ERR_PTR(ret) Date: Wed, 27 Nov 2013 10:59:18 +0900 Message-id: <000101ceeb14$480fee80$d82fcb80$%han@samsung.com> MIME-version: 1.0 X-Mailer: Microsoft Office Outlook 12.0 Thread-index: Ac7q0qkEMP8SUtb/TeufUZJxDVkqfAAPISKg Content-language: ko X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrEKsWRmVeSWpSXmKPExsVy+t8zI91vgVODDG5dF7U4Mucrs8WSpgyL 1/+ms1icPrWA1aJxyWUWi8sLL7FafL9hajH7/mMWi2UPTjNabHp8jdXi7LzjbBb3bu9nseha c4jV4umDJiYHPo8Vq66weDzZdJHRY8GmUo+2n2UeDQfOs3js3ZLlsXlJvcf3Hb2MHh+f3mLx +LLqGrNH35ZVjB6fN8kF8ERx2aSk5mSWpRbp2yVwZXRvXsVS0CVVsXXtBaYG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5GTg4JAROJjS9usUDYYhIX7q1n62Lk4hASWMQocX/9XTaQhJDA L0aJV8f0QWw2ATWJL18Os4MUiQhMY5T4/GsjM4jDLLCRWeLq7AZmiI4LjBKdR+xAbE4BK4kL a06wgtjCAjYSpx5sBJvKIqAqcfHjebDVvAK2EteOT2aEsAUlfky+BxZnFtCS2LytiRXClpfY vOYt0HwOoFPVJR791QUJiwgYSazeupgJokREYt+Ld4wTGIVmIZk0C8mkWUgmzULSsoCRZRWj aGpBckFxUnquoV5xYm5xaV66XnJ+7iZGcHp6JrWDcWWDxSFGAQ5GJR7eCZenBAmxJpYVV+Ye YpTgYFYS4X3hMDVIiDclsbIqtSg/vqg0J7X4EGMy0KMTmaVEk/OBqTOvJN7Q2MTMyNLIzMLI xNycNGElcd4DrdaBQgLpiSWp2ampBalFMFuYODilGhi1fs2uyfb7/syypNPSRZrrFH+Zhmj/ RIcXDbdfWnLJdu759aLxyDWHrPdLowNZ9y1333hpf+VS7rRL9S0WLl8YHr34+PxuxZHJ0Qur Jix335Qh8fDEC3MD57Ux+eFZMV92PVbY1bbM8HPP15sSh1Yc+OjK+e+O0qOYuvsW+1szjN6f Xf5pGd8MJZbijERDLeai4kQA3SgJs5MDAAA= DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20131126_205949_415523_44D10B33 X-CRM114-Status: GOOD ( 17.14 ) X-Spam-Score: -6.9 (------) Cc: 'Thomas Petazzoni' , 'Axel Lin' , 'Jason Cooper' , linux-pci@vger.kernel.org, 'Jingoo Han' , 'Jason Gunthorpe' , 'Julia Lawall' , 'Ezequiel Garcia' , 'Bjorn Helgaas' , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Wednesday, November 27, 2013 3:10 AM, Jason Gunthorpe wrote: > On Tue, Nov 26, 2013 at 02:31:44PM +0900, Jingoo Han wrote: > > Previously, I sent the patch in order to fix sparse warning as below: > > How about this? > > > > static void __iomem *mvebu_pcie_map_registers(struct platform_device *pdev, > > struct device_node *np, struct mvebu_pcie_port *port) > > { > > struct resource regs; > > int ret = 0; > > > > ret = of_address_to_resource(np, 0, ®s); > > if (ret) > > - return ERR_PTR(ret); > > + return (void __iomem *)ERR_PTR(ret); > > You should probably ask the sparse folks for guidance 'git grep > iomem.*ERR_PTR' returns nothing, so this isn't an established pattern. > > It seems like sparse should know that ERR_PTR functions can work with > any pointer no matter the type? IS_ERR_PTR will have the same problem > with implicitly dropping the iomem tag. +cc Christopher Li, sparse mailing-list, Joe Perches, Dan Carpenter, Axel Lin, Julia Lawall, Hi All, I have some questions about handling sparse warning. Currently, the following sparse warning happens at Marvell Armada PCIe driver. drivers/pci/host/pci-mvebu.c:743:31: warning: incorrect type in return expression (different address spaces) drivers/pci/host/pci-mvebu.c:743:31: expected void [noderef] * drivers/pci/host/pci-mvebu.c:743:31: got void * mvebu_pcie_map_registers() returns ERR_PTR(ret), however ERR_PTR() returns (void *), not (void __iomem *). ./drivers/pci/host/pci-mvebu.c static void __iomem *mvebu_pcie_map_registers(struct platform_device *pdev, struct device_node *np, struct mvebu_pcie_port *port) { struct resource regs; int ret = 0; ret = of_address_to_resource(np, 0, ®s); if (ret) return ERR_PTR(ret); return devm_ioremap_resource(&pdev->dev, ®s); } ./include/linux/err.h static inline void * __must_check ERR_PTR(long error) { return (void *) error; } Previously, I submitted the following patch, that adds (void __iomem *) cast. ./drivers/pci/host/pci-mvebu.c static void __iomem *mvebu_pcie_map_registers(struct platform_device *pdev, struct device_node *np, struct mvebu_pcie_port *port) { ..... ret = of_address_to_resource(np, 0, ®s); if (ret) - return ERR_PTR(ret); + return (void __iomem *)ERR_PTR(ret); However, other engineers said that "(void __iomem *)ERR_PTR(ret)" is not a general pattern. I cannot find the proper method to resolve this sparse warning. In this case, how can I resolve this sparse warning? Then, how about the following? Thank you for reading this. :-) Best regards, Jingoo Han --- a/drivers/pci/host/pci-mvebu.c +++ b/drivers/pci/host/pci-mvebu.c @@ -740,7 +740,7 @@ static void __iomem *mvebu_pcie_map_registers(struct platform_device *pdev, ret = of_address_to_resource(np, 0, ®s); if (ret) - return ERR_PTR(ret); + return NULL; return devm_ioremap_resource(&pdev->dev, ®s); } @@ -939,7 +939,7 @@ static int mvebu_pcie_probe(struct platform_device *pdev) continue; port->base = mvebu_pcie_map_registers(pdev, child, port); - if (IS_ERR(port->base)) { + if (IS_ERR_OR_NULL(port->base)) { dev_err(&pdev->dev, "PCIe%d.%d: cannot map registers\n", port->port, port->lane); port->base = NULL;