From patchwork Mon Nov 24 10:59:13 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 41399 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f71.google.com (mail-la0-f71.google.com [209.85.215.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 73FF823FFA for ; Mon, 24 Nov 2014 10:59:30 +0000 (UTC) Received: by mail-la0-f71.google.com with SMTP id s18sf5212552lam.10 for ; Mon, 24 Nov 2014 02:59:28 -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:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=AdJ5MXm2z0Ir7HS2HKZD+o5cYoqj0cWbwKVR4PhrV2E=; b=mfRViXxd/eKPxjpzYKooMWy9iigHyaNY/wpdOxBfeIMQd71gwxggB3evy/Hv9FgkuS gHlFZ7JGQNGODefKDYM0YgtxCnEFfV+sjgCVnq2Vlk2J6nOwTxmNRlgScaq5kqI79iA2 W+tzUkrsREV/Or9vLb2sRhiZ7xiw0Oc6yfwU4lEIw7nvyn/DpynXWQYFddI86lsigpdG eFgy4PmfsOLjPux716Bg0xxem622+9g/UHwBxFasBkhDY6spRiZiThNI6vez9Cj+c3Xf TseeYEuUxwsVWwKfrU1GWvAllj4xQ0seTEhdxmR2edgB59VML91KigtAz9GrJAlCS7ae Gg6A== X-Gm-Message-State: ALoCoQl1oj3JzMmnwrpqmA/dm2d++4bSORab3JGfQkOicSkQ77UbGm7c5Lg+nz7UeH347f4GEgpj X-Received: by 10.112.143.136 with SMTP id se8mr319333lbb.18.1416826768765; Mon, 24 Nov 2014 02:59:28 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.30.5 with SMTP id o5ls393382lah.84.gmail; Mon, 24 Nov 2014 02:59:28 -0800 (PST) X-Received: by 10.112.210.100 with SMTP id mt4mr19726839lbc.31.1416826768626; Mon, 24 Nov 2014 02:59:28 -0800 (PST) Received: from mail-la0-f54.google.com (mail-la0-f54.google.com. [209.85.215.54]) by mx.google.com with ESMTPS id la7si14749276lab.98.2014.11.24.02.59.28 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 24 Nov 2014 02:59:28 -0800 (PST) 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 mail-la0-f54.google.com with SMTP id gf13so7392972lab.27 for ; Mon, 24 Nov 2014 02:59:28 -0800 (PST) X-Received: by 10.152.43.79 with SMTP id u15mr16013202lal.29.1416826768502; Mon, 24 Nov 2014 02:59:28 -0800 (PST) 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.184.201 with SMTP id ew9csp231648lbc; Mon, 24 Nov 2014 02:59:27 -0800 (PST) X-Received: by 10.70.14.4 with SMTP id l4mr32358316pdc.56.1416826766989; Mon, 24 Nov 2014 02:59:26 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id rb7si20892713pab.142.2014.11.24.02.59.26 for ; Mon, 24 Nov 2014 02:59:26 -0800 (PST) Received-SPF: none (google.com: linux-pm-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 S1753693AbaKXK7X (ORCPT + 12 others); Mon, 24 Nov 2014 05:59:23 -0500 Received: from mail-pd0-f177.google.com ([209.85.192.177]:43226 "EHLO mail-pd0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753683AbaKXK7U (ORCPT ); Mon, 24 Nov 2014 05:59:20 -0500 Received: by mail-pd0-f177.google.com with SMTP id ft15so9474364pdb.22 for ; Mon, 24 Nov 2014 02:59:20 -0800 (PST) X-Received: by 10.68.221.162 with SMTP id qf2mr31772480pbc.148.1416826760152; Mon, 24 Nov 2014 02:59:20 -0800 (PST) Received: from localhost ([122.167.112.210]) by mx.google.com with ESMTPSA id oq6sm12102849pdb.45.2014.11.24.02.59.18 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 24 Nov 2014 02:59:19 -0800 (PST) From: Viresh Kumar To: Rafael Wysocki Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, l.majewski@samsung.com, edubezval@gmail.com, Viresh Kumar Subject: [PATCH] cpufreq-dt: register cooling device after validating cpufreq table Date: Mon, 24 Nov 2014 16:29:13 +0530 Message-Id: X-Mailer: git-send-email 2.0.3.693.g996b0fd 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: , of_cpufreq_cooling_register() can use frequency values from policy->min/max/cpuinfo.min_freq/cpuinfo.max_freq, which are available only after calling cpufreq_table_validate_and_show(). The right order of calling should be: cpufreq_table_validate_and_show() followed by of_cpufreq_cooling_register(). Fix it. Reported-by: Lukasz Majewski Reported-by: Eduardo Valentin Signed-off-by: Viresh Kumar --- For 3.18. --- drivers/cpufreq/cpufreq-dt.c | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/drivers/cpufreq/cpufreq-dt.c b/drivers/cpufreq/cpufreq-dt.c index 8cba13d..22eb6e5 100644 --- a/drivers/cpufreq/cpufreq-dt.c +++ b/drivers/cpufreq/cpufreq-dt.c @@ -186,7 +186,6 @@ static int cpufreq_init(struct cpufreq_policy *policy) { struct cpufreq_dt_platform_data *pd; struct cpufreq_frequency_table *freq_table; - struct thermal_cooling_device *cdev; struct device_node *np; struct private_data *priv; struct device *cpu_dev; @@ -269,20 +268,6 @@ static int cpufreq_init(struct cpufreq_policy *policy) goto out_free_priv; } - /* - * For now, just loading the cooling device; - * thermal DT code takes care of matching them. - */ - if (of_find_property(np, "#cooling-cells", NULL)) { - cdev = of_cpufreq_cooling_register(np, cpu_present_mask); - if (IS_ERR(cdev)) - dev_err(cpu_dev, - "running cpufreq without cooling device: %ld\n", - PTR_ERR(cdev)); - else - priv->cdev = cdev; - } - priv->cpu_dev = cpu_dev; priv->cpu_reg = cpu_reg; policy->driver_data = priv; @@ -292,7 +277,22 @@ static int cpufreq_init(struct cpufreq_policy *policy) if (ret) { dev_err(cpu_dev, "%s: invalid frequency table: %d\n", __func__, ret); - goto out_cooling_unregister; + goto out_free_cpufreq_table; + } + + /* + * For now, just loading the cooling device; + * thermal DT code takes care of matching them. + */ + if (of_find_property(np, "#cooling-cells", NULL)) { + priv->cdev = of_cpufreq_cooling_register(np, cpu_present_mask); + if (IS_ERR(priv->cdev)) { + dev_err(cpu_dev, + "running cpufreq without cooling device: %ld\n", + PTR_ERR(priv->cdev)); + + priv->cdev = NULL; + } } policy->cpuinfo.transition_latency = transition_latency; @@ -305,8 +305,7 @@ static int cpufreq_init(struct cpufreq_policy *policy) return 0; -out_cooling_unregister: - cpufreq_cooling_unregister(priv->cdev); +out_free_cpufreq_table: dev_pm_opp_free_cpufreq_table(cpu_dev, &freq_table); out_free_priv: kfree(priv);