Skip to content

Commit 3bdcfe6

Browse files
Peter Chengregkh
authored andcommitted
usb: phy: show USB charger type for user
Current USB charger framework only shows charger state for user, but the user may also need charger type for further use, add support for it. Signed-off-by: Peter Chen <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent c120431 commit 3bdcfe6

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

drivers/usb/phy/phy.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,14 @@ struct phy_devm {
3434
struct notifier_block *nb;
3535
};
3636

37+
static const char *const usb_chger_type[] = {
38+
[UNKNOWN_TYPE] = "USB_CHARGER_UNKNOWN_TYPE",
39+
[SDP_TYPE] = "USB_CHARGER_SDP_TYPE",
40+
[CDP_TYPE] = "USB_CHARGER_CDP_TYPE",
41+
[DCP_TYPE] = "USB_CHARGER_DCP_TYPE",
42+
[ACA_TYPE] = "USB_CHARGER_ACA_TYPE",
43+
};
44+
3745
static struct usb_phy *__usb_find_phy(struct list_head *list,
3846
enum usb_phy_type type)
3947
{
@@ -98,7 +106,8 @@ static void usb_phy_notify_charger_work(struct work_struct *work)
98106
{
99107
struct usb_phy *usb_phy = container_of(work, struct usb_phy, chg_work);
100108
char uchger_state[50] = { 0 };
101-
char *envp[] = { uchger_state, NULL };
109+
char uchger_type[50] = { 0 };
110+
char *envp[] = { uchger_state, uchger_type, NULL };
102111
unsigned int min, max;
103112

104113
switch (usb_phy->chg_state) {
@@ -122,6 +131,8 @@ static void usb_phy_notify_charger_work(struct work_struct *work)
122131
return;
123132
}
124133

134+
snprintf(uchger_type, ARRAY_SIZE(uchger_type),
135+
"USB_CHARGER_TYPE=%s", usb_chger_type[usb_phy->chg_type]);
125136
kobject_uevent_env(&usb_phy->dev->kobj, KOBJ_CHANGE, envp);
126137
}
127138

0 commit comments

Comments
 (0)