From patchwork Tue Mar 29 10:43:34 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jaehoon Chung X-Patchwork-Id: 8685711 Return-Path: X-Original-To: patchwork-linux-mmc@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 2483FC0553 for ; Tue, 29 Mar 2016 10:43:43 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 352262026F for ; Tue, 29 Mar 2016 10:43:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5181820212 for ; Tue, 29 Mar 2016 10:43:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756589AbcC2Knj (ORCPT ); Tue, 29 Mar 2016 06:43:39 -0400 Received: from mailout4.samsung.com ([203.254.224.34]:35211 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751450AbcC2Kni (ORCPT ); Tue, 29 Mar 2016 06:43:38 -0400 Received: from epcpsbgr1.samsung.com (u141.gpu120.samsung.co.kr [203.254.230.141]) by mailout4.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0O4S01IQVR4M01D0@mailout4.samsung.com> for linux-mmc@vger.kernel.org; Tue, 29 Mar 2016 19:43:34 +0900 (KST) Received: from epcpsbgm2new.samsung.com ( [172.20.52.113]) by epcpsbgr1.samsung.com (EPCPMTA) with SMTP id 82.F6.04826.65C5AF65; Tue, 29 Mar 2016 19:43:34 +0900 (KST) X-AuditID: cbfee68d-f79e86d0000012da-40-56fa5c56fa5f Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm2new.samsung.com (EPCPMTA) with SMTP id FB.B9.06699.65C5AF65; Tue, 29 Mar 2016 19:43:34 +0900 (KST) Received: from [10.113.62.216] by mmp2.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0O4S00554R4LRMA0@mmp2.samsung.com>; Tue, 29 Mar 2016 19:43:34 +0900 (KST) Message-id: <56FA5C56.9080009@samsung.com> Date: Tue, 29 Mar 2016 19:43:34 +0900 From: Jaehoon Chung User-Agent: Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-version: 1.0 To: "linux-mmc@vger.kernel.org" Cc: Ulf Hansson , Shawn Lin , Adrian Hunter Subject: [RFC PATCH] mmc: block: Support the fixed index for mmcblk with aliases nodes Content-type: text/plain; charset=utf-8 Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrMLMWRmVeSWpSXmKPExsWyRsSkUDcs5leYwc//OhYnn6xhszjyv5/R 4s6T9awWx9eGO7B4LN7zksnjzrU9bB5/Z+1n8fi8SS6AJYrLJiU1J7MstUjfLoErY+OP50wF t8Uq9qyOamBcL9TFyMkhIWAi0fn1IjuELSZx4d56ti5GLg4hgRWMEr+7eplgiq40rWCHSMxi lPh4fBUThPOAUeLr21dgVbwCWhLb7q9jAbFZBFQlnn06yAxiswnoSGz/dhysRlQgTOLBur2s EPWCEj8m3wOq5+AQEbCWaP4tCxJmFqiUmHRyKxuILSwQIXH75U9WkBJmAXWJKVNyIUrkJTav ecsMcoKEwHR2iY+vV7JCrBWQ+Db5ENhICQFZiU0HmCHul5Q4uOIGywRGkVlIFs9CmDoLydQF jMyrGEVTC5ILipPSiwz1ihNzi0vz0vWS83M3MQLj4vS/Z707GG8fsD7EKMDBqMTDy7DgZ5gQ a2JZcWXuIUZToCMmMkuJJucDoy+vJN7Q2MzIwtTE1NjI3NJMSZxXUepnsJBAemJJanZqakFq UXxRaU5q8SFGJg5OqQZGPeYzPnd/nHD4YfmUISNyBZuemHZK2nML2ScfD7+IeVm9/JXSqo+f TB33vG/mCXeePCOb7cqaWTXqGe19d5vV2rlfX90127p82+ctJXuEVbQnuHwVb9hm3P089/qH pPX8IR1NPpvTDxutv8oQ3atw4sOv5yKPxey/rJbpFj6aUmWm/OlA1dubSizFGYmGWsxFxYkA aGdbSYYCAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrAIsWRmVeSWpSXmKPExsVy+t9jQd2wmF9hBl/f8VqcfLKGzeLI/35G iztP1rNaHF8b7sDisXjPSyaPO9f2sHn8nbWfxePzJrkAlqgGRpuM1MSU1CKF1Lzk/JTMvHRb Je/geOd4UzMDQ11DSwtzJYW8xNxUWyUXnwBdt8wcoJVKCmWJOaVAoYDE4mIlfTtME0JD3HQt YBojdH1DguB6jAzQQMIaxoyNP54zFdwWq9izGuig9UJdjJwcEgImEleaVrBD2GISF+6tZ+ti 5OIQEpjFKPHx+ComCOcBo8TXt6+YQKp4BbQktt1fxwJiswioSjz7dJAZxGYT0JHY/u04WI2o QJjEg3V7WSHqBSV+TL4HVM/BISJgLdH8WxYkzCxQKTHp5FY2EFtYIELi9sufrCAlzALqElOm 5EKUyEtsXvOWeQIj3ywkg2YhVM1CUrWAkXkVo0RqQXJBcVJ6rlFearlecWJucWleul5yfu4m RnDsPZPewXh4l/shRgEORiUeXoYFP8OEWBPLiitzDzFKcDArifAejv4VJsSbklhZlVqUH19U mpNafIjRFOjTicxSosn5wLSQVxJvaGxiZmRpZG5oYWRsriTO+/j/ujAhgfTEktTs1NSC1CKY PiYOTqkGRrlWa4snbX8s2JtXsPYJGCau+MEekiT8ItFNfiVL//NPPW++fX+T4K462Tm+If7B 5Ydhi+paBQM2VdZ6nVrEGeGQ2buo/cthzdIHOnE3F6X4TGPsUVer2syR/ZWj6WPyhdDP4fH/ SzjOehh9SDzcNPFBQ8PUtfKtK0Ranky5yataxnbHOOWEEktxRqKhFnNRcSIAGOMCU9MCAAA= DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected 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.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 This patch is just RFC. I want to know opinions. Now, index of mmcblk is allocated in accordance with probing time. If want to use the mmcblk1 for some device, it can use alias. aliases { mmc0 = &mmc0; /* mmcblk0 for eMMC */ mmc1 = &mmc2; /* mmcblk1 for SD */ mmc2 = &mmc1; /* mmcblk2 for SDIO*/ }; If there are no corresponding values, it might be allocated with existing scheme. Signed-off-by: Jaehoon Chung --- Documentation/devicetree/bindings/mmc/mmc.txt | 11 +++++++++++ drivers/mmc/card/block.c | 17 ++++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/mmc/mmc.txt b/Documentation/devicetree/bindings/mmc/mmc.txt index ed23b9b..e37ea29 100644 --- a/Documentation/devicetree/bindings/mmc/mmc.txt +++ b/Documentation/devicetree/bindings/mmc/mmc.txt @@ -71,6 +71,10 @@ Optional SDIO properties: - wakeup-source: Enables wake up of host system on SDIO IRQ assertion (Legacy property supported: "enable-sdio-wakeup") +Aliases (Optional): +- If you want to use the fixed index for block device like mmcblkX, should be +represented in the aliases node using following format "mmc(X)". +(X is an unique number for the alias.) MMC power sequences: -------------------- @@ -145,3 +149,10 @@ mmc3: mmc@01c12000 { interrupt-names = "host-wake"; }; }; + +Example with aliases nodes: + +aliases { + mmc0 = &mmc0; /* Fixed to mmcblk0 for &mmc0 */ + mmc1 = &mmc2; /* Fixed to mmcblk1 for &mmc2 */ +}; diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c index 3bdbe50..6a40de5 100644 --- a/drivers/mmc/card/block.c +++ b/drivers/mmc/card/block.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include @@ -2190,6 +2191,7 @@ static struct mmc_blk_data *mmc_blk_alloc_req(struct mmc_card *card, { struct mmc_blk_data *md; int devidx, ret; + int idx = 0; devidx = find_first_zero_bit(dev_use, max_devices); if (devidx >= max_devices) @@ -2209,7 +2211,20 @@ static struct mmc_blk_data *mmc_blk_alloc_req(struct mmc_card *card, * index anymore so we keep track of a name index. */ if (!subname) { - md->name_idx = find_first_zero_bit(name_use, max_devices); + if (card->dev.parent->parent->of_node) + idx = of_alias_get_id(card->dev.parent->parent->of_node, + "mmc"); + + if (idx < 0) + md->name_idx = find_first_zero_bit(name_use, + max_devices); + else { + if (test_bit(idx, name_use)) + md->name_idx = find_first_zero_bit(name_use, + max_devices); + else + md->name_idx = (unsigned int)idx; + } __set_bit(md->name_idx, name_use); } else md->name_idx = ((struct mmc_blk_data *)