All of lore.kernel.org
 help / color / mirror / Atom feed
From: Masahiro Yamada <yamada.masahiro@socionext.com>
To: linux-mmc@vger.kernel.org,
	Wolfram Sang <wsa+renesas@sang-engineering.com>
Cc: Simon Horman <simon.horman@netronome.com>,
	Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>,
	linux-renesas-soc@vger.kernel.org,
	Masahiro Yamada <yamada.masahiro@socionext.com>,
	linux-kernel@vger.kernel.org,
	Ulf Hansson <ulf.hansson@linaro.org>
Subject: [PATCH v2 19/22] mmc: tmio: ioremap memory resource in tmio_mmc_host_alloc()
Date: Sat, 25 Nov 2017 01:24:54 +0900	[thread overview]
Message-ID: <1511540697-27387-20-git-send-email-yamada.masahiro@socionext.com> (raw)
In-Reply-To: <1511540697-27387-1-git-send-email-yamada.masahiro@socionext.com>

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 <yamada.masahiro@socionext.com>
---

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(-)

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;
-- 
2.7.4

  parent reply	other threads:[~2017-11-24 16:27 UTC|newest]

Thread overview: 64+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-24 16:24 [PATCH v2 00/22] mmc: tmio: various fixes and cleanups Masahiro Yamada
2017-11-24 16:24 ` [PATCH v2 01/22] mmc: renesas_sdhi: consolidate DMAC CONFIG options Masahiro Yamada
2017-11-24 16:24 ` [PATCH v2 02/22] mmc: renesas_sdhi: remove wrong depends on to enable compile test Masahiro Yamada
2017-11-26  9:02   ` Geert Uytterhoeven
2017-12-04 15:25   ` Wolfram Sang
2017-12-05  4:16     ` Masahiro Yamada
2017-11-24 16:24 ` [PATCH v2 03/22] mmc: renesas_sdhi: remove eprobe jump label Masahiro Yamada
2017-12-04 15:02   ` Wolfram Sang
2017-11-24 16:24 ` [PATCH v2 04/22] mmc: tmio: set tmio_mmc_host to driver data Masahiro Yamada
2017-11-24 16:24 ` [PATCH v2 05/22] mmc: tmio: use devm_ioremap_resource() instead of devm_ioremap() Masahiro Yamada
2017-11-24 16:24 ` [PATCH v2 06/22] mmc: tmio: move mmc_host_ops to struct tmio_mmc_host from static data Masahiro Yamada
2017-11-24 16:24 ` [PATCH v2 07/22] mmc: tmio, renesas_sdhi: set mmc_host_ops hooks directly Masahiro Yamada
2017-11-24 16:24 ` [PATCH v2 08/22] mmc: tmio: move mmc_gpio_request_cd() before mmc_add_host() Masahiro Yamada
2017-12-04 15:14   ` Wolfram Sang
2017-11-24 16:24 ` [PATCH v2 09/22] mmc: tmio: use mmc_can_gpio_cd() instead of checking TMIO_MMC_USE_GPIO_CD Masahiro Yamada
2017-12-04 22:22   ` Wolfram Sang
2018-01-02 12:56   ` Wolfram Sang
2018-01-12  4:06     ` Masahiro Yamada
2018-01-12 14:29   ` Ulf Hansson
2017-11-24 16:24 ` [PATCH v2 10/22] mmc: tmio: support IP-builtin card detection logic Masahiro Yamada
2017-12-04 15:13   ` Wolfram Sang
2017-12-05 15:03     ` Masahiro Yamada
2017-12-05 15:28       ` Wolfram Sang
2018-01-02 12:58   ` Wolfram Sang
2017-11-24 16:24 ` [PATCH v2 11/22] mmc: renesas_sdhi: remove always false condition Masahiro Yamada
2017-12-04 15:04   ` Wolfram Sang
2017-11-24 16:24 ` [PATCH v2 12/22] mmc: tmio,renesas_sdhi: move struct tmio_mmc_dma to renesas_sdhi.h Masahiro Yamada
2017-12-04 15:05   ` Wolfram Sang
2017-11-24 16:24 ` [PATCH v2 13/22] mmc: tmio,renesas_sdhi: move Renesas-specific DMA data " Masahiro Yamada
2017-12-04 15:05   ` Wolfram Sang
2017-11-24 16:24 ` [PATCH v2 14/22] mmc: tmio,renesas_sdhi: move ssc_tappos " Masahiro Yamada
2017-12-04 15:05   ` Wolfram Sang
2017-11-24 16:24 ` [PATCH v2 15/22] mmc: tmio: change bus_shift to unsigned int Masahiro Yamada
2017-12-04 15:05   ` Wolfram Sang
2017-11-24 16:24 ` [PATCH v2 16/22] mmc: tmio: fix never-detected card insertion bug Masahiro Yamada
2018-01-02 13:15   ` Wolfram Sang
2018-01-02 17:13     ` Wolfram Sang
2018-01-05 15:58       ` Masahiro Yamada
2018-01-13 20:59         ` Wolfram Sang
2018-01-17 16:32           ` Masahiro Yamada
2017-11-24 16:24 ` [PATCH v2 17/22] mmc: tmio: move TMIO_MASK_{READOP,WRITEOP} handling to correct place Masahiro Yamada
2018-01-16  8:01   ` Wolfram Sang
2018-01-17 16:45     ` Masahiro Yamada
2017-11-24 16:24 ` [PATCH v2 18/22] mmc: tmio: remove useless TMIO_MASK_CMD handling in tmio_mmc_host_probe() Masahiro Yamada
2018-01-16  9:44   ` Wolfram Sang
2017-11-24 16:24 ` Masahiro Yamada [this message]
2018-01-16  9:44   ` [PATCH v2 19/22] mmc: tmio: ioremap memory resource in tmio_mmc_host_alloc() Wolfram Sang
2017-11-24 16:24 ` [PATCH v2 20/22] mmc: tmio: move clk_enable/disable out of tmio_mmc_host_probe() Masahiro Yamada
2018-01-16 22:42   ` Wolfram Sang
2017-11-24 16:24 ` [PATCH v2 21/22] mmc: tmio: move {tmio_}mmc_of_parse() to tmio_mmc_host_alloc() Masahiro Yamada
2018-01-16 22:42   ` Wolfram Sang
2017-11-24 16:24 ` [PATCH v2 22/22] mmc: tmio: remove dma_ops from tmio_mmc_host_probe() argument Masahiro Yamada
2018-01-16 22:43   ` Wolfram Sang
2017-11-27 17:13 ` [PATCH v2 00/22] mmc: tmio: various fixes and cleanups Wolfram Sang
2017-11-28  2:18   ` Masahiro Yamada
2017-12-15  9:18 ` Ulf Hansson
2017-12-15 10:08   ` Masahiro Yamada
2017-12-15 11:12     ` Wolfram Sang
2017-12-15 13:34       ` Ulf Hansson
2017-12-15 16:30         ` Wolfram Sang
2017-12-15 16:34           ` Ulf Hansson
2017-12-15 19:08             ` Wolfram Sang
2017-12-19  3:56   ` Masahiro Yamada
2017-12-19  7:54     ` Ulf Hansson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1511540697-27387-20-git-send-email-yamada.masahiro@socionext.com \
    --to=yamada.masahiro@socionext.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=simon.horman@netronome.com \
    --cc=ulf.hansson@linaro.org \
    --cc=wsa+renesas@sang-engineering.com \
    --cc=yoshihiro.shimoda.uh@renesas.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.