From patchwork Thu Dec 11 02:58:45 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abhilash Kesavan X-Patchwork-Id: 5474721 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id B5C339F1D4 for ; Thu, 11 Dec 2014 08:45:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E645E20172 for ; Thu, 11 Dec 2014 08:45:33 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 7B3E42018E for ; Thu, 11 Dec 2014 08:45:32 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 9E400265091; Thu, 11 Dec 2014 09:45:31 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,NO_DNS_FOR_FROM, UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id DA92F2606CC; Thu, 11 Dec 2014 09:44:50 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id BBDCB2606E4; Thu, 11 Dec 2014 03:58:43 +0100 (CET) Received: from mailout3.samsung.com (mailout3.samsung.com [203.254.224.33]) by alsa0.perex.cz (Postfix) with ESMTP id ACB9C2606CC for ; Thu, 11 Dec 2014 03:58:35 +0100 (CET) Received: from epcpsbgr3.samsung.com (u143.gpu120.samsung.co.kr [203.254.230.143]) by mailout3.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0NGE00LRRDLK7Z70@mailout3.samsung.com> for alsa-devel@alsa-project.org; Thu, 11 Dec 2014 11:58:32 +0900 (KST) Received: from epcpsbgm2.samsung.com ( [172.20.52.124]) by epcpsbgr3.samsung.com (EPCPMTA) with SMTP id 91.C7.18484.85809845; Thu, 11 Dec 2014 11:58:32 +0900 (KST) X-AuditID: cbfee68f-f791c6d000004834-48-548908584b0a Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id 4B.47.09430.85809845; Thu, 11 Dec 2014 11:58:32 +0900 (KST) Received: from abhilash-ubuntu.sisodomain.com ([107.108.73.92]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0NGE00CKBDL82N00@mmp1.samsung.com>; Thu, 11 Dec 2014 11:58:32 +0900 (KST) From: Abhilash Kesavan To: catalin.marinas@arm.com, Will.Deacon@arm.com, heiko@sntech.de, Li.Xiubo@freescale.com, shc_work@mail.ru, p.zabel@pengutronix.de, nicoleotsuka@gmail.com, arnd@arndb.de, gregkh@linuxfoundation.org, robh+dt@kernel.org, grant.likely@linaro.org, linux-kernel@vger.kernel.org, corbet@lwn.net Date: Thu, 11 Dec 2014 08:28:45 +0530 Message-id: <1418266726-12004-1-git-send-email-a.kesavan@samsung.com> X-Mailer: git-send-email 1.7.9.5 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrEIsWRmVeSWpSXmKPExsWyRsSkRjeCozPE4NpjA4srFw8xWfyddIzd 4s78v6wW75f1MFo8OdDOaHHgzw5Gi+bF69ks/j96zWqxaupOFos1f5Us+h+/ZrbovNDBanF5 1xw2i1e9N9gt7t47wWLx++Z3NosJ09eyWLTuPcJusayljcVi0g4pi/1XvCxefjzB4iDmseFz E5vHmnlrGD1+/5rE6PHt6yQWj/c3Wtk9/h3uZ/LYOesuu8emVZ1sHneu7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xxv amZgqGtoaWGupJCXmJtqq+TiE6DrlpkDDAUlhbLEnFKgUEBicbGSvh2mCaEhbroWMI0Rur4h QXA9RgZoIGENY8bV38cYC/YJVyyZNJetgfE5fxcjJ4eEgInEm1n32CFsMYkL99azgdhCAosY Jaa153UxcgHZfUwSB/a3gRWxCehJLPj3lRkkISKwkkni1bt/jCAOs8BlRomORQ9ZQaqEBdwk vn88DNbBIqAq8ezXJbA4r4CrRFPzPqAGDqB1ChJzJtlMYORewMiwilE0tSC5oDgpPddIrzgx t7g0L10vOT93EyM4JTyT3sG4qsHiEKMAB6MSD2/A5fYQIdbEsuLK3EOMEhzMSiK8STc6QoR4 UxIrq1KL8uOLSnNSiw8xmgItn8gsJZqcD0xXeSXxhsYm5qbGppYmFiZmlkrivEr2bSFCAumJ JanZqakFqUUwfUwcnFINjI4zt8f9vfZJ2vsKU9khjoMBCoc1Ig+ZWdTZHI/6dsiOc/9hwbXR yYt6LzKoaP+eXnpcTl14golW7pFbj+MjzO3dzksXm6bbHdbqzp904Vlf3cYlD+9EskXu+p3v Gvc2JktRU1jIf+/lH0rGJVt3Ked+6Z/pwDj1UUL7mk1sj4OvpOZo3d9npsRSnJFoqMVcVJwI AIDR6BUfAwAA DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected X-Mailman-Approved-At: Thu, 11 Dec 2014 09:44:49 +0100 Cc: alsa-devel@alsa-project.org, bcousson@baylibre.com, pawel.moll@arm.com, padma.v@samsung.com, tony@atomide.com, kesavan.abhilash@gmail.com, kgene@kernel.org, kernel@pengutronix.de, shawn.guo@freescale.com Subject: [alsa-devel] [PATCH 1/2] lib: devres: add a helper function for ioremap_wc X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP Implement a resource managed writecombine ioremap function. Signed-off-by: Abhilash Kesavan --- Documentation/driver-model/devres.txt | 1 + include/linux/io.h | 2 ++ lib/devres.c | 28 ++++++++++++++++++++++++++++ 3 files changed, 31 insertions(+) diff --git a/Documentation/driver-model/devres.txt b/Documentation/driver-model/devres.txt index b5ab416..0f80cee 100644 --- a/Documentation/driver-model/devres.txt +++ b/Documentation/driver-model/devres.txt @@ -274,6 +274,7 @@ IOMAP devm_ioport_unmap() devm_ioremap() devm_ioremap_nocache() + devm_ioremap_wc() devm_ioremap_resource() : checks resource, requests memory region, ioremaps devm_iounmap() pcim_iomap() diff --git a/include/linux/io.h b/include/linux/io.h index fa02e55..42b33f0 100644 --- a/include/linux/io.h +++ b/include/linux/io.h @@ -64,6 +64,8 @@ void __iomem *devm_ioremap(struct device *dev, resource_size_t offset, resource_size_t size); void __iomem *devm_ioremap_nocache(struct device *dev, resource_size_t offset, resource_size_t size); +void __iomem *devm_ioremap_wc(struct device *dev, resource_size_t offset, + resource_size_t size); void devm_iounmap(struct device *dev, void __iomem *addr); int check_signature(const volatile void __iomem *io_addr, const unsigned char *signature, int length); diff --git a/lib/devres.c b/lib/devres.c index 0f1dd2e..e8e1738 100644 --- a/lib/devres.c +++ b/lib/devres.c @@ -72,6 +72,34 @@ void __iomem *devm_ioremap_nocache(struct device *dev, resource_size_t offset, EXPORT_SYMBOL(devm_ioremap_nocache); /** + * devm_ioremap_wc - Managed ioremap_wc() + * @dev: Generic device to remap IO address for + * @offset: BUS offset to map + * @size: Size of map + * + * Managed ioremap_wc(). Map is automatically unmapped on driver detach. + */ +void __iomem *devm_ioremap_wc(struct device *dev, resource_size_t offset, + resource_size_t size) +{ + void __iomem **ptr, *addr; + + ptr = devres_alloc(devm_ioremap_release, sizeof(*ptr), GFP_KERNEL); + if (!ptr) + return NULL; + + addr = ioremap_wc(offset, size); + if (addr) { + *ptr = addr; + devres_add(dev, ptr); + } else + devres_free(ptr); + + return addr; +} +EXPORT_SYMBOL(devm_ioremap_wc); + +/** * devm_iounmap - Managed iounmap() * @dev: Generic device to unmap for * @addr: Address to unmap