From patchwork Fri Jun 23 09:25:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 106252 Delivered-To: patch@linaro.org Received: by 10.140.91.2 with SMTP id y2csp112355qgd; Fri, 23 Jun 2017 02:26:20 -0700 (PDT) X-Received: by 10.98.13.219 with SMTP id 88mr7232278pfn.191.1498209980033; Fri, 23 Jun 2017 02:26:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498209980; cv=none; d=google.com; s=arc-20160816; b=NqGOPA735Q0IgXgnyJ2iGSq+/CoZAWxdInvTjCqWW3q99cpHsL1vYwaUYw7jVwJ8HN TYP31/WkXqLBxtL7RRFz8GW0lxJPDoWAgl2TaMZdbYKdAnojfkzDDMOjs867dRss50mG A+FCi/W7wDxoCvCAU09igq8CyHmWkFgby85B99BGm/6hbunYUDaS6lCCOPnpYzw9VOt0 +DrnaJrOJrPYbsGBXk/gctc5mt6nke9sicSQYzFPVbYypcLzm2ZWKPn0YagOS+m2wjXC GVzXw717EBXo6WsdvPZkZ85kvUJs22AHgaBmp4eGRS9NpH90zTdkYr/X+cpaE1/5KzcN BtCw== 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=N5WU1w8GXcrMAE9Bpj1YpWWO/ng0eDCB/EfYstgg0Ic=; b=yna0qrkqZHjy8sT52TXbszHtSQ6quOLZv00wHgMKFIPWqdzm0hm6MSIcU+IGCZaYnT fNpU5UB+hrivhBm37fPeN7tLW8lGKdrdKZ/OpPgSi2yKfkpOaAdxc0E5x3IFrdbbYftQ YPYDzrLT7W6bV8Wdm6pkRZ9iklyhNud6Pf6WYR9GeSBV4MWcti/LnEzdygCe1Pd5EacY nWfN243SlpeQyO1e2NDO+bgYmXxL/aIYT5h1UVfCFzt75a7QeghJgpKIAeE8uU0BjJAX aBRtA6h+bp+czH5qUG2tGdfkAXomu6r7GzC1whCDXUXFCeD3Khtzx7EM1jYInVXazPp7 QhRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.b=VpbnD50L; 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 t18si2984519pge.491.2017.06.23.02.26.19; Fri, 23 Jun 2017 02:26:20 -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=VpbnD50L; 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 S1754696AbdFWJZ4 (ORCPT + 25 others); Fri, 23 Jun 2017 05:25:56 -0400 Received: from mail-pg0-f48.google.com ([74.125.83.48]:33060 "EHLO mail-pg0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754617AbdFWJZo (ORCPT ); Fri, 23 Jun 2017 05:25:44 -0400 Received: by mail-pg0-f48.google.com with SMTP id f127so19037673pgc.0 for ; Fri, 23 Jun 2017 02:25:44 -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=N5WU1w8GXcrMAE9Bpj1YpWWO/ng0eDCB/EfYstgg0Ic=; b=VpbnD50L7T2nek2uJRWvVI5Jju41aQfHa4pic+jFhIXRM6/EYHpmBvhyQqC2UFdVSI HPl1IgAQufJIlIGIcydypEtOYt4rbpXjTeQYNG9yM1yR2L8e46psmD31oUMOFWbC5rrE 0DvAL/Ne1cnUkDzUQ2bS6javCHJWZti9D+unQ= 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=N5WU1w8GXcrMAE9Bpj1YpWWO/ng0eDCB/EfYstgg0Ic=; b=Kv1HB5LoqOTQKtbKhX7T1Y9xhvQ5HeSiYBVtW6Zzlpwg5LU4xUmV6sU1XRyyHs01mw qgZiLbxzDNTJaYJwF8DNEduVqjaaYltJVabf9g0di1b7kAffrGeS7Zq1OJCUA+BSCcvt xawg8fZBiEQ2IdT0a/yupA6ZteGRnr1LX87O/ZD0Lo5gWK+nIyOHidZSmdGiQgzHztBQ ojrwQFBEXajTPvlwFBy8DGDDCFl2KIpP/R8ZMTiOoOx2+z+c6xZvry0nP2iJnrclN9dd HKDXSKDKU18s03CVFFsR48eEWeOqBpGrkAqR8b3z7+aUhqLRbBMlo4guF2pORk7JVcyQ DdjQ== X-Gm-Message-State: AKS2vOxXBv6nfYw+rK8XrCZ20QTqZHTbPkfkMUtprOhIRbEKEA1u3wNf NNmP3VD7wMOnFywU X-Received: by 10.84.132.42 with SMTP id 39mr7809559ple.226.1498209943934; Fri, 23 Jun 2017 02:25:43 -0700 (PDT) Received: from localhost ([122.172.59.234]) by smtp.gmail.com with ESMTPSA id u2sm9616108pgn.28.2017.06.23.02.25.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Jun 2017 02:25:43 -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 V3 2/5] arch_topology: Convert switch block to if block Date: Fri, 23 Jun 2017 14:55:31 +0530 Message-Id: <7b5f25af1e0f1365ec6b3996cc31848f529322cd.1498209817.git.viresh.kumar@linaro.org> 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 0ad79b5cd56d..a3cd7c869c3e 100644 --- a/drivers/base/arch_topology.c +++ b/drivers/base/arch_topology.c @@ -174,26 +174,29 @@ init_cpu_capacity_callback(struct notifier_block *nb, if (cap_parsing_failed || cap_parsing_done) 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_done = 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_done = true; + schedule_work(&parsing_done_work); + } + return 0; }