From patchwork Thu Nov 12 14:14:23 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 7602741 Return-Path: X-Original-To: patchwork-linux-mmc@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 355509F1D3 for ; Thu, 12 Nov 2015 14:20:21 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 410642078B for ; Thu, 12 Nov 2015 14:20:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4AB8C20788 for ; Thu, 12 Nov 2015 14:20:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753855AbbKLOUO (ORCPT ); Thu, 12 Nov 2015 09:20:14 -0500 Received: from mout.kundenserver.de ([212.227.126.131]:56666 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752537AbbKLOUN (ORCPT ); Thu, 12 Nov 2015 09:20:13 -0500 Received: from wuerfel.localnet ([134.3.118.24]) by mrelayeu.kundenserver.de (mreue005) with ESMTPSA (Nemesis) id 0MC5PI-1a5iLY3HSi-008vmz; Thu, 12 Nov 2015 15:14:24 +0100 From: Arnd Bergmann To: Ulf Hansson Cc: Jaehoon Chung , linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH] mmc: dw_mmc: use resource_size_t to store physical address Date: Thu, 12 Nov 2015 15:14:23 +0100 Message-ID: <28102387.ALpaBHpim0@wuerfel> User-Agent: KMail/4.11.5 (Linux/3.16.0-10-generic; KDE/4.11.5; x86_64; ; ) MIME-Version: 1.0 X-Provags-ID: V03:K0:kDwbWcgujsHwCgMy82uAnhA1pFXmMZa6o5AkQCCG89UMJ4nAD6D IK6KvzUDbQKX8NmOcGBBJpVUP4C9qYsUNu1Zj/K1TgS4XoyQIeDjJCCyhuc3stCNJMW0q6i SO5QNdLZhb2OBsTt7OwfWk10cA35YJorpABFmZrWNZ8vvqsk9qX5nZaoDTvEjuq9ncVmm75 RJezGobgm5d8p2SIp1byg== X-UI-Out-Filterresults: notjunk:1; V01:K0:EnOrHpbuv/Q=:qnzTKF95dPGzeqhowMm2Ki UcbkXXkn+t5qxX19sYwPHSl+qlakvQW2IkqfLYAxtMzpw5gezUUjvvri6CoJAXf/zNT0TqxmQ zLyuhaL8TlJiPEtPbcF65+R5V1+gv3z60R+3Vk0wUs2D7YD46wl4AySo06HZA/XDeEC/AwA2u DA/Jr0k4h75kqxlmXIdSI1sJYpVyrZBRgwQdO0Tcsu2tVf1/pgwdRPvA+WLS8w4Y8JJtrEiCf 4ewOTDLGAA2FLJK/8lkg4sfI3jOBYVI/7hqUVFLJw1vcV7RBMtGLtvs4bo1fgtLzGlNYog0cz nTvAKvq6uBhInRZYRdadagsSpyCPvdmFHjVmiSRHrT7IPnwpUOojbHT3apZ7tRmfI4lHUeJ7h sN9S8mJ1yKdPkhXozfyK9TdyKUtCezZRmWA1Img5Wd0ijqA+4TovQwTYLVSzol9PWg8ygw0vT MVcsUcSD8Lgputq5Z3Y/AgLd9N9Rb7Uu3Nvp7PvYcJrEtv1KK6rvF7nQYNJF/DEFUowppZ1aU TSBEcye2FmW3caDjVJCVWxy+yJsGw4p9tP/zD15ye3/OjePmqmxZFomB/4MKPUWFW4aprN1j+ aHeoJsQdGXaXpfs7Xe1OazoA3tXQo3cSMBiBlOh157MwHcjdhv5HnQw0/9uGH1O3IaecPZoPP uABK0rO/fThGnmQL08QiZWMk5rTrdk8Rp2RrsVB0ALeSqr22497V0R5focSXVRMRMdMmYfzFY 5fqmilFnJ468QxRj Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 The dw_mmc driver stores the physical address of the MMIO registers in a pointer, which requires the use of type casts, and is actually broken if anyone ever has this device on a 32-bit SoC in registers above 4GB. Gcc warns about this possibility when the driver is built with ARM LPAE enabled: mmc/host/dw_mmc.c: In function 'dw_mci_edmac_start_dma': mmc/host/dw_mmc.c:702:17: warning: cast from pointer to integer of different size cfg.dst_addr = (dma_addr_t)(host->phy_regs + fifo_offset); ^ mmc/host/dw_mmc-pltfm.c: In function 'dw_mci_pltfm_register': mmc/host/dw_mmc-pltfm.c:63:19: warning: cast to pointer from integer of different size host->phy_regs = (void *)(regs->start); This changes the code to use resource_size_t, which gets rid of the warning, the bug and the useless casts. Signed-off-by: Arnd Bergmann --- From the arm64 allmodconfig build reports -- To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/mmc/host/dw_mmc-pltfm.c b/drivers/mmc/host/dw_mmc-pltfm.c index 7e1d13b68b06..81bdeeb05a4d 100644 --- a/drivers/mmc/host/dw_mmc-pltfm.c +++ b/drivers/mmc/host/dw_mmc-pltfm.c @@ -60,7 +60,7 @@ int dw_mci_pltfm_register(struct platform_device *pdev, regs = platform_get_resource(pdev, IORESOURCE_MEM, 0); /* Get registers' physical base address */ - host->phy_regs = (void *)(regs->start); + host->phy_regs = regs->start; host->regs = devm_ioremap_resource(&pdev->dev, regs); if (IS_ERR(host->regs)) return PTR_ERR(host->regs); diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c index 7a6cedbe48a8..fb204ee6ff89 100644 --- a/drivers/mmc/host/dw_mmc.c +++ b/drivers/mmc/host/dw_mmc.c @@ -699,7 +699,7 @@ static int dw_mci_edmac_start_dma(struct dw_mci *host, int ret = 0; /* Set external dma config: burst size, burst width */ - cfg.dst_addr = (dma_addr_t)(host->phy_regs + fifo_offset); + cfg.dst_addr = host->phy_regs + fifo_offset; cfg.src_addr = cfg.dst_addr; cfg.dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; cfg.src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; diff --git a/include/linux/mmc/dw_mmc.h b/include/linux/mmc/dw_mmc.h index f67b2ec18e6d..7776afb0ffa5 100644 --- a/include/linux/mmc/dw_mmc.h +++ b/include/linux/mmc/dw_mmc.h @@ -172,7 +172,7 @@ struct dw_mci { /* For edmac */ struct dw_mci_dma_slave *dms; /* Registers's physical base address */ - void *phy_regs; + resource_size_t phy_regs; u32 cmd_status; u32 data_status;