From patchwork Wed Jul 24 09:09:33 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steffen Trumtrar X-Patchwork-Id: 2832608 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 48F2B9F4E2 for ; Wed, 24 Jul 2013 09:10:15 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8DD0B20264 for ; Wed, 24 Jul 2013 09:10:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 58E522018A for ; Wed, 24 Jul 2013 09:10:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752338Ab3GXJKI (ORCPT ); Wed, 24 Jul 2013 05:10:08 -0400 Received: from metis.ext.pengutronix.de ([92.198.50.35]:56714 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752153Ab3GXJKH (ORCPT ); Wed, 24 Jul 2013 05:10:07 -0400 Received: from dude.hi.pengutronix.de ([2001:6f8:1178:2:21e:67ff:fe11:9c5c]) by metis.ext.pengutronix.de with esmtp (Exim 4.72) (envelope-from ) id 1V1v4t-0006OG-0Q; Wed, 24 Jul 2013 11:09:47 +0200 Received: from str by dude.hi.pengutronix.de with local (Exim 4.80) (envelope-from ) id 1V1v4s-0006BF-Df; Wed, 24 Jul 2013 11:09:46 +0200 From: Steffen Trumtrar To: linux-mmc@vger.kernel.org Cc: Chris Ball , devicetree@vger.kernel.org, kernel@pengutronix.de, Steffen Trumtrar Subject: [RFC 2/2] mmc: host: allow setting index via devicetree Date: Wed, 24 Jul 2013 11:09:33 +0200 Message-Id: <1374656973-16250-3-git-send-email-s.trumtrar@pengutronix.de> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1374656973-16250-1-git-send-email-s.trumtrar@pengutronix.de> References: <1374656973-16250-1-git-send-email-s.trumtrar@pengutronix.de> X-SA-Exim-Connect-IP: 2001:6f8:1178:2:21e:67ff:fe11:9c5c X-SA-Exim-Mail-From: str@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-mmc@vger.kernel.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=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, 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 As with gpio, uart and others, allow specifying the host index via the aliases-node in the devicetree. On embedded devices, there is often a combination of removable (e.g. SD card) and non-removable mmc devices (e.g. eMMC). Therefore the mmcblk name_idx might change depending on - host of removable device - removable card present or not This makes it difficult to hard code the root device, if it is on the non-removable device. E.g. if SD card is present eMMC will be mmcblk1, if SD card is not present at boot, eMMC will be mmcblk0. To match the host index with the mmcblk, allow setting the index via an alias node. Signed-off-by: Steffen Trumtrar --- drivers/mmc/core/host.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c index 6fb6f77..640228f 100644 --- a/drivers/mmc/core/host.c +++ b/drivers/mmc/core/host.c @@ -450,16 +450,21 @@ struct mmc_host *mmc_alloc_host(int extra, struct device *dev) { int err; struct mmc_host *host; + int alias_id; host = kzalloc(sizeof(struct mmc_host) + extra, GFP_KERNEL); if (!host) return NULL; + alias_id = of_alias_get_id(dev->of_node, "mmc"); + if (alias_id < 0) + alias_id = 0; + /* scanning will be enabled when we're ready */ host->rescan_disable = 1; idr_preload(GFP_KERNEL); spin_lock(&mmc_host_lock); - err = idr_alloc(&mmc_host_idr, host, 0, 0, GFP_NOWAIT); + err = idr_alloc(&mmc_host_idr, host, alias_id, 0, GFP_NOWAIT); if (err >= 0) host->index = err; spin_unlock(&mmc_host_lock);