Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933659AbaLKC6j (ORCPT ); Wed, 10 Dec 2014 21:58:39 -0500 Received: from mailout3.samsung.com ([203.254.224.33]:32467 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933176AbaLKC6h (ORCPT ); Wed, 10 Dec 2014 21:58:37 -0500 X-AuditID: cbfee68f-f791c6d000004834-48-548908584b0a 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 Cc: padma.v@samsung.com, alsa-devel@alsa-project.org, shawn.guo@freescale.com, bcousson@baylibre.com, tony@atomide.com, kernel@pengutronix.de, kgene@kernel.org, kesavan.abhilash@gmail.com, pawel.moll@arm.com Subject: [PATCH 1/2] lib: devres: add a helper function for ioremap_wc 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/LYOesuu8emVZ1sHneu7WHz2D93DbvH4r7J rB5T5h5h9ej/a+DRt2UVo8f2a/OYPT5vkgsQiOKySUnNySxLLdK3S+DKuPr7GGPBPuGKJZPm sjUwPufvYuTkkBAwkTg2tZMJwha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4eEgInEm1n32CFsMYkL99azgdhCAosY 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 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/