From patchwork Fri Oct 16 07:11:12 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 55076 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lf0-f70.google.com (mail-lf0-f70.google.com [209.85.215.70]) by patches.linaro.org (Postfix) with ESMTPS id 7A41622EAC for ; Fri, 16 Oct 2015 07:11:46 +0000 (UTC) Received: by lffv3 with SMTP id v3sf13913634lff.1 for ; Fri, 16 Oct 2015 00:11:45 -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:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=1ekrlyNNso+wV6KSa9VMCUJ4ws1WTv1EFMYk2Lx8PfE=; b=GqTypm9XgThrYetzHOOoYX32qxYMsepNJZGBAg09fK/2+WPxZnMM9s7BdAzztW2W37 4JZ0JeFH4/btjjMAsiXpEmG2IdsDthXqAqklf51YioLONRoKQDKQ0cvhwCxim3M4Qqas uVAQ4a4HoO2sqqEBTqji2xzTYb7gTye34woZYahi0XFozjVzEXBshelJ8oq4G1aTeaIk GgAFWbQgGOoHHImTh5YaiGPPMyOLJg/UK8Daeu4wWhDYny5+ZUNja8+NO7ah0knL0Gyr mvdMb7o184ud+KZcuov4X1kTeBz7E9QMvCXuTSAxDJI0ggvgq8ExLORZt/daLOoS++Dc R+dw== X-Gm-Message-State: ALoCoQkLRHjfl6cQqjAGbWFZMJa6Vbapd8D7BJEbtXoHQSKYaieHpsKp4bVEbL+MVxJsgffUHqyR X-Received: by 10.112.147.7 with SMTP id tg7mr3212647lbb.16.1444979505474; Fri, 16 Oct 2015 00:11:45 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.25.141.198 with SMTP id p189ls278646lfd.79.gmail; Fri, 16 Oct 2015 00:11:45 -0700 (PDT) X-Received: by 10.112.161.201 with SMTP id xu9mr7336582lbb.10.1444979505271; Fri, 16 Oct 2015 00:11:45 -0700 (PDT) Received: from mail-lf0-f52.google.com (mail-lf0-f52.google.com. [209.85.215.52]) by mx.google.com with ESMTPS id sc1si11957761lbb.8.2015.10.16.00.11.45 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 16 Oct 2015 00:11:45 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.52 as permitted sender) client-ip=209.85.215.52; Received: by lfaz124 with SMTP id z124so71922106lfa.1 for ; Fri, 16 Oct 2015 00:11:45 -0700 (PDT) X-Received: by 10.25.86.213 with SMTP id k204mr4787509lfb.36.1444979505159; Fri, 16 Oct 2015 00:11:45 -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.59.35 with SMTP id w3csp1067219lbq; Fri, 16 Oct 2015 00:11:44 -0700 (PDT) X-Received: by 10.68.239.33 with SMTP id vp1mr14873599pbc.167.1444979504098; Fri, 16 Oct 2015 00:11:44 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q6si5326746pap.120.2015.10.16.00.11.43; Fri, 16 Oct 2015 00:11:44 -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 S1752495AbbJPHLm (ORCPT + 12 others); Fri, 16 Oct 2015 03:11:42 -0400 Received: from mail-pa0-f42.google.com ([209.85.220.42]:33158 "EHLO mail-pa0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752370AbbJPHLl (ORCPT ); Fri, 16 Oct 2015 03:11:41 -0400 Received: by pabrc13 with SMTP id rc13so112320302pab.0 for ; Fri, 16 Oct 2015 00:11:41 -0700 (PDT) X-Received: by 10.68.185.132 with SMTP id fc4mr14655528pbc.96.1444979501402; Fri, 16 Oct 2015 00:11:41 -0700 (PDT) Received: from localhost ([223.227.62.197]) by smtp.gmail.com with ESMTPSA id an5sm6963602pbd.45.2015.10.16.00.11.39 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 16 Oct 2015 00:11:40 -0700 (PDT) From: Viresh Kumar To: Rafael Wysocki Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, skannan@codeaurora.org, Viresh Kumar , linux-kernel@vger.kernel.org (open list) Subject: [PATCH V3 5/5] cpufreq: postfix policy directory with the first CPU in related_cpus Date: Fri, 16 Oct 2015 12:41:12 +0530 Message-Id: <44a5b86d1df41812461630e5a7c5366d276e2855.1444979341.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.4.0 In-Reply-To: <20151016070842.GY19018@linux> References: <20151016070842.GY19018@linux> 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.52 as permitted sender) smtp.mailfrom=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: , The sysfs policy directory is postfixed currently with the CPU number for which the policy was created, which isn't necessarily the first CPU in related_cpus mask. To make it more consistent and predictable, lets postfix the policy with the first cpu in related-cpus mask. Suggested-by: Saravana Kannan Signed-off-by: Viresh Kumar Reviewed-by: Saravana Kannan --- V2->V3: - Fix error path where we may try to put an uninitialized kobject. - Break kobject_init_and_add() to kobject_init() and kobject_add(). drivers/cpufreq/cpufreq.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 4fa2215cc6ec..7c48e7316d91 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -1022,7 +1022,6 @@ static struct cpufreq_policy *cpufreq_policy_alloc(unsigned int cpu) { struct device *dev = get_cpu_device(cpu); struct cpufreq_policy *policy; - int ret; if (WARN_ON(!dev)) return NULL; @@ -1040,13 +1039,7 @@ static struct cpufreq_policy *cpufreq_policy_alloc(unsigned int cpu) if (!zalloc_cpumask_var(&policy->real_cpus, GFP_KERNEL)) goto err_free_rcpumask; - ret = kobject_init_and_add(&policy->kobj, &ktype_cpufreq, - cpufreq_global_kobject, "policy%u", cpu); - if (ret) { - pr_err("%s: failed to init policy->kobj: %d\n", __func__, ret); - goto err_free_real_cpus; - } - + kobject_init(&policy->kobj, &ktype_cpufreq); INIT_LIST_HEAD(&policy->policy_list); init_rwsem(&policy->rwsem); spin_lock_init(&policy->transition_lock); @@ -1057,8 +1050,6 @@ static struct cpufreq_policy *cpufreq_policy_alloc(unsigned int cpu) policy->cpu = cpu; return policy; -err_free_real_cpus: - free_cpumask_var(policy->real_cpus); err_free_rcpumask: free_cpumask_var(policy->related_cpus); err_free_cpumask: @@ -1163,6 +1154,16 @@ static int cpufreq_online(unsigned int cpu) cpumask_copy(policy->related_cpus, policy->cpus); /* Remember CPUs present at the policy creation time. */ cpumask_and(policy->real_cpus, policy->cpus, cpu_present_mask); + + /* Name and add the kobject */ + ret = kobject_add(&policy->kobj, cpufreq_global_kobject, + "policy%u", + cpumask_first(policy->related_cpus)); + if (ret) { + pr_err("%s: failed to add policy->kobj: %d\n", __func__, + ret); + goto out_exit_policy; + } } /*