From patchwork Wed Jul 9 03:38:11 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 368060 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 56D5A140087 for ; Wed, 9 Jul 2014 13:40:04 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 2EFBFB3795; Wed, 9 Jul 2014 05:40:01 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id aNmLMjFebkuF; Wed, 9 Jul 2014 05:40:00 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 9DFD1A74C1; Wed, 9 Jul 2014 05:39:08 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 7404BA747F for ; Wed, 9 Jul 2014 05:39:04 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id WR1ph-wTCBmH for ; Wed, 9 Jul 2014 05:39:01 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-ob0-f202.google.com (mail-ob0-f202.google.com [209.85.214.202]) by theia.denx.de (Postfix) with ESMTPS id 0AF09AB57C for ; Wed, 9 Jul 2014 05:38:58 +0200 (CEST) Received: by mail-ob0-f202.google.com with SMTP id va2so1480835obc.3 for ; Tue, 08 Jul 2014 20:38:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=F5+q52rOsg+xnY33jFQygn+rRy8GpkK8eLk9APxIJws=; b=ezwDwat4YSvb9QFwGW85Sg2lkj3h8dd88MvQ+SUNtZvREhGr8frDRsamSP1Rc45qkB IISmTm82s+eHkG3a2LyIASyEZ8hLAorw5I1I/pIgR/KFS71JeiqHfXZLcQV9nINIpEFI jlpI2Yc2prcPw7kC6iihAetEJLmi01LWFlvnDXVLTO6kgX21BEvY6vUltfxsxY3eIs5F dKXCewFTckXm08Zv8+WijZWoraCBtINHUn2DtSOZfpg4cAFllGsFuy76TTFMvtPei9ms 3N0Uwi3JQGufTVUtnqPSnJdaaaNsvexpJPtCkzqMaq24wkloLgZ7DnF46yLz8pBtDXBd LfoA== X-Gm-Message-State: ALoCoQnwyCLEooi+PyvM7TQRTISsg4N6ID/p6Q3Kdijxm7X1BVZXVGMMxrH2Vmts8XdrmqJw2d+h X-Received: by 10.182.43.196 with SMTP id y4mr17826673obl.35.1404877137215; Tue, 08 Jul 2014 20:38:57 -0700 (PDT) Received: from corp2gmr1-2.hot.corp.google.com (corp2gmr1-2.hot.corp.google.com [172.24.189.93]) by gmr-mx.google.com with ESMTPS id o69si2680723yhp.6.2014.07.08.20.38.57 for (version=TLSv1.1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 08 Jul 2014 20:38:57 -0700 (PDT) Received: from kaki.bld.corp.google.com (kaki.bld.corp.google.com [172.29.216.32]) by corp2gmr1-2.hot.corp.google.com (Postfix) with ESMTP id 0EB185A4ADE; Tue, 8 Jul 2014 20:38:57 -0700 (PDT) Received: by kaki.bld.corp.google.com (Postfix, from userid 121222) id AD0C8220ADC; Tue, 8 Jul 2014 21:38:56 -0600 (MDT) From: Simon Glass To: U-Boot Mailing List Date: Tue, 8 Jul 2014 21:38:11 -0600 Message-Id: <1404877099-7314-22-git-send-email-sjg@chromium.org> X-Mailer: git-send-email 2.0.0.526.g5318336 In-Reply-To: <1404877099-7314-1-git-send-email-sjg@chromium.org> References: <1404877099-7314-1-git-send-email-sjg@chromium.org> Cc: Jerry Van Baren Subject: [U-Boot] [PATCH v2 21/29] fdt: Add a function to get the node offset of an alias X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de This simple function returns the node offset of a named alias. Signed-off-by: Simon Glass --- Changes in v2: None include/fdtdec.h | 11 +++++++++++ lib/fdtdec.c | 15 +++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/include/fdtdec.h b/include/fdtdec.h index f454f7e..856e6cf 100644 --- a/include/fdtdec.h +++ b/include/fdtdec.h @@ -363,6 +363,17 @@ int fdtdec_add_aliases_for_id(const void *blob, const char *name, int fdtdec_get_alias_seq(const void *blob, const char *base, int node, int *seqp); +/** + * Get the offset of the given alias node + * + * This looks up an alias in /aliases then finds the offset of that node. + * + * @param blob Device tree blob (if NULL, then error is returned) + * @param name Alias name, e.g. "console" + * @return Node offset referred to by that alias, or -ve FDT_ERR_... + */ +int fdtdec_get_alias_node(const void *blob, const char *name); + /* * Get the name for a compatible ID * diff --git a/lib/fdtdec.c b/lib/fdtdec.c index 1b4ae9f..eb5aa20 100644 --- a/lib/fdtdec.c +++ b/lib/fdtdec.c @@ -365,6 +365,21 @@ int fdtdec_get_alias_seq(const void *blob, const char *base, int offset, return -ENOENT; } +int fdtdec_get_alias_node(const void *blob, const char *name) +{ + const char *prop; + int alias_node; + int len; + + if (!blob) + return -FDT_ERR_NOTFOUND; + alias_node = fdt_path_offset(blob, "/aliases"); + prop = fdt_getprop(blob, alias_node, name, &len); + if (!prop) + return -FDT_ERR_NOTFOUND; + return fdt_path_offset(blob, prop); +} + int fdtdec_check_fdt(void) { /*