From patchwork Fri Oct 2 16:36:53 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Dooks X-Patchwork-Id: 7317481 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 9C2749F1B9 for ; Fri, 2 Oct 2015 16:37:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C4A6620821 for ; Fri, 2 Oct 2015 16:36:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CEFD7206B0 for ; Fri, 2 Oct 2015 16:36:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752002AbbJBQg5 (ORCPT ); Fri, 2 Oct 2015 12:36:57 -0400 Received: from ducie-dc1.codethink.co.uk ([185.25.241.215]:40384 "EHLO ducie-dc1.codethink.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751781AbbJBQg4 (ORCPT ); Fri, 2 Oct 2015 12:36:56 -0400 Received: from localhost (localhost [127.0.0.1]) by ducie-dc1.codethink.co.uk (Postfix) with ESMTP id 2EEE5461898; Fri, 2 Oct 2015 17:36:55 +0100 (BST) X-Virus-Scanned: Debian amavisd-new at ducie-dc1.codethink.co.uk Received: from ducie-dc1.codethink.co.uk ([127.0.0.1]) by localhost (ducie-dc1.codethink.co.uk [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id n-9exG3yxS+M; Fri, 2 Oct 2015 17:36:55 +0100 (BST) Received: from rainbowdash.ducie.codethink.co.uk (unknown [10.24.1.119]) by ducie-dc1.codethink.co.uk (Postfix) with ESMTPS id 0A2BF461874; Fri, 2 Oct 2015 17:36:55 +0100 (BST) Received: from ben by rainbowdash.ducie.codethink.co.uk with local (Exim 4.86) (envelope-from ) id 1Zi3KI-0003UH-RN; Fri, 02 Oct 2015 17:36:54 +0100 From: Ben Dooks To: linux-kernel@lists.codethink.co.uk, ulf.hansson@linaro.org, linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, kejia.hu@codethink.co.uk Cc: devicetree@vger.kernel.org, Ben Dooks Subject: [PATCH] mmc: read alias from device-tree if probing via of. Date: Fri, 2 Oct 2015 17:36:53 +0100 Message-Id: <1443803813-13369-1-git-send-email-ben.dooks@codethink.co.uk> X-Mailer: git-send-email 2.5.3 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, 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 The mmc host controller fails to check for the presence of an aliases entry in the device tree when creating a new mmc host. This means that mmc bus numbers are not as specified in the aliases node. For example, the following on an imx6 would make mmc0 the second sdhci, and mmc2 the first sdhci: aliases { mmc0 = &usdhc2; mmc2 = &usdhc0; } Signed-off-by: Ben Dooks Tested-by: Kejia Hu --- drivers/mmc/core/host.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c index abd933b..3bed4d0 100644 --- a/drivers/mmc/core/host.c +++ b/drivers/mmc/core/host.c @@ -561,7 +561,11 @@ struct mmc_host *mmc_alloc_host(int extra, struct device *dev) 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 = of_alias_get_id(dev->of_node, "mmc"); + if (err >= 0) + err = idr_alloc(&mmc_host_idr, host, err, err+1, GFP_NOWAIT); + if (err < 0) + err = idr_alloc(&mmc_host_idr, host, 0, 0, GFP_NOWAIT); if (err >= 0) host->index = err; spin_unlock(&mmc_host_lock);