From patchwork Tue Feb 9 23:12:54 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Al Stone X-Patchwork-Id: 61604 Delivered-To: patches@linaro.org Received: by 10.112.43.199 with SMTP id y7csp2323809lbl; Tue, 9 Feb 2016 15:13:18 -0800 (PST) X-Received: by 10.182.105.197 with SMTP id go5mr33911940obb.12.1455059598435; Tue, 09 Feb 2016 15:13:18 -0800 (PST) Return-Path: Received: from mail-ob0-x22c.google.com (mail-ob0-x22c.google.com. [2607:f8b0:4003:c01::22c]) by mx.google.com with ESMTPS id ny9si215549oeb.27.2016.02.09.15.13.18 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Feb 2016 15:13:18 -0800 (PST) Received-SPF: pass (google.com: domain of al.stone@linaro.org designates 2607:f8b0:4003:c01::22c as permitted sender) client-ip=2607:f8b0:4003:c01::22c; Authentication-Results: mx.google.com; spf=pass (google.com: domain of al.stone@linaro.org designates 2607:f8b0:4003:c01::22c as permitted sender) smtp.mailfrom=al.stone@linaro.org; dkim=pass header.i=@linaro.org Received: by mail-ob0-x22c.google.com with SMTP id xk3so3714809obc.2 for ; Tue, 09 Feb 2016 15:13:18 -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=bwq9AHPjbci28EwdiWC9giR93cQ0J6PJrszrbQZFQY1ajweMQ5VlplXwHgPCEJSAiz aZb2KTKPYagq/h9t9LSpmm1zyrF7ZVDGEQSz/QrvcWxEOCT5n97ABLbyAhb4GJCxzjpe hr3q9jYIrGgfVp5VXAVIvW54Vibz77GXAZfJU= 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=G087ML8cvaJOKsqHPax2cc4MuFHuV/K/DzRs1BOxTr+R+JojLQOudRBhvf5BlA7jE1 +tgt3E/cJzkAfJT8X7GF0hdlL5mYxzzDn+QUCrdM4mZWMNzThp1wDN9t48fyww3HnXkA v27D/P8DIGFhwIu9eEHhRjurJ1JSYrZAX7Mdp5xX0hXUyXt+nbUY/3HwCX8kaRZi9tiF bAjvY8xX27G+lO2VZoiFbNW5LFXNHye7sItNz4mqPtKW71yWbFo+5PMy9OjeS+rgfYAI zd21EBuJo69jqfMKiyehZKgRunb8QHtz6jlujPs+DLcoNHf4gXO3/guh8AqZm/KJOCB/ EXcQ== X-Gm-Message-State: AG10YOS0SvVFxa6gE5QXkTY1v/PJ9wGqP51OqF/0h0DVOEZYnH2ipOPqRjvfMsOLtKbdsPXXL88= X-Received: by 10.182.19.164 with SMTP id g4mr34040308obe.15.1455059598157; Tue, 09 Feb 2016 15:13:18 -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 q8sm203282oep.2.2016.02.09.15.13.16 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 09 Feb 2016 15:13:17 -0800 (PST) From: Al Stone To: fwts-devel@lists.ubuntu.com Cc: linaro-acpi@lists.linaro.org, patches@linaro.org, Al Stone Subject: [PATCH v2 2/5] utilities: add a helper function for printing out architecture names Date: Tue, 9 Feb 2016 16:12:54 -0700 Message-Id: <1455059577-7100-3-git-send-email-al.stone@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1455059577-7100-1-git-send-email-al.stone@linaro.org> References: <1455059577-7100-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; +}