From patchwork Fri Jan 22 01:14:17 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Al Stone X-Patchwork-Id: 60115 Delivered-To: patches@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp336123lbb; Thu, 21 Jan 2016 17:14:44 -0800 (PST) X-Received: by 10.202.83.74 with SMTP id h71mr219148oib.115.1453425284466; Thu, 21 Jan 2016 17:14:44 -0800 (PST) Return-Path: Received: from mail-oi0-x22c.google.com (mail-oi0-x22c.google.com. [2607:f8b0:4003:c06::22c]) by mx.google.com with ESMTPS id f9si3425023oej.97.2016.01.21.17.14.44 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Jan 2016 17:14:44 -0800 (PST) Received-SPF: pass (google.com: domain of al.stone@linaro.org designates 2607:f8b0:4003:c06::22c as permitted sender) client-ip=2607:f8b0:4003:c06::22c; Authentication-Results: mx.google.com; spf=pass (google.com: domain of al.stone@linaro.org designates 2607:f8b0:4003:c06::22c as permitted sender) smtp.mailfrom=al.stone@linaro.org; dkim=pass header.i=@linaro.org Received: by mail-oi0-x22c.google.com with SMTP id k206so38815062oia.1 for ; Thu, 21 Jan 2016 17:14:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=BsWa9oxNHSNoNjGxV8DGxgs7zh6mWzdBYoRf44t8BSA=; b=Q5PPYL6r1WjrNaCwzOnycbPbdjkI8gymnEpBRye0dXfAhUyA7C471VD73dXumAy4b1 yRl1snvBzdr5bAxcMakHEod2wRNWCkoUhjJA3JywDOhOxyQGLytHbizMdAVHVhrKtxr1 z2kkLOFf2q8hVe7/SgaL3HC6yuzb86DkWfsNE= 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=BsWa9oxNHSNoNjGxV8DGxgs7zh6mWzdBYoRf44t8BSA=; b=QyJj1kIG2p9L9AwDt5gEMxV8gSeKqDiTp16shnxSSPxEQ4pMU6NpHHpi+jifhuySrK 9V1kSt3vTt+4oG27b1dGtCB9N/SljSpraQbywqnmYf/R2/AVF+g/FBBsi5j49qHDn926 w6TBo4nd9PtWOtU9uj8UkJxKMiQy7ef/ffgKqTmccuHVzylyXdxegULpL/O3BZWD3y7d M7sLC1QWDoshCyrO0nehRa9pu5MCeamMuXrOGv1BGHjOw7I5wTFoA8r7qz9/22vlkuDx 3Ug9SE2U1uZyDC8B5cMBQHi639E7GjZwJOaTaD570n3V+7wVV9m3NRrYH4EXUxVS01w3 CYLg== X-Gm-Message-State: AG10YOQ91gWt+2xB26lmytW8p7aLg2E+dQ6+sn75iTsu004JMQzT+D//5zXLIbg+dvG4YVi+0P4= X-Received: by 10.202.241.130 with SMTP id p124mr262059oih.58.1453425284165; Thu, 21 Jan 2016 17:14:44 -0800 (PST) Return-Path: Received: from fidelio.ahs3 (c-50-134-239-249.hsd1.co.comcast.net. [50.134.239.249]) by smtp.googlemail.com with ESMTPSA id mj1sm1921252oeb.17.2016.01.21.17.14.42 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 21 Jan 2016 17:14:42 -0800 (PST) From: Al Stone To: fwts-devel@lists.ubuntu.com Cc: linaro-acpi@lists.linaro.org, patches@linaro.org, Al Stone Subject: [PATCH 2/5] utilities: add a helper function for printing out architecture names Date: Thu, 21 Jan 2016 18:14:17 -0700 Message-Id: <1453425260-21576-3-git-send-email-al.stone@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1453425260-21576-1-git-send-email-al.stone@linaro.org> References: <1453425260-21576-1-git-send-email-al.stone@linaro.org> Add in a small helper function that converts the arch enum value to a readable string; this helps with error output. Signed-off-by: Al Stone --- src/lib/include/fwts_arch.h | 1 + src/lib/src/fwts_arch.c | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) -- 2.5.0 diff --git a/src/lib/include/fwts_arch.h b/src/lib/include/fwts_arch.h index 082e5d3..4862da4 100644 --- a/src/lib/include/fwts_arch.h +++ b/src/lib/include/fwts_arch.h @@ -33,5 +33,6 @@ typedef enum { extern fwts_architecture fwts_arch_get_host(void); extern fwts_architecture fwts_arch_get_arch(const char *name); extern const char *fwts_arch_names(void); +extern const char *fwts_arch_get_name(const fwts_architecture arch); #endif diff --git a/src/lib/src/fwts_arch.c b/src/lib/src/fwts_arch.c index 6f37e9f..f5e8b78 100644 --- a/src/lib/src/fwts_arch.c +++ b/src/lib/src/fwts_arch.c @@ -33,6 +33,13 @@ static const struct fwts_arch_info arch_info[] = { { FWTS_ARCH_OTHER, "other" } }; +static const struct fwts_arch_info arch_name[] = { + { FWTS_ARCH_X86, "x86" }, + { FWTS_ARCH_IA64, "ia64" }, + { FWTS_ARCH_ARM64, "arm64" }, + { FWTS_ARCH_OTHER, "other" }, +}; + static char *arch_names; static fwts_architecture __fwts_arch_get_arch(const char *name) @@ -82,3 +89,14 @@ const char *fwts_arch_names(void) return arch_names; } + +const char *fwts_arch_get_name(const fwts_architecture arch) +{ + const struct fwts_arch_info *ptr; + + for (ptr = arch_name; ptr->arch != FWTS_ARCH_OTHER; ptr++) + if (ptr->arch == arch) + break; + + return ptr->name; +}