From patchwork Fri Oct 14 06:01:30 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stewart Smith X-Patchwork-Id: 682132 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 3swH7F5cQCz9ryk for ; Fri, 14 Oct 2016 17:02:17 +1100 (AEDT) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3swH7F50mwzDt3t for ; Fri, 14 Oct 2016 17:02:17 +1100 (AEDT) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (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 3swH6g53wNzDt2c for ; Fri, 14 Oct 2016 17:01:47 +1100 (AEDT) Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.17/8.16.0.17) with SMTP id u9E5xTcd103360 for ; Fri, 14 Oct 2016 02:01:45 -0400 Received: from e17.ny.us.ibm.com (e17.ny.us.ibm.com [129.33.205.207]) by mx0a-001b2d01.pphosted.com with ESMTP id 262jts66jb-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Fri, 14 Oct 2016 02:01:45 -0400 Received: from localhost by e17.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 14 Oct 2016 02:01:44 -0400 Received: from d01dlp01.pok.ibm.com (9.56.250.166) by e17.ny.us.ibm.com (146.89.104.204) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 14 Oct 2016 02:01:41 -0400 Received: from b01cxnp23034.gho.pok.ibm.com (b01cxnp23034.gho.pok.ibm.com [9.57.198.29]) by d01dlp01.pok.ibm.com (Postfix) with ESMTP id 87DB538C8054; Fri, 14 Oct 2016 02:01:40 -0400 (EDT) Received: from b01ledav001.gho.pok.ibm.com (b01ledav001.gho.pok.ibm.com [9.57.199.106]) by b01cxnp23034.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u9E61enF15073668; Fri, 14 Oct 2016 06:01:40 GMT Received: from b01ledav001.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 93F2328046; Fri, 14 Oct 2016 02:01:40 -0400 (EDT) Received: from birb.localdomain (unknown [9.81.213.224]) by b01ledav001.gho.pok.ibm.com (Postfix) with SMTP id 818B52803A; Fri, 14 Oct 2016 02:01:39 -0400 (EDT) Received: from ka1.ozlabs.ibm.com (localhost.localdomain [127.0.0.1]) by birb.localdomain (Postfix) with ESMTP id 62A3D229DB2C; Fri, 14 Oct 2016 17:01:35 +1100 (AEDT) From: Stewart Smith To: skiboot@lists.ozlabs.org Date: Fri, 14 Oct 2016 17:01:30 +1100 X-Mailer: git-send-email 2.1.4 In-Reply-To: <1476424893-7292-1-git-send-email-stewart@linux.vnet.ibm.com> References: <1476424893-7292-1-git-send-email-stewart@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16101406-0040-0000-0000-00000196587B X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00005908; HX=3.00000240; KW=3.00000007; PH=3.00000004; SC=3.00000186; SDB=6.00768163; UDB=6.00367652; IPR=6.00544304; BA=6.00004807; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00012985; XFM=3.00000011; UTC=2016-10-14 06:01:42 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16101406-0041-0000-0000-0000058959DB Message-Id: <1476424893-7292-3-git-send-email-stewart@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-10-14_01:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1609300000 definitions=main-1610140105 Subject: [Skiboot] [PATCH 2/5] nvram: add nvram_query_eq() 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: , MIME-Version: 1.0 Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" From: Oliver O'Halloran Adds a helper that looks for the given NVRAM config string and checks that associated value is equal to the supplied value. Signed-off-by: Oliver O'Halloran Signed-off-by: Stewart Smith --- core/nvram-format.c | 11 +++++++++++ include/nvram.h | 1 + 2 files changed, 12 insertions(+) diff --git a/core/nvram-format.c b/core/nvram-format.c index b98aee1430ff..b110d804ffb7 100644 --- a/core/nvram-format.c +++ b/core/nvram-format.c @@ -262,3 +262,14 @@ const char *nvram_query(const char *key) return NULL; } + + +bool nvram_query_eq(const char *key, const char *value) +{ + const char *s = nvram_query(key); + + if (!s) + return false; + + return !strcmp(s, value); +} diff --git a/include/nvram.h b/include/nvram.h index d87561d79397..288b536827b5 100644 --- a/include/nvram.h +++ b/include/nvram.h @@ -23,5 +23,6 @@ void nvram_reinit(void); bool nvram_validate(void); const char *nvram_query(const char *name); +bool nvram_query_eq(const char *key, const char *value); #endif /* __NVRAM_H */