From patchwork Fri Dec 25 08:29:56 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hongbo Zhang X-Patchwork-Id: 58992 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp213359lbb; Fri, 25 Dec 2015 00:31:34 -0800 (PST) X-Received: by 10.50.110.33 with SMTP id hx1mr2977470igb.59.1451032293992; Fri, 25 Dec 2015 00:31:33 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id m8si13347363igx.42.2015.12.25.00.31.33; Fri, 25 Dec 2015 00:31:33 -0800 (PST) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dkim=neutral (body hash did not verify) header.i=@linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 5B176616E6; Fri, 25 Dec 2015 08:31:33 +0000 (UTC) Authentication-Results: lists.linaro.org; dkim=fail reason="verification failed; unprotected key" header.d=linaro.org header.i=@linaro.org header.b=fYhoxxnh; dkim-adsp=none (unprotected policy); dkim-atps=neutral X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 62388616AF; Fri, 25 Dec 2015 08:30:48 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 39AF6616DD; Fri, 25 Dec 2015 08:30:44 +0000 (UTC) Received: from mail-pa0-f49.google.com (mail-pa0-f49.google.com [209.85.220.49]) by lists.linaro.org (Postfix) with ESMTPS id DA3AF616AF for ; Fri, 25 Dec 2015 08:30:19 +0000 (UTC) Received: by mail-pa0-f49.google.com with SMTP id cy9so76121152pac.0 for ; Fri, 25 Dec 2015 00:30:19 -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=NG43jjUpW/Rtsdz6utOny0flNVKYhv44tx245L+u6+U=; b=fYhoxxnhxxrokMISQ9Ds/xgREbQ/npiH9PYPdJGJXXbt8PwMidSil43bAIA3bVReZL bztZpMibU2CXnC/MqCSm+kBAH6Wx6PhfmY1zHlfkQNmz8iLG/MaMaCKBlNaktrP2YBJn uxXTS5vXAHr1ZXbbFf9T2z1jMTtL9vj2syqqA= 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=NG43jjUpW/Rtsdz6utOny0flNVKYhv44tx245L+u6+U=; b=OqImbJecbLax07EVmZVP3+MpRxwuQVcN5DlJ/vI2H8f/dOJwXcvVHPlLr4K38nBq2+ 2jX6wmgm9S7gg4jjhSwzMEIwjqzllGoKSmuqvP1tDYWnBMVciXwByCvqJvS0l8rTmcQT 8dQtDbEjd+WbGnFGf1JI5VB8X/kCPpc7zx/xeL+m1wGtFJQamg+QsL2NNhP6fIe81MMK oHzGpvPcANKF/K6NdzsXcCN+44Z/gWtQSkoJtFIqeXQGgIpSebp34zpO0Gmi5xsFhlcE c2C7JeZ9u27/FTB8qayJ6HXcUsQ1k3DrDEE/HF+RdMaSfNTslYDI3khlxklHgC41sebZ ukrA== X-Gm-Message-State: ALoCoQkEFi2Ta38v/L2SoMk7w8J/sg/731nEUsb9cMfJt6gRXEgTVWuMFvJcB9b6XHn4qXiyNohM50NM6wQf16EarjenoP9rrg== X-Received: by 10.66.148.99 with SMTP id tr3mr57603063pab.19.1451032219090; Fri, 25 Dec 2015 00:30:19 -0800 (PST) Received: from ubuntu1504.ap.freescale.net (gate-zmy3.freescale.com. [192.88.167.1]) by smtp.gmail.com with ESMTPSA id p80sm33503452pfi.12.2015.12.25.00.30.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 25 Dec 2015 00:30:18 -0800 (PST) From: hongbo.zhang@linaro.org To: lng-odp@lists.linaro.org Date: Fri, 25 Dec 2015 16:29:56 +0800 Message-Id: <1451032201-19954-3-git-send-email-hongbo.zhang@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1451032201-19954-1-git-send-email-hongbo.zhang@linaro.org> References: <1451032201-19954-1-git-send-email-hongbo.zhang@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCH API-NEXT 2/7] linux-generic: sysinfo: use uniform call odp_sysinfo_parser X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" From: Hongbo Zhang It is common way that the general top layer calls a uniform interface to initialize data structrure for different plarform, this patch introduces odp_sysinfo_parser() instead of using different interfaces for each platform, and also removes using structure odp_compiler_info_t since both members inside it become useless now. This is still another pre-step for separating platform specific codes into their own arch files. Signed-off-by: Hongbo Zhang --- platform/linux-generic/odp_system_info.c | 34 +++++--------------------------- 1 file changed, 5 insertions(+), 29 deletions(-) diff --git a/platform/linux-generic/odp_system_info.c b/platform/linux-generic/odp_system_info.c index 8cbdd58..a829b01 100644 --- a/platform/linux-generic/odp_system_info.c +++ b/platform/linux-generic/odp_system_info.c @@ -24,12 +24,6 @@ #include - -typedef struct { - int (*cpuinfo_parser)(FILE *file, odp_system_info_t *sysinfo); - -} odp_compiler_info_t; - #define CACHE_LNSZ_FILE \ "/sys/devices/system/cpu/cpu0/cache/index0/coherency_line_size" @@ -116,7 +110,7 @@ static int huge_page_size(void) */ #if defined __x86_64__ || defined __i386__ -static int cpuinfo_x86(FILE *file, odp_system_info_t *sysinfo) +static int odp_cpuinfo_parser(FILE *file, odp_system_info_t *sysinfo) { char str[1024]; char *pos; @@ -180,7 +174,7 @@ static uint64_t arch_cpu_hz_current(int id) #elif defined __arm__ || defined __aarch64__ -static int cpuinfo_arm(FILE *file ODP_UNUSED, +static int odp_cpuinfo_parser(FILE *file ODP_UNUSED, odp_system_info_t *sysinfo ODP_UNUSED) { return 0; @@ -193,7 +187,7 @@ static uint64_t arch_cpu_hz_current(int id ODP_UNUSED) #elif defined __OCTEON__ -static int cpuinfo_octeon(FILE *file, odp_system_info_t *sysinfo) +static int odp_cpuinfo_parser(FILE *file, odp_system_info_t *sysinfo) { char str[1024]; char *pos; @@ -239,7 +233,7 @@ static uint64_t arch_cpu_hz_current(int id ODP_UNUSED) } #elif defined __powerpc__ -static int cpuinfo_powerpc(FILE *file, odp_system_info_t *sysinfo) +static int odp_cpuinfo_parser(FILE *file, odp_system_info_t *sysinfo) { char str[1024]; char *pos; @@ -288,24 +282,6 @@ static uint64_t arch_cpu_hz_current(int id ODP_UNUSED) #error GCC target not found #endif -static odp_compiler_info_t compiler_info = { - #if defined __x86_64__ || defined __i386__ - .cpuinfo_parser = cpuinfo_x86 - - #elif defined __arm__ || defined __aarch64__ - .cpuinfo_parser = cpuinfo_arm - - #elif defined __OCTEON__ - .cpuinfo_parser = cpuinfo_octeon - - #elif defined __powerpc__ - .cpuinfo_parser = cpuinfo_powerpc - - #else - #error GCC target not found - #endif -}; - #if defined __x86_64__ || defined __i386__ || defined __OCTEON__ || \ defined __powerpc__ @@ -397,7 +373,7 @@ int odp_system_info_init(void) return -1; } - compiler_info.cpuinfo_parser(file, &odp_global_data.system_info); + odp_cpuinfo_parser(file, &odp_global_data.system_info); fclose(file);