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: 8984191 Return-Path: X-Original-To: patchwork-linux-rockchip@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 2F226BF29F for ; Fri, 29 Apr 2016 17:33:15 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 30DFF201CE for ; Fri, 29 Apr 2016 17:33:14 +0000 (UTC) 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.kernel.org (Postfix) with ESMTPS id E07DA201ED for ; Fri, 29 Apr 2016 17:33:12 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1awCHw-0003zx-Lw; Fri, 29 Apr 2016 17:33:12 +0000 Received: from mail-pf0-x229.google.com ([2607:f8b0:400e:c00::229]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1awCHn-0003nG-QC for linux-rockchip@lists.infradead.org; Fri, 29 Apr 2016 17:33:04 +0000 Received: by mail-pf0-x229.google.com with SMTP id 77so18145617pfv.2 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=h22hKu2kc0jU7PiT/74ju18efCWaa0H/9Hrkpn0tQrlTD1REMmO4n9jFOYstlAkBtg JRx7HpZWi1qOeDkR73eR7XDxiY1KWMjZ0tA4XIN/QGHh/H8WtK5VYm3AgSriTtDn5Hw3 fu1SuCiYvJjPAHOqp9uUyPwfDOpd+wRklU0v8BCe8wXXmakCcBLhxbwCUmL01Abs1ZRk KTM9YisYffVuHbStwrV5r+UdwvusCZmlfaNrFKDsHUnB8PNl2F9uNZTOP7rt+MBg57cX ddDZYMHY3Ujk0W9syZyapjIdKXj+tkhuVsTCEZSbB8iJwB/Djyz/ftlige0s+is3gSDB t4bg== X-Gm-Message-State: AOPr4FWzp7rhJGzp1Dk14tTyePik2uJTQ87Al1OagWNvjfildOL2nD6k3GRZk44PJTk81Q== 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 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160429_103303_879256_AEBC6059 X-CRM114-Status: GOOD ( 13.94 ) X-Spam-Score: -2.7 (--) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jszhang@marvell.com, Heiko Stuebner , sergei.shtylyov@cogentembedded.com, devicetree-spec@vger.kernel.org, linux-kernel@vger.kernel.org, shawn.lin@rock-chips.com, dmitry.torokhov@gmail.com, linux-mmc@vger.kernel.org, adrian.hunter@intel.com, stefan@agner.ch, Douglas Anderson , vbyravarasu@nvidia.com, linux-rockchip@lists.infradead.org, chaotian.jing@mediatek.com, computersforpeace@gmail.com, Dmitry Torokhov , zhonghui.fu@linux.intel.com, kirill.shutemov@linux.intel.com MIME-Version: 1.0 Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-5.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,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: 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) {