From patchwork Fri Mar 15 13:00:16 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduardo Valentin X-Patchwork-Id: 2276781 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 F28F43FC8A for ; Fri, 15 Mar 2013 13:11:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754928Ab3CONLc (ORCPT ); Fri, 15 Mar 2013 09:11:32 -0400 Received: from comal.ext.ti.com ([198.47.26.152]:50477 "EHLO comal.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754661Ab3CONLa (ORCPT ); Fri, 15 Mar 2013 09:11:30 -0400 Received: from dlelxv30.itg.ti.com ([172.17.2.17]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id r2FDBR1r027386; Fri, 15 Mar 2013 08:11:27 -0500 Received: from DLEE71.ent.ti.com (dlee71.ent.ti.com [157.170.170.114]) by dlelxv30.itg.ti.com (8.13.8/8.13.8) with ESMTP id r2FDBRqU011581; Fri, 15 Mar 2013 08:11:27 -0500 Received: from dlelxv23.itg.ti.com (172.17.1.198) by DLEE71.ent.ti.com (157.170.170.114) with Microsoft SMTP Server id 14.2.342.3; Fri, 15 Mar 2013 08:11:26 -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 r2FDBQ6P001735; Fri, 15 Mar 2013 08:11:26 -0500 Received: from localhost (h64-13.vpn.ti.com [172.24.64.13]) by legion.dal.design.ti.com (8.11.7p1+Sun/8.11.7) with ESMTP id r2FDBNV10272; Fri, 15 Mar 2013 08:11:23 -0500 (CDT) From: Eduardo Valentin To: CC: , , , , Eduardo Valentin Subject: [PATCH 28/50] staging: omap-thermal: rename add_hyst to omap_bandgap_add_hyst Date: Fri, 15 Mar 2013 09:00:16 -0400 Message-ID: <1363352438-15935-29-git-send-email-eduardo.valentin@ti.com> X-Mailer: git-send-email 1.7.7.1.488.ge8e1c In-Reply-To: <1363352438-15935-1-git-send-email-eduardo.valentin@ti.com> References: <1363352438-15935-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 This patch improves the add_hyst function by: . Renaming it to omap_bandgap_add_hyst . Moving it to the ADC conversion functions section . Changing its signature to follow the driver standard Signed-off-by: Eduardo Valentin --- drivers/staging/omap-thermal/omap-bandgap.c | 42 ++++++++++++++++---------- 1 files changed, 26 insertions(+), 16 deletions(-) diff --git a/drivers/staging/omap-thermal/omap-bandgap.c b/drivers/staging/omap-thermal/omap-bandgap.c index 39bfe8d..7b10d18 100644 --- a/drivers/staging/omap-thermal/omap-bandgap.c +++ b/drivers/staging/omap-thermal/omap-bandgap.c @@ -303,6 +303,28 @@ exit: return ret; } +static +int omap_bandgap_add_hyst(struct omap_bandgap *bg_ptr, int adc_val, + int hyst_val, u32 *sum) +{ + int temp, ret; + + /* + * Need to add in the mcelsius domain, so we have a temperature + * the conv_table range + */ + ret = omap_bandgap_adc_to_mcelsius(bg_ptr, adc_val, &temp); + if (ret < 0) + goto exit; + + temp += hyst_val; + + ret = omap_bandgap_mcelsius_to_adc(bg_ptr, temp, sum); + +exit: + return ret; +} + /* Talert masks. Call it only if HAS(TALERT) is set */ static int temp_sensor_unmask_interrupts(struct omap_bandgap *bg_ptr, int id, u32 t_hot, u32 t_cold) @@ -330,20 +352,6 @@ static int temp_sensor_unmask_interrupts(struct omap_bandgap *bg_ptr, int id, return 0; } -static -int add_hyst(int adc_val, int hyst_val, struct omap_bandgap *bg_ptr, u32 *sum) -{ - int temp, ret; - - ret = omap_bandgap_adc_to_mcelsius(bg_ptr, adc_val, &temp); - if (ret < 0) - return ret; - - temp += hyst_val; - - return omap_bandgap_mcelsius_to_adc(bg_ptr, temp, sum); -} - /* Talert Thot threshold. Call it only if HAS(TALERT) is set */ static int temp_sensor_configure_thot(struct omap_bandgap *bg_ptr, int id, int t_hot) @@ -361,7 +369,8 @@ int temp_sensor_configure_thot(struct omap_bandgap *bg_ptr, int id, int t_hot) __ffs(tsr->threshold_tcold_mask); if (t_hot <= cold) { /* change the t_cold to t_hot - 5000 millidegrees */ - err |= add_hyst(t_hot, -ts_data->hyst_val, bg_ptr, &cold); + err |= omap_bandgap_add_hyst(bg_ptr, t_hot, + -ts_data->hyst_val, &cold); /* write the new t_cold value */ reg_val = thresh_val & (~tsr->threshold_tcold_mask); reg_val |= cold << __ffs(tsr->threshold_tcold_mask); @@ -399,7 +408,8 @@ int temp_sensor_configure_tcold(struct omap_bandgap *bg_ptr, int id, if (t_cold >= hot) { /* change the t_hot to t_cold + 5000 millidegrees */ - err |= add_hyst(t_cold, ts_data->hyst_val, bg_ptr, &hot); + err |= omap_bandgap_add_hyst(bg_ptr, t_cold, + ts_data->hyst_val, &hot); /* write the new t_hot value */ reg_val = thresh_val & (~tsr->threshold_thot_mask); reg_val |= hot << __ffs(tsr->threshold_thot_mask);