aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/devicetree/bindings/power_supply/lp8727_charger.txt44
-rw-r--r--MAINTAINERS8
-rw-r--r--drivers/power/88pm860x_battery.c1
-rw-r--r--drivers/power/88pm860x_charger.c1
-rw-r--r--drivers/power/ab8500_btemp.c1
-rw-r--r--drivers/power/ab8500_charger.c2
-rw-r--r--drivers/power/ab8500_fg.c7
-rw-r--r--drivers/power/abx500_chargalg.c1
-rw-r--r--drivers/power/bq27x00_battery.c2
-rw-r--r--drivers/power/charger-manager.c146
-rw-r--r--drivers/power/generic-adc-battery.c4
-rw-r--r--drivers/power/gpio-charger.c2
-rw-r--r--drivers/power/intel_mid_battery.c2
-rw-r--r--drivers/power/jz4740-battery.c4
-rw-r--r--drivers/power/lp8727_charger.c68
-rw-r--r--drivers/power/pcf50633-charger.c8
-rw-r--r--drivers/power/pm2301_charger.c11
-rw-r--r--drivers/power/power_supply_core.c4
-rw-r--r--drivers/power/reset/Kconfig3
-rw-r--r--drivers/power/rx51_battery.c5
-rw-r--r--drivers/power/sbs-battery.c1
-rw-r--r--drivers/power/tps65090-charger.c40
-rw-r--r--drivers/power/twl4030_charger.c2
-rw-r--r--include/linux/power_supply.h4
24 files changed, 241 insertions, 130 deletions
diff --git a/Documentation/devicetree/bindings/power_supply/lp8727_charger.txt b/Documentation/devicetree/bindings/power_supply/lp8727_charger.txt
new file mode 100644
index 000000000000..2246bc5c874b
--- /dev/null
+++ b/Documentation/devicetree/bindings/power_supply/lp8727_charger.txt
@@ -0,0 +1,44 @@
1Binding for TI/National Semiconductor LP8727 Charger
2
3Required properties:
4- compatible: "ti,lp8727"
5- reg: I2C slave address 27h
6
7Optional properties:
8- interrupt-parent: interrupt controller node (see interrupt binding[0])
9- interrupts: interrupt specifier (see interrupt binding[0])
10- debounce-ms: interrupt debounce time. (u32)
11
12AC and USB charging parameters
13- charger-type: "ac" or "usb" (string)
14- eoc-level: value of 'enum lp8727_eoc_level' (u8)
15- charging-current: value of 'enum lp8727_ichg' (u8)
16
17[0]: Documentation/devicetree/bindings/interrupt-controller/interrupts.txt
18
19Example)
20
21lp8727@27 {
22 compatible = "ti,lp8727";
23 reg = <0x27>;
24
25 /* GPIO 134 is used for LP8728 interrupt pin */
26 interrupt-parent = <&gpio5>; /* base = 128 */
27 interrupts = <6 0x2>; /* offset = 6, falling edge type */
28
29 debounce-ms = <300>;
30
31 /* AC charger: 5% EOC and 500mA charging current */
32 ac {
33 charger-type = "ac";
34 eoc-level = /bits/ 8 <0>;
35 charging-current = /bits/ 8 <4>;
36 };
37
38 /* USB charger: 10% EOC and 400mA charging current */
39 usb {
40 charger-type = "usb";
41 eoc-level = /bits/ 8 <1>;
42 charging-current = /bits/ 8 <2>;
43 };
44};
diff --git a/MAINTAINERS b/MAINTAINERS
index bb700731dcfa..3c433aec12db 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -752,7 +752,7 @@ S: Maintained
752F: arch/arm/mach-highbank/ 752F: arch/arm/mach-highbank/
753 753
754ARM/CAVIUM NETWORKS CNS3XXX MACHINE SUPPORT 754ARM/CAVIUM NETWORKS CNS3XXX MACHINE SUPPORT
755M: Anton Vorontsov <avorontsov@mvista.com> 755M: Anton Vorontsov <anton@enomsg.org>
756S: Maintained 756S: Maintained
757F: arch/arm/mach-cns3xxx/ 757F: arch/arm/mach-cns3xxx/
758T: git git://git.infradead.org/users/cbou/linux-cns3xxx.git 758T: git git://git.infradead.org/users/cbou/linux-cns3xxx.git
@@ -6406,7 +6406,7 @@ F: include/linux/timer*
6406F: kernel/*timer* 6406F: kernel/*timer*
6407 6407
6408POWER SUPPLY CLASS/SUBSYSTEM and DRIVERS 6408POWER SUPPLY CLASS/SUBSYSTEM and DRIVERS
6409M: Anton Vorontsov <cbou@mail.ru> 6409M: Anton Vorontsov <anton@enomsg.org>
6410M: David Woodhouse <dwmw2@infradead.org> 6410M: David Woodhouse <dwmw2@infradead.org>
6411T: git git://git.infradead.org/battery-2.6.git 6411T: git git://git.infradead.org/battery-2.6.git
6412S: Maintained 6412S: Maintained
@@ -6516,7 +6516,7 @@ S: Maintained
6516F: drivers/block/ps3vram.c 6516F: drivers/block/ps3vram.c
6517 6517
6518PSTORE FILESYSTEM 6518PSTORE FILESYSTEM
6519M: Anton Vorontsov <cbouatmailru@gmail.com> 6519M: Anton Vorontsov <anton@enomsg.org>
6520M: Colin Cross <ccross@android.com> 6520M: Colin Cross <ccross@android.com>
6521M: Kees Cook <keescook@chromium.org> 6521M: Kees Cook <keescook@chromium.org>
6522M: Tony Luck <tony.luck@intel.com> 6522M: Tony Luck <tony.luck@intel.com>
@@ -7214,7 +7214,7 @@ F: drivers/mmc/host/sdhci.*
7214F: drivers/mmc/host/sdhci-pltfm.[ch] 7214F: drivers/mmc/host/sdhci-pltfm.[ch]
7215 7215
7216SECURE DIGITAL HOST CONTROLLER INTERFACE, OPEN FIRMWARE BINDINGS (SDHCI-OF) 7216SECURE DIGITAL HOST CONTROLLER INTERFACE, OPEN FIRMWARE BINDINGS (SDHCI-OF)
7217M: Anton Vorontsov <avorontsov@ru.mvista.com> 7217M: Anton Vorontsov <anton@enomsg.org>
7218L: linuxppc-dev@lists.ozlabs.org 7218L: linuxppc-dev@lists.ozlabs.org
7219L: linux-mmc@vger.kernel.org 7219L: linux-mmc@vger.kernel.org
7220S: Maintained 7220S: Maintained
diff --git a/drivers/power/88pm860x_battery.c b/drivers/power/88pm860x_battery.c
index d338c1c4e8c8..dfcda3a49403 100644
--- a/drivers/power/88pm860x_battery.c
+++ b/drivers/power/88pm860x_battery.c
@@ -992,7 +992,6 @@ static int pm860x_battery_remove(struct platform_device *pdev)
992 free_irq(info->irq_batt, info); 992 free_irq(info->irq_batt, info);
993 free_irq(info->irq_cc, info); 993 free_irq(info->irq_cc, info);
994 power_supply_unregister(&info->battery); 994 power_supply_unregister(&info->battery);
995 platform_set_drvdata(pdev, NULL);
996 return 0; 995 return 0;
997} 996}
998 997
diff --git a/drivers/power/88pm860x_charger.c b/drivers/power/88pm860x_charger.c
index 36fb4b5a4b0d..ffff66b1c1aa 100644
--- a/drivers/power/88pm860x_charger.c
+++ b/drivers/power/88pm860x_charger.c
@@ -722,7 +722,6 @@ static int pm860x_charger_remove(struct platform_device *pdev)
722 struct pm860x_charger_info *info = platform_get_drvdata(pdev); 722 struct pm860x_charger_info *info = platform_get_drvdata(pdev);
723 int i; 723 int i;
724 724
725 platform_set_drvdata(pdev, NULL);
726 power_supply_unregister(&info->usb); 725 power_supply_unregister(&info->usb);
727 free_irq(info->irq[0], info); 726 free_irq(info->irq[0], info);
728 for (i = 0; i < info->irq_nums; i++) 727 for (i = 0; i < info->irq_nums; i++)
diff --git a/drivers/power/ab8500_btemp.c b/drivers/power/ab8500_btemp.c
index d412d34bf3df..7f9a4547dccd 100644
--- a/drivers/power/ab8500_btemp.c
+++ b/drivers/power/ab8500_btemp.c
@@ -1045,7 +1045,6 @@ static int ab8500_btemp_remove(struct platform_device *pdev)
1045 1045
1046 flush_scheduled_work(); 1046 flush_scheduled_work();
1047 power_supply_unregister(&di->btemp_psy); 1047 power_supply_unregister(&di->btemp_psy);
1048 platform_set_drvdata(pdev, NULL);
1049 1048
1050 return 0; 1049 return 0;
1051} 1050}
diff --git a/drivers/power/ab8500_charger.c b/drivers/power/ab8500_charger.c
index a558318b169c..f098fdafee9f 100644
--- a/drivers/power/ab8500_charger.c
+++ b/drivers/power/ab8500_charger.c
@@ -3425,8 +3425,6 @@ static int ab8500_charger_remove(struct platform_device *pdev)
3425 if (di->ac_chg.enabled && !di->ac_chg.external) 3425 if (di->ac_chg.enabled && !di->ac_chg.external)
3426 power_supply_unregister(&di->ac_chg.psy); 3426 power_supply_unregister(&di->ac_chg.psy);
3427 3427
3428 platform_set_drvdata(pdev, NULL);
3429
3430 return 0; 3428 return 0;
3431} 3429}
3432 3430
diff --git a/drivers/power/ab8500_fg.c b/drivers/power/ab8500_fg.c
index c5391f5c372d..754970717c31 100644
--- a/drivers/power/ab8500_fg.c
+++ b/drivers/power/ab8500_fg.c
@@ -2465,9 +2465,9 @@ static ssize_t charge_full_store(struct ab8500_fg *di, const char *buf,
2465 size_t count) 2465 size_t count)
2466{ 2466{
2467 unsigned long charge_full; 2467 unsigned long charge_full;
2468 ssize_t ret = -EINVAL; 2468 ssize_t ret;
2469 2469
2470 ret = strict_strtoul(buf, 10, &charge_full); 2470 ret = kstrtoul(buf, 10, &charge_full);
2471 2471
2472 dev_dbg(di->dev, "Ret %zd charge_full %lu", ret, charge_full); 2472 dev_dbg(di->dev, "Ret %zd charge_full %lu", ret, charge_full);
2473 2473
@@ -2489,7 +2489,7 @@ static ssize_t charge_now_store(struct ab8500_fg *di, const char *buf,
2489 unsigned long charge_now; 2489 unsigned long charge_now;
2490 ssize_t ret; 2490 ssize_t ret;
2491 2491
2492 ret = strict_strtoul(buf, 10, &charge_now); 2492 ret = kstrtoul(buf, 10, &charge_now);
2493 2493
2494 dev_dbg(di->dev, "Ret %zd charge_now %lu was %d", 2494 dev_dbg(di->dev, "Ret %zd charge_now %lu was %d",
2495 ret, charge_now, di->bat_cap.prev_mah); 2495 ret, charge_now, di->bat_cap.prev_mah);
@@ -3070,7 +3070,6 @@ static int ab8500_fg_remove(struct platform_device *pdev)
3070 flush_scheduled_work(); 3070 flush_scheduled_work();
3071 ab8500_fg_sysfs_psy_remove_attrs(di->fg_psy.dev); 3071 ab8500_fg_sysfs_psy_remove_attrs(di->fg_psy.dev);
3072 power_supply_unregister(&di->fg_psy); 3072 power_supply_unregister(&di->fg_psy);
3073 platform_set_drvdata(pdev, NULL);
3074 return ret; 3073 return ret;
3075} 3074}
3076 3075
diff --git a/drivers/power/abx500_chargalg.c b/drivers/power/abx500_chargalg.c
index 9863e423602c..6d2723664a01 100644
--- a/drivers/power/abx500_chargalg.c
+++ b/drivers/power/abx500_chargalg.c
@@ -2035,7 +2035,6 @@ static int abx500_chargalg_remove(struct platform_device *pdev)
2035 destroy_workqueue(di->chargalg_wq); 2035 destroy_workqueue(di->chargalg_wq);
2036 2036
2037 power_supply_unregister(&di->chargalg_psy); 2037 power_supply_unregister(&di->chargalg_psy);
2038 platform_set_drvdata(pdev, NULL);
2039 2038
2040 return 0; 2039 return 0;
2041} 2040}
diff --git a/drivers/power/bq27x00_battery.c b/drivers/power/bq27x00_battery.c
index 26037ca7efb4..b309713b63bc 100644
--- a/drivers/power/bq27x00_battery.c
+++ b/drivers/power/bq27x00_battery.c
@@ -966,7 +966,6 @@ static int bq27000_battery_probe(struct platform_device *pdev)
966 return 0; 966 return 0;
967 967
968err_free: 968err_free:
969 platform_set_drvdata(pdev, NULL);
970 kfree(di); 969 kfree(di);
971 970
972 return ret; 971 return ret;
@@ -978,7 +977,6 @@ static int bq27000_battery_remove(struct platform_device *pdev)
978 977
979 bq27x00_powersupply_unregister(di); 978 bq27x00_powersupply_unregister(di);
980 979
981 platform_set_drvdata(pdev, NULL);
982 kfree(di); 980 kfree(di);
983 981
984 return 0; 982 return 0;
diff --git a/drivers/power/charger-manager.c b/drivers/power/charger-manager.c
index fefc39fe42be..e30e847600bb 100644
--- a/drivers/power/charger-manager.c
+++ b/drivers/power/charger-manager.c
@@ -12,6 +12,8 @@
12 * published by the Free Software Foundation. 12 * published by the Free Software Foundation.
13**/ 13**/
14 14
15#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
16
15#include <linux/io.h> 17#include <linux/io.h>
16#include <linux/module.h> 18#include <linux/module.h>
17#include <linux/irq.h> 19#include <linux/irq.h>
@@ -195,8 +197,8 @@ static bool is_charging(struct charger_manager *cm)
195 cm->charger_stat[i], 197 cm->charger_stat[i],
196 POWER_SUPPLY_PROP_ONLINE, &val); 198 POWER_SUPPLY_PROP_ONLINE, &val);
197 if (ret) { 199 if (ret) {
198 dev_warn(cm->dev, "Cannot read ONLINE value from %s.\n", 200 dev_warn(cm->dev, "Cannot read ONLINE value from %s\n",
199 cm->desc->psy_charger_stat[i]); 201 cm->desc->psy_charger_stat[i]);
200 continue; 202 continue;
201 } 203 }
202 if (val.intval == 0) 204 if (val.intval == 0)
@@ -210,8 +212,8 @@ static bool is_charging(struct charger_manager *cm)
210 cm->charger_stat[i], 212 cm->charger_stat[i],
211 POWER_SUPPLY_PROP_STATUS, &val); 213 POWER_SUPPLY_PROP_STATUS, &val);
212 if (ret) { 214 if (ret) {
213 dev_warn(cm->dev, "Cannot read STATUS value from %s.\n", 215 dev_warn(cm->dev, "Cannot read STATUS value from %s\n",
214 cm->desc->psy_charger_stat[i]); 216 cm->desc->psy_charger_stat[i]);
215 continue; 217 continue;
216 } 218 }
217 if (val.intval == POWER_SUPPLY_STATUS_FULL || 219 if (val.intval == POWER_SUPPLY_STATUS_FULL ||
@@ -289,7 +291,7 @@ static bool is_polling_required(struct charger_manager *cm)
289 return is_charging(cm); 291 return is_charging(cm);
290 default: 292 default:
291 dev_warn(cm->dev, "Incorrect polling_mode (%d)\n", 293 dev_warn(cm->dev, "Incorrect polling_mode (%d)\n",
292 cm->desc->polling_mode); 294 cm->desc->polling_mode);
293 } 295 }
294 296
295 return false; 297 return false;
@@ -331,9 +333,8 @@ static int try_charger_enable(struct charger_manager *cm, bool enable)
331 333
332 err = regulator_enable(desc->charger_regulators[i].consumer); 334 err = regulator_enable(desc->charger_regulators[i].consumer);
333 if (err < 0) { 335 if (err < 0) {
334 dev_warn(cm->dev, 336 dev_warn(cm->dev, "Cannot enable %s regulator\n",
335 "Cannot enable %s regulator\n", 337 desc->charger_regulators[i].regulator_name);
336 desc->charger_regulators[i].regulator_name);
337 } 338 }
338 } 339 }
339 } else { 340 } else {
@@ -350,9 +351,8 @@ static int try_charger_enable(struct charger_manager *cm, bool enable)
350 351
351 err = regulator_disable(desc->charger_regulators[i].consumer); 352 err = regulator_disable(desc->charger_regulators[i].consumer);
352 if (err < 0) { 353 if (err < 0) {
353 dev_warn(cm->dev, 354 dev_warn(cm->dev, "Cannot disable %s regulator\n",
354 "Cannot disable %s regulator\n", 355 desc->charger_regulators[i].regulator_name);
355 desc->charger_regulators[i].regulator_name);
356 } 356 }
357 } 357 }
358 358
@@ -365,9 +365,8 @@ static int try_charger_enable(struct charger_manager *cm, bool enable)
365 desc->charger_regulators[i].consumer)) { 365 desc->charger_regulators[i].consumer)) {
366 regulator_force_disable( 366 regulator_force_disable(
367 desc->charger_regulators[i].consumer); 367 desc->charger_regulators[i].consumer);
368 dev_warn(cm->dev, 368 dev_warn(cm->dev, "Disable regulator(%s) forcibly\n",
369 "Disable regulator(%s) forcibly.\n", 369 desc->charger_regulators[i].regulator_name);
370 desc->charger_regulators[i].regulator_name);
371 } 370 }
372 } 371 }
373 } 372 }
@@ -450,7 +449,7 @@ static void uevent_notify(struct charger_manager *cm, const char *event)
450 strncpy(env_str, event, UEVENT_BUF_SIZE); 449 strncpy(env_str, event, UEVENT_BUF_SIZE);
451 kobject_uevent(&cm->dev->kobj, KOBJ_CHANGE); 450 kobject_uevent(&cm->dev->kobj, KOBJ_CHANGE);
452 451
453 dev_info(cm->dev, event); 452 dev_info(cm->dev, "%s\n", event);
454} 453}
455 454
456/** 455/**
@@ -478,7 +477,7 @@ static void fullbatt_vchk(struct work_struct *work)
478 477
479 err = get_batt_uV(cm, &batt_uV); 478 err = get_batt_uV(cm, &batt_uV);
480 if (err) { 479 if (err) {
481 dev_err(cm->dev, "%s: get_batt_uV error(%d).\n", __func__, err); 480 dev_err(cm->dev, "%s: get_batt_uV error(%d)\n", __func__, err);
482 return; 481 return;
483 } 482 }
484 483
@@ -486,7 +485,7 @@ static void fullbatt_vchk(struct work_struct *work)
486 if (diff < 0) 485 if (diff < 0)
487 return; 486 return;
488 487
489 dev_info(cm->dev, "VBATT dropped %duV after full-batt.\n", diff); 488 dev_info(cm->dev, "VBATT dropped %duV after full-batt\n", diff);
490 489
491 if (diff > desc->fullbatt_vchkdrop_uV) { 490 if (diff > desc->fullbatt_vchkdrop_uV) {
492 try_charger_restart(cm); 491 try_charger_restart(cm);
@@ -519,7 +518,7 @@ static int check_charging_duration(struct charger_manager *cm)
519 duration = curr - cm->charging_start_time; 518 duration = curr - cm->charging_start_time;
520 519
521 if (duration > desc->charging_max_duration_ms) { 520 if (duration > desc->charging_max_duration_ms) {
522 dev_info(cm->dev, "Charging duration exceed %lldms", 521 dev_info(cm->dev, "Charging duration exceed %lldms\n",
523 desc->charging_max_duration_ms); 522 desc->charging_max_duration_ms);
524 uevent_notify(cm, "Discharging"); 523 uevent_notify(cm, "Discharging");
525 try_charger_enable(cm, false); 524 try_charger_enable(cm, false);
@@ -530,9 +529,9 @@ static int check_charging_duration(struct charger_manager *cm)
530 529
531 if (duration > desc->charging_max_duration_ms && 530 if (duration > desc->charging_max_duration_ms &&
532 is_ext_pwr_online(cm)) { 531 is_ext_pwr_online(cm)) {
533 dev_info(cm->dev, "DisCharging duration exceed %lldms", 532 dev_info(cm->dev, "Discharging duration exceed %lldms\n",
534 desc->discharging_max_duration_ms); 533 desc->discharging_max_duration_ms);
535 uevent_notify(cm, "Recharing"); 534 uevent_notify(cm, "Recharging");
536 try_charger_enable(cm, true); 535 try_charger_enable(cm, true);
537 ret = true; 536 ret = true;
538 } 537 }
@@ -579,7 +578,7 @@ static bool _cm_monitor(struct charger_manager *cm)
579 */ 578 */
580 } else if (!cm->emergency_stop && check_charging_duration(cm)) { 579 } else if (!cm->emergency_stop && check_charging_duration(cm)) {
581 dev_dbg(cm->dev, 580 dev_dbg(cm->dev,
582 "Charging/Discharging duration is out of range"); 581 "Charging/Discharging duration is out of range\n");
583 /* 582 /*
584 * Check dropped voltage of battery. If battery voltage is more 583 * Check dropped voltage of battery. If battery voltage is more
585 * dropped than fullbatt_vchkdrop_uV after fully charged state, 584 * dropped than fullbatt_vchkdrop_uV after fully charged state,
@@ -595,7 +594,7 @@ static bool _cm_monitor(struct charger_manager *cm)
595 */ 594 */
596 } else if (!cm->emergency_stop && is_full_charged(cm) && 595 } else if (!cm->emergency_stop && is_full_charged(cm) &&
597 cm->charger_enabled) { 596 cm->charger_enabled) {
598 dev_info(cm->dev, "EVENT_HANDLE: Battery Fully Charged.\n"); 597 dev_info(cm->dev, "EVENT_HANDLE: Battery Fully Charged\n");
599 uevent_notify(cm, default_event_names[CM_EVENT_BATT_FULL]); 598 uevent_notify(cm, default_event_names[CM_EVENT_BATT_FULL]);
600 599
601 try_charger_enable(cm, false); 600 try_charger_enable(cm, false);
@@ -725,7 +724,7 @@ static void fullbatt_handler(struct charger_manager *cm)
725 cm->fullbatt_vchk_jiffies_at = 1; 724 cm->fullbatt_vchk_jiffies_at = 1;
726 725
727out: 726out:
728 dev_info(cm->dev, "EVENT_HANDLE: Battery Fully Charged.\n"); 727 dev_info(cm->dev, "EVENT_HANDLE: Battery Fully Charged\n");
729 uevent_notify(cm, default_event_names[CM_EVENT_BATT_FULL]); 728 uevent_notify(cm, default_event_names[CM_EVENT_BATT_FULL]);
730} 729}
731 730
@@ -972,7 +971,7 @@ static bool cm_setup_timer(void)
972 mutex_unlock(&cm_list_mtx); 971 mutex_unlock(&cm_list_mtx);
973 972
974 if (wakeup_ms < UINT_MAX && wakeup_ms > 0) { 973 if (wakeup_ms < UINT_MAX && wakeup_ms > 0) {
975 pr_info("Charger Manager wakeup timer: %u ms.\n", wakeup_ms); 974 pr_info("Charger Manager wakeup timer: %u ms\n", wakeup_ms);
976 if (rtc_dev) { 975 if (rtc_dev) {
977 struct rtc_wkalrm tmp; 976 struct rtc_wkalrm tmp;
978 unsigned long time, now; 977 unsigned long time, now;
@@ -1005,8 +1004,7 @@ static bool cm_setup_timer(void)
1005 ret = false; 1004 ret = false;
1006 } 1005 }
1007 1006
1008 pr_info("Waking up after %lu secs.\n", 1007 pr_info("Waking up after %lu secs\n", time - now);
1009 time - now);
1010 1008
1011 rtc_time_to_tm(time, &tmp.time); 1009 rtc_time_to_tm(time, &tmp.time);
1012 rtc_set_alarm(rtc_dev, &tmp); 1010 rtc_set_alarm(rtc_dev, &tmp);
@@ -1101,7 +1099,7 @@ int setup_charger_manager(struct charger_global_desc *gd)
1101 g_desc = NULL; 1099 g_desc = NULL;
1102 1100
1103 if (!gd->rtc_only_wakeup) { 1101 if (!gd->rtc_only_wakeup) {
1104 pr_err("The callback rtc_only_wakeup is not given.\n"); 1102 pr_err("The callback rtc_only_wakeup is not given\n");
1105 return -EINVAL; 1103 return -EINVAL;
1106 } 1104 }
1107 1105
@@ -1112,7 +1110,7 @@ int setup_charger_manager(struct charger_global_desc *gd)
1112 /* Retry at probe. RTC may be not registered yet */ 1110 /* Retry at probe. RTC may be not registered yet */
1113 } 1111 }
1114 } else { 1112 } else {
1115 pr_warn("No wakeup timer is given for charger manager." 1113 pr_warn("No wakeup timer is given for charger manager. "
1116 "In-suspend monitoring won't work.\n"); 1114 "In-suspend monitoring won't work.\n");
1117 } 1115 }
1118 1116
@@ -1138,13 +1136,13 @@ static void charger_extcon_work(struct work_struct *work)
1138 cable->min_uA, cable->max_uA); 1136 cable->min_uA, cable->max_uA);
1139 if (ret < 0) { 1137 if (ret < 0) {
1140 pr_err("Cannot set current limit of %s (%s)\n", 1138 pr_err("Cannot set current limit of %s (%s)\n",
1141 cable->charger->regulator_name, cable->name); 1139 cable->charger->regulator_name, cable->name);
1142 return; 1140 return;
1143 } 1141 }
1144 1142
1145 pr_info("Set current limit of %s : %duA ~ %duA\n", 1143 pr_info("Set current limit of %s : %duA ~ %duA\n",
1146 cable->charger->regulator_name, 1144 cable->charger->regulator_name,
1147 cable->min_uA, cable->max_uA); 1145 cable->min_uA, cable->max_uA);
1148 } 1146 }
1149 1147
1150 try_charger_enable(cable->cm, cable->attached); 1148 try_charger_enable(cable->cm, cable->attached);
@@ -1210,9 +1208,8 @@ static int charger_extcon_init(struct charger_manager *cm,
1210 ret = extcon_register_interest(&cable->extcon_dev, 1208 ret = extcon_register_interest(&cable->extcon_dev,
1211 cable->extcon_name, cable->name, &cable->nb); 1209 cable->extcon_name, cable->name, &cable->nb);
1212 if (ret < 0) { 1210 if (ret < 0) {
1213 pr_info("Cannot register extcon_dev for %s(cable: %s).\n", 1211 pr_info("Cannot register extcon_dev for %s(cable: %s)\n",
1214 cable->extcon_name, 1212 cable->extcon_name, cable->name);
1215 cable->name);
1216 ret = -EINVAL; 1213 ret = -EINVAL;
1217 } 1214 }
1218 1215
@@ -1242,11 +1239,10 @@ static int charger_manager_register_extcon(struct charger_manager *cm)
1242 1239
1243 charger->consumer = regulator_get(cm->dev, 1240 charger->consumer = regulator_get(cm->dev,
1244 charger->regulator_name); 1241 charger->regulator_name);
1245 if (charger->consumer == NULL) { 1242 if (IS_ERR(charger->consumer)) {
1246 dev_err(cm->dev, "Cannot find charger(%s)n", 1243 dev_err(cm->dev, "Cannot find charger(%s)\n",
1247 charger->regulator_name); 1244 charger->regulator_name);
1248 ret = -EINVAL; 1245 return PTR_ERR(charger->consumer);
1249 goto err;
1250 } 1246 }
1251 charger->cm = cm; 1247 charger->cm = cm;
1252 1248
@@ -1255,8 +1251,8 @@ static int charger_manager_register_extcon(struct charger_manager *cm)
1255 1251
1256 ret = charger_extcon_init(cm, cable); 1252 ret = charger_extcon_init(cm, cable);
1257 if (ret < 0) { 1253 if (ret < 0) {
1258 dev_err(cm->dev, "Cannot initialize charger(%s)n", 1254 dev_err(cm->dev, "Cannot initialize charger(%s)\n",
1259 charger->regulator_name); 1255 charger->regulator_name);
1260 goto err; 1256 goto err;
1261 } 1257 }
1262 cable->charger = charger; 1258 cable->charger = charger;
@@ -1347,10 +1343,8 @@ static ssize_t charger_externally_control_store(struct device *dev,
1347 } 1343 }
1348 } else { 1344 } else {
1349 dev_warn(cm->dev, 1345 dev_warn(cm->dev,
1350 "'%s' regulator should be controlled " 1346 "'%s' regulator should be controlled in charger-manager because charger-manager must need at least one charger for charging\n",
1351 "in charger-manager because charger-manager " 1347 charger->regulator_name);
1352 "must need at least one charger for charging\n",
1353 charger->regulator_name);
1354 } 1348 }
1355 1349
1356 return count; 1350 return count;
@@ -1386,8 +1380,6 @@ static int charger_manager_register_sysfs(struct charger_manager *cm)
1386 snprintf(buf, 10, "charger.%d", i); 1380 snprintf(buf, 10, "charger.%d", i);
1387 str = kzalloc(sizeof(char) * (strlen(buf) + 1), GFP_KERNEL); 1381 str = kzalloc(sizeof(char) * (strlen(buf) + 1), GFP_KERNEL);
1388 if (!str) { 1382 if (!str) {
1389 dev_err(cm->dev, "Cannot allocate memory: %s\n",
1390 charger->regulator_name);
1391 ret = -ENOMEM; 1383 ret = -ENOMEM;
1392 goto err; 1384 goto err;
1393 } 1385 }
@@ -1423,26 +1415,21 @@ static int charger_manager_register_sysfs(struct charger_manager *cm)
1423 !chargers_externally_control) 1415 !chargers_externally_control)
1424 chargers_externally_control = 0; 1416 chargers_externally_control = 0;
1425 1417
1426 dev_info(cm->dev, "'%s' regulator's externally_control" 1418 dev_info(cm->dev, "'%s' regulator's externally_control is %d\n",
1427 "is %d\n", charger->regulator_name, 1419 charger->regulator_name, charger->externally_control);
1428 charger->externally_control);
1429 1420
1430 ret = sysfs_create_group(&cm->charger_psy.dev->kobj, 1421 ret = sysfs_create_group(&cm->charger_psy.dev->kobj,
1431 &charger->attr_g); 1422 &charger->attr_g);
1432 if (ret < 0) { 1423 if (ret < 0) {
1433 dev_err(cm->dev, "Cannot create sysfs entry" 1424 dev_err(cm->dev, "Cannot create sysfs entry of %s regulator\n",
1434 "of %s regulator\n", 1425 charger->regulator_name);
1435 charger->regulator_name);
1436 ret = -EINVAL; 1426 ret = -EINVAL;
1437 goto err; 1427 goto err;
1438 } 1428 }
1439 } 1429 }
1440 1430
1441 if (chargers_externally_control) { 1431 if (chargers_externally_control) {
1442 dev_err(cm->dev, "Cannot register regulator because " 1432 dev_err(cm->dev, "Cannot register regulator because charger-manager must need at least one charger for charging battery\n");
1443 "charger-manager must need at least "
1444 "one charger for charging battery\n");
1445
1446 ret = -EINVAL; 1433 ret = -EINVAL;
1447 goto err; 1434 goto err;
1448 } 1435 }
@@ -1463,7 +1450,7 @@ static int charger_manager_probe(struct platform_device *pdev)
1463 rtc_dev = rtc_class_open(g_desc->rtc_name); 1450 rtc_dev = rtc_class_open(g_desc->rtc_name);
1464 if (IS_ERR_OR_NULL(rtc_dev)) { 1451 if (IS_ERR_OR_NULL(rtc_dev)) {
1465 rtc_dev = NULL; 1452 rtc_dev = NULL;
1466 dev_err(&pdev->dev, "Cannot get RTC %s.\n", 1453 dev_err(&pdev->dev, "Cannot get RTC %s\n",
1467 g_desc->rtc_name); 1454 g_desc->rtc_name);
1468 ret = -ENODEV; 1455 ret = -ENODEV;
1469 goto err_alloc; 1456 goto err_alloc;
@@ -1471,14 +1458,13 @@ static int charger_manager_probe(struct platform_device *pdev)
1471 } 1458 }
1472 1459
1473 if (!desc) { 1460 if (!desc) {
1474 dev_err(&pdev->dev, "No platform data (desc) found.\n"); 1461 dev_err(&pdev->dev, "No platform data (desc) found\n");
1475 ret = -ENODEV; 1462 ret = -ENODEV;
1476 goto err_alloc; 1463 goto err_alloc;
1477 } 1464 }
1478 1465
1479 cm = kzalloc(sizeof(struct charger_manager), GFP_KERNEL); 1466 cm = kzalloc(sizeof(struct charger_manager), GFP_KERNEL);
1480 if (!cm) { 1467 if (!cm) {
1481 dev_err(&pdev->dev, "Cannot allocate memory.\n");
1482 ret = -ENOMEM; 1468 ret = -ENOMEM;
1483 goto err_alloc; 1469 goto err_alloc;
1484 } 1470 }
@@ -1487,7 +1473,6 @@ static int charger_manager_probe(struct platform_device *pdev)
1487 cm->dev = &pdev->dev; 1473 cm->dev = &pdev->dev;
1488 cm->desc = kmemdup(desc, sizeof(struct charger_desc), GFP_KERNEL); 1474 cm->desc = kmemdup(desc, sizeof(struct charger_desc), GFP_KERNEL);
1489 if (!cm->desc) { 1475 if (!cm->desc) {
1490 dev_err(&pdev->dev, "Cannot allocate memory.\n");
1491 ret = -ENOMEM; 1476 ret = -ENOMEM;
1492 goto err_alloc_desc; 1477 goto err_alloc_desc;
1493 } 1478 }
@@ -1498,33 +1483,28 @@ static int charger_manager_probe(struct platform_device *pdev)
1498 * Users may intentionally ignore those two features. 1483 * Users may intentionally ignore those two features.
1499 */ 1484 */
1500 if (desc->fullbatt_uV == 0) { 1485 if (desc->fullbatt_uV == 0) {
1501 dev_info(&pdev->dev, "Ignoring full-battery voltage threshold" 1486 dev_info(&pdev->dev, "Ignoring full-battery voltage threshold as it is not supplied\n");
1502 " as it is not supplied.");
1503 } 1487 }
1504 if (!desc->fullbatt_vchkdrop_ms || !desc->fullbatt_vchkdrop_uV) { 1488 if (!desc->fullbatt_vchkdrop_ms || !desc->fullbatt_vchkdrop_uV) {
1505 dev_info(&pdev->dev, "Disabling full-battery voltage drop " 1489 dev_info(&pdev->dev, "Disabling full-battery voltage drop checking mechanism as it is not supplied\n");
1506 "checking mechanism as it is not supplied.");
1507 desc->fullbatt_vchkdrop_ms = 0; 1490 desc->fullbatt_vchkdrop_ms = 0;
1508 desc->fullbatt_vchkdrop_uV = 0; 1491 desc->fullbatt_vchkdrop_uV = 0;
1509 } 1492 }
1510 if (desc->fullbatt_soc == 0) { 1493 if (desc->fullbatt_soc == 0) {
1511 dev_info(&pdev->dev, "Ignoring full-battery soc(state of" 1494 dev_info(&pdev->dev, "Ignoring full-battery soc(state of charge) threshold as it is not supplied\n");
1512 " charge) threshold as it is not"
1513 " supplied.");
1514 } 1495 }
1515 if (desc->fullbatt_full_capacity == 0) { 1496 if (desc->fullbatt_full_capacity == 0) {
1516 dev_info(&pdev->dev, "Ignoring full-battery full capacity" 1497 dev_info(&pdev->dev, "Ignoring full-battery full capacity threshold as it is not supplied\n");
1517 " threshold as it is not supplied.");
1518 } 1498 }
1519 1499
1520 if (!desc->charger_regulators || desc->num_charger_regulators < 1) { 1500 if (!desc->charger_regulators || desc->num_charger_regulators < 1) {
1521 ret = -EINVAL; 1501 ret = -EINVAL;
1522 dev_err(&pdev->dev, "charger_regulators undefined.\n"); 1502 dev_err(&pdev->dev, "charger_regulators undefined\n");
1523 goto err_no_charger; 1503 goto err_no_charger;
1524 } 1504 }
1525 1505
1526 if (!desc->psy_charger_stat || !desc->psy_charger_stat[0]) { 1506 if (!desc->psy_charger_stat || !desc->psy_charger_stat[0]) {
1527 dev_err(&pdev->dev, "No power supply defined.\n"); 1507 dev_err(&pdev->dev, "No power supply defined\n");
1528 ret = -EINVAL; 1508 ret = -EINVAL;
1529 goto err_no_charger_stat; 1509 goto err_no_charger_stat;
1530 } 1510 }
@@ -1544,9 +1524,8 @@ static int charger_manager_probe(struct platform_device *pdev)
1544 cm->charger_stat[i] = power_supply_get_by_name( 1524 cm->charger_stat[i] = power_supply_get_by_name(
1545 desc->psy_charger_stat[i]); 1525 desc->psy_charger_stat[i]);
1546 if (!cm->charger_stat[i]) { 1526 if (!cm->charger_stat[i]) {
1547 dev_err(&pdev->dev, "Cannot find power supply " 1527 dev_err(&pdev->dev, "Cannot find power supply \"%s\"\n",
1548 "\"%s\"\n", 1528 desc->psy_charger_stat[i]);
1549 desc->psy_charger_stat[i]);
1550 ret = -ENODEV; 1529 ret = -ENODEV;
1551 goto err_chg_stat; 1530 goto err_chg_stat;
1552 } 1531 }
@@ -1555,7 +1534,7 @@ static int charger_manager_probe(struct platform_device *pdev)
1555 cm->fuel_gauge = power_supply_get_by_name(desc->psy_fuel_gauge); 1534 cm->fuel_gauge = power_supply_get_by_name(desc->psy_fuel_gauge);
1556 if (!cm->fuel_gauge) { 1535 if (!cm->fuel_gauge) {
1557 dev_err(&pdev->dev, "Cannot find power supply \"%s\"\n", 1536 dev_err(&pdev->dev, "Cannot find power supply \"%s\"\n",
1558 desc->psy_fuel_gauge); 1537 desc->psy_fuel_gauge);
1559 ret = -ENODEV; 1538 ret = -ENODEV;
1560 goto err_chg_stat; 1539 goto err_chg_stat;
1561 } 1540 }
@@ -1575,9 +1554,7 @@ static int charger_manager_probe(struct platform_device *pdev)
1575 1554
1576 if (!desc->charging_max_duration_ms || 1555 if (!desc->charging_max_duration_ms ||
1577 !desc->discharging_max_duration_ms) { 1556 !desc->discharging_max_duration_ms) {
1578 dev_info(&pdev->dev, "Cannot limit charging duration " 1557 dev_info(&pdev->dev, "Cannot limit charging duration checking mechanism to prevent overcharge/overheat and control discharging duration\n");
1579 "checking mechanism to prevent overcharge/overheat "
1580 "and control discharging duration");
1581 desc->charging_max_duration_ms = 0; 1558 desc->charging_max_duration_ms = 0;
1582 desc->discharging_max_duration_ms = 0; 1559 desc->discharging_max_duration_ms = 0;
1583 } 1560 }
@@ -1598,7 +1575,6 @@ static int charger_manager_probe(struct platform_device *pdev)
1598 NUM_CHARGER_PSY_OPTIONAL), 1575 NUM_CHARGER_PSY_OPTIONAL),
1599 GFP_KERNEL); 1576 GFP_KERNEL);
1600 if (!cm->charger_psy.properties) { 1577 if (!cm->charger_psy.properties) {
1601 dev_err(&pdev->dev, "Cannot allocate for psy properties.\n");
1602 ret = -ENOMEM; 1578 ret = -ENOMEM;
1603 goto err_chg_stat; 1579 goto err_chg_stat;
1604 } 1580 }
@@ -1636,8 +1612,8 @@ static int charger_manager_probe(struct platform_device *pdev)
1636 1612
1637 ret = power_supply_register(NULL, &cm->charger_psy); 1613 ret = power_supply_register(NULL, &cm->charger_psy);
1638 if (ret) { 1614 if (ret) {
1639 dev_err(&pdev->dev, "Cannot register charger-manager with" 1615 dev_err(&pdev->dev, "Cannot register charger-manager with name \"%s\"\n",
1640 " name \"%s\".\n", cm->charger_psy.name); 1616 cm->charger_psy.name);
1641 goto err_register; 1617 goto err_register;
1642 } 1618 }
1643 1619
@@ -1689,7 +1665,9 @@ err_reg_extcon:
1689 charger = &desc->charger_regulators[i]; 1665 charger = &desc->charger_regulators[i];
1690 for (j = 0; j < charger->num_cables; j++) { 1666 for (j = 0; j < charger->num_cables; j++) {
1691 struct charger_cable *cable = &charger->cables[j]; 1667 struct charger_cable *cable = &charger->cables[j];
1692 extcon_unregister_interest(&cable->extcon_dev); 1668 /* Remove notifier block if only edev exists */
1669 if (cable->extcon_dev.edev)
1670 extcon_unregister_interest(&cable->extcon_dev);
1693 } 1671 }
1694 1672
1695 regulator_put(desc->charger_regulators[i].consumer); 1673 regulator_put(desc->charger_regulators[i].consumer);
@@ -1948,7 +1926,7 @@ void cm_notify_event(struct power_supply *psy, enum cm_event_types type,
1948 uevent_notify(cm, msg ? msg : default_event_names[type]); 1926 uevent_notify(cm, msg ? msg : default_event_names[type]);
1949 break; 1927 break;
1950 default: 1928 default:
1951 dev_err(cm->dev, "%s type not specified.\n", __func__); 1929 dev_err(cm->dev, "%s: type not specified\n", __func__);
1952 break; 1930 break;
1953 } 1931 }
1954} 1932}
diff --git a/drivers/power/generic-adc-battery.c b/drivers/power/generic-adc-battery.c
index 8cb5d7f67ace..59a1421f9288 100644
--- a/drivers/power/generic-adc-battery.c
+++ b/drivers/power/generic-adc-battery.c
@@ -299,8 +299,10 @@ static int gab_probe(struct platform_device *pdev)
299 } 299 }
300 300
301 /* none of the channels are supported so let's bail out */ 301 /* none of the channels are supported so let's bail out */
302 if (index == ARRAY_SIZE(gab_chan_name)) 302 if (index == 0) {
303 ret = -ENODEV;
303 goto second_mem_fail; 304 goto second_mem_fail;
305 }
304 306
305 /* 307 /*
306 * Total number of properties is equal to static properties 308 * Total number of properties is equal to static properties
diff --git a/drivers/power/gpio-charger.c b/drivers/power/gpio-charger.c
index e9883eeeee76..4e858a23568f 100644
--- a/drivers/power/gpio-charger.c
+++ b/drivers/power/gpio-charger.c
@@ -155,8 +155,6 @@ static int gpio_charger_remove(struct platform_device *pdev)
155 155
156 gpio_free(gpio_charger->pdata->gpio); 156 gpio_free(gpio_charger->pdata->gpio);
157 157
158 platform_set_drvdata(pdev, NULL);
159
160 return 0; 158 return 0;
161} 159}
162 160
diff --git a/drivers/power/intel_mid_battery.c b/drivers/power/intel_mid_battery.c
index 18d136b443ee..4520811168ad 100644
--- a/drivers/power/intel_mid_battery.c
+++ b/drivers/power/intel_mid_battery.c
@@ -756,7 +756,7 @@ static int platform_pmic_battery_probe(struct platform_device *pdev)
756 756
757static int platform_pmic_battery_remove(struct platform_device *pdev) 757static int platform_pmic_battery_remove(struct platform_device *pdev)
758{ 758{
759 struct pmic_power_module_info *pbi = dev_get_drvdata(&pdev->dev); 759 struct pmic_power_module_info *pbi = platform_get_drvdata(pdev);
760 760
761 free_irq(pbi->irq, pbi); 761 free_irq(pbi->irq, pbi);
762 cancel_delayed_work_sync(&pbi->monitor_battery); 762 cancel_delayed_work_sync(&pbi->monitor_battery);
diff --git a/drivers/power/jz4740-battery.c b/drivers/power/jz4740-battery.c
index c675553d4647..d9686aa9270a 100644
--- a/drivers/power/jz4740-battery.c
+++ b/drivers/power/jz4740-battery.c
@@ -292,7 +292,7 @@ static int jz_battery_probe(struct platform_device *pdev)
292 jz_battery); 292 jz_battery);
293 if (ret) { 293 if (ret) {
294 dev_err(&pdev->dev, "Failed to request irq %d\n", ret); 294 dev_err(&pdev->dev, "Failed to request irq %d\n", ret);
295 goto err; 295 return ret;
296 } 296 }
297 disable_irq(jz_battery->irq); 297 disable_irq(jz_battery->irq);
298 298
@@ -349,8 +349,6 @@ err_free_gpio:
349 gpio_free(jz_battery->pdata->gpio_charge); 349 gpio_free(jz_battery->pdata->gpio_charge);
350err_free_irq: 350err_free_irq:
351 free_irq(jz_battery->irq, jz_battery); 351 free_irq(jz_battery->irq, jz_battery);
352err:
353 platform_set_drvdata(pdev, NULL);
354 return ret; 352 return ret;
355} 353}
356 354
diff --git a/drivers/power/lp8727_charger.c b/drivers/power/lp8727_charger.c
index 5ef41b819172..32de636dcd73 100644
--- a/drivers/power/lp8727_charger.c
+++ b/drivers/power/lp8727_charger.c
@@ -16,6 +16,7 @@
16#include <linux/i2c.h> 16#include <linux/i2c.h>
17#include <linux/power_supply.h> 17#include <linux/power_supply.h>
18#include <linux/platform_data/lp8727.h> 18#include <linux/platform_data/lp8727.h>
19#include <linux/of.h>
19 20
20#define LP8788_NUM_INTREGS 2 21#define LP8788_NUM_INTREGS 2
21#define DEFAULT_DEBOUNCE_MSEC 270 22#define DEFAULT_DEBOUNCE_MSEC 270
@@ -481,6 +482,60 @@ static void lp8727_unregister_psy(struct lp8727_chg *pchg)
481 power_supply_unregister(&psy->batt); 482 power_supply_unregister(&psy->batt);
482} 483}
483 484
485#ifdef CONFIG_OF
486static struct lp8727_chg_param
487*lp8727_parse_charge_pdata(struct device *dev, struct device_node *np)
488{
489 struct lp8727_chg_param *param;
490
491 param = devm_kzalloc(dev, sizeof(*param), GFP_KERNEL);
492 if (!param)
493 goto out;
494
495 of_property_read_u8(np, "eoc-level", (u8 *)&param->eoc_level);
496 of_property_read_u8(np, "charging-current", (u8 *)&param->ichg);
497out:
498 return param;
499}
500
501static int lp8727_parse_dt(struct device *dev)
502{
503 struct device_node *np = dev->of_node;
504 struct device_node *child;
505 struct lp8727_platform_data *pdata;
506 const char *type;
507
508 /* If charging parameter is not defined, just skip parsing the dt */
509 if (of_get_child_count(np) == 0)
510 goto out;
511
512 pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
513 if (!pdata)
514 return -ENOMEM;
515
516 of_property_read_u32(np, "debounce-ms", &pdata->debounce_msec);
517
518 for_each_child_of_node(np, child) {
519 of_property_read_string(child, "charger-type", &type);
520
521 if (!strcmp(type, "ac"))
522 pdata->ac = lp8727_parse_charge_pdata(dev, child);
523
524 if (!strcmp(type, "usb"))
525 pdata->usb = lp8727_parse_charge_pdata(dev, child);
526 }
527
528 dev->platform_data = pdata;
529out:
530 return 0;
531}
532#else
533static int lp8727_parse_dt(struct device *dev)
534{
535 return 0;
536}
537#endif
538
484static int lp8727_probe(struct i2c_client *cl, const struct i2c_device_id *id) 539static int lp8727_probe(struct i2c_client *cl, const struct i2c_device_id *id)
485{ 540{
486 struct lp8727_chg *pchg; 541 struct lp8727_chg *pchg;
@@ -489,6 +544,12 @@ static int lp8727_probe(struct i2c_client *cl, const struct i2c_device_id *id)
489 if (!i2c_check_functionality(cl->adapter, I2C_FUNC_SMBUS_I2C_BLOCK)) 544 if (!i2c_check_functionality(cl->adapter, I2C_FUNC_SMBUS_I2C_BLOCK))
490 return -EIO; 545 return -EIO;
491 546
547 if (cl->dev.of_node) {
548 ret = lp8727_parse_dt(&cl->dev);
549 if (ret)
550 return ret;
551 }
552
492 pchg = devm_kzalloc(&cl->dev, sizeof(*pchg), GFP_KERNEL); 553 pchg = devm_kzalloc(&cl->dev, sizeof(*pchg), GFP_KERNEL);
493 if (!pchg) 554 if (!pchg)
494 return -ENOMEM; 555 return -ENOMEM;
@@ -531,6 +592,12 @@ static int lp8727_remove(struct i2c_client *cl)
531 return 0; 592 return 0;
532} 593}
533 594
595static const struct of_device_id lp8727_dt_ids[] = {
596 { .compatible = "ti,lp8727", },
597 { }
598};
599MODULE_DEVICE_TABLE(of, lp8727_dt_ids);
600
534static const struct i2c_device_id lp8727_ids[] = { 601static const struct i2c_device_id lp8727_ids[] = {
535 {"lp8727", 0}, 602 {"lp8727", 0},
536 { } 603 { }
@@ -540,6 +607,7 @@ MODULE_DEVICE_TABLE(i2c, lp8727_ids);
540static struct i2c_driver lp8727_driver = { 607static struct i2c_driver lp8727_driver = {
541 .driver = { 608 .driver = {
542 .name = "lp8727", 609 .name = "lp8727",
610 .of_match_table = of_match_ptr(lp8727_dt_ids),
543 }, 611 },
544 .probe = lp8727_probe, 612 .probe = lp8727_probe,
545 .remove = lp8727_remove, 613 .remove = lp8727_remove,
diff --git a/drivers/power/pcf50633-charger.c b/drivers/power/pcf50633-charger.c
index 17fd77f24b2a..771c4f0fb8ac 100644
--- a/drivers/power/pcf50633-charger.c
+++ b/drivers/power/pcf50633-charger.c
@@ -191,9 +191,9 @@ static ssize_t set_usblim(struct device *dev,
191 unsigned long ma; 191 unsigned long ma;
192 int ret; 192 int ret;
193 193
194 ret = strict_strtoul(buf, 10, &ma); 194 ret = kstrtoul(buf, 10, &ma);
195 if (ret) 195 if (ret)
196 return -EINVAL; 196 return ret;
197 197
198 pcf50633_mbc_usb_curlim_set(mbc->pcf, ma); 198 pcf50633_mbc_usb_curlim_set(mbc->pcf, ma);
199 199
@@ -228,9 +228,9 @@ static ssize_t set_chglim(struct device *dev,
228 if (!mbc->pcf->pdata->charger_reference_current_ma) 228 if (!mbc->pcf->pdata->charger_reference_current_ma)
229 return -ENODEV; 229 return -ENODEV;
230 230
231 ret = strict_strtoul(buf, 10, &ma); 231 ret = kstrtoul(buf, 10, &ma);
232 if (ret) 232 if (ret)
233 return -EINVAL; 233 return ret;
234 234
235 mbcc5 = (ma << 8) / mbc->pcf->pdata->charger_reference_current_ma; 235 mbcc5 = (ma << 8) / mbc->pcf->pdata->charger_reference_current_ma;
236 if (mbcc5 > 255) 236 if (mbcc5 > 255)
diff --git a/drivers/power/pm2301_charger.c b/drivers/power/pm2301_charger.c
index fef56e2041b3..1c0bfcbae062 100644
--- a/drivers/power/pm2301_charger.c
+++ b/drivers/power/pm2301_charger.c
@@ -1007,9 +1007,14 @@ static int pm2xxx_wall_charger_probe(struct i2c_client *i2c_client,
1007 u8 val; 1007 u8 val;
1008 int i; 1008 int i;
1009 1009
1010 if (!pl_data) {
1011 dev_err(&i2c_client->dev, "No platform data supplied\n");
1012 return -EINVAL;
1013 }
1014
1010 pm2 = kzalloc(sizeof(struct pm2xxx_charger), GFP_KERNEL); 1015 pm2 = kzalloc(sizeof(struct pm2xxx_charger), GFP_KERNEL);
1011 if (!pm2) { 1016 if (!pm2) {
1012 dev_err(pm2->dev, "pm2xxx_charger allocation failed\n"); 1017 dev_err(&i2c_client->dev, "pm2xxx_charger allocation failed\n");
1013 return -ENOMEM; 1018 return -ENOMEM;
1014 } 1019 }
1015 1020
@@ -1070,9 +1075,9 @@ static int pm2xxx_wall_charger_probe(struct i2c_client *i2c_client,
1070 pm2->ac_chg.external = true; 1075 pm2->ac_chg.external = true;
1071 1076
1072 /* Create a work queue for the charger */ 1077 /* Create a work queue for the charger */
1073 pm2->charger_wq = 1078 pm2->charger_wq = create_singlethread_workqueue("pm2xxx_charger_wq");
1074 create_singlethread_workqueue("pm2xxx_charger_wq");
1075 if (pm2->charger_wq == NULL) { 1079 if (pm2->charger_wq == NULL) {
1080 ret = -ENOMEM;
1076 dev_err(pm2->dev, "failed to create work queue\n"); 1081 dev_err(pm2->dev, "failed to create work queue\n");
1077 goto free_device_info; 1082 goto free_device_info;
1078 } 1083 }
diff --git a/drivers/power/power_supply_core.c b/drivers/power/power_supply_core.c
index 1c517c34e4be..3b2d5df45e7a 100644
--- a/drivers/power/power_supply_core.c
+++ b/drivers/power/power_supply_core.c
@@ -109,8 +109,10 @@ static int __power_supply_populate_supplied_from(struct device *dev,
109 psy->name, epsy->name); 109 psy->name, epsy->name);
110 psy->supplied_from[i-1] = (char *)epsy->name; 110 psy->supplied_from[i-1] = (char *)epsy->name;
111 psy->num_supplies++; 111 psy->num_supplies++;
112 of_node_put(np);
112 break; 113 break;
113 } 114 }
115 of_node_put(np);
114 } while (np); 116 } while (np);
115 117
116 return 0; 118 return 0;
@@ -193,8 +195,10 @@ static int power_supply_check_supplies(struct power_supply *psy)
193 ret = power_supply_find_supply_from_node(np); 195 ret = power_supply_find_supply_from_node(np);
194 if (ret) { 196 if (ret) {
195 dev_dbg(psy->dev, "Failed to find supply, defer!\n"); 197 dev_dbg(psy->dev, "Failed to find supply, defer!\n");
198 of_node_put(np);
196 return -EPROBE_DEFER; 199 return -EPROBE_DEFER;
197 } 200 }
201 of_node_put(np);
198 } while (np); 202 } while (np);
199 203
200 /* All supplies found, allocate char ** array for filling */ 204 /* All supplies found, allocate char ** array for filling */
diff --git a/drivers/power/reset/Kconfig b/drivers/power/reset/Kconfig
index 349e9ae8090a..ee039dcead04 100644
--- a/drivers/power/reset/Kconfig
+++ b/drivers/power/reset/Kconfig
@@ -32,7 +32,8 @@ config POWER_RESET_RESTART
32 user presses a key. u-boot then boots into Linux. 32 user presses a key. u-boot then boots into Linux.
33 33
34config POWER_RESET_VEXPRESS 34config POWER_RESET_VEXPRESS
35 bool 35 bool "ARM Versatile Express power-off and reset driver"
36 depends on ARM || ARM64
36 depends on POWER_RESET 37 depends on POWER_RESET
37 help 38 help
38 Power off and reset support for the ARM Ltd. Versatile 39 Power off and reset support for the ARM Ltd. Versatile
diff --git a/drivers/power/rx51_battery.c b/drivers/power/rx51_battery.c
index cbde1d6d3228..8a6288d87056 100644
--- a/drivers/power/rx51_battery.c
+++ b/drivers/power/rx51_battery.c
@@ -216,10 +216,8 @@ static int rx51_battery_probe(struct platform_device *pdev)
216 di->bat.get_property = rx51_battery_get_property; 216 di->bat.get_property = rx51_battery_get_property;
217 217
218 ret = power_supply_register(di->dev, &di->bat); 218 ret = power_supply_register(di->dev, &di->bat);
219 if (ret) { 219 if (ret)
220 platform_set_drvdata(pdev, NULL);
221 return ret; 220 return ret;
222 }
223 221
224 return 0; 222 return 0;
225} 223}
@@ -229,7 +227,6 @@ static int rx51_battery_remove(struct platform_device *pdev)
229 struct rx51_device_info *di = platform_get_drvdata(pdev); 227 struct rx51_device_info *di = platform_get_drvdata(pdev);
230 228
231 power_supply_unregister(&di->bat); 229 power_supply_unregister(&di->bat);
232 platform_set_drvdata(pdev, NULL);
233 230
234 return 0; 231 return 0;
235} 232}
diff --git a/drivers/power/sbs-battery.c b/drivers/power/sbs-battery.c
index c8c78a74e75a..b5f2a76b6cdf 100644
--- a/drivers/power/sbs-battery.c
+++ b/drivers/power/sbs-battery.c
@@ -704,6 +704,7 @@ static int sbs_probe(struct i2c_client *client,
704 chip->power_supply.properties = sbs_properties; 704 chip->power_supply.properties = sbs_properties;
705 chip->power_supply.num_properties = ARRAY_SIZE(sbs_properties); 705 chip->power_supply.num_properties = ARRAY_SIZE(sbs_properties);
706 chip->power_supply.get_property = sbs_get_property; 706 chip->power_supply.get_property = sbs_get_property;
707 chip->power_supply.of_node = client->dev.of_node;
707 /* ignore first notification of external change, it is generated 708 /* ignore first notification of external change, it is generated
708 * from the power_supply_register call back 709 * from the power_supply_register call back
709 */ 710 */
diff --git a/drivers/power/tps65090-charger.c b/drivers/power/tps65090-charger.c
index 9fbca310a2ad..bdd7b9b2546a 100644
--- a/drivers/power/tps65090-charger.c
+++ b/drivers/power/tps65090-charger.c
@@ -27,6 +27,7 @@
27#include <linux/mfd/tps65090.h> 27#include <linux/mfd/tps65090.h>
28 28
29#define TPS65090_REG_INTR_STS 0x00 29#define TPS65090_REG_INTR_STS 0x00
30#define TPS65090_REG_INTR_MASK 0x02
30#define TPS65090_REG_CG_CTRL0 0x04 31#define TPS65090_REG_CG_CTRL0 0x04
31#define TPS65090_REG_CG_CTRL1 0x05 32#define TPS65090_REG_CG_CTRL1 0x05
32#define TPS65090_REG_CG_CTRL2 0x06 33#define TPS65090_REG_CG_CTRL2 0x06
@@ -67,8 +68,7 @@ static int tps65090_low_chrg_current(struct tps65090_charger *charger)
67 return 0; 68 return 0;
68} 69}
69 70
70static int tps65090_enable_charging(struct tps65090_charger *charger, 71static int tps65090_enable_charging(struct tps65090_charger *charger)
71 uint8_t enable)
72{ 72{
73 int ret; 73 int ret;
74 uint8_t ctrl0 = 0; 74 uint8_t ctrl0 = 0;
@@ -84,7 +84,7 @@ static int tps65090_enable_charging(struct tps65090_charger *charger,
84 ret = tps65090_write(charger->dev->parent, TPS65090_REG_CG_CTRL0, 84 ret = tps65090_write(charger->dev->parent, TPS65090_REG_CG_CTRL0,
85 (ctrl0 | TPS65090_CHARGER_ENABLE)); 85 (ctrl0 | TPS65090_CHARGER_ENABLE));
86 if (ret < 0) { 86 if (ret < 0) {
87 dev_err(charger->dev, "%s(): error reading in register 0x%x\n", 87 dev_err(charger->dev, "%s(): error writing in register 0x%x\n",
88 __func__, TPS65090_REG_CG_CTRL0); 88 __func__, TPS65090_REG_CG_CTRL0);
89 return ret; 89 return ret;
90 } 90 }
@@ -93,6 +93,7 @@ static int tps65090_enable_charging(struct tps65090_charger *charger,
93 93
94static int tps65090_config_charger(struct tps65090_charger *charger) 94static int tps65090_config_charger(struct tps65090_charger *charger)
95{ 95{
96 uint8_t intrmask = 0;
96 int ret; 97 int ret;
97 98
98 if (charger->pdata->enable_low_current_chrg) { 99 if (charger->pdata->enable_low_current_chrg) {
@@ -104,6 +105,23 @@ static int tps65090_config_charger(struct tps65090_charger *charger)
104 } 105 }
105 } 106 }
106 107
108 /* Enable the VACG interrupt for AC power detect */
109 ret = tps65090_read(charger->dev->parent, TPS65090_REG_INTR_MASK,
110 &intrmask);
111 if (ret < 0) {
112 dev_err(charger->dev, "%s(): error reading in register 0x%x\n",
113 __func__, TPS65090_REG_INTR_MASK);
114 return ret;
115 }
116
117 ret = tps65090_write(charger->dev->parent, TPS65090_REG_INTR_MASK,
118 (intrmask | TPS65090_VACG));
119 if (ret < 0) {
120 dev_err(charger->dev, "%s(): error writing in register 0x%x\n",
121 __func__, TPS65090_REG_CG_CTRL0);
122 return ret;
123 }
124
107 return 0; 125 return 0;
108} 126}
109 127
@@ -146,7 +164,7 @@ static irqreturn_t tps65090_charger_isr(int irq, void *dev_id)
146 } 164 }
147 165
148 if (intrsts & TPS65090_VACG) { 166 if (intrsts & TPS65090_VACG) {
149 ret = tps65090_enable_charging(charger, 1); 167 ret = tps65090_enable_charging(charger);
150 if (ret < 0) 168 if (ret < 0)
151 return IRQ_HANDLED; 169 return IRQ_HANDLED;
152 charger->ac_online = 1; 170 charger->ac_online = 1;
@@ -154,6 +172,13 @@ static irqreturn_t tps65090_charger_isr(int irq, void *dev_id)
154 charger->ac_online = 0; 172 charger->ac_online = 0;
155 } 173 }
156 174
175 /* Clear interrupts. */
176 ret = tps65090_write(charger->dev->parent, TPS65090_REG_INTR_STS, 0x00);
177 if (ret < 0) {
178 dev_err(charger->dev, "%s(): Error in writing reg 0x%x\n",
179 __func__, TPS65090_REG_INTR_STS);
180 }
181
157 if (charger->prev_ac_online != charger->ac_online) 182 if (charger->prev_ac_online != charger->ac_online)
158 power_supply_changed(&charger->ac); 183 power_supply_changed(&charger->ac);
159 184
@@ -218,7 +243,7 @@ static int tps65090_charger_probe(struct platform_device *pdev)
218 return -ENOMEM; 243 return -ENOMEM;
219 } 244 }
220 245
221 dev_set_drvdata(&pdev->dev, cdata); 246 platform_set_drvdata(pdev, cdata);
222 247
223 cdata->dev = &pdev->dev; 248 cdata->dev = &pdev->dev;
224 cdata->pdata = pdata; 249 cdata->pdata = pdata;
@@ -230,6 +255,7 @@ static int tps65090_charger_probe(struct platform_device *pdev)
230 cdata->ac.num_properties = ARRAY_SIZE(tps65090_ac_props); 255 cdata->ac.num_properties = ARRAY_SIZE(tps65090_ac_props);
231 cdata->ac.supplied_to = pdata->supplied_to; 256 cdata->ac.supplied_to = pdata->supplied_to;
232 cdata->ac.num_supplicants = pdata->num_supplicants; 257 cdata->ac.num_supplicants = pdata->num_supplicants;
258 cdata->ac.of_node = pdev->dev.of_node;
233 259
234 ret = power_supply_register(&pdev->dev, &cdata->ac); 260 ret = power_supply_register(&pdev->dev, &cdata->ac);
235 if (ret) { 261 if (ret) {
@@ -270,7 +296,7 @@ static int tps65090_charger_probe(struct platform_device *pdev)
270 } 296 }
271 297
272 if (status1 != 0) { 298 if (status1 != 0) {
273 ret = tps65090_enable_charging(cdata, 1); 299 ret = tps65090_enable_charging(cdata);
274 if (ret < 0) { 300 if (ret < 0) {
275 dev_err(cdata->dev, "error enabling charger\n"); 301 dev_err(cdata->dev, "error enabling charger\n");
276 goto fail_free_irq; 302 goto fail_free_irq;
@@ -291,7 +317,7 @@ fail_unregister_supply:
291 317
292static int tps65090_charger_remove(struct platform_device *pdev) 318static int tps65090_charger_remove(struct platform_device *pdev)
293{ 319{
294 struct tps65090_charger *cdata = dev_get_drvdata(&pdev->dev); 320 struct tps65090_charger *cdata = platform_get_drvdata(pdev);
295 321
296 devm_free_irq(cdata->dev, cdata->irq, cdata); 322 devm_free_irq(cdata->dev, cdata->irq, cdata);
297 power_supply_unregister(&cdata->ac); 323 power_supply_unregister(&cdata->ac);
diff --git a/drivers/power/twl4030_charger.c b/drivers/power/twl4030_charger.c
index bed458172dd2..be98e70380f9 100644
--- a/drivers/power/twl4030_charger.c
+++ b/drivers/power/twl4030_charger.c
@@ -594,7 +594,6 @@ fail_chg_irq:
594fail_register_usb: 594fail_register_usb:
595 power_supply_unregister(&bci->ac); 595 power_supply_unregister(&bci->ac);
596fail_register_ac: 596fail_register_ac:
597 platform_set_drvdata(pdev, NULL);
598 kfree(bci); 597 kfree(bci);
599 598
600 return ret; 599 return ret;
@@ -622,7 +621,6 @@ static int __exit twl4030_bci_remove(struct platform_device *pdev)
622 free_irq(bci->irq_chg, bci); 621 free_irq(bci->irq_chg, bci);
623 power_supply_unregister(&bci->usb); 622 power_supply_unregister(&bci->usb);
624 power_supply_unregister(&bci->ac); 623 power_supply_unregister(&bci->ac);
625 platform_set_drvdata(pdev, NULL);
626 kfree(bci); 624 kfree(bci);
627 625
628 return 0; 626 return 0;
diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h
index 3828cefb4f65..804b90643a85 100644
--- a/include/linux/power_supply.h
+++ b/include/linux/power_supply.h
@@ -162,6 +162,8 @@ union power_supply_propval {
162 const char *strval; 162 const char *strval;
163}; 163};
164 164
165struct device_node;
166
165struct power_supply { 167struct power_supply {
166 const char *name; 168 const char *name;
167 enum power_supply_type type; 169 enum power_supply_type type;
@@ -173,9 +175,7 @@ struct power_supply {
173 175
174 char **supplied_from; 176 char **supplied_from;
175 size_t num_supplies; 177 size_t num_supplies;
176#ifdef CONFIG_OF
177 struct device_node *of_node; 178 struct device_node *of_node;
178#endif
179 179
180 int (*get_property)(struct power_supply *psy, 180 int (*get_property)(struct power_supply *psy,
181 enum power_supply_property psp, 181 enum power_supply_property psp,