Merge tag 'for-v3.8-merged' of git://git.infradead.org/battery-2.6
authorLinus Torvalds <torvalds@linux-foundation.org>
Fri, 14 Dec 2012 03:26:04 +0000 (19:26 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 14 Dec 2012 03:26:04 +0000 (19:26 -0800)
Pull battery subsystem updates from Anton Vorontsov:
 "Highlights:

   - Two new drivers from Pali Roh├ír and N900 hackers: rx51_battery and
     bq2415x_charger.  The drivers are a part of a solution to replace
     the proprietary Nokia BME stack

   - Power supply core now registers devices with a thermal cooling
     subsystem, so we can now automatically throttle charging.  Thanks
     to Ramakrishna Pallala!

   - Device tree support for ab8500 and max8925_power drivers

   - Random fixups and enhancements for a bunch of drivers."

* tag 'for-v3.8-merged' of git://git.infradead.org/battery-2.6: (22 commits)
  max8925_power: Add support for device-tree initialization
  ab8500: Add devicetree support for chargalg
  ab8500: Add devicetree support for charger
  ab8500: Add devicetree support for btemp
  ab8500: Add devicetree support for fuelgauge
  twl4030_charger: Change TWL4030_MODULE_* ids to TWL_MODULE_*
  jz4740-battery: Use devm_request_and_ioremap
  jz4740-battery: Use devm_kzalloc
  bq27x00_battery: Fixup nominal available capacity reporting
  bq2415x_charger: Fix style issues
  bq2415x_charger: Add Kconfig/Makefile entries
  power_supply: Add bq2415x charger driver
  power_supply: Add new Nokia RX-51 (N900) power supply battery driver
  max17042_battery: Fix missing verify_model_lock() return value check
  ds2782_battery: Fix signedness bug in ds278x_read_reg16()
  lp8788-charger: Fix ADC channel names
  lp8788-charger: Fix wrong ADC conversion
  lp8788-charger: Use consumer device name on setting IIO channels
  power_supply: Register power supply for thermal cooling device
  power_supply: Add support for CHARGE_CONTROL_* attributes
  ...

1  2 
arch/arm/boot/dts/dbx5x0.dtsi
drivers/mfd/ab8500-core.c
drivers/power/Kconfig
drivers/power/Makefile
drivers/power/power_supply_core.c

index 0d69322f689f03bbe16b1d061d33cd847ced989f,12a68af4490333e040166a73a9024b2756d95c12..2efd9c891bc91f85522a6158854fd14e89b7f65f
                                reg = <0x80157450 0xC>;
                        };
  
 +                      thermal@801573c0 {
 +                              compatible = "stericsson,db8500-thermal";
 +                              reg = <0x801573c0 0x40>;
 +                              interrupts = <21 0x4>, <22 0x4>;
 +                              interrupt-names = "IRQ_HOTMON_LOW", "IRQ_HOTMON_HIGH";
 +                              status = "disabled";
 +                       };
 +
                        db8500-prcmu-regulators {
                                compatible = "stericsson,db8500-prcmu-regulator";
  
                                // DB8500_REGULATOR_VAPE
                                db8500_vape_reg: db8500_vape {
                                        regulator-compatible = "db8500_vape";
 -                                      regulator-name = "db8500-vape";
                                        regulator-always-on;
                                };
  
                                // DB8500_REGULATOR_VARM
                                db8500_varm_reg: db8500_varm {
                                        regulator-compatible = "db8500_varm";
 -                                      regulator-name = "db8500-varm";
                                };
  
                                // DB8500_REGULATOR_VMODEM
                                db8500_vmodem_reg: db8500_vmodem {
                                        regulator-compatible = "db8500_vmodem";
 -                                      regulator-name = "db8500-vmodem";
                                };
  
                                // DB8500_REGULATOR_VPLL
                                db8500_vpll_reg: db8500_vpll {
                                        regulator-compatible = "db8500_vpll";
 -                                      regulator-name = "db8500-vpll";
                                };
  
                                // DB8500_REGULATOR_VSMPS1
                                db8500_vsmps1_reg: db8500_vsmps1 {
                                        regulator-compatible = "db8500_vsmps1";
 -                                      regulator-name = "db8500-vsmps1";
                                };
  
                                // DB8500_REGULATOR_VSMPS2
                                db8500_vsmps2_reg: db8500_vsmps2 {
                                        regulator-compatible = "db8500_vsmps2";
 -                                      regulator-name = "db8500-vsmps2";
                                };
  
                                // DB8500_REGULATOR_VSMPS3
                                db8500_vsmps3_reg: db8500_vsmps3 {
                                        regulator-compatible = "db8500_vsmps3";
 -                                      regulator-name = "db8500-vsmps3";
                                };
  
                                // DB8500_REGULATOR_VRF1
                                db8500_vrf1_reg: db8500_vrf1 {
                                        regulator-compatible = "db8500_vrf1";
 -                                      regulator-name = "db8500-vrf1";
                                };
  
                                // DB8500_REGULATOR_SWITCH_SVAMMDSP
                                db8500_sva_mmdsp_reg: db8500_sva_mmdsp {
                                        regulator-compatible = "db8500_sva_mmdsp";
 -                                      regulator-name = "db8500-sva-mmdsp";
                                };
  
                                // DB8500_REGULATOR_SWITCH_SVAMMDSPRET
                                db8500_sva_mmdsp_ret_reg: db8500_sva_mmdsp_ret {
                                        regulator-compatible = "db8500_sva_mmdsp_ret";
 -                                      regulator-name = "db8500-sva-mmdsp-ret";
                                };
  
                                // DB8500_REGULATOR_SWITCH_SVAPIPE
                                db8500_sva_pipe_reg: db8500_sva_pipe {
                                        regulator-compatible = "db8500_sva_pipe";
 -                                      regulator-name = "db8500_sva_pipe";
                                };
  
                                // DB8500_REGULATOR_SWITCH_SIAMMDSP
                                db8500_sia_mmdsp_reg: db8500_sia_mmdsp {
                                        regulator-compatible = "db8500_sia_mmdsp";
 -                                      regulator-name = "db8500_sia_mmdsp";
                                };
  
                                // DB8500_REGULATOR_SWITCH_SIAMMDSPRET
                                db8500_sia_mmdsp_ret_reg: db8500_sia_mmdsp_ret {
 -                                      regulator-name = "db8500-sia-mmdsp-ret";
                                };
  
                                // DB8500_REGULATOR_SWITCH_SIAPIPE
                                db8500_sia_pipe_reg: db8500_sia_pipe {
                                        regulator-compatible = "db8500_sia_pipe";
 -                                      regulator-name = "db8500-sia-pipe";
                                };
  
                                // DB8500_REGULATOR_SWITCH_SGA
                                db8500_sga_reg: db8500_sga {
                                        regulator-compatible = "db8500_sga";
 -                                      regulator-name = "db8500-sga";
                                        vin-supply = <&db8500_vape_reg>;
                                };
  
                                // DB8500_REGULATOR_SWITCH_B2R2_MCDE
                                db8500_b2r2_mcde_reg: db8500_b2r2_mcde {
                                        regulator-compatible = "db8500_b2r2_mcde";
 -                                      regulator-name = "db8500-b2r2-mcde";
                                        vin-supply = <&db8500_vape_reg>;
                                };
  
                                // DB8500_REGULATOR_SWITCH_ESRAM12
                                db8500_esram12_reg: db8500_esram12 {
                                        regulator-compatible = "db8500_esram12";
 -                                      regulator-name = "db8500-esram12";
                                };
  
                                // DB8500_REGULATOR_SWITCH_ESRAM12RET
                                db8500_esram12_ret_reg: db8500_esram12_ret {
                                        regulator-compatible = "db8500_esram12_ret";
 -                                      regulator-name = "db8500-esram12-ret";
                                };
  
                                // DB8500_REGULATOR_SWITCH_ESRAM34
                                db8500_esram34_reg: db8500_esram34 {
                                        regulator-compatible = "db8500_esram34";
 -                                      regulator-name = "db8500-esram34";
                                };
  
                                // DB8500_REGULATOR_SWITCH_ESRAM34RET
                                db8500_esram34_ret_reg: db8500_esram34_ret {
                                        regulator-compatible = "db8500_esram34_ret";
 -                                      regulator-name = "db8500-esram34-ret";
                                };
                        };
  
                                        vddadc-supply = <&ab8500_ldo_tvout_reg>;
                                };
  
-                               ab8500-usb {
+                               ab8500_battery: ab8500_battery {
+                                       stericsson,battery-type = "LIPO";
+                                       thermistor-on-batctrl;
+                               };
+                               ab8500_fg {
+                                       compatible = "stericsson,ab8500-fg";
+                                       battery    = <&ab8500_battery>;
+                               };
+                               ab8500_btemp {
+                                       compatible = "stericsson,ab8500-btemp";
+                                       battery    = <&ab8500_battery>;
+                               };
+                               ab8500_charger {
+                                       compatible      = "stericsson,ab8500-charger";
+                                       battery         = <&ab8500_battery>;
+                                       vddadc-supply   = <&ab8500_ldo_tvout_reg>;
+                               };
+                               ab8500_chargalg {
+                                       compatible      = "stericsson,ab8500-chargalg";
+                                       battery         = <&ab8500_battery>;
+                               };
+                               ab8500_usb {
                                        compatible = "stericsson,ab8500-usb";
                                        interrupts = < 90 0x4
                                                       96 0x4
                                        // supplies to the display/camera
                                        ab8500_ldo_aux1_reg: ab8500_ldo_aux1 {
                                                regulator-compatible = "ab8500_ldo_aux1";
 -                                              regulator-name = "V-DISPLAY";
                                                regulator-min-microvolt = <2500000>;
                                                regulator-max-microvolt = <2900000>;
                                                regulator-boot-on;
                                        // supplies to the on-board eMMC
                                        ab8500_ldo_aux2_reg: ab8500_ldo_aux2 {
                                                regulator-compatible = "ab8500_ldo_aux2";
 -                                              regulator-name = "V-eMMC1";
                                                regulator-min-microvolt = <1100000>;
                                                regulator-max-microvolt = <3300000>;
                                        };
                                        // supply for VAUX3; SDcard slots
                                        ab8500_ldo_aux3_reg: ab8500_ldo_aux3 {
                                                regulator-compatible = "ab8500_ldo_aux3";
 -                                              regulator-name = "V-MMC-SD";
                                                regulator-min-microvolt = <1100000>;
                                                regulator-max-microvolt = <3300000>;
                                        };
                                        // supply for v-intcore12; VINTCORE12 LDO
                                        ab8500_ldo_initcore_reg: ab8500_ldo_initcore {
                                                regulator-compatible = "ab8500_ldo_initcore";
 -                                              regulator-name = "V-INTCORE";
                                        };
  
                                        // supply for tvout; gpadc; TVOUT LDO
                                        ab8500_ldo_tvout_reg: ab8500_ldo_tvout {
                                                regulator-compatible = "ab8500_ldo_tvout";
 -                                              regulator-name = "V-TVOUT";
                                        };
  
                                        // supply for ab8500-usb; USB LDO
                                        ab8500_ldo_usb_reg: ab8500_ldo_usb {
                                                regulator-compatible = "ab8500_ldo_usb";
 -                                              regulator-name = "dummy";
                                        };
  
                                        // supply for ab8500-vaudio; VAUDIO LDO
                                        ab8500_ldo_audio_reg: ab8500_ldo_audio {
                                                regulator-compatible = "ab8500_ldo_audio";
 -                                              regulator-name = "V-AUD";
                                        };
  
                                        // supply for v-anamic1 VAMic1-LDO
                                        ab8500_ldo_anamic1_reg: ab8500_ldo_anamic1 {
                                                regulator-compatible = "ab8500_ldo_anamic1";
 -                                              regulator-name = "V-AMIC1";
                                        };
  
                                        // supply for v-amic2; VAMIC2 LDO; reuse constants for AMIC1
                                        ab8500_ldo_amamic2_reg: ab8500_ldo_amamic2 {
                                                regulator-compatible = "ab8500_ldo_amamic2";
 -                                              regulator-name = "V-AMIC2";
                                        };
  
                                        // supply for v-dmic; VDMIC LDO
                                        ab8500_ldo_dmic_reg: ab8500_ldo_dmic {
                                                regulator-compatible = "ab8500_ldo_dmic";
 -                                              regulator-name = "V-DMIC";
                                        };
  
                                        // supply for U8500 CSI/DSI; VANA LDO
                                        ab8500_ldo_ana_reg: ab8500_ldo_ana {
                                                regulator-compatible = "ab8500_ldo_ana";
 -                                              regulator-name = "V-CSI/DSI";
                                        };
                                };
                        };
                        status = "disabled";
                };
  
 -              sdi@80126000 {
 +              sdi0_per1@80126000 {
                        compatible = "arm,pl18x", "arm,primecell";
                        reg = <0x80126000 0x1000>;
                        interrupts = <0 60 0x4>;
                        status = "disabled";
                };
  
 -              sdi@80118000 {
 +              sdi1_per2@80118000 {
                        compatible = "arm,pl18x", "arm,primecell";
                        reg = <0x80118000 0x1000>;
                        interrupts = <0 50 0x4>;
                        status = "disabled";
                };
  
 -              sdi@80005000 {
 +              sdi2_per3@80005000 {
                        compatible = "arm,pl18x", "arm,primecell";
                        reg = <0x80005000 0x1000>;
                        interrupts = <0 41 0x4>;
                        status = "disabled";
                };
  
 -              sdi@80119000 {
 +              sdi3_per2@80119000 {
                        compatible = "arm,pl18x", "arm,primecell";
                        reg = <0x80119000 0x1000>;
                        interrupts = <0 59 0x4>;
                        status = "disabled";
                };
  
 -              sdi@80114000 {
 +              sdi4_per2@80114000 {
                        compatible = "arm,pl18x", "arm,primecell";
                        reg = <0x80114000 0x1000>;
                        interrupts = <0 99 0x4>;
                        status = "disabled";
                };
  
 -              sdi@80008000 {
 +              sdi5_per3@80008000 {
                        compatible = "arm,pl18x", "arm,primecell";
                        reg = <0x80008000 0x1000>;
                        interrupts = <0 100 0x4>;
                        ranges = <0 0x50000000 0x4000000>;
                        status = "disabled";
                };
 +
 +              cpufreq-cooling {
 +                      compatible = "stericsson,db8500-cpufreq-cooling";
 +                      status = "disabled";
 +               };
 +
 +              vmmci: regulator-gpio {
 +                      compatible = "regulator-gpio";
 +
 +                      regulator-min-microvolt = <1800000>;
 +                      regulator-max-microvolt = <2600000>;
 +                      regulator-name = "mmci-reg";
 +                      regulator-type = "voltage";
 +
 +                      states = <1800000 0x1
 +                                2900000 0x0>;
 +
 +                      status = "disabled";
 +              };
        };
  };
index 3e27c031aeaa26fad637fadb86641851470595e0,908d09b8ff43f98fd3dd6af80e808277d0d1fd25..59da1650fb814ea5c688f2c83051734d6bc2e8a7
@@@ -565,10 -565,15 +565,10 @@@ static int ab8500_irq_init(struct ab850
        else
                num_irqs = AB8500_NR_IRQS;
  
 -      if (ab8500->irq_base) {
 -              ab8500->domain = irq_domain_add_legacy(
 -                      NULL, num_irqs, ab8500->irq_base,
 -                      0, &ab8500_irq_ops, ab8500);
 -      }
 -      else {
 -              ab8500->domain = irq_domain_add_linear(
 -                      np, num_irqs, &ab8500_irq_ops, ab8500);
 -      }
 +      /* If ->irq_base is zero this will give a linear mapping */
 +      ab8500->domain = irq_domain_add_simple(NULL,
 +                      num_irqs, ab8500->irq_base,
 +                      &ab8500_irq_ops, ab8500);
  
        if (!ab8500->domain) {
                dev_err(ab8500->dev, "Failed to create irqdomain\n");
@@@ -1036,23 -1041,43 +1036,43 @@@ static struct mfd_cell abx500_common_de
  static struct mfd_cell ab8500_bm_devs[] = {
        {
                .name = "ab8500-charger",
+               .of_compatible = "stericsson,ab8500-charger",
                .num_resources = ARRAY_SIZE(ab8500_charger_resources),
                .resources = ab8500_charger_resources,
+ #ifndef CONFIG_OF
+               .platform_data = &ab8500_bm_data,
+               .pdata_size = sizeof(ab8500_bm_data),
+ #endif
        },
        {
                .name = "ab8500-btemp",
+               .of_compatible = "stericsson,ab8500-btemp",
                .num_resources = ARRAY_SIZE(ab8500_btemp_resources),
                .resources = ab8500_btemp_resources,
+ #ifndef CONFIG_OF
+               .platform_data = &ab8500_bm_data,
+               .pdata_size = sizeof(ab8500_bm_data),
+ #endif
        },
        {
                .name = "ab8500-fg",
+               .of_compatible = "stericsson,ab8500-fg",
                .num_resources = ARRAY_SIZE(ab8500_fg_resources),
                .resources = ab8500_fg_resources,
+ #ifndef CONFIG_OF
+               .platform_data = &ab8500_bm_data,
+               .pdata_size = sizeof(ab8500_bm_data),
+ #endif
        },
        {
                .name = "ab8500-chargalg",
+               .of_compatible = "stericsson,ab8500-chargalg",
                .num_resources = ARRAY_SIZE(ab8500_chargalg_resources),
                .resources = ab8500_chargalg_resources,
+ #ifndef CONFIG_OF
+               .platform_data = &ab8500_bm_data,
+               .pdata_size = sizeof(ab8500_bm_data),
+ #endif
        },
  };
  
diff --combined drivers/power/Kconfig
index b1d956d81f0c341fc8f24a8c013e3ddc1d016079,263499f8709a3ffadb49f1e401139161504395c7..9f45e2f77d531748016db6799a39fcd7465b6ab9
@@@ -245,6 -245,13 +245,13 @@@ config BATTERY_INTEL_MI
          Say Y here to enable the battery driver on Intel MID
          platforms.
  
+ config BATTERY_RX51
+       tristate "Nokia RX-51 (N900) battery driver"
+       depends on TWL4030_MADC
+       help
+         Say Y here to enable support for battery information on Nokia
+         RX-51, also known as N900 tablet.
  config CHARGER_ISP1704
        tristate "ISP1704 USB Charger Detection"
        depends on USB_OTG_UTILS
@@@ -315,6 -322,16 +322,16 @@@ config CHARGER_MAX899
          Say Y to enable support for the battery charger control sysfs and
          platform data of MAX8998/LP3974 PMICs.
  
+ config CHARGER_BQ2415X
+       tristate "TI BQ2415x battery charger driver"
+       depends on I2C
+       help
+         Say Y to enable support for the TI BQ2415x battery charger
+         PMICs.
+         You'll need this driver to charge batteries on e.g. Nokia
+         RX-51/N900.
  config CHARGER_SMB347
        tristate "Summit Microelectronics SMB347 Battery Charger"
        depends on I2C
@@@ -329,15 -346,6 +346,8 @@@ config AB8500_B
        help
          Say Y to include support for AB8500 battery management.
  
- config AB8500_BATTERY_THERM_ON_BATCTRL
-       bool "Thermistor connected on BATCTRL ADC"
-       depends on AB8500_BM
-       help
-         Say Y to enable battery temperature measurements using
-         thermistor connected on BATCTRL ADC.
 +source "drivers/power/reset/Kconfig"
 +
  endif # POWER_SUPPLY
  
  source "drivers/power/avs/Kconfig"
diff --combined drivers/power/Makefile
index f1d99f4a0bc35b8b64c8e494a03c2f4049688985,696e3a960b3ea04fb96c88541759a99d2b9a61b7..22c8913382c0839bda10690268fb740e5ea42999
@@@ -37,7 -37,8 +37,8 @@@ obj-$(CONFIG_CHARGER_88PM860X)        += 88pm8
  obj-$(CONFIG_CHARGER_PCF50633)        += pcf50633-charger.o
  obj-$(CONFIG_BATTERY_JZ4740)  += jz4740-battery.o
  obj-$(CONFIG_BATTERY_INTEL_MID)       += intel_mid_battery.o
- obj-$(CONFIG_AB8500_BM)               += ab8500_charger.o ab8500_btemp.o ab8500_fg.o abx500_chargalg.o
+ obj-$(CONFIG_BATTERY_RX51)    += rx51_battery.o
+ obj-$(CONFIG_AB8500_BM)               += ab8500_bmdata.o ab8500_charger.o ab8500_btemp.o ab8500_fg.o abx500_chargalg.o
  obj-$(CONFIG_CHARGER_ISP1704) += isp1704_charger.o
  obj-$(CONFIG_CHARGER_MAX8903) += max8903_charger.o
  obj-$(CONFIG_CHARGER_TWL4030) += twl4030_charger.o
@@@ -47,6 -48,6 +48,7 @@@ obj-$(CONFIG_CHARGER_GPIO)    += gpio-char
  obj-$(CONFIG_CHARGER_MANAGER) += charger-manager.o
  obj-$(CONFIG_CHARGER_MAX8997) += max8997_charger.o
  obj-$(CONFIG_CHARGER_MAX8998) += max8998_charger.o
+ obj-$(CONFIG_CHARGER_BQ2415X) += bq2415x_charger.o
  obj-$(CONFIG_POWER_AVS)               += avs/
  obj-$(CONFIG_CHARGER_SMB347)  += smb347-charger.o
 +obj-$(CONFIG_POWER_RESET)     += reset/
index f77a41272e5d6f3e5f9fecf1b40b7a4a5e1bb459,f984da1066ec3e49d4cd7ec7203294f1638b9f0c..8a7cfb3cc16694e7fdd4881d9bede20b7aaf4099
@@@ -201,7 -201,7 +201,7 @@@ static int psy_register_thermal(struct 
        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);
 +                                      psy, &psy_tzd_ops, NULL, 0, 0);
                        if (IS_ERR(psy->tzd))
                                return PTR_ERR(psy->tzd);
                        break;
@@@ -216,6 -216,86 +216,86 @@@ static void psy_unregister_thermal(stru
                return;
        thermal_zone_device_unregister(psy->tzd);
  }
+ /* thermal cooling device callbacks */
+ static int ps_get_max_charge_cntl_limit(struct thermal_cooling_device *tcd,
+                                       unsigned long *state)
+ {
+       struct power_supply *psy;
+       union power_supply_propval val;
+       int ret;
+       psy = tcd->devdata;
+       ret = psy->get_property(psy,
+               POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT_MAX, &val);
+       if (!ret)
+               *state = val.intval;
+       return ret;
+ }
+ static int ps_get_cur_chrage_cntl_limit(struct thermal_cooling_device *tcd,
+                                       unsigned long *state)
+ {
+       struct power_supply *psy;
+       union power_supply_propval val;
+       int ret;
+       psy = tcd->devdata;
+       ret = psy->get_property(psy,
+               POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT, &val);
+       if (!ret)
+               *state = val.intval;
+       return ret;
+ }
+ static int ps_set_cur_charge_cntl_limit(struct thermal_cooling_device *tcd,
+                                       unsigned long state)
+ {
+       struct power_supply *psy;
+       union power_supply_propval val;
+       int ret;
+       psy = tcd->devdata;
+       val.intval = state;
+       ret = psy->set_property(psy,
+               POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT, &val);
+       return ret;
+ }
+ static struct thermal_cooling_device_ops psy_tcd_ops = {
+       .get_max_state = ps_get_max_charge_cntl_limit,
+       .get_cur_state = ps_get_cur_chrage_cntl_limit,
+       .set_cur_state = ps_set_cur_charge_cntl_limit,
+ };
+ static int psy_register_cooler(struct power_supply *psy)
+ {
+       int i;
+       /* Register for cooling device if psy can control charging */
+       for (i = 0; i < psy->num_properties; i++) {
+               if (psy->properties[i] ==
+                               POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT) {
+                       psy->tcd = thermal_cooling_device_register(
+                                                       (char *)psy->name,
+                                                       psy, &psy_tcd_ops);
+                       if (IS_ERR(psy->tcd))
+                               return PTR_ERR(psy->tcd);
+                       break;
+               }
+       }
+       return 0;
+ }
+ static void psy_unregister_cooler(struct power_supply *psy)
+ {
+       if (IS_ERR_OR_NULL(psy->tcd))
+               return;
+       thermal_cooling_device_unregister(psy->tcd);
+ }
  #else
  static int psy_register_thermal(struct power_supply *psy)
  {
  static void psy_unregister_thermal(struct power_supply *psy)
  {
  }
+ static int psy_register_cooler(struct power_supply *psy)
+ {
+       return 0;
+ }
+ static void psy_unregister_cooler(struct power_supply *psy)
+ {
+ }
  #endif
  
  int power_supply_register(struct device *parent, struct power_supply *psy)
        if (rc)
                goto register_thermal_failed;
  
+       rc = psy_register_cooler(psy);
+       if (rc)
+               goto register_cooler_failed;
        rc = power_supply_create_triggers(psy);
        if (rc)
                goto create_triggers_failed;
        goto success;
  
  create_triggers_failed:
+       psy_unregister_cooler(psy);
+ register_cooler_failed:
        psy_unregister_thermal(psy);
  register_thermal_failed:
        device_del(dev);
@@@ -284,6 -379,7 +379,7 @@@ void power_supply_unregister(struct pow
        cancel_work_sync(&psy->changed_work);
        sysfs_remove_link(&psy->dev->kobj, "powers");
        power_supply_remove_triggers(psy);
+       psy_unregister_cooler(psy);
        psy_unregister_thermal(psy);
        device_unregister(psy->dev);
  }