From patchwork Wed May 21 11:10:01 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 30524 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ob0-f198.google.com (mail-ob0-f198.google.com [209.85.214.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 9F55D20671 for ; Wed, 21 May 2014 11:11:02 +0000 (UTC) Received: by mail-ob0-f198.google.com with SMTP id va2sf7804238obc.9 for ; Wed, 21 May 2014 04:11:02 -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=ZKQg08MUpkDzmxs9MDvP57FWANHwwzMm+iHIIoS59w8=; b=LuNwh0ROH6SzaacuBjdF8tn+R1QKh0i2YLz7frEOlJH8YDTVSMbwieKTB4jlqRxMLl 99/EtEB0X1V/9c6CHJpBBDNFkIwoyHDdQAuFWiyS+3/zWn2Z+E4jT5eAnH1YTD5vxwdo b2ZxYHNGDPSrXC/Ps73D3FJGhX47q8PDk1AtsBhjz1s7lNHZku1NHxixaRL22lFV7gbQ qDaTZ1P1ufVzOzoLeS+H3F0ZnxAcC439emPz+SpZTfyhR9yg38iaS2rTuDpVBQ5j4F6T /ES+FadOHYZILjSXfGjwqfZDK97hhT7griOD0+/fDBgJHMwStmP1t2njG1m1MNdwaPaf Dmbw== X-Gm-Message-State: ALoCoQkIFp0ihs23Y3cx/km94JTBlS4CsBS75Z1+nRftiFS5a8Ihbzg+KdpOFiWswXo55QrDsovG X-Received: by 10.42.83.17 with SMTP id f17mr17905127icl.17.1400670662105; Wed, 21 May 2014 04:11:02 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.47.82 with SMTP id l76ls693787qga.61.gmail; Wed, 21 May 2014 04:11:01 -0700 (PDT) X-Received: by 10.52.164.70 with SMTP id yo6mr19596vdb.67.1400670661904; Wed, 21 May 2014 04:11:01 -0700 (PDT) Received: from mail-vc0-f182.google.com (mail-vc0-f182.google.com [209.85.220.182]) by mx.google.com with ESMTPS id qc5si2679200vcb.53.2014.05.21.04.11.01 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 21 May 2014 04:11:01 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.182 as permitted sender) client-ip=209.85.220.182; Received: by mail-vc0-f182.google.com with SMTP id la4so2299971vcb.13 for ; Wed, 21 May 2014 04:11:01 -0700 (PDT) X-Received: by 10.220.12.66 with SMTP id w2mr9101402vcw.15.1400670661810; Wed, 21 May 2014 04:11:01 -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.220.221.72 with SMTP id ib8csp103812vcb; Wed, 21 May 2014 04:11:01 -0700 (PDT) X-Received: by 10.66.251.233 with SMTP id zn9mr58477597pac.67.1400670660763; Wed, 21 May 2014 04:11:00 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id uv11si28693483pab.15.2014.05.21.04.11.00; Wed, 21 May 2014 04:11:00 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752329AbaEULKo (ORCPT + 27 others); Wed, 21 May 2014 07:10:44 -0400 Received: from mail-qc0-f174.google.com ([209.85.216.174]:57910 "EHLO mail-qc0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752300AbaEULKm (ORCPT ); Wed, 21 May 2014 07:10:42 -0400 Received: by mail-qc0-f174.google.com with SMTP id x13so2869393qcv.33 for ; Wed, 21 May 2014 04:10:41 -0700 (PDT) X-Received: by 10.140.36.105 with SMTP id o96mr64583223qgo.25.1400670641636; Wed, 21 May 2014 04:10:41 -0700 (PDT) Received: from localhost (ec2-23-23-178-99.compute-1.amazonaws.com. [23.23.178.99]) by mx.google.com with ESMTPSA id b5sm1449191qar.1.2014.05.21.04.10.35 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 21 May 2014 04:10:41 -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, nm@ti.com, chander.kashyap@linaro.org, pavel@ucw.cz, len.brown@intel.com, sudeep.holla@arm.com, Viresh Kumar , Greg Kroah-Hartman , Amit Daniel Kachhap , Kukjin Kim , Shawn Guo Subject: [PATCH V2 3/7] driver/core: cpu: initialize opp table Date: Wed, 21 May 2014 16:40:01 +0530 Message-Id: X-Mailer: git-send-email 2.0.0.rc2 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@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.220.182 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: , 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 Signed-off-by: Viresh Kumar --- drivers/base/cpu.c | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c index 006b1bc..853e99e 100644 --- a/drivers/base/cpu.c +++ b/drivers/base/cpu.c @@ -16,6 +16,7 @@ #include #include #include +#include #include "base.h" @@ -322,6 +323,25 @@ static int cpu_uevent(struct device *dev, struct kobj_uevent_env *env) } #endif +#if defined(CONFIG_PM_OPP) && defined(CONFIG_OF) +static inline void of_init_cpu_opp_table(struct cpu *cpu) +{ + int error; + + /* Initialize CPU's OPP table */ + error = of_init_opp_table(&cpu->dev); + if (!error) + dev_info(&cpu->dev, "%s: created OPP table for cpu: %d\n", + __func__, cpu->dev.id); + /* Print error only if there is an issue with OPP table */ + else if (error != -ENOSYS && error != -ENODEV) + dev_err(&cpu->dev, "%s: failed to init OPP table for cpu%d, err: %d\n", + __func__, cpu->dev.id, error); +} +#else +static inline void of_init_cpu_opp_table(struct cpu *cpu) {} +#endif + /* * register_cpu - Setup a sysfs device for a CPU. * @cpu - cpu->hotpluggable field set to 1 will generate a control file in @@ -349,10 +369,12 @@ 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) - per_cpu(cpu_sys_devices, num) = &cpu->dev; - if (!error) - register_cpu_under_node(num, cpu_to_node(num)); + if (error) + return error; + + per_cpu(cpu_sys_devices, num) = &cpu->dev; + register_cpu_under_node(num, cpu_to_node(num)); + of_init_cpu_opp_table(cpu); return error; }