aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEduardo Valentin <eduardo.valentin@ti.com>2013-03-15 09:00:16 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-03-15 12:02:22 -0400
commit0f0ed7dee23ff06456c13ad4f30829ccb761834b (patch)
tree0c45ece84cea19e6ec55d765c84fd1b78fb7ade0
parente7f60b5360ff093a220b0022e62648d9090eae4e (diff)
staging: omap-thermal: rename add_hyst to omap_bandgap_add_hyst
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 <eduardo.valentin@ti.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/staging/omap-thermal/omap-bandgap.c42
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 39bfe8d48eff..7b10d1851092 100644
--- a/drivers/staging/omap-thermal/omap-bandgap.c
+++ b/drivers/staging/omap-thermal/omap-bandgap.c
@@ -303,6 +303,28 @@ exit:
303 return ret; 303 return ret;
304} 304}
305 305
306static
307int omap_bandgap_add_hyst(struct omap_bandgap *bg_ptr, int adc_val,
308 int hyst_val, u32 *sum)
309{
310 int temp, ret;
311
312 /*
313 * Need to add in the mcelsius domain, so we have a temperature
314 * the conv_table range
315 */
316 ret = omap_bandgap_adc_to_mcelsius(bg_ptr, adc_val, &temp);
317 if (ret < 0)
318 goto exit;
319
320 temp += hyst_val;
321
322 ret = omap_bandgap_mcelsius_to_adc(bg_ptr, temp, sum);
323
324exit:
325 return ret;
326}
327
306/* Talert masks. Call it only if HAS(TALERT) is set */ 328/* Talert masks. Call it only if HAS(TALERT) is set */
307static int temp_sensor_unmask_interrupts(struct omap_bandgap *bg_ptr, int id, 329static int temp_sensor_unmask_interrupts(struct omap_bandgap *bg_ptr, int id,
308 u32 t_hot, u32 t_cold) 330 u32 t_hot, u32 t_cold)
@@ -330,20 +352,6 @@ static int temp_sensor_unmask_interrupts(struct omap_bandgap *bg_ptr, int id,
330 return 0; 352 return 0;
331} 353}
332 354
333static
334int add_hyst(int adc_val, int hyst_val, struct omap_bandgap *bg_ptr, u32 *sum)
335{
336 int temp, ret;
337
338 ret = omap_bandgap_adc_to_mcelsius(bg_ptr, adc_val, &temp);
339 if (ret < 0)
340 return ret;
341
342 temp += hyst_val;
343
344 return omap_bandgap_mcelsius_to_adc(bg_ptr, temp, sum);
345}
346
347/* Talert Thot threshold. Call it only if HAS(TALERT) is set */ 355/* Talert Thot threshold. Call it only if HAS(TALERT) is set */
348static 356static
349int temp_sensor_configure_thot(struct omap_bandgap *bg_ptr, int id, int t_hot) 357int 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)
361 __ffs(tsr->threshold_tcold_mask); 369 __ffs(tsr->threshold_tcold_mask);
362 if (t_hot <= cold) { 370 if (t_hot <= cold) {
363 /* change the t_cold to t_hot - 5000 millidegrees */ 371 /* change the t_cold to t_hot - 5000 millidegrees */
364 err |= add_hyst(t_hot, -ts_data->hyst_val, bg_ptr, &cold); 372 err |= omap_bandgap_add_hyst(bg_ptr, t_hot,
373 -ts_data->hyst_val, &cold);
365 /* write the new t_cold value */ 374 /* write the new t_cold value */
366 reg_val = thresh_val & (~tsr->threshold_tcold_mask); 375 reg_val = thresh_val & (~tsr->threshold_tcold_mask);
367 reg_val |= cold << __ffs(tsr->threshold_tcold_mask); 376 reg_val |= cold << __ffs(tsr->threshold_tcold_mask);
@@ -399,7 +408,8 @@ int temp_sensor_configure_tcold(struct omap_bandgap *bg_ptr, int id,
399 408
400 if (t_cold >= hot) { 409 if (t_cold >= hot) {
401 /* change the t_hot to t_cold + 5000 millidegrees */ 410 /* change the t_hot to t_cold + 5000 millidegrees */
402 err |= add_hyst(t_cold, ts_data->hyst_val, bg_ptr, &hot); 411 err |= omap_bandgap_add_hyst(bg_ptr, t_cold,
412 ts_data->hyst_val, &hot);
403 /* write the new t_hot value */ 413 /* write the new t_hot value */
404 reg_val = thresh_val & (~tsr->threshold_thot_mask); 414 reg_val = thresh_val & (~tsr->threshold_thot_mask);
405 reg_val |= hot << __ffs(tsr->threshold_thot_mask); 415 reg_val |= hot << __ffs(tsr->threshold_thot_mask);