From patchwork Thu Sep 1 09:40:31 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Francois Moine X-Patchwork-Id: 9309019 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 330A460756 for ; Thu, 1 Sep 2016 12:51:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2D99A29331 for ; Thu, 1 Sep 2016 12:51:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2160329386; Thu, 1 Sep 2016 12:51:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=2.0 tests=BAYES_00, DATE_IN_PAST_03_06, FREEMAIL_FROM,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0E4C829383 for ; Thu, 1 Sep 2016 12:51:30 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bfRRI-0006Dz-Bs; Thu, 01 Sep 2016 12:49:52 +0000 Received: from smtp4-g21.free.fr ([212.27.42.4]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bfRR8-0005nR-S1 for linux-arm-kernel@lists.infradead.org; Thu, 01 Sep 2016 12:49:46 +0000 Received: from localhost (unknown [37.166.57.209]) by smtp4-g21.free.fr (Postfix) with ESMTP id 622AC19F5D0; Thu, 1 Sep 2016 14:53:53 +0200 (CEST) X-Mailbox-Line: From 3bd41e1611e4c1af4d8f2141b5244a8d5f4b98fc Mon Sep 17 00:00:00 2001 From: Jean-Francois Moine Date: Thu, 1 Sep 2016 11:40:31 +0200 Subject: [PATCH] mmc: core: Assign a fixed number to MMC devices To: Ulf Hansson , linux-mmc@vger.kernel.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160901_054943_174363_A9568538 X-CRM114-Status: UNSURE ( 9.43 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Message-ID: Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP This patch prevents MMC device numbering to change at each reboot by using DT labels. Signed-off-by: Jean-Francois Moine --- drivers/mmc/core/host.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c index 98f25ff..38b94ce 100644 --- a/drivers/mmc/core/host.c +++ b/drivers/mmc/core/host.c @@ -346,6 +346,14 @@ struct mmc_host *mmc_alloc_host(int extra, struct device *dev) { int err; struct mmc_host *host; + int id = 0; + + /* use DT label as mmc index */ + if (dev->of_node) { + id = of_alias_get_id(dev->of_node, "mmc"); + if (id < 0) + id = 0; + } host = kzalloc(sizeof(struct mmc_host) + extra, GFP_KERNEL); if (!host) @@ -361,7 +369,7 @@ again: } spin_lock(&mmc_host_lock); - err = ida_get_new(&mmc_host_ida, &host->index); + err = ida_get_new_above(&mmc_host_ida, id, &host->index); spin_unlock(&mmc_host_lock); if (err == -EAGAIN) {