From patchwork Sat Nov 10 00:48:52 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: stepanm@codeaurora.org X-Patchwork-Id: 1722671 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork1.kernel.org (Postfix) with ESMTP id CB0DC3FC8F for ; Sat, 10 Nov 2012 00:51:14 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TWzGC-00066P-FC; Sat, 10 Nov 2012 00:49:20 +0000 Received: from wolverine02.qualcomm.com ([199.106.114.251]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1TWzG8-00065u-FB for linux-arm-kernel@lists.infradead.org; Sat, 10 Nov 2012 00:49:17 +0000 X-IronPort-AV: E=McAfee;i="5400,1158,6891"; a="5753877" Received: from pdmz-ns-snip_115_219.qualcomm.com (HELO mostmsg01.qualcomm.com) ([199.106.115.219]) by wolverine02.qualcomm.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 09 Nov 2012 16:48:56 -0800 Received: from stepanm-linux.qualcomm.com (pdmz-ns-snip_218_1.qualcomm.com [192.168.218.1]) by mostmsg01.qualcomm.com (Postfix) with ESMTPA id 5080010004C4; Fri, 9 Nov 2012 16:48:56 -0800 (PST) From: Stepan Moskovchenko To: Grant Likely , Rob Herring , devicetree-discuss@lists.ozlabs.org Subject: [RFC] dt/platform: Use cell-index for device naming if available Date: Fri, 9 Nov 2012 16:48:52 -0800 Message-Id: <1352508532-19241-1-git-send-email-stepanm@codeaurora.org> X-Mailer: git-send-email 1.7.8.3 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20121109_194916_731559_9091075D X-CRM114-Status: GOOD ( 17.18 ) X-Spam-Score: -1.2 (-) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-1.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- 3.0 KHOP_BIG_TO_CC Sent to 10+ recipients instaed of Bcc or a list -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, medium trust [199.106.114.251 listed in list.dnswl.org] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Russell King , linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Bryan Huntsman , Stepan Moskovchenko , Daniel Walker , David Brown , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Use the cell-index property to construct names for platform devices, falling back on the existing scheme of using the device register address if cell-index is not specified. The cell-index property is a more useful device identifier, especially in systems containing several numbered instances of a particular hardware block, since it more easily illustrates how devices relate to each other. Additionally, userspace software may rely on the classic . naming scheme to access device attributes in sysfs, without having to know the physical addresses of that device on every platform the userspace software may support. Using cell-index for device naming allows the device addresses to be hidden from userspace and to be exposed by logical device number without having to rely on auxdata to perform name overrides. This allows userspace to make assumptions about which sysfs nodes map to which logical instance of a specific hardware block. Signed-off-by: Stepan Moskovchenko --- I had also considered using something like the linux,label property to allow custom names for platform devices without resorting to auxdata, but the cell-index approach seems more in line with what cell-index was intended for and with what the pre-DT platform device naming scheme used to be. Please let me know if you think there is a better way to accomplish this. This is just being sent out as an RFC for now. If there are no objections, I will send this out as an official patch, along with (or combined with) a patch to fix up the device names in things like clock tables of any affected platforms. drivers/of/platform.c | 13 ++++++++++++- 1 files changed, 12 insertions(+), 1 deletions(-) -- The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation diff --git a/drivers/of/platform.c b/drivers/of/platform.c index 343ad29..472e374 100644 --- a/drivers/of/platform.c +++ b/drivers/of/platform.c @@ -77,8 +77,9 @@ void of_device_make_bus_id(struct device *dev) static atomic_t bus_no_reg_magic; struct device_node *node = dev->of_node; const u32 *reg; + u32 cell_index; u64 addr; - int magic; + int magic, ret; #ifdef CONFIG_PPC_DCR /* @@ -101,6 +102,16 @@ void of_device_make_bus_id(struct device *dev) #endif /* CONFIG_PPC_DCR */ /* + * For devices with a specified cell-index, use the traditional + * naming scheme of . + */ + ret = of_property_read_u32(node, "cell-index", &cell_index); + if (ret == 0) { + dev_set_name(dev, "%s.%d", node->name, cell_index); + return; + } + + /* * For MMIO, get the physical address */ reg = of_get_property(node, "reg", NULL);