From patchwork Mon May 19 06:29:11 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 4199741 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id E34E59F32A for ; Mon, 19 May 2014 06:29:40 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 215C020274 for ; Mon, 19 May 2014 06:29:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 309A52018E for ; Mon, 19 May 2014 06:29:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753264AbaESG3X (ORCPT ); Mon, 19 May 2014 02:29:23 -0400 Received: from mail-wg0-f49.google.com ([74.125.82.49]:62055 "EHLO mail-wg0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753257AbaESG3V (ORCPT ); Mon, 19 May 2014 02:29:21 -0400 Received: by mail-wg0-f49.google.com with SMTP id m15so7520105wgh.32 for ; Sun, 18 May 2014 23:29: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:from:to:cc:subject:date:message-id:in-reply-to :references; bh=DFZtvYgQulGYBCITSwMfpc23uLwsqq9Bb6RuW8xhTpc=; b=QFaBEOSmruEe02oArG4m/EuTbGo/SvXxG91MyItyv8iizT79mgyCjg2jXIIDjE9+I0 oUYmiXtOZvl+TMS7lZTtKBWLKAJDODPbViIF88qoNXXsDaGcuVJbFipMWq6vow6kDzSv cjtIkH2CPRllgcmcBNItyHb9dVTXkVfFb2gZrsIhF8O7EJhhtQTXmtp5SWC5lPxkH4/I UvY9y4TrUJbD0ot5E0AZuI+eFLuqe6Oq/w4UvpuIcWTKdlFqgFO2HQpB9wOrJpaIkyTi p874KqSS5hzEX9j9DeMtniBWsebHBb2BKxUmzgjCQay57XwdyxmUgnXDbGrdBnXkTran yI6g== X-Gm-Message-State: ALoCoQnX2wnNQGQFXVs/DNabuIXnUjRQ3tDlYW8DDOut/JVE5q8IpT+Dz7xoK9t7hdIKXNM2/soc X-Received: by 10.180.11.239 with SMTP id t15mr11015696wib.25.1400480960380; Sun, 18 May 2014 23:29:20 -0700 (PDT) Received: from localhost ([213.122.173.131]) by mx.google.com with ESMTPSA id vp5sm12837776wjc.31.2014.05.18.23.29.14 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sun, 18 May 2014 23:29:19 -0700 (PDT) From: Viresh Kumar To: rjw@rjwysocki.net Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, arvind.chauhan@arm.com, inderpal.s@samsung.com, pavel@ucw.cz, nm@ti.com, chander.kashyap@linaro.org, Viresh Kumar , Greg Kroah-Hartman , Amit Daniel Kachhap , Kukjin Kim , Shawn Guo , Sudeep Holla Subject: [PATCH Resend] driver/core: cpu: initialize opp table Date: Mon, 19 May 2014 11:59:11 +0530 Message-Id: X-Mailer: git-send-email 2.0.0.rc2 In-Reply-To: <60d825e8bfe01f8a5ff98fffaf51ffbf04c7d175.1400480033.git.viresh.kumar@linaro.org> References: <60d825e8bfe01f8a5ff98fffaf51ffbf04c7d175.1400480033.git.viresh.kumar@linaro.org> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP All drivers expecting CPU's OPPs from device tree initialize OPP table using of_init_opp_table() and there is nothing driver specific in that. They all do it in the same way adding to code redundancy. It would be better if we can get rid of code redundancy by initializing CPU OPPs from core code for all CPUs that have a "operating-points" property defined in their node. This patch initializes OPPs as soon as CPU device is registered in register_cpu(). Cc: Greg Kroah-Hartman Cc: Amit Daniel Kachhap Cc: Kukjin Kim Cc: Shawn Guo Cc: Sudeep Holla Signed-off-by: Viresh Kumar --- V1-V2: A colleague spotted some extra debug prints in my first mail :( Replace + pr_err("****%s: failed to init OPP table for cpu%d, err: %d\n", with + pr_err("%s: failed to init OPP table for cpu%d, err: %d\n", drivers/base/cpu.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c index 006b1bc..74ce944 100644 --- a/drivers/base/cpu.c +++ b/drivers/base/cpu.c @@ -16,6 +16,7 @@ #include #include #include +#include #include "base.h" @@ -349,11 +350,20 @@ int register_cpu(struct cpu *cpu, int num) if (cpu->hotpluggable) cpu->dev.groups = hotplugable_cpu_attr_groups; error = device_register(&cpu->dev); - if (!error) + if (!error) { per_cpu(cpu_sys_devices, num) = &cpu->dev; - if (!error) register_cpu_under_node(num, cpu_to_node(num)); + /* Initialize CPUs OPP table */ + if (of_node_get(cpu->dev.of_node)) { + error = of_init_opp_table(&cpu->dev); + if (error && error != -ENODEV) + pr_err("%s: failed to init OPP table for cpu%d, err: %d\n", + __func__, num, error); + of_node_put(cpu->dev.of_node); + } + } + return error; }