aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChanwoo Choi <cw00.choi@samsung.com>2016-03-20 21:36:26 -0400
committerChanwoo Choi <cw00.choi@samsung.com>2016-06-09 22:12:35 -0400
commitb396cff519da6ab9094d5d9cd95e2849701ef9de (patch)
tree23f1f07e615adce1f69839cf9f2b3940f9ccf3bc
parent1a695a905c18548062509178b98bc91e67510864 (diff)
power: axp288_charger: Replace deprecatd API of extcon
This patch removes the deprecated notifier API of extcon framework and then use the new extcon API[2] with the unique id[1] to indicate the each external connector. Alter deprecated API as following: - extcon_register_interest() -> extcon_register_notifier() - extcon_unregister_interest() -> extcon_unregister_notifier() - extcon_get_cable_state() -> extcon_get_cable_state_() And, extcon alters the name of USB charger connector in patch[3] as following: - EXTCON_CHG_USB_SDP /* Standard Downstream Port */ - EXTCON_CHG_USB_DCP /* Dedicated Charging Port */ - EXTCON_CHG_USB_CDP /* Charging Downstream Port */ - EXTCON_CHG_USB_ACA /* Accessory Charger Adapter */ [1] Commit 2a9de9c0f08d61 - ("extcon: Use the unique id for external connector instead of string) [2] Commit 046050f6e623e4 - ("extcon: Update the prototype of extcon_register_notifier() with enum extcon [3] Commit 11eecf910bd81d - ("extcon: Modify the id and name of external connector") Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com> Acked-By: Sebastian Reichel <sre@kernel.org>
-rw-r--r--drivers/power/axp288_charger.c77
1 files changed, 53 insertions, 24 deletions
diff --git a/drivers/power/axp288_charger.c b/drivers/power/axp288_charger.c
index e4d569f57acc..4030eeb7cf65 100644
--- a/drivers/power/axp288_charger.c
+++ b/drivers/power/axp288_charger.c
@@ -129,10 +129,6 @@
129 129
130#define AXP288_EXTCON_DEV_NAME "axp288_extcon" 130#define AXP288_EXTCON_DEV_NAME "axp288_extcon"
131 131
132#define AXP288_EXTCON_SLOW_CHARGER "SLOW-CHARGER"
133#define AXP288_EXTCON_DOWNSTREAM_CHARGER "CHARGE-DOWNSTREAM"
134#define AXP288_EXTCON_FAST_CHARGER "FAST-CHARGER"
135
136enum { 132enum {
137 VBUS_OV_IRQ = 0, 133 VBUS_OV_IRQ = 0,
138 CHARGE_DONE_IRQ, 134 CHARGE_DONE_IRQ,
@@ -158,7 +154,7 @@ struct axp288_chrg_info {
158 /* OTG/Host mode */ 154 /* OTG/Host mode */
159 struct { 155 struct {
160 struct work_struct work; 156 struct work_struct work;
161 struct extcon_specific_cable_nb cable; 157 struct extcon_dev *cable;
162 struct notifier_block id_nb; 158 struct notifier_block id_nb;
163 bool id_short; 159 bool id_short;
164 } otg; 160 } otg;
@@ -586,17 +582,15 @@ static void axp288_charger_extcon_evt_worker(struct work_struct *work)
586 bool old_connected = info->cable.connected; 582 bool old_connected = info->cable.connected;
587 583
588 /* Determine cable/charger type */ 584 /* Determine cable/charger type */
589 if (extcon_get_cable_state(edev, AXP288_EXTCON_SLOW_CHARGER) > 0) { 585 if (extcon_get_cable_state_(edev, EXTCON_CHG_USB_SDP) > 0) {
590 dev_dbg(&info->pdev->dev, "USB SDP charger is connected"); 586 dev_dbg(&info->pdev->dev, "USB SDP charger is connected");
591 info->cable.connected = true; 587 info->cable.connected = true;
592 info->cable.chg_type = POWER_SUPPLY_TYPE_USB; 588 info->cable.chg_type = POWER_SUPPLY_TYPE_USB;
593 } else if (extcon_get_cable_state(edev, 589 } else if (extcon_get_cable_state_(edev, EXTCON_CHG_USB_CDP) > 0) {
594 AXP288_EXTCON_DOWNSTREAM_CHARGER) > 0) {
595 dev_dbg(&info->pdev->dev, "USB CDP charger is connected"); 590 dev_dbg(&info->pdev->dev, "USB CDP charger is connected");
596 info->cable.connected = true; 591 info->cable.connected = true;
597 info->cable.chg_type = POWER_SUPPLY_TYPE_USB_CDP; 592 info->cable.chg_type = POWER_SUPPLY_TYPE_USB_CDP;
598 } else if (extcon_get_cable_state(edev, 593 } else if (extcon_get_cable_state_(edev, EXTCON_CHG_USB_DCP) > 0) {
599 AXP288_EXTCON_FAST_CHARGER) > 0) {
600 dev_dbg(&info->pdev->dev, "USB DCP charger is connected"); 594 dev_dbg(&info->pdev->dev, "USB DCP charger is connected");
601 info->cable.connected = true; 595 info->cable.connected = true;
602 info->cable.chg_type = POWER_SUPPLY_TYPE_USB_DCP; 596 info->cable.chg_type = POWER_SUPPLY_TYPE_USB_DCP;
@@ -692,8 +686,8 @@ static int axp288_charger_handle_otg_evt(struct notifier_block *nb,
692{ 686{
693 struct axp288_chrg_info *info = 687 struct axp288_chrg_info *info =
694 container_of(nb, struct axp288_chrg_info, otg.id_nb); 688 container_of(nb, struct axp288_chrg_info, otg.id_nb);
695 struct extcon_dev *edev = param; 689 struct extcon_dev *edev = info->otg.cable;
696 int usb_host = extcon_get_cable_state(edev, "USB-Host"); 690 int usb_host = extcon_get_cable_state_(edev, EXTCON_USB_HOST);
697 691
698 dev_dbg(&info->pdev->dev, "external connector USB-Host is %s\n", 692 dev_dbg(&info->pdev->dev, "external connector USB-Host is %s\n",
699 usb_host ? "attached" : "detached"); 693 usb_host ? "attached" : "detached");
@@ -848,10 +842,33 @@ static int axp288_charger_probe(struct platform_device *pdev)
848 /* Register for extcon notification */ 842 /* Register for extcon notification */
849 INIT_WORK(&info->cable.work, axp288_charger_extcon_evt_worker); 843 INIT_WORK(&info->cable.work, axp288_charger_extcon_evt_worker);
850 info->cable.nb.notifier_call = axp288_charger_handle_cable_evt; 844 info->cable.nb.notifier_call = axp288_charger_handle_cable_evt;
851 ret = extcon_register_notifier(info->cable.edev, EXTCON_NONE, &info->cable.nb); 845 ret = extcon_register_notifier(info->cable.edev, EXTCON_CHG_USB_SDP,
846 &info->cable.nb);
847 if (ret) {
848 dev_err(&info->pdev->dev,
849 "failed to register extcon notifier for SDP %d\n", ret);
850 return ret;
851 }
852
853 ret = extcon_register_notifier(info->cable.edev, EXTCON_CHG_USB_CDP,
854 &info->cable.nb);
855 if (ret) {
856 dev_err(&info->pdev->dev,
857 "failed to register extcon notifier for CDP %d\n", ret);
858 extcon_unregister_notifier(info->cable.edev,
859 EXTCON_CHG_USB_SDP, &info->cable.nb);
860 return ret;
861 }
862
863 ret = extcon_register_notifier(info->cable.edev, EXTCON_CHG_USB_DCP,
864 &info->cable.nb);
852 if (ret) { 865 if (ret) {
853 dev_err(&info->pdev->dev, 866 dev_err(&info->pdev->dev,
854 "failed to register extcon notifier %d\n", ret); 867 "failed to register extcon notifier for DCP %d\n", ret);
868 extcon_unregister_notifier(info->cable.edev,
869 EXTCON_CHG_USB_SDP, &info->cable.nb);
870 extcon_unregister_notifier(info->cable.edev,
871 EXTCON_CHG_USB_CDP, &info->cable.nb);
855 return ret; 872 return ret;
856 } 873 }
857 874
@@ -871,14 +888,14 @@ static int axp288_charger_probe(struct platform_device *pdev)
871 /* Register for OTG notification */ 888 /* Register for OTG notification */
872 INIT_WORK(&info->otg.work, axp288_charger_otg_evt_worker); 889 INIT_WORK(&info->otg.work, axp288_charger_otg_evt_worker);
873 info->otg.id_nb.notifier_call = axp288_charger_handle_otg_evt; 890 info->otg.id_nb.notifier_call = axp288_charger_handle_otg_evt;
874 ret = extcon_register_interest(&info->otg.cable, NULL, "USB-Host", 891 ret = extcon_register_notifier(info->otg.cable, EXTCON_USB_HOST,
875 &info->otg.id_nb); 892 &info->otg.id_nb);
876 if (ret) 893 if (ret)
877 dev_warn(&pdev->dev, "failed to register otg notifier\n"); 894 dev_warn(&pdev->dev, "failed to register otg notifier\n");
878 895
879 if (info->otg.cable.edev) 896 if (info->otg.cable)
880 info->otg.id_short = extcon_get_cable_state( 897 info->otg.id_short = extcon_get_cable_state_(
881 info->otg.cable.edev, "USB-Host"); 898 info->otg.cable, EXTCON_USB_HOST);
882 899
883 /* Register charger interrupts */ 900 /* Register charger interrupts */
884 for (i = 0; i < CHRG_INTR_END; i++) { 901 for (i = 0; i < CHRG_INTR_END; i++) {
@@ -905,11 +922,17 @@ static int axp288_charger_probe(struct platform_device *pdev)
905 return 0; 922 return 0;
906 923
907intr_reg_failed: 924intr_reg_failed:
908 if (info->otg.cable.edev) 925 if (info->otg.cable)
909 extcon_unregister_interest(&info->otg.cable); 926 extcon_unregister_notifier(info->otg.cable, EXTCON_USB_HOST,
927 &info->otg.id_nb);
910 power_supply_unregister(info->psy_usb); 928 power_supply_unregister(info->psy_usb);
911psy_reg_failed: 929psy_reg_failed:
912 extcon_unregister_notifier(info->cable.edev, EXTCON_NONE, &info->cable.nb); 930 extcon_unregister_notifier(info->cable.edev, EXTCON_CHG_USB_SDP,
931 &info->cable.nb);
932 extcon_unregister_notifier(info->cable.edev, EXTCON_CHG_USB_CDP,
933 &info->cable.nb);
934 extcon_unregister_notifier(info->cable.edev, EXTCON_CHG_USB_DCP,
935 &info->cable.nb);
913 return ret; 936 return ret;
914} 937}
915 938
@@ -917,10 +940,16 @@ static int axp288_charger_remove(struct platform_device *pdev)
917{ 940{
918 struct axp288_chrg_info *info = dev_get_drvdata(&pdev->dev); 941 struct axp288_chrg_info *info = dev_get_drvdata(&pdev->dev);
919 942
920 if (info->otg.cable.edev) 943 if (info->otg.cable)
921 extcon_unregister_interest(&info->otg.cable); 944 extcon_unregister_notifier(info->otg.cable, EXTCON_USB_HOST,
945 &info->otg.id_nb);
922 946
923 extcon_unregister_notifier(info->cable.edev, EXTCON_NONE, &info->cable.nb); 947 extcon_unregister_notifier(info->cable.edev, EXTCON_CHG_USB_SDP,
948 &info->cable.nb);
949 extcon_unregister_notifier(info->cable.edev, EXTCON_CHG_USB_CDP,
950 &info->cable.nb);
951 extcon_unregister_notifier(info->cable.edev, EXTCON_CHG_USB_DCP,
952 &info->cable.nb);
924 power_supply_unregister(info->psy_usb); 953 power_supply_unregister(info->psy_usb);
925 954
926 return 0; 955 return 0;