From patchwork Wed Sep 28 04:56:30 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver O'Halloran X-Patchwork-Id: 675950 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 AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3skQRb506jz9s4x for ; Wed, 28 Sep 2016 14:57:15 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=wKfE1LO7; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3skQRb3tj7zDrYf for ; Wed, 28 Sep 2016 14:57:15 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=wKfE1LO7; dkim-atps=neutral X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Received: from mail-pf0-x243.google.com (mail-pf0-x243.google.com [IPv6:2607:f8b0:400e:c00::243]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3skQR61TsbzDrX7 for ; Wed, 28 Sep 2016 14:56:50 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=wKfE1LO7; dkim-atps=neutral Received: by mail-pf0-x243.google.com with SMTP id 21so1618750pfy.1 for ; Tue, 27 Sep 2016 21:56:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ce6nv5t2JxKpTu85hfghgtGRGijr7PXMitI8UMDYdXg=; b=wKfE1LO7EmM5935QUANrA0LAvLsTRx2yNCkoHczRWc1SPdtoj0BGlCBr5LqUtpv++S /XbnDQmxLwHP9apVJqoulpx5Knb3UjxUk8BtSOuE4EGBO4Tb1VB1xwm3l7Ariq4emsfh DgkJgrQb3portj2a+/9wYh3z35We3pfMh/AxYANR9RUCYFMh4/fNfrbVqE7moOIrWB2A PUZQt1cAFfxbiNpRH/wyJhyD7zeoaWHNn4fOB6G8ytaPZQ7qVqVEfax4Ce6wkfgPP20P xJpWeIFInKYpEjcDn02Y1B0/g9upmLHxcjBaY7pDrQURSQ6nMoAihTVmGU2s3Si+RpkE FJVQ== 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=ce6nv5t2JxKpTu85hfghgtGRGijr7PXMitI8UMDYdXg=; b=dM89I/iVC0YMUyMsITXLbtjPgtTGlMTO2iRxQcmSULG8O95mqPhLC8uFJJbCIdXNgg j2detv/+q+gvRHCPrvguX7AWuP4KSbXLFiS9qS1L844T3+TPy/JxKZfjKcwGwP0rP3DG OYFjgLElTAU64UXDWFQ1bRZkgSBdeI8sd6E2+D1zgohpp5G1nNIh9wKzo6mdBGB/rfcX evy1FKKdiHaPw64OtyiPhDiPKmbTcgtESOfZX3abmRsvsyggTJI8slFE5ghK/4DPHl6G EeSwKH/V+iK8tMTGw3Hox5WZWrPQkqCbzSSBgq/b8KjfnnKZptt5VCRy8DhjAmjckOE7 3n7A== X-Gm-Message-State: AE9vXwPzBd18by5ASK8OVAgT73757w8TmQ5JscRvosgA3K3T28Zms4tZPuPMLiCiPH2wNw== X-Received: by 10.98.85.198 with SMTP id j189mr53542432pfb.123.1475038608662; Tue, 27 Sep 2016 21:56:48 -0700 (PDT) Received: from canetoad.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id g14sm8433832pfb.77.2016.09.27.21.56.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Sep 2016 21:56:48 -0700 (PDT) From: Oliver O'Halloran To: skiboot@lists.ozlabs.org Date: Wed, 28 Sep 2016 14:56:30 +1000 Message-Id: <1475038592-24094-2-git-send-email-oohall@gmail.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1475038592-24094-1-git-send-email-oohall@gmail.com> References: <1475038592-24094-1-git-send-email-oohall@gmail.com> Subject: [Skiboot] [PATCH 2/4] 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" 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 --- 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 */