From patchwork Thu Jan 8 14:12:42 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikhil Devshatwar X-Patchwork-Id: 5593281 Return-Path: X-Original-To: patchwork-linux-omap@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 ACD6ABF6C3 for ; Thu, 8 Jan 2015 14:13:08 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6CC632038D for ; Thu, 8 Jan 2015 14:13:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4704820384 for ; Thu, 8 Jan 2015 14:13:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753676AbbAHONE (ORCPT ); Thu, 8 Jan 2015 09:13:04 -0500 Received: from devils.ext.ti.com ([198.47.26.153]:43043 "EHLO devils.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751391AbbAHONC (ORCPT ); Thu, 8 Jan 2015 09:13:02 -0500 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by devils.ext.ti.com (8.13.7/8.13.7) with ESMTP id t08ED1i2026078; Thu, 8 Jan 2015 08:13:01 -0600 Received: from DFLE72.ent.ti.com (dfle72.ent.ti.com [128.247.5.109]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id t08ED1HQ001083; Thu, 8 Jan 2015 08:13:01 -0600 Received: from dlep32.itg.ti.com (157.170.170.100) by DFLE72.ent.ti.com (128.247.5.109) with Microsoft SMTP Server id 14.3.174.1; Thu, 8 Jan 2015 08:13:00 -0600 Received: from localhost.localdomain (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep32.itg.ti.com (8.14.3/8.13.8) with ESMTP id t08ECwEu009849; Thu, 8 Jan 2015 08:12:59 -0600 From: Nikhil Devshatwar To: , , , CC: Nikhil Devshatwar Subject: [PATCH] dtc: parser: Add label while overriding nodes Date: Thu, 8 Jan 2015 19:42:42 +0530 Message-ID: <1420726362-22555-1-git-send-email-nikhil.nd@ti.com> X-Mailer: git-send-email 1.7.9.5 MIME-Version: 1.0 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@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 Current device tree compiler allows to define multiple labels when defining the device node the first time. Typically device nodes are defined in DTSI files. Now these nodes can be overriden for updating some of the properties. Typically, device nodes are overridden in DTS files. When working with adapter boards, most of the time adapter board can fit to multiple base boards. But depending on which base board it is connected to, the devices on the adapter board would be children of different devices. e.g. On dra7-evm.dts, i2c2 is exported for expansion connector whereas on dra72-evm.dts, i2c5 is exported for expansion connector. This causes a problem when writing a generic device tree file for the adapter board. Because, you cannot know wheather all the devices on adpter board are present on i2c or i2c5. The problem can be solved by adding a common label (e.g. i2cexp) in both of the DTS files when overriding the device nodes for i2c2 or i2c5. This way, generic adapter board file would override the i2cexp. And depending on which base board you use the adpter board, all the devices are automatically added for correct device nodes. Change-Id: I3ad7247a79baed7268a91fc691360aece73d6d1b Signed-off-by: Nikhil Devshatwar --- scripts/dtc/dtc-parser.y | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/scripts/dtc/dtc-parser.y b/scripts/dtc/dtc-parser.y index f412460..d9ed3b7 100644 --- a/scripts/dtc/dtc-parser.y +++ b/scripts/dtc/dtc-parser.y @@ -145,6 +145,18 @@ devicetree: { $$ = merge_nodes($1, $3); } + + | devicetree DT_LABEL DT_REF nodedef + { + struct node *target = get_node_by_ref($1, $3); + + add_label(&target->labels, $2); + if (target) + merge_nodes(target, $4); + else + print_error("label or path, '%s', not found", $2); + $$ = $1; + } | devicetree DT_REF nodedef { struct node *target = get_node_by_ref($1, $2);