Commit Graph

67 Commits

Author SHA1 Message Date
Guenter Roeck 79a49168b5 thermal: fix potential out-of-bounds memory access
temp_crit.name and temp_input.name have a length of 16 bytes.  Using
THERMAL_NAME_LENGTH (20) as length parameter for snprintf() may result in
out-of-bounds memory accesses.  Replace it with sizeof().

Addresses Coverity #115679

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Cc: Len Brown <lenb@kernel.org>
Cc: "Brown, Len" <len.brown@intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
2012-09-24 14:44:37 +08:00
Zhang Rui f4a821ce6e Thermal: Introduce locking for cdev.thermal_instances list.
we need to go over all the thermal_instance list of a cooling device
to decide which cooling state to put the cooling device to.

But at this time, as a cooling device may be referenced in multiple
thermal zones, we need to lock the list first in case
another thermal zone is updating this cooling device.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Reviewed-by: Rafael J. Wysocki <rjw@sisk.pl>
Reviewed-by: Eduardo Valentin <eduardo.valentin@ti.com>
2012-09-24 14:44:37 +08:00
Zhang Rui 908b9fb792 Thermal: Unify the code for both active and passive cooling
Remove thermal_zone_device_passive(). And use
thermal_zone_trip_update() and thermal_zone_do_update()
for both active and passive cooling.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Reviewed-by: Rafael J. Wysocki <rjw@sisk.pl>
Reviewed-by: Eduardo Valentin <eduardo.valentin@ti.com>
2012-09-24 14:44:37 +08:00
Zhang Rui ce119f8325 Thermal: Introduce simple arbitrator for setting device cooling state
This fixes the problem that a cooling device may be referenced by
by multiple trip points in multiple thermal zones.

With this patch, we have two stages for updating a thermal zone,
1. check if a thermal_instance needs to be updated or not
2. update the cooling device, based on the target cooling state
   of all its instances.

Note that, currently, the cooling device is set to the deepest
cooling state required.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Reviewed-by: Rafael J. Wysocki <rjw@sisk.pl>
Reviewed-by: Eduardo Valentin <eduardo.valentin@ti.com>
2012-09-24 14:44:37 +08:00
Zhang Rui b5e4ae620b Thermal: List thermal_instance in thermal_cooling_device.
List thermal_instance in thermal_cooling_device so that
cooling device can know the cooling state requirement
of all the thermal instances.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Reviewed-by: Rafael J. Wysocki <rjw@sisk.pl>
Reviewed-by: Eduardo Valentin <eduardo.valentin@ti.com>
2012-09-24 14:44:37 +08:00
Zhang Rui cddf31b3b2 Thermal: Rename thermal_instance.node to thermal_instance.tz_node.
thermal_instance should be referenced by both thermal zone devices
and thermal cooling devices.

Rename thermal_instance.node to thermal_instance.tz_node in this patch
and thermal_instanace.cdev_node will be introduced in next patch.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Reviewed-by: Rafael J. Wysocki <rjw@sisk.pl>
Reviewed-by: Eduardo Valentin <eduardo.valentin@ti.com>
2012-09-24 14:44:37 +08:00
Zhang Rui 2d374139d5 Thermal: Rename thermal_zone_device.cooling_devices
Rename thermal_zone_device.cooling_devices
to thermal_zone_device.thermal_instances

thermal_zone_device.cooling_devices is not accurate
as this is a list for thermal instances, rather than cooling devices.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Reviewed-by: Rafael J. Wysocki <rjw@sisk.pl>
Reviewed-by: Eduardo Valentin <eduardo.valentin@ti.com>
2012-09-24 14:44:37 +08:00
Zhang Rui b81b6ba3d9 Thermal: rename structure thermal_cooling_device_instance to thermal_instance
This struct is used to describe the behavior for a thermal
cooling device on a certain trip point for a certain thremal zone.

thermal_cooling_device_instance is not accurate, as a cooling device
can be used for more than one trip point in one thermal zone device.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Reviewed-by: Rafael J. Wysocki <rjw@sisk.pl>
Reviewed-by: Eduardo Valentin <eduardo.valentin@ti.com>
2012-09-24 14:44:37 +08:00
Zhang Rui 4ae46befb4 Thermal: Introduce thermal_zone_trip_update()
This function is used to update the cooling state of
all the cooling devices that are bound to an active trip point.

This will be used for passive cooling as well, in the future patches.
as both active and passive cooling can share the same algorithm,
which is

1. if the temperature is higher than a trip point,
   a. if the trend is THERMAL_TREND_RAISING, use higher cooling
      state for this trip point
   b. if the trend is THERMAL_TREND_DROPPING, use lower cooling
      state for this trip point

2. if the temperature is lower than a trip point, use lower
   cooling state for this trip point.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Reviewed-by: Rafael J. Wysocki <rjw@sisk.pl>
Reviewed-by: Eduardo Valentin <eduardo.valentin@ti.com>
2012-09-24 14:44:37 +08:00
Zhang Rui 1b7ddb840c Thermal: Remove tc1/tc2 in generic thermal layer.
Remove tc1/tc2 in generic thermal layer.
.get_trend() callback starts to take effect from this patch.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Reviewed-by: Rafael J. Wysocki <rjw@sisk.pl>
Reviewed-by: Valentin, Eduardo <eduardo.valentin@ti.com>
2012-09-24 14:44:36 +08:00
Zhang Rui 601f3d4242 Thermal: Introduce .get_trend() callback.
According to ACPI spec, tc1 and tc2 are used by OSPM
to anticipate the temperature trends.
We introduced the same concept to the generic thermal layer
for passive cooling, but now it seems that these values
are hard to be used on other platforms.

So We introduce .get_trend() as a more general solution.

For the platform thermal drivers that have their own way to
anticipate the temperature trends, they should provide
their own .get_trend() callback.
Or else, we will calculate the temperature trends by simply
comparing the current temperature and the cached previous
temperature reading.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Reviewed-by: Rafael J. Wysocki <rjw@sisk.pl>
Reviewed-by: Valentin, Eduardo <eduardo.valentin@ti.com>
2012-09-24 14:44:36 +08:00
Zhang Rui 9d99842f99 Thermal: set upper and lower limits
set upper and lower limits when binding
a thermal cooling device to a thermal zone device.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Reviewed-by: Rafael J. Wysocki <rjw@sisk.pl>
Reviewed-by: Eduardo Valentin <eduardo.valentin@ti.com>
2012-09-24 14:44:36 +08:00
Zhang Rui 74051ba505 Thermal: Introduce cooling states range support
As the active cooling devices can have multiple cooling states,
we may want only several cooling states for a certain trip point,
and other cooling states for other active trip points.

To do this, we should be able to describe the cooling device
behavior for a certain trip point, rather than for the entire thermal zone.
And when updating thermal zone, we need to check the upper and lower limit
to make sure the cooling device is set to the proper cooling state.

Note that this patch will not bring any different behavior as
upper limit is set to max_state and lower limit is set to 0
in this patch, for now.

Next patch will set these to real values.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Reviewed-by: Rafael J. Wysocki <rjw@sisk.pl>
Reviewed-by: Eduardo Valentin <eduardo.valentin@ti.com>
2012-09-24 14:44:36 +08:00
Zhang Rui e3f25e6e58 Thermal: Introduce multiple cooling states support
This is because general active cooling devices, like fans,
may have multiple speeds, which can be mapped to different cooling states.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Reviewed-by: Rafael J. Wysocki <rjw@sisk.pl>
Reviewed-by: Valentin, Eduardo <eduardo.valentin@ti.com>
2012-09-24 14:44:36 +08:00
Linus Torvalds 4b24ff7110 The tag contains just a few battery-related changes for v3.6. It's is
all pretty straightforward, except one thing.
 
 One of our patches added thermal support for power supply class, but
 thermal/ subsystem changed under our feet. We (well, Stephen, that is)
 caught the issue and it was decided[1] that I'd just delay the battery
 pull request, and then will fix it up by merging upstream back into
 battery tree at the specific commit.
 
 That's not all though: another[2] small fixup for thermal subsystem was
 needed to get rid of a warning in power supply subsystem (the warning
 was not drivers/power's "fault", the thermal registration function just
 needed a proper const annotation, which is also done by a small commit
 on top of the merge.
 
 So, to sum this up:
 - The 'master' branch of the battery tree was in the -next tree for
   weeks, was never rebased, altered etc. It should be all OK;
 - Although, for-v3.6 tag contains the 'master' branch + merge + the
   warning fix.
 
 [1] http://lkml.org/lkml/2012/6/19/23
 [2] http://lkml.org/lkml/2012/6/18/28
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2.0.18 (GNU/Linux)
 
 iQIcBAABAgAGBQJQF9V8AAoJEGgI9fZJve1bLvkP/j/Nt1fBud2w5Q/NJr310hYJ
 NWIMSJwFbMhPoNd7sESznogXH8eHQ6YJP+CmkA5Gxr0t8pjEEJHEEyEcf1eNv6/c
 YDZfDB3TIaeYzulvRUkXMQ1f7hiA5Bq2t13yXeMM19+r9DzNZ51jZ3TXETLkpWZG
 BfZPg5wmP0xssXB3fjJMWuW5hVEc503WLpLFXkWfWKMU3PGdy/8DckV/YLvf2l7K
 1fkBLZry0gtruKqFbwcXhanP1JQ8FFFO8n1tSVLJhXXoym5twn/5GAgcpcKSFfJg
 mkGXAQLLuXKfERBIda7qbQl74HmTzYadCcueeXy1hTpom+VwfOpG+by2t/FrXT/M
 aJW6hfSLMgicG8FIuSYqbkutvijU9srU/YI00zrSGDBgi4sGKChRMf4sKQXnHO7X
 Lb7csQ7hEWsfG5gkgjRkmgZdhqWYoIxxe5Gv2Z9MKF27mHoSM03KHiZGlDJMrmNs
 w4KcU5H9tA62dT/UFszuu7NZenmsVS/ktiHWe5k+EXElZMZRrxKDJk2cvLPkRz/E
 VkXGvAmTDYPasZm29yzTnPKcuo6pfeOVJnUWybHOYxhkqAhJu1QzHCatqapgfy8E
 F2ODI5FoWtQES96B9t3tY4lTzq/0yUHcbiJt4BsyRcCGP+ggEQjCq0HGqOca12XX
 gxE20O3l+YQTCQIYKH+S
 =1NaS
 -----END PGP SIGNATURE-----

Merge tag 'for-v3.6' of git://git.infradead.org/battery-2.6

Pull battery updates from Anton Vorontsov:
 "The tag contains just a few battery-related changes for v3.6.  It's is
  all pretty straightforward, except one thing.

  One of our patches added thermal support for power supply class, but
  thermal/ subsystem changed under our feet.  We (well, Stephen, that
  is) caught the issue and it was decided[1] that I'd just delay the
  battery pull request, and then will fix it up by merging upstream back
  into battery tree at the specific commit.

  That's not all though: another[2] small fixup for thermal subsystem
  was needed to get rid of a warning in power supply subsystem (the
  warning was not drivers/power's "fault", the thermal registration
  function just needed a proper const annotation, which is also done by
  a small commit on top of the merge.

  So, to sum this up:
   - The 'master' branch of the battery tree was in the -next tree for
     weeks, was never rebased, altered etc.  It should be all OK;
   - Although, for-v3.6 tag contains the 'master' branch + merge + the
     warning fix.

  [1] http://lkml.org/lkml/2012/6/19/23
  [2] http://lkml.org/lkml/2012/6/18/28"

* tag 'for-v3.6' of git://git.infradead.org/battery-2.6: (23 commits)
  thermal: Constify 'type' argument for the registration routine
  olpc-battery: update CHARGE_FULL_DESIGN property for BYD LiFe batteries
  olpc-battery: Add VOLTAGE_MAX_DESIGN property
  charger-manager: Fix build break related to EXTCON
  lp8727_charger: Move header file into platform_data directory
  power_supply: Add min/max alert properties for CAPACITY, TEMP, TEMP_AMBIENT
  bq27x00_battery: Add support for BQ27425 chip
  charger-manager: Set current limit of regulator for over current protection
  charger-manager: Use EXTCON Subsystem to detect charger cables for charging
  test_power: Add VOLTAGE_NOW and BATTERY_TEMP properties
  test_power: Add support for USB AC source
  gpio-charger: Use cansleep version of gpio_set_value
  bq27x00_battery: Add support for power average and health properties
  sbs-battery: Don't trigger false supply_changed event
  twl4030_charger: Allow charger to control the regulator that feeds it
  twl4030_charger: Add backup-battery charging
  twl4030_charger: Fix some typos
  max17042_battery: Support CHARGE_COUNTER power supply attribute
  smb347-charger: Add constant charge and current properties
  power_supply: Add constant charge_current and charge_voltage properties
  ...
2012-07-31 18:08:25 -07:00
Anton Vorontsov 4b1bf5871f thermal: Constify 'type' argument for the registration routine
thermal_zone_device_register() does not modify 'type' argument, so it is
safe to declare it as const. Otherwise, if we pass a const string, we are
getting the ugly warning:

CC drivers/power/power_supply_core.o
drivers/power/power_supply_core.c: In function 'psy_register_thermal':
drivers/power/power_supply_core.c:204:6: warning: passing argument 1 of 'thermal_zone_device_register' discards 'const' qualifier from pointer target type [enabled by default]
include/linux/thermal.h:140:29: note: expected 'char *' but argument is of type 'const char *'

Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
Acked-by: Jean Delvare <khali@linux-fr.org>
2012-07-31 05:45:37 -07:00
Len Brown ec033d0a02 Merge branches 'acpi_pad', 'acpica', 'apei-bugzilla-43282', 'battery', 'cpuidle-coupled', 'cpuidle-tweaks', 'intel_idle-ivb', 'ost', 'red-hat-bz-772730', 'thermal', 'thermal-spear' and 'turbostat-v2' into release 2012-07-26 00:03:58 -04:00
Durgadoss R 27365a6c7d Thermal: Add Hysteresis attributes
The Linux Thermal Framework does not support hysteresis
attributes. Most thermal sensors, today, have a
hysteresis value associated with trip points.

This patch adds hysteresis attributes on a per-trip-point
basis, to the Thermal Framework. These attributes are
optionally writable.

Signed-off-by: Durgadoss R <durgadoss.r@intel.com>
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
2012-07-24 23:19:26 -04:00
Durgadoss R c56f5c0342 Thermal: Make Thermal trip points writeable
Some of the thermal drivers using the Generic Thermal Framework
require (all/some) trip points to be writeable. This patch makes
the trip point temperatures writeable on a per-trip point basis,
and modifies the required function call in thermal.c. This patch
also updates the Documentation to reflect the new change.

Signed-off-by: Durgadoss R <durgadoss.r@intel.com>
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
2012-07-24 23:17:20 -04:00
Viresh Kumar b9c7aff481 drivers/thermal/spear_thermal.c: add Device Tree probing capability
SPEAr platforms now support DT and so must convert all drivers to support
DT.  This patch adds DT probing support for SPEAr thermal sensor driver
and updates its documentation too.

Also, as SPEAr is the only user of this driver and is only available with
DT, make this an only DT driver.  So, platform_data is completely removed
and passed via DT now.

Signed-off-by: Viresh Kumar <viresh.kumar@st.com>
Cc: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Vincenzo Frascino <vincenzo.frascino@st.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Len Brown <len.brown@intel.com>
2012-06-02 01:49:38 -04:00
Amit Daniel Kachhap f1f0e2ac59 thermal: Fix for setting the thermal zone mode to enable/disable
Basically without this patch changing the mode of thermal zone
is not possible as wrong string size is passed to strncmp.

Signed-off-by: Amit Daniel Kachhap <amit.kachhap@linaro.org>
Acked-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Len Brown <len.brown@intel.com>
2012-03-22 01:10:18 -04:00
Dan Carpenter 03ee62f0b9 thermal: spear13xx: checking for NULL instead of IS_ERR()
thermal_zone_device_register() never returns NULL, on error it returns and
ERR_PTR().

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Viresh Kumar <viresh.kumar@st.com>
Reviewed-by: Vincenzo Frascino <vincenzo.frascino@st.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Len Brown <len.brown@intel.com>
2012-03-22 01:07:22 -04:00
Viresh Kumar de716e32e6 thermal/spear_thermal: replace readl/writel with lighter _relaxed variants
readl/writel versions for ARM contain memory barrier instruction for
synchronizing DMA buffers.  These are not required at least on this
module.  So use lighter _relaxed variants.

Signed-off-by: Viresh Kumar <viresh.kumar@st.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Len Brown <len.brown@intel.com>
2012-03-22 01:06:43 -04:00
Vincenzo Frascino 6a92c36688 thermal: add support for thermal sensor present on SPEAr13xx machines
ST's SPEAr13xx machines are based on CortexA9 ARM processors.  These
machines contain a thermal sensor for junction temperature monitoring.

This patch adds support for this thermal sensor in existing thermal
framework.

[akpm@linux-foundation.org: little code cleanup]
[akpm@linux-foundation.org: print the pointer correctly]
[viresh.kumar@st.com: thermal/spear_thermal: add compilation dependency on PLAT_SPEAR]
Signed-off-by: Vincenzo Frascino <vincenzo.frascino@st.com>
Signed-off-by: Viresh Kumar <viresh.kumar@st.com>
Signed-off-by: Viresh Kumar <viresh.kumar@st.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Len Brown <len.brown@intel.com>
2012-03-22 01:05:32 -04:00
Joe Perches c5a01dd52d thermal_sys: convert printks to pr_<level>
Use the current logging style.

Remove PREFIX, add pr_fmt, convert the printks.  All dmesg output now
prefixed with "thermal_sys: ".

Signed-off-by: Joe Perches <joe@perches.com>
Cc: Jesper Juhl <jj@chaosbits.net>
Cc: Len Brown <lenb@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Len Brown <len.brown@intel.com>
2012-03-22 01:04:40 -04:00
Joe Perches caca8b8035 thermal_sys: kernel style cleanups
Just a few tidies to make it more like most kernel sources.

A couple of long lines still remain.

Signed-off-by: Joe Perches <joe@perches.com>
Reviewed-by: Jesper Juhl <jj@chaosbits.net>
Cc: Len Brown <lenb@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Len Brown <len.brown@intel.com>
2012-03-22 01:03:09 -04:00
Joe Perches ec79768560 thermal_sys: remove obfuscating used-once macros
These don't add any value as they are used only once and the surrounding
code uses similar variable.

Signed-off-by: Joe Perches <joe@perches.com>
Cc: Jesper Juhl <jj@chaosbits.net>
Cc: Len Brown <lenb@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Len Brown <len.brown@intel.com>
2012-03-22 01:02:31 -04:00
Joe Perches 886ee54635 thermal_sys: remove unnecessary line continuations
Line continations are not necessary in function calls or statements.
Remove them.

Signed-off-by: Joe Perches <joe@perches.com>
Reviewed-by: Jesper Juhl <jj@chaosbits.net>
Cc: Len Brown <lenb@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Len Brown <len.brown@intel.com>
2012-03-22 01:01:46 -04:00
Fabio Estevam b11de07ce5 drivers/thermal/thermal_sys.c: fix build warning
With CONFIG_NET=n:

drivers/thermal/thermal_sys.c:63: warning: 'thermal_event_seqnum' defined but not used

Move 'thermal_event_seqnum' definition inside the '#ifdef CONFIG_NET'

[akpm@linux-foundation.org: make thermal_event_seqnum local to generate_netlink_event()]
Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
Acked-by: Guenter Roeck <guenter.roeck@ericsson.com>
Acked-by: Durgadoss R <durgadoss.r@intel.com>
Cc: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Len Brown <len.brown@intel.com>
2012-03-22 01:01:27 -04:00
Jean Delvare 2d58d7ea91 thermal: Rename generate_netlink_event
It doesn't seem right for the thermal subsystem to export a symbol
named generate_netlink_event. This function is thermal-specific and
its name should reflect that fact. Rename it to
thermal_generate_netlink_event.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Acked-by: Rafael J. Wysocki <rjw@sisk.pl>
Acked-by: R.Durgadoss <durgadoss.r@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
2012-01-23 03:15:25 -05:00
Rafael J. Wysocki 51e20d0e3a thermal: Prevent polling from happening during system suspend
The thermal driver should use a freezable workqueue to schedule
polling to prevent thermal_zone_device_update() from being run
during system suspend, when the devices it relies on may be inactive.
Make it use the system freezable workqueue for this purpose.

Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Signed-off-by: Len Brown <len.brown@intel.com>
2011-11-06 20:38:49 -05:00
Jean Delvare 31f5396ad3 thermal: make THERMAL_HWMON implementation fully internal
THERMAL_HWMON is implemented inside the thermal_sys driver and has no
effect on drivers implementing thermal zones, so they shouldn't see
anything related to it in <linux/thermal.h>.  Making the THERMAL_HWMON
implementation fully internal has two advantages beyond the cleaner
design:

* This avoids rebuilding all thermal drivers if the THERMAL_HWMON
  implementation changes, or if CONFIG_THERMAL_HWMON gets enabled or
  disabled.

* This avoids breaking the thermal kABI in these cases too, which should
  make distributions happy.

The only drawback I can see is slightly higher memory fragmentation, as
the number of kzalloc() calls will increase by one per thermal zone.  But
I doubt it will be a problem in practice, as I've never seen a system with
more than two thermal zones.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Cc: Rene Herman <rene.herman@gmail.com>
Acked-by: Guenter Roeck <guenter.roeck@ericsson.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Len Brown <len.brown@intel.com>
2011-08-02 14:51:57 -04:00
Jean Delvare 0d97d7a494 thermal: split hwmon lookup to a separate function
We'll soon need to reuse it.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Cc: Rene Herman <rene.herman@gmail.com>
Acked-by: Guenter Roeck <guenter.roeck@ericsson.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Len Brown <len.brown@intel.com>
2011-08-02 14:51:41 -04:00
Jean Delvare ab92402af0 thermal: hide CONFIG_THERMAL_HWMON
It's about time to revert 16d7523973 ("thermal: Create
CONFIG_THERMAL_HWMON=n").  Anybody running a kernel >= 2.6.40 would also
be running a recent enough version of lm-sensors.

Actually having CONFIG_THERMAL_HWMON is pretty convenient so instead of
dropping it, we keep it but hide it.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Cc: Rene Herman <rene.herman@gmail.com>
Acked-by: Guenter Roeck <guenter.roeck@ericsson.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Len Brown <len.brown@intel.com>
2011-08-02 14:51:25 -04:00
Durgadoss R b299eb5cde ACPI:Fix goto flows in thermal-sys
This patch fixes two minor bugs in thermal_sys:
(a) The flow of goto's in thermal_hwmon_add_sysfs.
(b) Remove the temp*_crit only if there is a get_crit_temp defined, in
    thermal_remove_hwmon_sysfs.

Signed-off-by: Durgadoss R <durgadoss.r@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
2011-03-23 01:43:44 -04:00
Rafael J. Wysocki af06216a8e ACPI: Fix build for CONFIG_NET unset
Several ACPI drivers fail to build if CONFIG_NET is unset, because
they refer to things depending on CONFIG_THERMAL that in turn depends
on CONFIG_NET.  However, CONFIG_THERMAL doesn't really need to depend
on CONFIG_NET, because the only part of it requiring CONFIG_NET is
the netlink interface in thermal_sys.c.

Put the netlink interface in thermal_sys.c under #ifdef CONFIG_NET
and remove the dependency of CONFIG_THERMAL on CONFIG_NET from
drivers/thermal/Kconfig.

Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Acked-by: Randy Dunlap <randy.dunlap@oracle.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Len Brown <lenb@kernel.org>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>
Cc: Luming Yu <luming.yu@intel.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-02-28 18:00:31 -08:00
Len Brown 156d821270 Merge branch 'misc' into release 2011-01-12 05:14:15 -05:00
R.Durgadoss 4cb1872870 thermal: Add event notification to thermal framework
This patch adds event notification support to the generic
thermal sysfs framework in the kernel. The notification is in the
form of a netlink event.

Signed-off-by: R.Durgadoss <durgadoss.r@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
2011-01-12 00:08:35 -05:00
Alan Cox 5b275ce270 thermal: make ops constant
And while touching that function definition do something about the disaster
of formatting there.

Signed-off-by: Alan Cox <alan@linux.intel.com>
Acked-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
2010-11-30 18:56:23 -05:00
Sergey Senozhatsky 975f8c5653 drivers/thermal/thermal_sys.c: fix 'key f70f4b50 not in .data' in thermal_sys
Initialize sysfs attributes before device_create_file call.

Addresses https://bugzilla.kernel.org/show_bug.cgi?id=15548

Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Greg KH <gregkh@suse.de>
Cc: Zhang Rui <rui.zhang@intel.com>
Cc: Len Brown <len.brown@intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2010-04-07 08:38:03 -07:00
Tejun Heo 5a0e3ad6af include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files.  percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.

percpu.h -> slab.h dependency is about to be removed.  Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability.  As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.

  http://userweb.kernel.org/~tj/misc/slabh-sweep.py

The script does the followings.

* Scan files for gfp and slab usages and update includes such that
  only the necessary includes are there.  ie. if only gfp is used,
  gfp.h, if slab is used, slab.h.

* When the script inserts a new include, it looks at the include
  blocks and try to put the new include such that its order conforms
  to its surrounding.  It's put in the include block which contains
  core kernel includes, in the same order that the rest are ordered -
  alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
  doesn't seem to be any matching order.

* If the script can't find a place to put a new include (mostly
  because the file doesn't have fitting include block), it prints out
  an error message indicating which .h file needs to be added to the
  file.

The conversion was done in the following steps.

1. The initial automatic conversion of all .c files updated slightly
   over 4000 files, deleting around 700 includes and adding ~480 gfp.h
   and ~3000 slab.h inclusions.  The script emitted errors for ~400
   files.

2. Each error was manually checked.  Some didn't need the inclusion,
   some needed manual addition while adding it to implementation .h or
   embedding .c file was more appropriate for others.  This step added
   inclusions to around 150 files.

3. The script was run again and the output was compared to the edits
   from #2 to make sure no file was left behind.

4. Several build tests were done and a couple of problems were fixed.
   e.g. lib/decompress_*.c used malloc/free() wrappers around slab
   APIs requiring slab.h to be added manually.

5. The script was run on all .h files but without automatically
   editing them as sprinkling gfp.h and slab.h inclusions around .h
   files could easily lead to inclusion dependency hell.  Most gfp.h
   inclusion directives were ignored as stuff from gfp.h was usually
   wildly available and often used in preprocessor macros.  Each
   slab.h inclusion directive was examined and added manually as
   necessary.

6. percpu.h was updated not to include slab.h.

7. Build test were done on the following configurations and failures
   were fixed.  CONFIG_GCOV_KERNEL was turned off for all tests (as my
   distributed build env didn't work with gcov compiles) and a few
   more options had to be turned off depending on archs to make things
   build (like ipr on powerpc/64 which failed due to missing writeq).

   * x86 and x86_64 UP and SMP allmodconfig and a custom test config.
   * powerpc and powerpc64 SMP allmodconfig
   * sparc and sparc64 SMP allmodconfig
   * ia64 SMP allmodconfig
   * s390 SMP allmodconfig
   * alpha SMP allmodconfig
   * um on x86_64 SMP allmodconfig

8. percpu.h modifications were reverted so that it could be applied as
   a separate patch and serve as bisection point.

Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.

Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-30 22:02:32 +09:00
Len Brown aa96ce0af8 Merge branch 'misc-2.6.33' into release 2009-12-16 14:22:32 -05:00
Roel Kluin edb9491852 thermal: Fix test of unsigned in thermal_cooling_device_cur_state_store()
state is unsigned long so the test did not work.

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
Acked-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
2009-12-16 00:07:21 -05:00
Frans Pop 3767cb54ac thermal: disable polling if passive_delay and polling_delay are both unset
Otherwise polling will continue for the thermal zone even when
it is no longer needed, for example because forced passive cooling
was disabled.

Signed-off-by: Frans Pop <elendil@planet.nl>
Acked-by: Matthew Garrett <mjg@redhat.com>
Acked-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Len Brown <len.brown@intel.com>
2009-11-05 18:19:01 -05:00
Frans Pop e4143b0324 thermal: Only set passive_delay for forced_passive cooling
Setting polling_delay is useless as passive_delay has priority,
so the value shown in proc isn't the actual polling delay. It
also gives the impression to the user that he can change the
polling interval through proc, while in fact he can't.

Also, unset passive_delay when the forced passive trip point is
unbound to allow polling to be disabled.

Signed-off-by: Frans Pop <elendil@planet.nl>
Acked-by: Matthew Garrett <mjg@redhat.com>
Acked-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Len Brown <len.brown@intel.com>
2009-11-05 18:18:36 -05:00
Frans Pop 3d8e3ad879 thermal: add sanity check for the passive attribute
Values below 1000 milli-celsius don't make sense and can cause the
system to go into a thermal heart attack: the actual temperature
will always be lower and thus the system will be throttled down to
its lowest setting.

An additional problem is that values below 1000 will show as 0 in
/proc/acpi/thermal/TZx/trip_points:passive.

cat passive
0
echo -n 90 >passive
bash: echo: write error: Invalid argument
echo -n 90000 >passive
cat passive
90000

Signed-off-by: Frans Pop <elendil@planet.nl>
Acked-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Len Brown <len.brown@intel.com>
2009-11-05 18:18:10 -05:00
Amit Kucheria 625120a42b acpi: thermal: Add EOL to the trip_point_N_type strings
Make the trip_point_N_type sysfs files return a string ending in EOL for
consistency with other sysfs files.

Signed-off-by: Amit Kucheria <amit.kucheria@canonical.com>
Acked-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Len Brown <len.brown@intel.com>
2009-11-05 17:33:24 -05:00
Jan Beulich df43176c93 thermal: add missing Kconfig dependency
Otherwise THERMAL_HWMON can be selected when HWMON=n and THERMAL=n, which
fails to build.

Signed-off-by: Jan Beulich <jbeulich@novell.com>
Cc: Zhang Rui <rui.zhang@intel.com>
Cc: Matthew Garrett <mjg@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Len Brown <len.brown@intel.com>
2009-09-19 01:41:49 -04:00
Michael Brunner 0d288162f2 thermal_sys: check get_temp return value
The return value of the get_temp function is not checked when doing a
thermal zone update.  This may lead to a critical shutdown if get_temp
fails and the content of the temp variable is incorrectly set higher than
the critical trip point.

This has been observed on a system with incorrect ACPI implementation
where the corresponding methods were not serialized and therefore
sometimes triggered ACPI errors (AE_ALREADY_EXISTS).  The following
critical shutdowns indicated a temperature of 2097 C, which was obviously
wrong.

The patch adds a return value check that jumps over all trip point
evaluations printing a warning if get_temp fails.  The trip points are
evaluated again on the next polling interval with successful get_temp
execution.

Signed-off-by: Michael Brunner <mibru@gmx.de>
Acked-by: Zhang Rui <rui.zhang@intel.com>
Cc: Len Brown <lenb@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2009-08-26 20:06:52 -07:00
Greg Kroah-Hartman 0e968a3b6d thermal: remove driver_data direct access of struct device
In the near future, the driver core is going to not allow direct access
to the driver_data pointer in struct device.  Instead, the functions
dev_get_drvdata() and dev_set_drvdata() should be used.  These functions
have been around since the beginning, so are backwards compatible with
all older kernel versions.


Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-06-15 21:30:27 -07:00