aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/ti-soc-thermal/ti-thermal-common.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2013-07-02 11:40:23 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2013-07-02 11:40:23 -0700
commitce49b6289fa3878b190f15192e54bb23dca552b6 (patch)
tree666f246067e02968d9526fb3e1a5f6ba70c7a4ca /drivers/staging/ti-soc-thermal/ti-thermal-common.c
parentMerge tag 'tty-3.11-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty (diff)
parentRevert "Revert "Revert "staging/lustre: drop CONFIG_BROKEN dependency""" (diff)
downloadlinux-dev-ce49b6289fa3878b190f15192e54bb23dca552b6.tar.xz
linux-dev-ce49b6289fa3878b190f15192e54bb23dca552b6.zip
Merge tag 'staging-3.11-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging
Pull staging tree update from Greg KH: "Here's the large staging tree merge for 3.11-rc1 Huge thing here is the Lustre client code. Unfortunatly, due to it not building properly on a wide variety of different architectures (this was production code???), it is currently disabled from the build so as to not annoy people. Other than Lustre, there are loads of comedi patches, working to clean up that subsystem, iio updates and new drivers, and a load of cleanups from the OPW applicants in their quest to get a summer internship. All of these have been in the linux-next releases for a while (hence the Lustre code being disabled)" Fixed up trivial conflict in drivers/staging/serqt_usb2/serqt_usb2.c due to independent renamings in the staging driver cleanup and the USB tree.. * tag 'staging-3.11-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging: (868 commits) Revert "Revert "Revert "staging/lustre: drop CONFIG_BROKEN dependency""" staging: rtl8192u: fix line length in r819xU_phy.h staging: rtl8192u: rename variables in r819xU_phy.h staging: rtl8192u: fix comments in r819xU_phy.h staging: rtl8192u: fix whitespace in r819xU_phy.h staging: rtl8192u: fix newlines in r819xU_phy.c staging: comedi: unioxx5: use comedi_alloc_spriv() staging: comedi: unioxx5: fix unioxx5_detach() silicom: checkpatch: errors caused by macros Staging: silicom: remove the board_t typedef in bpctl_mod.c Staging: silicom: capitalize labels in the bp_media_type enum Staging: silicom: remove bp_media_type enum typedef staging: rtl8192u: replace msleep(1) with usleep_range() in r819xU_phy.c staging: rtl8192u: rename dwRegRead and rtStatus in r819xU_phy.c staging: rtl8192u: replace __FUNCTION__ in r819xU_phy.c staging: rtl8192u: limit line size in r819xU_phy.c zram: allow request end to coincide with disksize staging: drm/imx: use generic irq chip unused field to block out invalid irqs staging: drm/imx: use generic irqchip staging: drm/imx: ipu-dmfc: use defines for ipu channel numbers ...
Diffstat (limited to 'drivers/staging/ti-soc-thermal/ti-thermal-common.c')
-rw-r--r--drivers/staging/ti-soc-thermal/ti-thermal-common.c30
1 files changed, 20 insertions, 10 deletions
diff --git a/drivers/staging/ti-soc-thermal/ti-thermal-common.c b/drivers/staging/ti-soc-thermal/ti-thermal-common.c
index e3c5e677eaa5..8e67ebf98404 100644
--- a/drivers/staging/ti-soc-thermal/ti-thermal-common.c
+++ b/drivers/staging/ti-soc-thermal/ti-thermal-common.c
@@ -38,6 +38,7 @@
/* common data structures */
struct ti_thermal_data {
struct thermal_zone_device *ti_thermal;
+ struct thermal_zone_device *pcb_tz;
struct thermal_cooling_device *cool_dev;
struct ti_bandgap *bgp;
enum thermal_device_mode mode;
@@ -77,10 +78,12 @@ static inline int ti_thermal_hotspot_temperature(int t, int s, int c)
static inline int ti_thermal_get_temp(struct thermal_zone_device *thermal,
unsigned long *temp)
{
+ struct thermal_zone_device *pcb_tz = NULL;
struct ti_thermal_data *data = thermal->devdata;
struct ti_bandgap *bgp;
const struct ti_temp_sensor *s;
- int ret, tmp, pcb_temp, slope, constant;
+ int ret, tmp, slope, constant;
+ unsigned long pcb_temp;
if (!data)
return 0;
@@ -92,16 +95,22 @@ static inline int ti_thermal_get_temp(struct thermal_zone_device *thermal,
if (ret)
return ret;
- pcb_temp = 0;
- /* TODO: Introduce pcb temperature lookup */
+ /* Default constants */
+ slope = s->slope;
+ constant = s->constant;
+
+ pcb_tz = data->pcb_tz;
/* In case pcb zone is available, use the extrapolation rule with it */
- if (pcb_temp) {
- tmp -= pcb_temp;
- slope = s->slope_pcb;
- constant = s->constant_pcb;
- } else {
- slope = s->slope;
- constant = s->constant;
+ if (!IS_ERR_OR_NULL(pcb_tz)) {
+ ret = thermal_zone_get_temp(pcb_tz, &pcb_temp);
+ if (!ret) {
+ tmp -= pcb_temp; /* got a valid PCB temp */
+ slope = s->slope_pcb;
+ constant = s->constant_pcb;
+ } else {
+ dev_err(bgp->dev,
+ "Failed to read PCB state. Using defaults\n");
+ }
}
*temp = ti_thermal_hotspot_temperature(tmp, slope, constant);
@@ -273,6 +282,7 @@ static struct ti_thermal_data
data->sensor_id = id;
data->bgp = bgp;
data->mode = THERMAL_DEVICE_ENABLED;
+ data->pcb_tz = thermal_zone_get_zone_by_name("pcb");
INIT_WORK(&data->thermal_wq, ti_thermal_work);
return data;