From patchwork Fri Feb 6 13:45:27 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abhilash Kesavan X-Patchwork-Id: 5791831 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.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C2CE99F30C for ; Fri, 6 Feb 2015 13:47:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DA406201FA for ; Fri, 6 Feb 2015 13:47:00 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id BD7AD201DD for ; Fri, 6 Feb 2015 13:46:59 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 54D052651FD; Fri, 6 Feb 2015 14:46:58 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, NO_DNS_FOR_FROM, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 7B81B265218; Fri, 6 Feb 2015 14:46:24 +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 80564265200; Fri, 6 Feb 2015 14:46:23 +0100 (CET) Received: from mail-pa0-f53.google.com (mail-pa0-f53.google.com [209.85.220.53]) by alsa0.perex.cz (Postfix) with ESMTP id D6FAA265173 for ; Fri, 6 Feb 2015 14:45:52 +0100 (CET) Received: by mail-pa0-f53.google.com with SMTP id lf10so9842674pab.12 for ; Fri, 06 Feb 2015 05:45:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=RM+tJGe12Ha19t2rhZeTa/UxdFI9uA4i8cadTcrP5xU=; b=hkA7pobauv7IjXEb6iPhUyG+vMMLkW3fvTNocc4jzxHYy8urmJGIpMtMlBx64JAf0R QSKi/tMFn5CKjzCZZm5Ci0FUEMsSaQ5Vzgu/MgduJz8ioxpXZWvqLOh23KlV1thVda3z Evf3ammrmC2LvG0yfmq4/h7f1mPd1IR7GdUcGC0IFnQ9EzZl+YlrB7xM3R8+xk4173mH wn+nX5Mx+WVHiwF4a4COVCow9TmTD5WT+A43Yp1i/UzbHqrogvpkTWhslHgEaiyxi0uc A+Qq3yTt4dR1etZprd/9O7QODGQ4+9TIJ5biQUkQDJF/DbToxmmQDZtMdL4LAjCyF1Xf wVHQ== X-Received: by 10.66.124.164 with SMTP id mj4mr5980341pab.83.1423230352235; Fri, 06 Feb 2015 05:45:52 -0800 (PST) Received: from localhost.localdomain ([122.172.209.203]) by mx.google.com with ESMTPSA id c9sm8173942pdm.51.2015.02.06.05.45.46 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 06 Feb 2015 05:45:51 -0800 (PST) From: Abhilash Kesavan To: gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, hirokazu.takata.wj@renesas.com Date: Fri, 6 Feb 2015 19:15:27 +0530 Message-Id: <1423230328-6721-3-git-send-email-a.kesavan@samsung.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1423230328-6721-1-git-send-email-a.kesavan@samsung.com> References: <1423230328-6721-1-git-send-email-a.kesavan@samsung.com> Cc: alsa-devel@alsa-project.org, heiko@sntech.de, shc_work@mail.ru, padma.v@samsung.com, tony@atomide.com, catalin.marinas@arm.com, Will.Deacon@arm.com, nicoleotsuka@gmail.com, kgene@kernel.org, arnd@arndb.de, p.zabel@pengutronix.de, bcousson@baylibre.com, shawn.guo@linaro.org, kernel@pengutronix.de Subject: [alsa-devel] [PATCH v2 2/3] 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 6d1e8ee..7fe7fd2 100644 --- a/Documentation/driver-model/devres.txt +++ b/Documentation/driver-model/devres.txt @@ -276,6 +276,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..fbe2aac 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