From patchwork Mon Apr 8 12:19:13 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduardo Valentin X-Patchwork-Id: 2408271 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 0B5F53FC71 for ; Mon, 8 Apr 2013 12:22:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935569Ab3DHMWd (ORCPT ); Mon, 8 Apr 2013 08:22:33 -0400 Received: from bear.ext.ti.com ([192.94.94.41]:55097 "EHLO bear.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935351Ab3DHMWc (ORCPT ); Mon, 8 Apr 2013 08:22:32 -0400 Received: from dlelxv30.itg.ti.com ([172.17.2.17]) by bear.ext.ti.com (8.13.7/8.13.7) with ESMTP id r38CMTZ5013541; Mon, 8 Apr 2013 07:22:29 -0500 Received: from DFLE73.ent.ti.com (dfle73.ent.ti.com [128.247.5.110]) by dlelxv30.itg.ti.com (8.13.8/8.13.8) with ESMTP id r38CMTRM005971; Mon, 8 Apr 2013 07:22:29 -0500 Received: from dlelxv23.itg.ti.com (172.17.1.198) by DFLE73.ent.ti.com (128.247.5.110) with Microsoft SMTP Server id 14.2.342.3; Mon, 8 Apr 2013 07:22:29 -0500 Received: from legion.dal.design.ti.com (legion.dal.design.ti.com [128.247.22.53]) by dlelxv23.itg.ti.com (8.13.8/8.13.8) with ESMTP id r38CMTKQ002380; Mon, 8 Apr 2013 07:22:29 -0500 Received: from localhost (h68-18.vpn.ti.com [172.24.68.18]) by legion.dal.design.ti.com (8.11.7p1+Sun/8.11.7) with ESMTP id r38CMPV03387; Mon, 8 Apr 2013 07:22:26 -0500 (CDT) From: Eduardo Valentin To: CC: , , , Eduardo Valentin Subject: [PATCH 7/8] staging: ti-soc-thermal: defer probe if cpufreq is not ready Date: Mon, 8 Apr 2013 08:19:13 -0400 Message-ID: <1365423555-2669-8-git-send-email-eduardo.valentin@ti.com> X-Mailer: git-send-email 1.7.7.1.488.ge8e1c In-Reply-To: <1365423555-2669-1-git-send-email-eduardo.valentin@ti.com> References: <1365423555-2669-1-git-send-email-eduardo.valentin@ti.com> MIME-Version: 1.0 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org When builtin compiled, there is a chance for this driver be probed before cpufreq driver is up and running. In this case, the cpucooling device can be wrong initialized. Thus, this patch makes sure this driver is probed only when cpufreq driver is ready. Whenever there is no cpufreq driver registered, the probe will return -EPROBE_DEFER. Tested-by: J Keerthy Signed-off-by: Eduardo Valentin --- drivers/staging/ti-soc-thermal/ti-bandgap.c | 27 ++++++++++++++++--- drivers/staging/ti-soc-thermal/ti-thermal-common.c | 5 +++ 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/drivers/staging/ti-soc-thermal/ti-bandgap.c b/drivers/staging/ti-soc-thermal/ti-bandgap.c index 5b06b12..37fdba6 100644 --- a/drivers/staging/ti-soc-thermal/ti-bandgap.c +++ b/drivers/staging/ti-soc-thermal/ti-bandgap.c @@ -1305,12 +1305,18 @@ int ti_bandgap_probe(struct platform_device *pdev) for (i = 0; i < bgp->conf->sensor_count; i++) { char *domain; - if (bgp->conf->sensors[i].register_cooling) - bgp->conf->sensors[i].register_cooling(bgp, i); + if (bgp->conf->sensors[i].register_cooling) { + ret = bgp->conf->sensors[i].register_cooling(bgp, i); + if (ret) + goto remove_sensors; + } - domain = bgp->conf->sensors[i].domain; - if (bgp->conf->expose_sensor) - bgp->conf->expose_sensor(bgp, i, domain); + if (bgp->conf->expose_sensor) { + domain = bgp->conf->sensors[i].domain; + ret = bgp->conf->expose_sensor(bgp, i, domain); + if (ret) + goto remove_last_cooling; + } } /* @@ -1329,6 +1335,17 @@ int ti_bandgap_probe(struct platform_device *pdev) return 0; +remove_last_cooling: + if (bgp->conf->sensors[i].unregister_cooling) + bgp->conf->sensors[i].unregister_cooling(bgp, i); +remove_sensors: + for (i--; i >= 0; i--) { + if (bgp->conf->sensors[i].unregister_cooling) + bgp->conf->sensors[i].unregister_cooling(bgp, i); + if (bgp->conf->remove_sensor) + bgp->conf->remove_sensor(bgp, i); + } + ti_bandgap_power(bgp, false); disable_clk: if (TI_BANDGAP_HAS(bgp, CLK_CTRL)) clk_disable_unprepare(bgp->fclock); diff --git a/drivers/staging/ti-soc-thermal/ti-thermal-common.c b/drivers/staging/ti-soc-thermal/ti-thermal-common.c index 58e19bc..e3c5e67 100644 --- a/drivers/staging/ti-soc-thermal/ti-thermal-common.c +++ b/drivers/staging/ti-soc-thermal/ti-thermal-common.c @@ -339,6 +339,11 @@ int ti_thermal_register_cpu_cooling(struct ti_bandgap *bgp, int id) if (!data) return -EINVAL; + if (!cpufreq_get_current_driver()) { + dev_dbg(bgp->dev, "no cpufreq driver yet\n"); + return -EPROBE_DEFER; + } + /* Register cooling device */ data->cool_dev = cpufreq_cooling_register(cpu_present_mask); if (IS_ERR_OR_NULL(data->cool_dev)) {