From patchwork Tue Oct 13 05:29:53 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiko Schocher X-Patchwork-Id: 7381431 Return-Path: X-Original-To: patchwork-linux-omap@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 D76F29F302 for ; Tue, 13 Oct 2015 05:30:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EE20920985 for ; Tue, 13 Oct 2015 05:30:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0757F20980 for ; Tue, 13 Oct 2015 05:30:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751872AbbJMFaA (ORCPT ); Tue, 13 Oct 2015 01:30:00 -0400 Received: from mail-out.m-online.net ([212.18.0.10]:51102 "EHLO mail-out.m-online.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750926AbbJMF37 (ORCPT ); Tue, 13 Oct 2015 01:29:59 -0400 Received: from frontend02.mail.m-online.net (unknown [192.168.8.183]) by mail-out.m-online.net (Postfix) with ESMTP id 3nZlnJ3VVrz3hp41; Tue, 13 Oct 2015 07:29:56 +0200 (CEST) Received: from localhost (dynscan2.mnet-online.de [192.168.6.69]) by mail.m-online.net (Postfix) with ESMTP id 3nZlnJ22rzzvdWV; Tue, 13 Oct 2015 07:29:56 +0200 (CEST) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.184]) by localhost (dynscan2.mail.m-online.net [192.168.6.69]) (amavisd-new, port 10024) with ESMTP id BtP9BfKo7wu1; Tue, 13 Oct 2015 07:29:54 +0200 (CEST) X-Auth-Info: OvzafAiqsGr3HKnFXgvZsqRfvbYBjkPRmMmEV0OI9bI= Received: from mail-internal.denx.de (host-82-135-33-74.customer.m-online.net [82.135.33.74]) by smtp-auth.mnet-online.de (Postfix) with ESMTPA; Tue, 13 Oct 2015 07:29:54 +0200 (CEST) Received: from pollux.denx.de (pollux [192.168.1.1]) by mail-internal.denx.de (Postfix) with ESMTP id 54D3234332A; Tue, 13 Oct 2015 07:29:54 +0200 (CEST) Received: by pollux.denx.de (Postfix, from userid 515) id 291B5F1FA; Tue, 13 Oct 2015 07:29:54 +0200 (CEST) From: Heiko Schocher To: linux-kernel@vger.kernel.org Cc: Heiko Schocher , Arnd Bergmann , linux-mmc@vger.kernel.org, Dirk Behme , Georg.Soffel@bosch-si.com, linux-omap@vger.kernel.org, Ulf Hansson Subject: [PATCH] mmc: omap_hsmmc: fix initialization order of mmc block devices Date: Tue, 13 Oct 2015 07:29:53 +0200 Message-Id: <1444714193-24816-1-git-send-email-hs@denx.de> X-Mailer: git-send-email 2.1.0 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_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 On embedded devices, often there is 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. Signed-off-by: Heiko Schocher --- Dirk Behme tried to bring this in, last mail I found: http://lists.infradead.org/pipermail/linux-arm-kernel/2012-July/111022.html where Dirk worked in Arnds suggestion to use the "/aliases" device node" I adapt this to the omap_hsmmc driver. Is there another solution for this problem? Or why was this patch not accepted to mainline? drivers/mmc/card/block.c | 6 ++++-- drivers/mmc/host/omap_hsmmc.c | 6 ++++++ include/linux/mmc/host.h | 3 +++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c index c742cfd..62250d8 100644 --- a/drivers/mmc/card/block.c +++ b/drivers/mmc/card/block.c @@ -2106,7 +2106,8 @@ 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); @@ -2124,7 +2125,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/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c index 7fb0753..0b45b48 100644 --- a/drivers/mmc/host/omap_hsmmc.c +++ b/drivers/mmc/host/omap_hsmmc.c @@ -2059,6 +2059,12 @@ static int omap_hsmmc_probe(struct platform_device *pdev) host->pbias_enabled = 0; host->vqmmc_enabled = 0; + if (pdev->dev.of_node) { + ret = of_alias_get_id(pdev->dev.of_node, "mmcblk"); + if (ret >= 0) + host->mmc->devidx = ret; + } + ret = omap_hsmmc_gpio_init(mmc, host, pdata); if (ret) goto err_gpio; diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h index 83b81fd..4f071681 100644 --- a/include/linux/mmc/host.h +++ b/include/linux/mmc/host.h @@ -382,6 +382,9 @@ struct mmc_host { int dsr_req; /* DSR value is valid */ u32 dsr; /* optional driver stage (DSR) value */ + /* preferred mmc block device index (mmcblkX) */ + unsigned int devidx; + unsigned long private[0] ____cacheline_aligned; };