From patchwork Wed Jan 17 16:28:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 124858 Delivered-To: patch@linaro.org Received: by 10.46.62.1 with SMTP id l1csp108099lja; Wed, 17 Jan 2018 08:43:14 -0800 (PST) X-Google-Smtp-Source: ACJfBoslrW/H012M9j/Pgy45NNe5ls2VJdW7w03j6sgSo0MZxuWirCLDdO4FgLexhTy0eY6zqaKl X-Received: by 10.159.218.144 with SMTP id w16mr32805692plp.237.1516207394619; Wed, 17 Jan 2018 08:43:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516207394; cv=none; d=google.com; s=arc-20160816; b=NSmWq8jpe8P0Uq5YRNJ0gkdB0ZNc9ekH5nki6MKO0x3ZAfsRN/1aIHLVQbIz5IRqyY anVDWoA+bQJ40J93ZUkhqSozBY4iaEmEPrONyQa/UEJKIku/k+DVoGZDxrNjyoj1z8mY LPRYwK9hmNANRNeYc2TS5psLLRyvX2AXMm/drbajJi3I60iHgLJFhU/AtF7iV5YpCg7E RsveTE8Jz44cTyEcv7lkK+8bIaH6TXxmXjXTJQMMZzHdM5QFvZb86sht84UVOn4F/mhG K506Fr7xUvI5tUvzMiVspb7qgZq3D7r3BgCGcQrIQprTr6Xcr67J+ztD561yxlHBI3y6 QOxw== 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=8ZKN06Tx6Un4pYaU/SYoEBgmcA2aNqX3LW/g+/BsHSc=; b=xT0ABp2ZvG/6Enxgd/e9vt7glUgUOes48usEf+vC0Hrfv/9Rm4ASEYZgHdAPBHkEJs WYQkpBesP3EUrV0p0EZBGIry9tYe4gAex/XZUdyJUdeZbCCIVIh43AR4kp4WZCcChZB/ le1NW7Lc8rplCQQ8hxZ4RlHNe/PHcrU+IKrKgQL4LjrSqUQRrsk/i0fYTDYQuKEa9u7u ZzLVi9NLZ5YGvbc8MIHqe011ckZnzi1ftER6VgySIMGy9BXXQyY84EPYWdSI32GMy3Dm C1AC69ipTFEtfj6aYmUWvDumRq+65b67At9BEZG/35lkcQ4+EcG8Jj/VCZ3CzbFR6c7J UM3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=iaXxa4/X; 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 s15si4153362pgf.99.2018.01.17.08.43.14; Wed, 17 Jan 2018 08:43:14 -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=iaXxa4/X; 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 S932113AbeAQQmf (ORCPT + 28 others); Wed, 17 Jan 2018 11:42:35 -0500 Received: from conuserg-08.nifty.com ([210.131.2.75]:36683 "EHLO conuserg-08.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753810AbeAQQ3d (ORCPT ); Wed, 17 Jan 2018 11:29:33 -0500 Received: from grover.sesame (FL1-125-199-20-195.osk.mesh.ad.jp [125.199.20.195]) (authenticated) by conuserg-08.nifty.com with ESMTP id w0HGSIKl014790; Thu, 18 Jan 2018 01:28:20 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-08.nifty.com w0HGSIKl014790 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1516206501; bh=8ZKN06Tx6Un4pYaU/SYoEBgmcA2aNqX3LW/g+/BsHSc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iaXxa4/X9TZlZWG8R9cGAmaGJt+9/9aEm3uVAIHe0leiYmGiJTIQQBlI1NsZwNF8v tcRUT3bARY4DCPqpc8+CCz5N1pIfurOcQfD1ygXzOO/H9wuH+LR4Aa/6ggDKEitu68 fi9xitetosMLiRkPU/lOA+VNWWl9R9kW8Tms3zpHHT0eS95gHkEq0ELLce26QOhCS7 bJ822Wwy6pDj26KzNXh4cPxJ97e0+DRit6VtegpONIJVN+8y77Dn64tD/3QgfrAgWv /L9LVhNEAhfq0A+NHLxreOTEDuZrFQT5lzYsxuJWjZyHNCke8usK/ODDo2WlSYL64c BMKFrT46DZ56A== X-Nifty-SrcIP: [125.199.20.195] From: Masahiro Yamada To: linux-mmc@vger.kernel.org, Wolfram Sang Cc: Ulf Magnusson , Geert Uytterhoeven , Simon Horman , Yoshihiro Shimoda , linux-renesas-soc@vger.kernel.org, Masahiro Yamada , linux-kernel@vger.kernel.org, Ulf Hansson Subject: [PATCH v3 01/16] mmc: tmio: ioremap memory resource in tmio_mmc_host_alloc() Date: Thu, 18 Jan 2018 01:28:01 +0900 Message-Id: <1516206496-16612-2-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1516206496-16612-1-git-send-email-yamada.masahiro@socionext.com> References: <1516206496-16612-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 Reviewed-by: Wolfram Sang --- Changes in v3: None Changes in v2: None 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 diff --git a/drivers/mmc/host/renesas_sdhi_core.c b/drivers/mmc/host/renesas_sdhi_core.c index 6a2988b..ccdde27 100644 --- a/drivers/mmc/host/renesas_sdhi_core.c +++ b/drivers/mmc/host/renesas_sdhi_core.c @@ -512,8 +512,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 610f26f..5f0f12a 100644 --- a/drivers/mmc/host/tmio_mmc_core.c +++ b/drivers/mmc/host/tmio_mmc_core.c @@ -1150,12 +1150,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; @@ -1177,7 +1185,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; u32 irq_mask = TMIO_MASK_CMD; @@ -1186,11 +1193,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;