From patchwork Mon Mar 6 05:30:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ananth N Mavinakayanahalli X-Patchwork-Id: 735539 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3vc7fZ6SF3z9s7Z for ; Mon, 6 Mar 2017 16:30:30 +1100 (AEDT) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3vc7fZ5cMSzDqXS for ; Mon, 6 Mar 2017 16:30:30 +1100 (AEDT) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3vc7fV28lMzDq5W for ; Mon, 6 Mar 2017 16:30:26 +1100 (AEDT) Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v265T3mg078424 for ; Mon, 6 Mar 2017 00:30:14 -0500 Received: from e28smtp01.in.ibm.com (e28smtp01.in.ibm.com [125.16.236.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 28ytn2ue8g-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 06 Mar 2017 00:30:14 -0500 Received: from localhost by e28smtp01.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 6 Mar 2017 11:00:11 +0530 Received: from d28dlp01.in.ibm.com (9.184.220.126) by e28smtp01.in.ibm.com (192.168.1.131) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 6 Mar 2017 11:00:09 +0530 Received: from d28relay09.in.ibm.com (d28relay09.in.ibm.com [9.184.220.160]) by d28dlp01.in.ibm.com (Postfix) with ESMTP id 0D12AE005F for ; Mon, 6 Mar 2017 11:01:57 +0530 (IST) Received: from d28av01.in.ibm.com (d28av01.in.ibm.com [9.184.220.63]) by d28relay09.in.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v265U8b710289342 for ; Mon, 6 Mar 2017 11:00:08 +0530 Received: from d28av01.in.ibm.com (localhost [127.0.0.1]) by d28av01.in.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id v265U7iY029763 for ; Mon, 6 Mar 2017 11:00:07 +0530 Received: from thinktux.in.ibm.com ([9.109.223.119]) by d28av01.in.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id v265U7xY029747 for ; Mon, 6 Mar 2017 11:00:07 +0530 From: Ananth N Mavinakayanahalli To: skiboot@lists.ozlabs.org Date: Mon, 06 Mar 2017 11:00:07 +0530 In-Reply-To: <148877817960.31016.12409558294342193031.stgit@thinktux.in.ibm.com> References: <148877817960.31016.12409558294342193031.stgit@thinktux.in.ibm.com> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 17030605-7323-0000-0000-000000D211C2 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17030605-7324-0000-0000-000002767138 Message-Id: <148877820242.31016.3052934121546761104.stgit@thinktux.in.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-03-06_05:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=3 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1702020001 definitions=main-1703060048 Subject: [Skiboot] [PATCH V3 2/3] hdata/vpd: Parse additional VINI records X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.23 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" While there, use the helper to add individual records. Signed-off-by: Ananth N Mavinakayanahalli Reviewed-by: Vasant Hegde --- hdata/vpd.c | 99 ++++++++++++++++++++++++++--------------------------------- 1 file changed, 43 insertions(+), 56 deletions(-) diff --git a/hdata/vpd.c b/hdata/vpd.c index 4c787c6..462a7f0 100644 --- a/hdata/vpd.c +++ b/hdata/vpd.c @@ -220,7 +220,8 @@ static const struct card_info *card_info_lookup(char *ccin) { int i; for(i = 0; i < ARRAY_SIZE(card_table); i++) - if (!strcmp(card_table[i].ccin, ccin)) + /* CCIN is always 4 bytes in size */ + if (!strncmp(card_table[i].ccin, ccin, 4)) return &card_table[i]; return NULL; } @@ -229,65 +230,62 @@ static void vpd_vini_parse(struct dt_node *node, const void *fruvpd, unsigned int fruvpd_sz) { const void *kw; - char *str; - uint8_t kwsz; + uint8_t sz; const struct card_info *cinfo; /* FRU Stocking Part Number */ - kw = vpd_find(fruvpd, fruvpd_sz, "VINI", "FN", &kwsz); - if (kw) { - str = zalloc(kwsz + 1); - if (!str) - goto no_memory; - memcpy(str, kw, kwsz); - dt_add_property_string(node, "fru-number", str); - free(str); - } + kw = vpd_find(fruvpd, fruvpd_sz, "VINI", "FN", &sz); + if (kw) + dt_add_property_nstr(node, "fru-number", kw, sz); /* Serial Number */ - kw = vpd_find(fruvpd, fruvpd_sz, "VINI", "SN", &kwsz); - if (kw) { - str = zalloc(kwsz + 1); - if (!str) - goto no_memory; - memcpy(str, kw, kwsz); - dt_add_property_string(node, "serial-number", str); - free(str); - } + kw = vpd_find(fruvpd, fruvpd_sz, "VINI", "SN", &sz); + if (kw) + dt_add_property_nstr(node, "serial-number", kw, sz); /* Part Number */ - kw = vpd_find(fruvpd, fruvpd_sz, "VINI", "PN", &kwsz); - if (kw) { - str = zalloc(kwsz + 1); - if (!str) - goto no_memory; - memcpy(str, kw, kwsz); - dt_add_property_string(node, "part-number", str); - free(str); - } + kw = vpd_find(fruvpd, fruvpd_sz, "VINI", "PN", &sz); + if (kw) + dt_add_property_nstr(node, "part-number", kw, sz); + + /* CCIN Extension */ + kw = vpd_find(fruvpd, fruvpd_sz, "VINI", "CE", &sz); + if (kw) + dt_add_property_nstr(node, "ccin-extension", kw, sz); + + /* HW Version info */ + kw = vpd_find(fruvpd, fruvpd_sz, "VINI", "HW", &sz); + if (kw) + dt_add_property_nstr(node, "hw-version", kw, sz); + + /* Card type info */ + kw = vpd_find(fruvpd, fruvpd_sz, "VINI", "CT", &sz); + if (kw) + dt_add_property_nstr(node, "card-type", kw, sz); + + /* HW characteristics info */ + kw = vpd_find(fruvpd, fruvpd_sz, "VINI", "B3", &sz); + if (kw) + dt_add_property_nstr(node, "hw-characteristics", kw, sz); /* Customer Card Identification Number (CCIN) */ - kw = vpd_find(fruvpd, fruvpd_sz, "VINI", "CC", &kwsz); + kw = vpd_find(fruvpd, fruvpd_sz, "VINI", "CC", &sz); if (kw) { - str = zalloc(kwsz + 1); - if (!str) - goto no_memory; - memcpy(str, kw, kwsz); - dt_add_property_string(node, "ccin", str); - cinfo = card_info_lookup(str); + dt_add_property_nstr(node, "ccin", kw, sz); + + cinfo = card_info_lookup((char *)kw); if (cinfo) { dt_add_property_string(node, "description", cinfo->description); } else { dt_add_property_string(node, "description", "Unknown"); prlog(PR_WARNING, - "VPD: CCIN desc not available for : %s\n", str); + "VPD: CCIN desc not available for: %s\n", + (char *)kw); } - free(str); } + return; -no_memory: - prerror("VPD: memory allocation failure in VINI parsing\n"); } static bool valid_child_entry(const struct slca_entry *entry) @@ -486,17 +484,6 @@ def_model: dt_add_property_string(dt_root, "model-name", model_name); } -static void vpd_add_property_string(struct dt_node *n, const char *name, - const void *vpd, unsigned int sz) -{ - char *str = zalloc(sz + 1); - if (!str) - return; - memcpy(str, vpd, sz); - dt_add_property_string(n, name, str); - free(str); -} - static void sysvpd_parse_opp(const void *sysvpd, unsigned int sysvpd_sz) { const char *v; @@ -504,10 +491,10 @@ static void sysvpd_parse_opp(const void *sysvpd, unsigned int sysvpd_sz) v = vpd_find(sysvpd, sysvpd_sz, "OSYS", "MM", &sz); if (v) - vpd_add_property_string(dt_root, "model", v, sz); + dt_add_property_nstr(dt_root, "model", v, sz); v = vpd_find(sysvpd, sysvpd_sz, "OSYS", "SS", &sz); if (v) - vpd_add_property_string(dt_root, "system-id", v, sz); + dt_add_property_nstr(dt_root, "system-id", v, sz); } @@ -533,13 +520,13 @@ static void sysvpd_parse_legacy(const void *sysvpd, unsigned int sysvpd_sz) system_id = vpd_find(sysvpd, sysvpd_sz, "VSYS", "SE", &sz); if (system_id) - vpd_add_property_string(dt_root, "system-id", system_id, sz); + dt_add_property_nstr(dt_root, "system-id", system_id, sz); else dt_add_property_string(dt_root, "system-id", "Unknown"); brand = vpd_find(sysvpd, sysvpd_sz, "VSYS", "BR", &sz); if (brand) - vpd_add_property_string(dt_root, "system-brand", brand, sz); + dt_add_property_nstr(dt_root, "system-brand", brand, sz); else dt_add_property_string(dt_root, "brand", "Unknown"); }