From patchwork Mon Dec 2 06:18:30 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 21920 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yh0-f70.google.com (mail-yh0-f70.google.com [209.85.213.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 9B8F720DB9 for ; Mon, 2 Dec 2013 06:20:40 +0000 (UTC) Received: by mail-yh0-f70.google.com with SMTP id l109sf29092987yhq.1 for ; Sun, 01 Dec 2013 22:20:40 -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:in-reply-to:references :x-original-sender:x-original-authentication-results:precedence :mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=bxMPxcbKZAiI6oclVqClWlkR9dHD9bt990EE8IBrlT8=; b=ZkEl1/7KB6DcvyCTDFKdXO7FzprBeUglE9K3Z1BK5+sIeYYriTLDBsi9ui8X1BwxhX TJRvr4lW1s0f3V+FrTMJ0hk58yBUqtDCcJ4DmkB6udBxvl/HgvD6+SZ/zcCstfAoUDTl nVRpZwz6I1Y79Js2CDg0sOy1ujn+cv75f173HpSG2U3ftXXcNLLLe8SJ0QMmTL7D6WgJ UAbB53AKH4QQ6Qzr/5xUdVMMXwULpbSeMZRo7ypt2Of2axtsP/kGvaC/yOcueQCph78V AffCoeK5wPJQExve2HsoqnF0kapY8m83wGH98u78wbCaoB/ag0LWCkcdvEfVFHmnDSSm h+sQ== X-Gm-Message-State: ALoCoQmx8xEipoT+rW/w7vn+QCRXY2krK39VgURR8QqryJf/sRIRw7B18i0AQ8AtvO4jhImtJPtS X-Received: by 10.58.128.33 with SMTP id nl1mr22380680veb.28.1385965240171; Sun, 01 Dec 2013 22:20:40 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.30.37 with SMTP id p5ls4669563qeh.51.gmail; Sun, 01 Dec 2013 22:20:40 -0800 (PST) X-Received: by 10.58.39.97 with SMTP id o1mr51497852vek.15.1385965240074; Sun, 01 Dec 2013 22:20:40 -0800 (PST) Received: from mail-vc0-f174.google.com (mail-vc0-f174.google.com [209.85.220.174]) by mx.google.com with ESMTPS id z11si29074850vcj.53.2013.12.01.22.20.40 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 01 Dec 2013 22:20:40 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.174 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.174; Received: by mail-vc0-f174.google.com with SMTP id id10so7927302vcb.19 for ; Sun, 01 Dec 2013 22:20:40 -0800 (PST) X-Received: by 10.58.146.71 with SMTP id ta7mr1260643veb.23.1385965239981; Sun, 01 Dec 2013 22:20:39 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp94076vcz; Sun, 1 Dec 2013 22:20:39 -0800 (PST) X-Received: by 10.49.2.170 with SMTP id 10mr2955731qev.24.1385965239593; Sun, 01 Dec 2013 22:20:39 -0800 (PST) Received: from mail-qe0-f45.google.com (mail-qe0-f45.google.com [209.85.128.45]) by mx.google.com with ESMTPS id g3si17028497qaf.6.2013.12.01.22.20.39 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 01 Dec 2013 22:20:39 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.45 is neither permitted nor denied by best guess record for domain of viresh.kumar@linaro.org) client-ip=209.85.128.45; Received: by mail-qe0-f45.google.com with SMTP id 6so12548271qea.4 for ; Sun, 01 Dec 2013 22:20:39 -0800 (PST) X-Received: by 10.229.137.135 with SMTP id w7mr110152384qct.14.1385965239439; Sun, 01 Dec 2013 22:20:39 -0800 (PST) Received: from localhost (git.linaro.org. [54.235.93.228]) by mx.google.com with ESMTPSA id o10sm157999008qaa.6.2013.12.01.22.20.37 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sun, 01 Dec 2013 22:20:39 -0800 (PST) From: Viresh Kumar To: rjw@rjwysocki.net Cc: linaro-kernel@lists.linaro.org, patches@linaro.org, cpufreq@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Viresh Kumar Subject: [PATCH 3/3] cpufreq: Remove unnecessary variable/parameter 'frozen' Date: Mon, 2 Dec 2013 11:48:30 +0530 Message-Id: <0ba44ae1bad46cb18967a679b25a574894df36a6.1385964947.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 1.7.12.rc2.18.g61b472e In-Reply-To: References: In-Reply-To: References: X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: viresh.kumar@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.174 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , We have used 'frozen' variable/function parameter at many places to differentiate CPU hotplugging on suspend/resume vs sysfs removals. We now have another variable cpufreq_suspended which can be used in these cases and hence we can get rid of all those variables or function parameters. Signed-off-by: Viresh Kumar --- drivers/cpufreq/cpufreq.c | 60 ++++++++++++++++++++--------------------------- 1 file changed, 25 insertions(+), 35 deletions(-) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index e7586e6..e2196f3 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -882,8 +882,7 @@ static void cpufreq_init_policy(struct cpufreq_policy *policy) #ifdef CONFIG_HOTPLUG_CPU static int cpufreq_add_policy_cpu(struct cpufreq_policy *policy, - unsigned int cpu, struct device *dev, - bool frozen) + unsigned int cpu, struct device *dev) { int ret = 0; unsigned long flags; @@ -915,7 +914,7 @@ static int cpufreq_add_policy_cpu(struct cpufreq_policy *policy, } /* Don't touch sysfs links during light-weight init */ - if (!frozen) + if (!cpufreq_suspended) ret = sysfs_create_link(&dev->kobj, &policy->kobj, "cpufreq"); return ret; @@ -986,8 +985,7 @@ static void update_policy_cpu(struct cpufreq_policy *policy, unsigned int cpu) CPUFREQ_UPDATE_POLICY_CPU, policy); } -static int __cpufreq_add_dev(struct device *dev, struct subsys_interface *sif, - bool frozen) +static int __cpufreq_add_dev(struct device *dev, struct subsys_interface *sif) { unsigned int j, cpu = dev->id; int ret = -ENOMEM; @@ -1022,7 +1020,7 @@ static int __cpufreq_add_dev(struct device *dev, struct subsys_interface *sif, list_for_each_entry(tpolicy, &cpufreq_policy_list, policy_list) { if (cpumask_test_cpu(cpu, tpolicy->related_cpus)) { read_unlock_irqrestore(&cpufreq_driver_lock, flags); - ret = cpufreq_add_policy_cpu(tpolicy, cpu, dev, frozen); + ret = cpufreq_add_policy_cpu(tpolicy, cpu, dev); up_read(&cpufreq_rwsem); return ret; } @@ -1030,7 +1028,7 @@ static int __cpufreq_add_dev(struct device *dev, struct subsys_interface *sif, read_unlock_irqrestore(&cpufreq_driver_lock, flags); #endif - if (frozen) + if (cpufreq_suspended) /* Restore the saved policy when doing light-weight init */ policy = cpufreq_policy_restore(cpu); else @@ -1039,14 +1037,13 @@ static int __cpufreq_add_dev(struct device *dev, struct subsys_interface *sif, if (!policy) goto nomem_out; - /* * In the resume path, since we restore a saved policy, the assignment * to policy->cpu is like an update of the existing policy, rather than * the creation of a brand new one. So we need to perform this update * by invoking update_policy_cpu(). */ - if (frozen && cpu != policy->cpu) + if (cpufreq_suspended && cpu != policy->cpu) update_policy_cpu(policy, cpu); else policy->cpu = cpu; @@ -1140,7 +1137,7 @@ static int __cpufreq_add_dev(struct device *dev, struct subsys_interface *sif, } #endif - if (!frozen) { + if (!cpufreq_suspended) { ret = cpufreq_add_dev_interface(policy, dev); if (ret) goto err_out_unregister; @@ -1187,11 +1184,11 @@ nomem_out: */ static int cpufreq_add_dev(struct device *dev, struct subsys_interface *sif) { - return __cpufreq_add_dev(dev, sif, false); + return __cpufreq_add_dev(dev, sif); } static int cpufreq_nominate_new_policy_cpu(struct cpufreq_policy *policy, - unsigned int old_cpu, bool frozen) + unsigned int old_cpu) { struct device *cpu_dev; int ret; @@ -1200,7 +1197,7 @@ static int cpufreq_nominate_new_policy_cpu(struct cpufreq_policy *policy, cpu_dev = get_cpu_device(cpumask_any_but(policy->cpus, old_cpu)); /* Don't touch sysfs files during light-weight tear-down */ - if (frozen) + if (cpufreq_suspended) return cpu_dev->id; sysfs_remove_link(&cpu_dev->kobj, "cpufreq"); @@ -1222,8 +1219,7 @@ static int cpufreq_nominate_new_policy_cpu(struct cpufreq_policy *policy, } static int __cpufreq_remove_dev_prepare(struct device *dev, - struct subsys_interface *sif, - bool frozen) + struct subsys_interface *sif) { unsigned int cpu = dev->id, cpus; int new_cpu, ret; @@ -1237,7 +1233,7 @@ static int __cpufreq_remove_dev_prepare(struct device *dev, policy = per_cpu(cpufreq_cpu_data, cpu); /* Save the policy somewhere when doing a light-weight tear-down */ - if (frozen) + if (cpufreq_suspended) per_cpu(cpufreq_cpu_data_fallback, cpu) = policy; write_unlock_irqrestore(&cpufreq_driver_lock, flags); @@ -1266,14 +1262,14 @@ static int __cpufreq_remove_dev_prepare(struct device *dev, up_read(&policy->rwsem); if (cpu != policy->cpu) { - if (!frozen) + if (!cpufreq_suspended) sysfs_remove_link(&dev->kobj, "cpufreq"); } else if (cpus > 1) { - new_cpu = cpufreq_nominate_new_policy_cpu(policy, cpu, frozen); + new_cpu = cpufreq_nominate_new_policy_cpu(policy, cpu); if (new_cpu >= 0) { update_policy_cpu(policy, new_cpu); - if (!frozen) { + if (!cpufreq_suspended) { pr_debug("%s: policy Kobject moved to cpu: %d from: %d\n", __func__, new_cpu, cpu); } @@ -1284,8 +1280,7 @@ static int __cpufreq_remove_dev_prepare(struct device *dev, } static int __cpufreq_remove_dev_finish(struct device *dev, - struct subsys_interface *sif, - bool frozen) + struct subsys_interface *sif) { unsigned int cpu = dev->id, cpus; int ret; @@ -1322,7 +1317,7 @@ static int __cpufreq_remove_dev_finish(struct device *dev, } } - if (!frozen) { + if (!cpufreq_suspended) { down_read(&policy->rwsem); kobj = &policy->kobj; cmp = &policy->kobj_unregister; @@ -1352,7 +1347,7 @@ static int __cpufreq_remove_dev_finish(struct device *dev, list_del(&policy->policy_list); write_unlock_irqrestore(&cpufreq_driver_lock, flags); - if (!frozen) + if (!cpufreq_suspended) cpufreq_policy_free(policy); } else { if (has_target()) { @@ -1382,10 +1377,10 @@ static int cpufreq_remove_dev(struct device *dev, struct subsys_interface *sif) if (cpu_is_offline(cpu)) return 0; - ret = __cpufreq_remove_dev_prepare(dev, sif, false); + ret = __cpufreq_remove_dev_prepare(dev, sif); if (!ret) - ret = __cpufreq_remove_dev_finish(dev, sif, false); + ret = __cpufreq_remove_dev_finish(dev, sif); return ret; } @@ -2153,30 +2148,25 @@ static int cpufreq_cpu_callback(struct notifier_block *nfb, { unsigned int cpu = (unsigned long)hcpu; struct device *dev; - bool frozen = false; dev = get_cpu_device(cpu); if (dev) { - - if (action & CPU_TASKS_FROZEN) - frozen = true; - - switch (action & ~CPU_TASKS_FROZEN) { + switch (action) { case CPU_ONLINE: - __cpufreq_add_dev(dev, NULL, frozen); + __cpufreq_add_dev(dev, NULL); cpufreq_update_policy(cpu); break; case CPU_DOWN_PREPARE: - __cpufreq_remove_dev_prepare(dev, NULL, frozen); + __cpufreq_remove_dev_prepare(dev, NULL); break; case CPU_POST_DEAD: - __cpufreq_remove_dev_finish(dev, NULL, frozen); + __cpufreq_remove_dev_finish(dev, NULL); break; case CPU_DOWN_FAILED: - __cpufreq_add_dev(dev, NULL, frozen); + __cpufreq_add_dev(dev, NULL); break; } }