From patchwork Mon May 18 05:13:32 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 48676 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f72.google.com (mail-la0-f72.google.com [209.85.215.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 8E9BB214BA for ; Mon, 18 May 2015 05:15:21 +0000 (UTC) Received: by labcd2 with SMTP id cd2sf1828304lab.0 for ; Sun, 17 May 2015 22:15:20 -0700 (PDT) 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 :sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=l0ssCGr9nR/M0Q7e5hOKO4dncchpnRsP+WBRlERVlWE=; b=NxsTA7TRUn34Lc1QXciQM9I3Hd1sUpmBB9xn0NAGz69jpXGyzhFiUpvqoCyF3pX2nk A3FaQBnuD/iVza1gXSVZShuCq8T2AtCVOx3gjOXCswqbrNvb3e0GRKDBoTZXeEfFv3z0 9EiQWhhaJNB9ZQAlnMYndL/u83lgjKkJDPX1ZKEkRaqyKyYcv6MbfhvFTtmMC2JDInJi ipAB7f2rYyB1qVZWvNbCj9iNZ9LYCZ4ULRqrpdnf4vzS8yr3HK9l9PTm/NtcoMJQEVV0 xqnF+1xIDdrZ6J4q0dVtvRPfywPzFzO06BZLBAvqkrNoGKerYnS/Fkk8BV3cqELNi6Xb rgYA== X-Gm-Message-State: ALoCoQkk4P8/5QG58NnfavC/sbUP0zLedSZ3jqITJxxi2OCQXgIaeQ2BVT/WH7IsxRk9di/QHkd3 X-Received: by 10.194.236.230 with SMTP id ux6mr16543936wjc.5.1431926120545; Sun, 17 May 2015 22:15:20 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.45.6 with SMTP id i6ls33087lam.4.gmail; Sun, 17 May 2015 22:15:20 -0700 (PDT) X-Received: by 10.152.243.9 with SMTP id wu9mr15674394lac.63.1431926120388; Sun, 17 May 2015 22:15:20 -0700 (PDT) Received: from mail-la0-f54.google.com (mail-la0-f54.google.com. [209.85.215.54]) by mx.google.com with ESMTPS id qv7si5939701lbb.162.2015.05.17.22.15.20 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 17 May 2015 22:15:20 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.54 as permitted sender) client-ip=209.85.215.54; Received: by labbd9 with SMTP id bd9so202313634lab.2 for ; Sun, 17 May 2015 22:15:20 -0700 (PDT) X-Received: by 10.152.4.137 with SMTP id k9mr15704178lak.29.1431926120297; Sun, 17 May 2015 22:15:20 -0700 (PDT) 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.108.230 with SMTP id hn6csp3711869lbb; Sun, 17 May 2015 22:15:19 -0700 (PDT) X-Received: by 10.68.57.170 with SMTP id j10mr24093590pbq.150.1431926118614; Sun, 17 May 2015 22:15:18 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id iu9si2678127pbc.77.2015.05.17.22.15.17; Sun, 17 May 2015 22:15:18 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751149AbbERFOZ (ORCPT + 11 others); Mon, 18 May 2015 01:14:25 -0400 Received: from mail-pd0-f176.google.com ([209.85.192.176]:33206 "EHLO mail-pd0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751183AbbERFOZ (ORCPT ); Mon, 18 May 2015 01:14:25 -0400 Received: by pdbqa5 with SMTP id qa5so133391682pdb.0 for ; Sun, 17 May 2015 22:14:24 -0700 (PDT) X-Received: by 10.66.230.130 with SMTP id sy2mr41413554pac.157.1431926064757; Sun, 17 May 2015 22:14:24 -0700 (PDT) Received: from localhost ([122.167.226.34]) by mx.google.com with ESMTPSA id bc3sm8589666pbb.47.2015.05.17.22.14.23 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sun, 17 May 2015 22:14:24 -0700 (PDT) From: Viresh Kumar To: Rafael Wysocki Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, sboyd@codeaurora.org, prarit@redhat.com, skannan@codeaurora.org, Srivatsa Bhat , Viresh Kumar Subject: [PATCH V5 09/14] cpufreq: add/remove sysfs links via cpufreq_add_remove_dev_symlink() Date: Mon, 18 May 2015 10:43:32 +0530 Message-Id: <93a3bfbe26dfa1c298e21da369e6ed37fca1da34.1431924457.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.4.0 In-Reply-To: References: In-Reply-To: References: Sender: linux-pm-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: viresh.kumar@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.54 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: , Later patches would require us to add/remove all sysfs links together. Create another routine cpufreq_add_remove_dev_symlink() to do that. This is a preparatory step for the next patch and is done separately for easier reviews. Signed-off-by: Viresh Kumar --- drivers/cpufreq/cpufreq.c | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index d7fc3d9294f8..b5e883f497dd 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -957,25 +957,42 @@ void cpufreq_sysfs_remove_file(const struct attribute *attr) } EXPORT_SYMBOL(cpufreq_sysfs_remove_file); -/* symlink affected CPUs */ -static int cpufreq_add_dev_symlink(struct cpufreq_policy *policy) +static inline int add_remove_cpu_dev_symlink(struct cpufreq_policy *policy, + int cpu, bool add) +{ + struct device *cpu_dev; + + pr_debug("%s: %s symlink for CPU: %u\n", __func__, + add ? "Adding" : "Removing", cpu); + + cpu_dev = get_cpu_device(cpu); + if (WARN_ON(!cpu_dev)) + return 0; + + if (add) + return sysfs_create_link(&cpu_dev->kobj, &policy->kobj, + "cpufreq"); + + sysfs_remove_link(&cpu_dev->kobj, "cpufreq"); + return 0; +} + +/* Add/remove symlinks for all affected CPUs */ +static int cpufreq_add_remove_dev_symlink(struct cpufreq_policy *policy, + bool add) { unsigned int j; int ret = 0; for_each_cpu(j, policy->cpus) { - struct device *cpu_dev; - if (j == policy->kobj_cpu) continue; - pr_debug("Adding link for CPU: %u\n", j); - cpu_dev = get_cpu_device(j); - ret = sysfs_create_link(&cpu_dev->kobj, &policy->kobj, - "cpufreq"); + ret = add_remove_cpu_dev_symlink(policy, j, add); if (ret) break; } + return ret; } @@ -1009,7 +1026,7 @@ static int cpufreq_add_dev_interface(struct cpufreq_policy *policy, return ret; } - return cpufreq_add_dev_symlink(policy); + return cpufreq_add_remove_dev_symlink(policy, true); } static void cpufreq_init_policy(struct cpufreq_policy *policy)