From patchwork Fri Apr 29 17:32:17 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 8984261 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.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 7443B9F39D for ; Fri, 29 Apr 2016 17:34:10 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9FA8C20155 for ; Fri, 29 Apr 2016 17:34:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B329F20149 for ; Fri, 29 Apr 2016 17:34:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752045AbcD2Rcq (ORCPT ); Fri, 29 Apr 2016 13:32:46 -0400 Received: from mail-pf0-f170.google.com ([209.85.192.170]:34163 "EHLO mail-pf0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752424AbcD2Rcn (ORCPT ); Fri, 29 Apr 2016 13:32:43 -0400 Received: by mail-pf0-f170.google.com with SMTP id y69so50656430pfb.1 for ; Fri, 29 Apr 2016 10:32:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=bWT3rtsmtAFIeeR9HWfwFnEcTijQvE8bL4ZIOJs8CVU=; b=oRYcnKNcSQDx54B3Qo94z40hgFZ8xcYntEV0LtoS1tanFkB8daQ4MFYeR4f6ZDWT3u 4zIG4sK2ZSiNNH3AwKu8OnvBl01rT+/x5aVHoKNADDxR43EWNNyRSjl26CxXjaMutRHP aK1RqYW2j2StIINq5Ox+cbU+SI/4+4Ye+Y7/E= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=bWT3rtsmtAFIeeR9HWfwFnEcTijQvE8bL4ZIOJs8CVU=; b=ZyqP9M0S2oh95QXs08fWjYJfqD22B1h2vHBftM7qEzc8iLUZlow8gCo5P1w2OD0fQ0 d7Hav/VWO1qdcQj8ai/X5x8Mhbcfr2taT11yyZoziKGUwxESQZggIOBNFvim5/YdxZzi 1CZEVQUbLoN5SNHi7AjcOqLhbZ3EBafbT4dYH72kOMayrANpV10c2NWoQmKII9bsvm0B ssmtjDufZKqaOUYF1V2v2mAtX3tQLpPt9dvDywE1ZeI1YLvqD77yU7ch8ygcklF4Jp9J wgx4R69aOTganIlntj9yP4QjcetoFQWg17dLUuJcz2dNmYM7jMGeN9DvCnMXiUmsmao4 07Dg== X-Gm-Message-State: AOPr4FXptXuCCooWOam2uLYiu7LeFJDOZKMM+CghB40Fo4RREsvtSMy6NG6RVyzG3l3j5Q== X-Received: by 10.98.1.197 with SMTP id 188mr30958234pfb.8.1461951162915; Fri, 29 Apr 2016 10:32:42 -0700 (PDT) Received: from tictac.mtv.corp.google.com ([172.22.65.76]) by smtp.gmail.com with ESMTPSA id 19sm24880623pfu.83.2016.04.29.10.32.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 29 Apr 2016 10:32:42 -0700 (PDT) From: Douglas Anderson To: ulf.hansson@linaro.org, jh80.chung@samsung.com Cc: shawn.lin@rock-chips.com, adrian.hunter@intel.com, stefan@agner.ch, linux-mmc@vger.kernel.org, computersforpeace@gmail.com, dmitry.torokhov@gmail.com, Heiko Stuebner , jszhang@marvell.com, linux-rockchip@lists.infradead.org, devicetree-spec@vger.kernel.org, Dmitry Torokhov , Douglas Anderson , vbyravarasu@nvidia.com, kirill.shutemov@linux.intel.com, chaotian.jing@mediatek.com, zhonghui.fu@linux.intel.com, sergei.shtylyov@cogentembedded.com, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/4] mmc: read mmc alias from device tree Date: Fri, 29 Apr 2016 10:32:17 -0700 Message-Id: <1461951139-6109-3-git-send-email-dianders@chromium.org> X-Mailer: git-send-email 2.8.0.rc3.226.g39d4020 In-Reply-To: <1461951139-6109-1-git-send-email-dianders@chromium.org> References: <1461951139-6109-1-git-send-email-dianders@chromium.org> Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,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 From: Stefan Agner To get the SD/MMC host device ID, read the alias from the device tree. This is useful in case a SoC has multipe SD/MMC host controllers while the second controller should logically be the first device (e.g. if the second controller is connected to an internal eMMC). Combined with block device numbering using MMC/SD host device ID, this results in predictable name assignment of the internal eMMC block device. Signed-off-by: Stefan Agner Signed-off-by: Dmitry Torokhov [dianders: rebase + roll in http://crosreview.com/259916] Signed-off-by: Douglas Anderson --- Changes in v2: - Rebased atop mmc-next - Stat dynamic allocation after fixed allocation; thanks Wolfram! drivers/mmc/core/host.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c index e0a3ee16c0d3..e09f1d6207d3 100644 --- a/drivers/mmc/core/host.c +++ b/drivers/mmc/core/host.c @@ -314,11 +314,26 @@ struct mmc_host *mmc_alloc_host(int extra, struct device *dev) { int err; struct mmc_host *host; + int id; host = kzalloc(sizeof(struct mmc_host) + extra, GFP_KERNEL); if (!host) return NULL; + /* If OF aliases exist, start dynamic assignment after highest */ + id = of_alias_get_highest_id("mmc"); + id = (id < 0) ? 0 : id + 1; + + /* If this devices has OF node, maybe it has an alias */ + if (dev->of_node) { + int of_id = of_alias_get_id(dev->of_node, "mmc"); + + if (of_id < 0) + dev_warn(dev, "/aliases ID not available\n"); + else + id = of_id; + } + /* scanning will be enabled when we're ready */ host->rescan_disable = 1; @@ -329,7 +344,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) {