From patchwork Mon Sep 23 02:38:17 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabio Estevam X-Patchwork-Id: 2925961 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.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id BC1A29F288 for ; Mon, 23 Sep 2013 02:38:44 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D990820494 for ; Mon, 23 Sep 2013 02:38:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8B9B720532 for ; Mon, 23 Sep 2013 02:38:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753256Ab3IWCie (ORCPT ); Sun, 22 Sep 2013 22:38:34 -0400 Received: from mail-yh0-f47.google.com ([209.85.213.47]:47800 "EHLO mail-yh0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753252Ab3IWCib (ORCPT ); Sun, 22 Sep 2013 22:38:31 -0400 Received: by mail-yh0-f47.google.com with SMTP id l109so1113957yhq.6 for ; Sun, 22 Sep 2013 19:38:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=fgrD887Zuai8XkCoK89VQYgWwOGmjRfAXxcjle0vCXE=; b=yAofqUbM01GwBmEjCaUYclUQAx0Zp0rc9zb04wHpLjWOClLOtohkzmodLvlZuOlkX8 b61ES6w7wFSXLqDaJabKHBTZcIj9AB0U3dDTr2pQRFSnCb/y4uepYJdZVG5vOLFXS7ti d06otctv1aCciO5b6xMyYlkBSBnmapJTm2xJXQXzYizIM3dSAJYKLEe4y8ISdMfWxN6l 4MrM8D5TQawv6FzzWWOYqhv7UFRqx2l3EghJQqu0pIOBfW+JzeIHaC1anDEUrPorXsbt IjbtrIVlD9RFYJwBG2Gll7/v6PmN7chkzlMk0EuKIkh4n78GOmuwX/OfWW+SFEq8WKpM flJw== X-Received: by 10.236.142.210 with SMTP id i58mr12401803yhj.33.1379903910824; Sun, 22 Sep 2013 19:38:30 -0700 (PDT) Received: from localhost.localdomain ([201.82.207.210]) by mx.google.com with ESMTPSA id u52sm33979204yhg.5.1969.12.31.16.00.00 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 22 Sep 2013 19:38:30 -0700 (PDT) From: Fabio Estevam To: cjb@laptop.org Cc: dirk.behme@gmail.com, kernel@pengutronix.de, shawn.guo@linaro.org, linux-mmc@vger.kernel.org, swarren@wwwdotorg.org, arnd@arndb.de, devicetree-discuss@lists.ozlabs.org, Fabio Estevam , Dirk Behme Subject: [PATCH] mmc: sdhci-esdhc-imx: Allow the usage of mmc aliases Date: Sun, 22 Sep 2013 23:38:17 -0300 Message-Id: <1379903897-16019-1-git-send-email-festevam@gmail.com> X-Mailer: git-send-email 1.8.1.2 Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Spam-Status: No, score=-9.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham 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 From: Fabio Estevam On embedded devices, there is often a combination of removable mmc devices (e.g. MMC/SD cards) and hard wired ones (e.g. eMMC). Depending on the hardware configuration, the 'mmcblkN' node might change if the removable device is available or not at boot time. E.g. if the removable device is attached at boot time, it might become mmxblk0. And the hard wired one mmcblk1. But if the removable device isn't there at boot time, the hard wired one will become mmcblk0. This makes it somehow difficult to hard code the root device to the non-removable device and boot fast. Allow the sdhci-esdhc-imx driver to retrieve the mmc aliases, so that we can map via the device tree which mmcblk corresponds to the rootfs. Signed-off-by: Dirk Behme Signed-off-by: Fabio Estevam --- drivers/mmc/card/block.c | 5 +++-- drivers/mmc/host/sdhci-esdhc-imx.c | 10 +++++++++- include/linux/mmc/host.h | 2 ++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c index 1a3163f..94f842b 100644 --- a/drivers/mmc/card/block.c +++ b/drivers/mmc/card/block.c @@ -2026,7 +2026,7 @@ static struct mmc_blk_data *mmc_blk_alloc_req(struct mmc_card *card, struct mmc_blk_data *md; int devidx, ret; - devidx = find_first_zero_bit(dev_use, max_devices); + devidx = find_next_zero_bit(dev_use, max_devices, card->host->devidx); if (devidx >= max_devices) return ERR_PTR(-ENOSPC); __set_bit(devidx, dev_use); @@ -2044,7 +2044,8 @@ static struct mmc_blk_data *mmc_blk_alloc_req(struct mmc_card *card, * index anymore so we keep track of a name index. */ if (!subname) { - md->name_idx = find_first_zero_bit(name_use, max_devices); + md->name_idx = find_next_zero_bit(name_use, max_devices, + card->host->devidx); __set_bit(md->name_idx, name_use); } else md->name_idx = ((struct mmc_blk_data *) diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c index abc8cf0..e11a6af 100644 --- a/drivers/mmc/host/sdhci-esdhc-imx.c +++ b/drivers/mmc/host/sdhci-esdhc-imx.c @@ -524,8 +524,9 @@ static int sdhci_esdhc_imx_probe(struct platform_device *pdev) struct sdhci_pltfm_host *pltfm_host; struct sdhci_host *host; struct esdhc_platform_data *boarddata; - int err; + int err, ret; struct pltfm_imx_data *imx_data; + struct device_node *np = pdev->dev.of_node; host = sdhci_pltfm_init(pdev, &sdhci_esdhc_imx_pdata, 0); if (IS_ERR(host)) @@ -602,6 +603,13 @@ static int sdhci_esdhc_imx_probe(struct platform_device *pdev) host->mmc->parent->platform_data); } + + if (np) { + ret = of_alias_get_id(np, "mmcblk"); + if (ret >= 0) + host->mmc->devidx = ret; + } + /* write_protect */ if (boarddata->wp_type == ESDHC_WP_GPIO) { err = mmc_gpio_request_ro(host->mmc, boarddata->wp_gpio); diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h index 3b0c33a..8209f72 100644 --- a/include/linux/mmc/host.h +++ b/include/linux/mmc/host.h @@ -362,6 +362,8 @@ struct mmc_host { unsigned int slotno; /* used for sdio acpi binding */ + /* preferred mmc block device index (mmcblkX) */ + unsigned int devidx; unsigned long private[0] ____cacheline_aligned; };