From patchwork Wed Jun 21 04:46:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 106036 Delivered-To: patch@linaro.org Received: by 10.140.91.2 with SMTP id y2csp1744154qgd; Tue, 20 Jun 2017 21:47:21 -0700 (PDT) X-Received: by 10.98.66.77 with SMTP id p74mr15719759pfa.240.1498020441055; Tue, 20 Jun 2017 21:47:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498020441; cv=none; d=google.com; s=arc-20160816; b=oKGe5rXixbIYJRfIQ2Oak6EjB3Nfmw547PVpflDf6o1cfCeiU0UDGm+RVZyS9yZcSU Q/m9JTsk/MnuwJHE1w4He4m74kY1AoOpAfVHvUiCI4XCH0f9cu8re9R3G5Gy9PhNHBP0 uUp9e6iZj7lOUA8mtBT4FPRZ+8FEPr5MeOrKp7jDLpOOf79+tXSTVEj1qSEpJh5qWghJ +TgrM8GPWpexNa/+OvxlbIgnCMfkHBxh1+SPKQQ2sWr49mf/OImP8dxl3UU/p5sXzKQc Gcmcbg/KalTJQPE/dDgN2STfoBC77SfnJWKxEXQui+Q79IgSycfcWEkQS7k+A5gB/wyS s2hA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=oIQICQeabtHayL+S/p0jPe0N5tkFj3ylN34KK/YLpRI=; b=B7+1lBc3NciXW4OX3hzn3LQrsd37GRRoHTE3BUWGxUt2cpczD4lCBmQP/fMEX2tE89 WsJLkX2ILIF5HCc3zk1Qzs0u2Je4ew2eQ4gHgysJ58TU1gYysyiV3P9l/OtFhknGwZNo J5g6HCqqfrZy6WiLZW29McxoeVATIGQCTwqfy8mx9V8OjI8kUmY3OafrdEazD2BvqClK l0CYmz5lE5JTkTdB/g15P7bg7Bixgt5Y4WEnTdfNcCP5+2zX9shklU+cUZK7uDgqw7Ba 8tDLVlmE6pp7zOpoqij6zkFXuLGJTrTaaWCt6Y/jShzWyfe8CaZVVnw5bMZS6F2rEgvU Fb2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.b=QoDg2QMK; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c19si12534085pgk.501.2017.06.20.21.47.20; Tue, 20 Jun 2017 21:47:21 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.b=QoDg2QMK; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752914AbdFUErF (ORCPT + 25 others); Wed, 21 Jun 2017 00:47:05 -0400 Received: from mail-pf0-f182.google.com ([209.85.192.182]:33626 "EHLO mail-pf0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752669AbdFUErC (ORCPT ); Wed, 21 Jun 2017 00:47:02 -0400 Received: by mail-pf0-f182.google.com with SMTP id 83so79707516pfr.0 for ; Tue, 20 Jun 2017 21:47:02 -0700 (PDT) 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 :in-reply-to:references; bh=oIQICQeabtHayL+S/p0jPe0N5tkFj3ylN34KK/YLpRI=; b=QoDg2QMKn1B+4bV4Psxq7YchLVIxlXbxIzHx4kBP82F58PblrrizLqWoAkCKeNNuCC scxpsshj/NG1r5ErJpS+jm1FSzfhFbp2491hQEuIWT126D1Bf7gVK7adzo+NwRby7d5S UFAxsmQWkQtDrvJDW3devHXbnB0jtAAAqOkR8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=oIQICQeabtHayL+S/p0jPe0N5tkFj3ylN34KK/YLpRI=; b=UMrNc6uongMKwkR7EBWWUyW2sv9DYeZI2LlMRuIvDiJfETgZS2Pdxu4fI/3n8wi9Ca FFVbpH+OXisq6tTvg2rxfNqU7ySbHmYAWx3HdSgrwUbaZ+SHnPSmaXRxAbSfhZkZiGr/ 0I64HhYNm3SimFGo0jfJ/ukbr9Umd1aOqGQ28gyJ1oi60JX+i563ohVVB6bYRyC0Zc8v DlHNPujYGrcKbqcayvekGZPsPb5BND8j51fMpzrhn7xED8SzuHawcawqN8lmXqZ7gyvJ Wz0WFjEP7HQRWB9pRJH0ESfN82NkZxOrugQNQEcJS7dE4Wuo9BBHBygtZX1D46VVGLXo w/wA== X-Gm-Message-State: AKS2vOxulpqDeltrwrASdRC0PpX6P527hNiqzDWd3u9dnYWSSRvTTEth FIcpHPyZo0MeQzuq X-Received: by 10.98.152.25 with SMTP id q25mr7073482pfd.47.1498020421723; Tue, 20 Jun 2017 21:47:01 -0700 (PDT) Received: from localhost ([122.172.59.234]) by smtp.gmail.com with ESMTPSA id m132sm8280232pfc.76.2017.06.20.21.47.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 20 Jun 2017 21:47:01 -0700 (PDT) From: Viresh Kumar To: Juri Lelli , Greg Kroah-Hartman Cc: Viresh Kumar , linux-arm-kernel@lists.infradead.org, Catalin Marinas , linux@arm.linux.org.uk, Will Deacon , Vincent Guittot , arnd.bergmann@linaro.org, linux-kernel@vger.kernel.org Subject: [PATCH V2 3/5] arch_topology: Covert switch block to if block Date: Wed, 21 Jun 2017 10:16:42 +0530 Message-Id: X-Mailer: git-send-email 2.13.0.71.gd7076ec9c9cb In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We only need to take care of one case here (CPUFREQ_NOTIFY) and there is no need to add an extra level of indentation to the case specific code by using a switch block. Use an if block instead. Also add some blank lines to make the code look better. Signed-off-by: Viresh Kumar --- drivers/base/arch_topology.c | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) -- 2.13.0.71.gd7076ec9c9cb diff --git a/drivers/base/arch_topology.c b/drivers/base/arch_topology.c index 2f1d9921ee54..07784ba666a7 100644 --- a/drivers/base/arch_topology.c +++ b/drivers/base/arch_topology.c @@ -173,26 +173,29 @@ init_cpu_capacity_callback(struct notifier_block *nb, if (cap_parsing_failed) return 0; - switch (val) { - case CPUFREQ_NOTIFY: - pr_debug("cpu_capacity: init cpu capacity for CPUs [%*pbl] (to_visit=%*pbl)\n", - cpumask_pr_args(policy->related_cpus), - cpumask_pr_args(cpus_to_visit)); - cpumask_andnot(cpus_to_visit, cpus_to_visit, - policy->related_cpus); - for_each_cpu(cpu, policy->related_cpus) { - raw_capacity[cpu] = topology_get_cpu_scale(NULL, cpu) * - policy->cpuinfo.max_freq / 1000UL; - capacity_scale = max(raw_capacity[cpu], capacity_scale); - } - if (cpumask_empty(cpus_to_visit)) { - topology_normalize_cpu_scale(); - kfree(raw_capacity); - pr_debug("cpu_capacity: parsing done\n"); - cap_parsing_failed = true; - schedule_work(&parsing_done_work); - } + if (val != CPUFREQ_NOTIFY) + return 0; + + pr_debug("cpu_capacity: init cpu capacity for CPUs [%*pbl] (to_visit=%*pbl)\n", + cpumask_pr_args(policy->related_cpus), + cpumask_pr_args(cpus_to_visit)); + + cpumask_andnot(cpus_to_visit, cpus_to_visit, policy->related_cpus); + + for_each_cpu(cpu, policy->related_cpus) { + raw_capacity[cpu] = topology_get_cpu_scale(NULL, cpu) * + policy->cpuinfo.max_freq / 1000UL; + capacity_scale = max(raw_capacity[cpu], capacity_scale); } + + if (cpumask_empty(cpus_to_visit)) { + topology_normalize_cpu_scale(); + kfree(raw_capacity); + pr_debug("cpu_capacity: parsing done\n"); + cap_parsing_failed = true; + schedule_work(&parsing_done_work); + } + return 0; }