Merge with upstream to accommodate with thermal changes
authorAnton Vorontsov <anton.vorontsov@linaro.org>
Tue, 31 Jul 2012 11:59:42 +0000 (04:59 -0700)
committerAnton Vorontsov <anton.vorontsov@linaro.org>
Tue, 31 Jul 2012 12:16:47 +0000 (05:16 -0700)
This merge is performed to take commit c56f5c0342dfee11a1 ("Thermal: Make
Thermal trip points writeable") out of Linus' tree and then fixup power
supply class. This is needed since thermal stuff added a new argument:

  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 3 of ‘thermal_zone_device_register’ makes integer from pointer without a cast [enabled by default]
include/linux/thermal.h:154:29: note: expected ‘int’ but argument is of type ‘struct power_supply *’
drivers/power/power_supply_core.c:204:6: error: too few arguments to function ‘thermal_zone_device_register’
include/linux/thermal.h:154:29: note: declared here
make[1]: *** [drivers/power/power_supply_core.o] Error 1
make: *** [drivers/power/] Error 2

Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
1  2 
drivers/power/power_supply_core.c

index ff990d26a0c03c4c13bdab9c003247705847082c,6ad612726785f48cdd8dbcc2785de8e211aae873..08cc8a3c15afb29b8147c1184c3477e543fdc01e
@@@ -170,63 -169,6 +170,63 @@@ static void power_supply_dev_release(st
        kfree(dev);
  }
  
-                       psy->tzd = thermal_zone_device_register(psy->name, 0,
 +#ifdef CONFIG_THERMAL
 +static int power_supply_read_temp(struct thermal_zone_device *tzd,
 +              unsigned long *temp)
 +{
 +      struct power_supply *psy;
 +      union power_supply_propval val;
 +      int ret;
 +
 +      WARN_ON(tzd == NULL);
 +      psy = tzd->devdata;
 +      ret = psy->get_property(psy, POWER_SUPPLY_PROP_TEMP, &val);
 +
 +      /* Convert tenths of degree Celsius to milli degree Celsius. */
 +      if (!ret)
 +              *temp = val.intval * 100;
 +
 +      return ret;
 +}
 +
 +static struct thermal_zone_device_ops psy_tzd_ops = {
 +      .get_temp = power_supply_read_temp,
 +};
 +
 +static int psy_register_thermal(struct power_supply *psy)
 +{
 +      int i;
 +
 +      /* Register battery zone device psy reports temperature */
 +      for (i = 0; i < psy->num_properties; i++) {
 +              if (psy->properties[i] == POWER_SUPPLY_PROP_TEMP) {
++                      psy->tzd = thermal_zone_device_register(psy->name, 0, 0,
 +                                      psy, &psy_tzd_ops, 0, 0, 0, 0);
 +                      if (IS_ERR(psy->tzd))
 +                              return PTR_ERR(psy->tzd);
 +                      break;
 +              }
 +      }
 +      return 0;
 +}
 +
 +static void psy_unregister_thermal(struct power_supply *psy)
 +{
 +      if (IS_ERR_OR_NULL(psy->tzd))
 +              return;
 +      thermal_zone_device_unregister(psy->tzd);
 +}
 +#else
 +static int psy_register_thermal(struct power_supply *psy)
 +{
 +      return 0;
 +}
 +
 +static void psy_unregister_thermal(struct power_supply *psy)
 +{
 +}
 +#endif
 +
  int power_supply_register(struct device *parent, struct power_supply *psy)
  {
        struct device *dev;