From patchwork Mon Jun 8 09:14:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen-Yu Tsai X-Patchwork-Id: 11593205 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 40CC6138C for ; Mon, 8 Jun 2020 12:01:37 +0000 (UTC) Received: from web01.groups.io (web01.groups.io [66.175.222.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BCFB72072F for ; Mon, 8 Jun 2020 12:01:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=lists.cip-project.org header.i=@lists.cip-project.org header.b="UJOH2QWA" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BCFB72072F Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=csie.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=bounce+64572+4761+4520428+8129116@lists.cip-project.org X-Received: by 127.0.0.2 with SMTP id NDDoYY4521763xIe8KZa8l71; Mon, 08 Jun 2020 05:01:36 -0700 X-Received: from wens.tw (wens.tw [140.112.30.76]) by mx.groups.io with SMTP id smtpd.web12.26181.1591607691140632371 for ; Mon, 08 Jun 2020 02:14:51 -0700 X-Received: by wens.tw (Postfix, from userid 1000) id 1BC746016E; Mon, 8 Jun 2020 17:14:44 +0800 (CST) From: "Chen-Yu Tsai (Moxa)" To: nobuhiro1.iwamatsu@toshiba.co.jp, pavel@denx.de Cc: cip-dev@lists.cip-project.org, JohnsonCH.Chen@moxa.com Subject: [cip-dev] [PATCH 4.4.y-cip v2 14/15] cpufreq-dt: fix handling regulator_get_voltage() result Date: Mon, 8 Jun 2020 17:14:31 +0800 Message-Id: <20200608091432.15366-15-wens@csie.org> In-Reply-To: <20200608091432.15366-1-wens@csie.org> References: <20200608091432.15366-1-wens@csie.org> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: cip-dev@lists.cip-project.org List-Id: Mailing-List: list cip-dev@lists.cip-project.org; contact cip-dev+owner@lists.cip-project.org Delivered-To: mailing list cip-dev@lists.cip-project.org Reply-To: cip-dev@lists.cip-project.org X-Gm-Message-State: GFAqqGdy0QN9jdAtyYgtsW9Wx4520428AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=lists.cip-project.org; q=dns/txt; s=20140610; t=1591617696; bh=+97tebu5p/Vl6KwFQcWeRiuSzd4+FV/fR24cEra3B/w=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=UJOH2QWAYF7d8kN0gwLfcnF4cdTEG91S11Xb0/tgLR8BbDMAPqptaf8MShq7GEx2edi mgAEmseDVRZfuShfpm0c6d6SVHT5ONT27WdDArLmP4LLYHNOWlT7G/U7xA1rd6BlAmoDn 06jHB1aaIzZX/B+teLcxXwoz1zKm2zUmwBg= From: Andrzej Hajda commit 929ca89c305a6ed7a4149115be99af6d73c36918 upstream. The function can return negative values so it should be assigned to signed type. The problem has been detected using proposed semantic patch scripts/coccinelle/tests/unsigned_lesser_than_zero.cocci. Link: http://permalink.gmane.org/gmane.linux.kernel/2038576 Signed-off-by: Andrzej Hajda Acked-by: Viresh Kumar Signed-off-by: Rafael J. Wysocki Signed-off-by: Chen-Yu Tsai (Moxa) --- drivers/cpufreq/cpufreq-dt.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/cpufreq/cpufreq-dt.c b/drivers/cpufreq/cpufreq-dt.c index 1ceece9d67112..9bc37c437874a 100644 --- a/drivers/cpufreq/cpufreq-dt.c +++ b/drivers/cpufreq/cpufreq-dt.c @@ -50,7 +50,8 @@ static int set_target(struct cpufreq_policy *policy, unsigned int index) struct private_data *priv = policy->driver_data; struct device *cpu_dev = priv->cpu_dev; struct regulator *cpu_reg = priv->cpu_reg; - unsigned long volt = 0, volt_old = 0, tol = 0; + unsigned long volt = 0, tol = 0; + int volt_old = 0; unsigned int old_freq, new_freq; long freq_Hz, freq_exact; int ret; @@ -83,7 +84,7 @@ static int set_target(struct cpufreq_policy *policy, unsigned int index) opp_freq / 1000, volt); } - dev_dbg(cpu_dev, "%u MHz, %ld mV --> %u MHz, %ld mV\n", + dev_dbg(cpu_dev, "%u MHz, %d mV --> %u MHz, %ld mV\n", old_freq / 1000, (volt_old > 0) ? volt_old / 1000 : -1, new_freq / 1000, volt ? volt / 1000 : -1);