From patchwork Sun Dec 21 18:30:24 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neelesh Gupta X-Patchwork-Id: 423194 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 5C1501400A0 for ; Mon, 22 Dec 2014 05:32:25 +1100 (AEDT) Received: from ozlabs.org (ozlabs.org [103.22.144.67]) by lists.ozlabs.org (Postfix) with ESMTP id 4D3CC1A0198 for ; Mon, 22 Dec 2014 05:32:25 +1100 (AEDT) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Received: from e23smtp08.au.ibm.com (e23smtp08.au.ibm.com [202.81.31.141]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id C25921A0147 for ; Mon, 22 Dec 2014 05:32:21 +1100 (AEDT) Received: from /spool/local by e23smtp08.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 22 Dec 2014 04:32:20 +1000 Received: from d23dlp02.au.ibm.com (202.81.31.213) by e23smtp08.au.ibm.com (202.81.31.205) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 22 Dec 2014 04:32:19 +1000 Received: from d23relay06.au.ibm.com (d23relay06.au.ibm.com [9.185.63.219]) by d23dlp02.au.ibm.com (Postfix) with ESMTP id B2B942BB005D for ; Mon, 22 Dec 2014 05:32:18 +1100 (EST) Received: from d23av02.au.ibm.com (d23av02.au.ibm.com [9.190.235.138]) by d23relay06.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id sBLIWIbR13893760 for ; Mon, 22 Dec 2014 05:32:18 +1100 Received: from d23av02.au.ibm.com (localhost [127.0.0.1]) by d23av02.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id sBLIWHnN030302 for ; Mon, 22 Dec 2014 05:32:18 +1100 Received: from [192.168.1.2] ([9.80.67.85]) by d23av02.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id sBLIWE4c030286; Mon, 22 Dec 2014 05:32:16 +1100 To: skiboot@lists.ozlabs.org, dipankar@in.ibm.com, ananth@in.ibm.com, benh@kernel.crashing.org From: Neelesh Gupta Date: Mon, 22 Dec 2014 00:00:24 +0530 Message-ID: <20141221183016.7062.67759.stgit@ZyXEL0> In-Reply-To: <20141221182235.7062.868.stgit@ZyXEL0> References: <20141221182235.7062.868.stgit@ZyXEL0> User-Agent: StGit/0.16 MIME-Version: 1.0 X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 14122118-0029-0000-0000-000000DDA0DB Subject: [Skiboot] [PATCH v1 2/3] hdata/slca: Function to return the slca root entry X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" Add a new function that returns the slca root entry. Signed-off-by: Neelesh Gupta --- hdata/hdata.h | 1 + hdata/slca.c | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/hdata/hdata.h b/hdata/hdata.h index 79cc576..329c4a8 100644 --- a/hdata/hdata.h +++ b/hdata/hdata.h @@ -43,6 +43,7 @@ extern const struct slca_entry *slca_get_entry(uint16_t slca_index); extern const char *slca_get_vpd_name(uint16_t slca_index); extern const char *slca_get_loc_code_index(uint16_t slca_index); extern void slca_vpd_add_loc_code(struct dt_node *node, uint16_t slca_index); +extern const struct slca_entry *slca_get_root_entry(uint16_t slca_index); extern bool hservices_from_hdat(const void *fdt, size_t size); diff --git a/hdata/slca.c b/hdata/slca.c index a709aaa..48303bb 100644 --- a/hdata/slca.c +++ b/hdata/slca.c @@ -87,3 +87,19 @@ void slca_vpd_add_loc_code(struct dt_node *node, uint16_t slca_index) strncpy(loc_code, fru_loc_code, LOC_CODE_SIZE); dt_add_property(node, "ibm,loc-code", loc_code, strlen(loc_code) + 1); } + +const struct slca_entry *slca_get_root_entry(uint16_t slca_index) +{ + const struct slca_entry *s_entry; + + s_entry = slca_get_entry(slca_index); + if (!s_entry) { + printf("SLCA: Entry %d bad idata\n", slca_index); + return NULL; + } + + while (s_entry->parent_index) + s_entry = slca_get_entry(s_entry->parent_index); + + return s_entry; +}