Skip to content

Commit b396cff

Browse files
committed
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 2a9de9c - ("extcon: Use the unique id for external connector instead of string) [2] Commit 046050f - ("extcon: Update the prototype of extcon_register_notifier() with enum extcon [3] Commit 11eecf9 - ("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>
1 parent 1a695a9 commit b396cff

1 file changed

Lines changed: 53 additions & 24 deletions

File tree

‎drivers/power/axp288_charger.c‎

Lines changed: 53 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,6 @@
129129

130130
#define AXP288_EXTCON_DEV_NAME "axp288_extcon"
131131

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-
136132
enum {
137133
VBUS_OV_IRQ = 0,
138134
CHARGE_DONE_IRQ,
@@ -158,7 +154,7 @@ struct axp288_chrg_info {
158154
/* OTG/Host mode */
159155
struct {
160156
struct work_struct work;
161-
struct extcon_specific_cable_nb cable;
157+
struct extcon_dev *cable;
162158
struct notifier_block id_nb;
163159
bool id_short;
164160
} otg;
@@ -586,17 +582,15 @@ static void axp288_charger_extcon_evt_worker(struct work_struct *work)
586582
bool old_connected = info->cable.connected;
587583

588584
/* 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) {
590586
dev_dbg(&info->pdev->dev, "USB SDP charger is connected");
591587
info->cable.connected = true;
592588
info->cable.chg_type = POWER_SUPPLY_TYPE_USB;
593-
} else if (extcon_get_cable_state(edev,
594-
AXP288_EXTCON_DOWNSTREAM_CHARGER) > 0) {
589+
} else if (extcon_get_cable_state_(edev, EXTCON_CHG_USB_CDP) > 0) {
595590
dev_dbg(&info->pdev->dev, "USB CDP charger is connected");
596591
info->cable.connected = true;
597592
info->cable.chg_type = POWER_SUPPLY_TYPE_USB_CDP;
598-
} else if (extcon_get_cable_state(edev,
599-
AXP288_EXTCON_FAST_CHARGER) > 0) {
593+
} else if (extcon_get_cable_state_(edev, EXTCON_CHG_USB_DCP) > 0) {
600594
dev_dbg(&info->pdev->dev, "USB DCP charger is connected");
601595
info->cable.connected = true;
602596
info->cable.chg_type = POWER_SUPPLY_TYPE_USB_DCP;
@@ -692,8 +686,8 @@ static int axp288_charger_handle_otg_evt(struct notifier_block *nb,
692686
{
693687
struct axp288_chrg_info *info =
694688
container_of(nb, struct axp288_chrg_info, otg.id_nb);
695-
struct extcon_dev *edev = param;
696-
int usb_host = extcon_get_cable_state(edev, "USB-Host");
689+
struct extcon_dev *edev = info->otg.cable;
690+
int usb_host = extcon_get_cable_state_(edev, EXTCON_USB_HOST);
697691

698692
dev_dbg(&info->pdev->dev, "external connector USB-Host is %s\n",
699693
usb_host ? "attached" : "detached");
@@ -848,10 +842,33 @@ static int axp288_charger_probe(struct platform_device *pdev)
848842
/* Register for extcon notification */
849843
INIT_WORK(&info->cable.work, axp288_charger_extcon_evt_worker);
850844
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);
852865
if (ret) {
853866
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);
855872
return ret;
856873
}
857874

@@ -871,14 +888,14 @@ static int axp288_charger_probe(struct platform_device *pdev)
871888
/* Register for OTG notification */
872889
INIT_WORK(&info->otg.work, axp288_charger_otg_evt_worker);
873890
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,
875892
&info->otg.id_nb);
876893
if (ret)
877894
dev_warn(&pdev->dev, "failed to register otg notifier\n");
878895

879-
if (info->otg.cable.edev)
880-
info->otg.id_short = extcon_get_cable_state(
881-
info->otg.cable.edev, "USB-Host");
896+
if (info->otg.cable)
897+
info->otg.id_short = extcon_get_cable_state_(
898+
info->otg.cable, EXTCON_USB_HOST);
882899

883900
/* Register charger interrupts */
884901
for (i = 0; i < CHRG_INTR_END; i++) {
@@ -905,22 +922,34 @@ static int axp288_charger_probe(struct platform_device *pdev)
905922
return 0;
906923

907924
intr_reg_failed:
908-
if (info->otg.cable.edev)
909-
extcon_unregister_interest(&info->otg.cable);
925+
if (info->otg.cable)
926+
extcon_unregister_notifier(info->otg.cable, EXTCON_USB_HOST,
927+
&info->otg.id_nb);
910928
power_supply_unregister(info->psy_usb);
911929
psy_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);
913936
return ret;
914937
}
915938

916939
static int axp288_charger_remove(struct platform_device *pdev)
917940
{
918941
struct axp288_chrg_info *info = dev_get_drvdata(&pdev->dev);
919942

920-
if (info->otg.cable.edev)
921-
extcon_unregister_interest(&info->otg.cable);
943+
if (info->otg.cable)
944+
extcon_unregister_notifier(info->otg.cable, EXTCON_USB_HOST,
945+
&info->otg.id_nb);
922946

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);
924953
power_supply_unregister(info->psy_usb);
925954

926955
return 0;

0 commit comments

Comments
 (0)