From patchwork Wed Feb 18 11:33:21 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Khoronzhuk X-Patchwork-Id: 44759 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-we0-f198.google.com (mail-we0-f198.google.com [74.125.82.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id BD88621544 for ; Wed, 18 Feb 2015 11:35:25 +0000 (UTC) Received: by wesu56 with SMTP id u56sf411416wes.1 for ; Wed, 18 Feb 2015 03:35:25 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=MVF5AOebAvwppYL5VspPqD1HoCwrCzs8AEpAgg5TN90=; b=WSAOtjeveJwN3TgiItCcVrcWOar7ricm6DQ80ioIt1Fsq2jf5el3DIeMw3L7D8MvYF TJd+I4ajM6a10HxHv5ZlVXC2y7HrmWLjXb3sSpW7ECncuexKAUl3WyjvBJJ5fpNxKhvQ rWdeCd8DddojMlrBPzorvI5ySbUb7CUr+lRJcH5u2Kcdp0jQWXbNNMN4zN8mhV5/NWFB F5m2t0fmvqT2ngFy/RJRZnNgys68vAvyvjyxQL8FIq1je4fMpL0+bv/qjEjsPJo5yP8n BSsWC9e7IguwHfIxn7dt79KKroyamviYaElt37hKKThkkXF2rq28MtCgbiU3nojxyLfd kAsQ== X-Gm-Message-State: ALoCoQlu2SUxEtKIOhP+X5P1UQOZnjrDXfeghKFPL8oRl+XR56WQwzCZTcV2gTuCD9VIj3r8prlS X-Received: by 10.181.29.66 with SMTP id ju2mr278153wid.1.1424259325080; Wed, 18 Feb 2015 03:35:25 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.206.104 with SMTP id ln8ls4010lac.94.gmail; Wed, 18 Feb 2015 03:35:24 -0800 (PST) X-Received: by 10.153.11.130 with SMTP id ei2mr24650952lad.53.1424259324718; Wed, 18 Feb 2015 03:35:24 -0800 (PST) Received: from mail-la0-f53.google.com (mail-la0-f53.google.com. [209.85.215.53]) by mx.google.com with ESMTPS id o7si12918258lag.165.2015.02.18.03.35.24 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 18 Feb 2015 03:35:24 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.53 as permitted sender) client-ip=209.85.215.53; Received: by labpn19 with SMTP id pn19so521103lab.4 for ; Wed, 18 Feb 2015 03:35:24 -0800 (PST) X-Received: by 10.152.116.18 with SMTP id js18mr32511646lab.106.1424259324629; Wed, 18 Feb 2015 03:35:24 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.35.133 with SMTP id h5csp2792962lbj; Wed, 18 Feb 2015 03:35:23 -0800 (PST) X-Received: by 10.66.186.110 with SMTP id fj14mr56592020pac.98.1424259322515; Wed, 18 Feb 2015 03:35:22 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a2si2545354pdf.154.2015.02.18.03.35.21; Wed, 18 Feb 2015 03:35:22 -0800 (PST) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752567AbbBRLdp (ORCPT + 28 others); Wed, 18 Feb 2015 06:33:45 -0500 Received: from mail-lb0-f173.google.com ([209.85.217.173]:37057 "EHLO mail-lb0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751595AbbBRLdm (ORCPT ); Wed, 18 Feb 2015 06:33:42 -0500 Received: by lbvn10 with SMTP id n10so511450lbv.4 for ; Wed, 18 Feb 2015 03:33:40 -0800 (PST) X-Received: by 10.152.23.42 with SMTP id j10mr33075027laf.104.1424259220644; Wed, 18 Feb 2015 03:33:40 -0800 (PST) Received: from khorivan.itg.ti.com (32-55-93-178.pool.ukrtel.net. [178.93.55.32]) by mx.google.com with ESMTPSA id w16sm4149125lbk.20.2015.02.18.03.33.38 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 18 Feb 2015 03:33:39 -0800 (PST) From: Ivan Khoronzhuk To: matt.fleming@intel.com, ard.biesheuvel@linaro.org Cc: leif.lindholm@linaro.org, linux-kernel@vger.kernel.org, Ivan Khoronzhuk Subject: [Patch v2 3/3] firmware: dmi_scan: use direct access to static vars Date: Wed, 18 Feb 2015 13:33:21 +0200 Message-Id: <1424259201-24886-4-git-send-email-ivan.khoronzhuk@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1424259201-24886-1-git-send-email-ivan.khoronzhuk@linaro.org> References: <1424259201-24886-1-git-send-email-ivan.khoronzhuk@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ivan.khoronzhuk@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.53 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , There is no reason to pass static vars to function that can use only them. The dmi_table() can use only dmi_len and dmi_num static vars, so use them directly. In this case we can freely change their type in one place and slightly decrease redundancy. Signed-off-by: Ivan Khoronzhuk --- drivers/firmware/dmi_scan.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c index 3f3470f..8c065f7 100644 --- a/drivers/firmware/dmi_scan.c +++ b/drivers/firmware/dmi_scan.c @@ -18,6 +18,8 @@ static const char dmi_empty_string[] = " "; static u32 dmi_ver __initdata; +static u32 dmi_len; +static u16 dmi_num; /* * Catch too early calls to dmi_check_system(): */ @@ -78,7 +80,7 @@ static const char * __init dmi_string(const struct dmi_header *dm, u8 s) * We have to be cautious here. We have seen BIOSes with DMI pointers * pointing to completely the wrong place for example */ -static void dmi_table(u8 *buf, u32 len, int num, +static void dmi_table(u8 *buf, void (*decode)(const struct dmi_header *, void *), void *private_data) { @@ -89,7 +91,8 @@ static void dmi_table(u8 *buf, u32 len, int num, * Stop when we see all the items the table claimed to have * OR we run off the end of the table (also happens) */ - while ((i < num) && (data - buf + sizeof(struct dmi_header)) <= len) { + while ((i < dmi_num) && (data - buf + sizeof(struct dmi_header)) + <= dmi_len) { const struct dmi_header *dm = (const struct dmi_header *)data; /* @@ -98,9 +101,9 @@ static void dmi_table(u8 *buf, u32 len, int num, * table in dmi_decode or dmi_string */ data += dm->length; - while ((data - buf < len - 1) && (data[0] || data[1])) + while ((data - buf < dmi_len - 1) && (data[0] || data[1])) data++; - if (data - buf < len - 1) + if (data - buf < dmi_len - 1) decode(dm, private_data); /* @@ -117,8 +120,6 @@ static void dmi_table(u8 *buf, u32 len, int num, static u8 smbios_header[32]; static int smbios_header_size; static phys_addr_t dmi_base; -static u32 dmi_len; -static u16 dmi_num; static int __init dmi_walk_early(void (*decode)(const struct dmi_header *, void *)) @@ -129,7 +130,7 @@ static int __init dmi_walk_early(void (*decode)(const struct dmi_header *, if (buf == NULL) return -1; - dmi_table(buf, dmi_len, dmi_num, decode, NULL); + dmi_table(buf, decode, NULL); add_device_randomness(buf, dmi_len); @@ -913,7 +914,7 @@ int dmi_walk(void (*decode)(const struct dmi_header *, void *), if (buf == NULL) return -1; - dmi_table(buf, dmi_len, dmi_num, decode, private_data); + dmi_table(buf, decode, private_data); dmi_unmap(buf); return 0;