From patchwork Fri Nov 24 16:24:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 119611 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp2446232qgn; Fri, 24 Nov 2017 08:29:52 -0800 (PST) X-Google-Smtp-Source: AGs4zMZ+nmEq2Io+cs9wXYDxyCGSrbBhjYtaJDnAhM7yti8KChu5qyWwd3b9M/i25wcMFG6sWk9i X-Received: by 10.84.232.8 with SMTP id h8mr22939884plk.274.1511540991912; Fri, 24 Nov 2017 08:29:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511540991; cv=none; d=google.com; s=arc-20160816; b=0ybcEvWsHKJoyg70Y4Vxj8oMbNbWqWTbk9zD/N7JNAqWp1DywH+6UHK15Js6/6BsVN 7W9c1JYcezhmIzC6bsS6azsPyxeMM9N2bSqDsr82SXp+MMMp4kRCIEFHjUwm5h3fEBVX iQfD6kl1a4NaUN1S8KPDYS0dF8vLJm02Lbw2IP/YMhQh7fmZCsi+adWvAJdgJ+yJvYDV WJLazid09uv8ihjt/PvKPkZdHfYGfP+NTZ9cmUcH92xKJ15avqTtU5DID9jnWL/SqLEa tfcTSJHYl1K8NforeJUgmGhw30mxGkMBVtauR0ozvTd8pWjLxI01prfhxgYpqoO0zLoZ Zp4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter :arc-authentication-results; bh=ApQOJB4Q/RVkBLUEaPdtl9pL2Yu6plA669hQat+GFwo=; b=QY1NP2ocpWudgLKcXwhbMYY2KTVBzSRBSi1cUE7B+i2ILBtb2tZhL4JEnVj8MkxJpD rdDql+8oY8/WQG8KGnBJcxR3/avj82W5g3aGY6xPQQsxjgo3f4M98mhx5SeTsQNhJAtm 8keVUxVbT/sKeLUynMdpy9JEkAQSMMZjphj4TEmKmFmswhv0r9vROfVcCOS3cBYmIIiK ZA/ZfkDNvzQahC/EhzEMH5KoVl4kvbCovfENN6fOWHjgYuXArm66T6A9Tdyg6Xzx1HWe 9R0W52BwLDNbIvkEgKexC/d95IUPFBCHJ52FfoLIx6qjH09MkuTBR10wJacgbN1oGkq8 IWPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=jU0R+xty; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g13si15602742pgf.431.2017.11.24.08.29.51; Fri, 24 Nov 2017 08:29:51 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=jU0R+xty; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753930AbdKXQ1W (ORCPT + 28 others); Fri, 24 Nov 2017 11:27:22 -0500 Received: from conuserg-11.nifty.com ([210.131.2.78]:61680 "EHLO conuserg-11.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753801AbdKXQ0J (ORCPT ); Fri, 24 Nov 2017 11:26:09 -0500 Received: from grover.sesame (FL1-125-199-20-195.osk.mesh.ad.jp [125.199.20.195]) (authenticated) by conuserg-11.nifty.com with ESMTP id vAOGP9W5007100; Sat, 25 Nov 2017 01:25:25 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-11.nifty.com vAOGP9W5007100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1511540726; bh=ApQOJB4Q/RVkBLUEaPdtl9pL2Yu6plA669hQat+GFwo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jU0R+xtyc1u8sz+c4SOYOcIwiziiKiNw60zmZf2P2Mz7mA4AnNfzBBCMpOc3Lt/wG n/7zshtpcEWFBsXLcheOct6OOgxJNgSro+9pEbNDu/2Lntg4Z0tyACB0ppASryZdNs 2IrsRTXQMUVbd4Ei5jqJVNVAUQjmshB1iDbHw+URT7MCS/QC9u247qtgRKRd5qkrRn Kuw7rB6aoQqmq4Ow/TNdp9JLAC6KkTppJl9O1oYhe86iaEtoj9P/M1VJv/bS+lb21R Gdo6lIpJM9SvR4MfFWlqbsfTITEFnWwhqPp1CE8iDosz3HXnh+ZUWXKelWrI9XFxF3 t/NOLx7S1NFlg== X-Nifty-SrcIP: [125.199.20.195] From: Masahiro Yamada To: linux-mmc@vger.kernel.org, Wolfram Sang Cc: Simon Horman , Yoshihiro Shimoda , linux-renesas-soc@vger.kernel.org, Masahiro Yamada , linux-kernel@vger.kernel.org, Ulf Hansson Subject: [PATCH v2 19/22] mmc: tmio: ioremap memory resource in tmio_mmc_host_alloc() Date: Sat, 25 Nov 2017 01:24:54 +0900 Message-Id: <1511540697-27387-20-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1511540697-27387-1-git-send-email-yamada.masahiro@socionext.com> References: <1511540697-27387-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The register region is ioremap'ed in the tmio_mmc_host_probe(), i.e. drivers cannot get access to the hardware before mmc_add_host(). Actually, renesas_sdhi_core.c reads out the CTL_VERSION register to complete the platform-specific settings. However, at this point, the MMC host is already running. Move the register ioremap to tmio_mmc_host_alloc() so that drivers can perform platform-specific settings between tmio_mmc_host_alloc() and tmio_mmc_host_probe(). I changed tmio_mmc_host_alloc() to return an error pointer to propagate the return code from devm_ioremap_resource(). Signed-off-by: Masahiro Yamada --- Changes in v2: - Newly added drivers/mmc/host/renesas_sdhi_core.c | 4 ++-- drivers/mmc/host/tmio_mmc.c | 4 +++- drivers/mmc/host/tmio_mmc_core.c | 16 +++++++++------- 3 files changed, 14 insertions(+), 10 deletions(-) -- 2.7.4 Reviewed-by: Wolfram Sang diff --git a/drivers/mmc/host/renesas_sdhi_core.c b/drivers/mmc/host/renesas_sdhi_core.c index e78dca7..446ff54 100644 --- a/drivers/mmc/host/renesas_sdhi_core.c +++ b/drivers/mmc/host/renesas_sdhi_core.c @@ -511,8 +511,8 @@ int renesas_sdhi_probe(struct platform_device *pdev, } host = tmio_mmc_host_alloc(pdev); - if (!host) - return -ENOMEM; + if (IS_ERR(host)) + return PTR_ERR(host); if (of_data) { mmc_data->flags |= of_data->tmio_flags; diff --git a/drivers/mmc/host/tmio_mmc.c b/drivers/mmc/host/tmio_mmc.c index ccfbc15..d660816 100644 --- a/drivers/mmc/host/tmio_mmc.c +++ b/drivers/mmc/host/tmio_mmc.c @@ -93,8 +93,10 @@ static int tmio_mmc_probe(struct platform_device *pdev) pdata->flags |= TMIO_MMC_HAVE_HIGH_REG; host = tmio_mmc_host_alloc(pdev); - if (!host) + if (IS_ERR(host)) { + ret = PTR_ERR(host); goto cell_disable; + } /* SD control register space size is 0x200, 0x400 for bus_shift=1 */ host->bus_shift = resource_size(res) >> 10; diff --git a/drivers/mmc/host/tmio_mmc_core.c b/drivers/mmc/host/tmio_mmc_core.c index f5b11b8..c392694 100644 --- a/drivers/mmc/host/tmio_mmc_core.c +++ b/drivers/mmc/host/tmio_mmc_core.c @@ -1165,12 +1165,20 @@ tmio_mmc_host_alloc(struct platform_device *pdev) { struct tmio_mmc_host *host; struct mmc_host *mmc; + struct resource *res; + void __iomem *ctl; + + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + ctl = devm_ioremap_resource(&pdev->dev, res); + if (IS_ERR(ctl)) + return ERR_CAST(ctl); mmc = mmc_alloc_host(sizeof(struct tmio_mmc_host), &pdev->dev); if (!mmc) - return NULL; + return ERR_PTR(-ENOMEM); host = mmc_priv(mmc); + host->ctl = ctl; host->mmc = mmc; host->pdev = pdev; host->ops = tmio_mmc_ops; @@ -1192,7 +1200,6 @@ int tmio_mmc_host_probe(struct tmio_mmc_host *_host, { struct platform_device *pdev = _host->pdev; struct mmc_host *mmc = _host->mmc; - struct resource *res_ctl; int ret; tmio_mmc_of_parse(pdev, pdata); @@ -1200,11 +1207,6 @@ int tmio_mmc_host_probe(struct tmio_mmc_host *_host, if (!(pdata->flags & TMIO_MMC_HAS_IDLE_WAIT)) _host->write16_hook = NULL; - res_ctl = platform_get_resource(pdev, IORESOURCE_MEM, 0); - _host->ctl = devm_ioremap_resource(&pdev->dev, res_ctl); - if (IS_ERR(_host->ctl)) - return PTR_ERR(_host->ctl); - ret = mmc_of_parse(mmc); if (ret < 0) return ret;