From patchwork Wed Jul 23 12:55:16 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 372922 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 5D0E3140174 for ; Wed, 23 Jul 2014 22:59:40 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id D061EA755E; Wed, 23 Jul 2014 14:58:50 +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 u98IFfq4BoEv; Wed, 23 Jul 2014 14:58:50 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 0BFC64A021; Wed, 23 Jul 2014 14:56:43 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 49F5FA7425 for ; Wed, 23 Jul 2014 14:56:16 +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 hXSQiHy1o80E for ; Wed, 23 Jul 2014 14:56:15 +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-yh0-f74.google.com (mail-yh0-f74.google.com [209.85.213.74]) by theia.denx.de (Postfix) with ESMTPS id 3DE68A7558 for ; Wed, 23 Jul 2014 14:55:56 +0200 (CEST) Received: by mail-yh0-f74.google.com with SMTP id 29so199351yhl.1 for ; Wed, 23 Jul 2014 05:55:55 -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=ixdoj+6xzKUyVP16zzdR0rWwbG65g8saPHfNVar/a1M=; b=WeQ/29VLYgPR4FnW0iaO9y5T2qCKDMCKqAHcLdzyONuLujC//1T1zgH80mi8iDpbJ6 f9hOmk+JzgRQ4Z/H+XTyE6oB9iMwYoeyH1fLs6lcWLUzUq9kdWOVb+5DME8ThwwihVPJ zCWGbrFYL91VBsX0RFS4WekYn3+FWodpUdOfmPnkvZ/fcT3LpODqTJHAGI7ly+o0VQsu 7muAbqFCJ5zLutZuYLfv7QLj58o94vOoKA7dDj6IKkORrkubwvsCLmLHWoa3c70V0l3L xyTWxdjgxkgibS0tc2383bF2KQCMFLAbCjJDplgJXUxLNQRr4hDqE3luPr0cnUD2EuA5 reTA== X-Gm-Message-State: ALoCoQk/s4phmzObYWXIVdcpEJFXA84PJmwVcZ3OlTS3Ml7yiDfRLS7ZTOh8WmNp1UqSYICghmeX X-Received: by 10.236.98.33 with SMTP id u21mr16821603yhf.39.1406120155139; Wed, 23 Jul 2014 05:55:55 -0700 (PDT) Received: from corp2gmr1-1.hot.corp.google.com (corp2gmr1-1.hot.corp.google.com [172.24.189.92]) by gmr-mx.google.com with ESMTPS id v44si391357yhv.0.2014.07.23.05.55.55 for (version=TLSv1.1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 23 Jul 2014 05:55:55 -0700 (PDT) Received: from kaki.bld.corp.google.com (kaki.bld.corp.google.com [172.29.216.32]) by corp2gmr1-1.hot.corp.google.com (Postfix) with ESMTP id 04C9D31C269; Wed, 23 Jul 2014 05:55:55 -0700 (PDT) Received: by kaki.bld.corp.google.com (Postfix, from userid 121222) id B612C2209D4; Wed, 23 Jul 2014 06:55:54 -0600 (MDT) From: Simon Glass To: U-Boot Mailing List Date: Wed, 23 Jul 2014 06:55:16 -0600 Message-Id: <1406120124-9373-22-git-send-email-sjg@chromium.org> X-Mailer: git-send-email 2.0.0.526.g5318336 In-Reply-To: <1406120124-9373-1-git-send-email-sjg@chromium.org> References: <1406120124-9373-1-git-send-email-sjg@chromium.org> Cc: Jerry Van Baren Subject: [U-Boot] [PATCH v3 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 v3: None 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 f96b0d3..5f88938 100644 --- a/include/fdtdec.h +++ b/include/fdtdec.h @@ -365,6 +365,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 3f3ed4e..c2f3645 100644 --- a/lib/fdtdec.c +++ b/lib/fdtdec.c @@ -367,6 +367,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) { /*