From patchwork Tue Dec 29 10:31:13 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hongbo Zhang X-Patchwork-Id: 59042 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp2196362lbb; Tue, 29 Dec 2015 02:33:36 -0800 (PST) X-Received: by 10.140.138.69 with SMTP id 66mr82458052qhk.18.1451385216180; Tue, 29 Dec 2015 02:33:36 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id y96si597033qge.18.2015.12.29.02.33.35; Tue, 29 Dec 2015 02:33:36 -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 A61C461707; Tue, 29 Dec 2015 10:33:35 +0000 (UTC) Authentication-Results: lists.linaro.org; dkim=fail reason="verification failed; unprotected key" header.d=linaro.org header.i=@linaro.org header.b=EABUFAU3; 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_H2,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 57267616DF; Tue, 29 Dec 2015 10:31:50 +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 A084A616D6; Tue, 29 Dec 2015 10:31:46 +0000 (UTC) Received: from mail-pf0-f170.google.com (mail-pf0-f170.google.com [209.85.192.170]) by lists.linaro.org (Postfix) with ESMTPS id 38E5F61674 for ; Tue, 29 Dec 2015 10:31:38 +0000 (UTC) Received: by mail-pf0-f170.google.com with SMTP id 65so81253736pff.3 for ; Tue, 29 Dec 2015 02:31:38 -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=EABUFAU3T86gN4vZ+tPNUKl/Jl1Sam9H6MavXpldpa8v/ff/nYaS0wqnlkr3WbS+Pa 1NDpDuFoSz+JI5Fir85YFfrKHGBrk4AE9L46yJ3Xr73ld3p7FDXObHJKC1RW8TvQG5Iy lyERvVujXK7PkcVBUWmI7C4SFWNFLuRDXVOT0= 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=HzIvORHmaZ5rpIlEwEdlbWpF1mtyD3qoFOksEOWGw7YsZ6UzSfBq7dZdrkcMM52o6H UlJLmjjwBOnJOB9Bmo+eX5nTq91uA9vndRACwCBGIVg5xcRZNBPMDN9jzl96CEFSi3VY kzT4usPwbTQ428+kOXNfrE3Bxf4gd0jm6kCiEf+gT4XrgNAr26qgfuJkEXztsucuToIo kVcudNyEndJ0se4OhZ/aw9ZxaxlfSHoIfF29zc4raV4SR/4tD6XYK8Y90NiaX3Gz/mx0 Y9o1zxRqlvGuktuJS63PdUtl0i7uJj1Iz6ztJ6kx+gu2zZrbE4nCUpfLdj/SYvMRLHN0 MxtQ== X-Gm-Message-State: ALoCoQlP4GhHrc8Ufz2LdM3PTwy3XcePMR5oq4WPue7dhPLO8CUKzzQbq87OiOzaK67mPB9bSYIIb4ODC7QbqAS4weR73Z1xcw== X-Received: by 10.98.18.71 with SMTP id a68mr22361236pfj.50.1451385097533; Tue, 29 Dec 2015 02:31:37 -0800 (PST) Received: from ubuntu1504.ap.freescale.net (gate-zmy3.freescale.com. [192.88.167.1]) by smtp.gmail.com with ESMTPSA id 7sm82291757pfb.62.2015.12.29.02.31.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 29 Dec 2015 02:31:37 -0800 (PST) From: hongbo.zhang@linaro.org To: lng-odp@lists.linaro.org Date: Tue, 29 Dec 2015 18:31:13 +0800 Message-Id: <1451385082-8364-3-git-send-email-hongbo.zhang@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1451385082-8364-1-git-send-email-hongbo.zhang@linaro.org> References: <1451385082-8364-1-git-send-email-hongbo.zhang@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCH v3 API-NEXT 02/11] 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);