usb: typec: ucsi: Report power supply changes
Subsystems (3)
Heikki Krogerus
maintainerPATCH 1/1 usb: typec: ucsi: Report power supply changes
When the ucsi power supply goes online/offline, and when the power levels change, the power supply class needs to be notified so it can inform the user space.
Fixes 992a60ed0d5e ("usb: typec: ucsi: register with power_supply class")
Reported-by Vladimir Yerilov <[email protected]>
Signed-off-by Heikki Krogerus <[email protected]>
--- drivers/usb/typec/ucsi/psy.c | 9 +++++++++ drivers/usb/typec/ucsi/ucsi.c | 7 ++++++- drivers/usb/typec/ucsi/ucsi.h | 2 ++ 3 files changed, 17 insertions(+), 1 deletion(-)
drivers/usb/typec/ucsi/psy.c +9 -0
@@ -238,4 +238,13 @@ void ucsi_unregister_port_psy(struct ucsi_connector *con)return ;power_supply_unregister (con->psy); + con->psy =NULL ; +} + +void ucsi_port_psy_changed (struct ucsi_connector *con) +{ +if (IS_ERR_OR_NULL (con->psy)) +return ; + +power_supply_changed (con->psy); }
drivers/usb/typec/ucsi/ucsi.c +6 -1
@@ -643,8 +643,10 @@ static void ucsi_handle_connector_change(struct work_struct *work) role = !!(con->status.flags &UCSI_CONSTAT_PWR_DIR );if (con->status.change &UCSI_CONSTAT_POWER_OPMODE_CHANGE || - con->status.change &UCSI_CONSTAT_POWER_LEVEL_CHANGE ) + con->status.change &UCSI_CONSTAT_POWER_LEVEL_CHANGE ) {ucsi_pwr_opmode_change (con); +ucsi_port_psy_changed (con); + }if (con->status.change &UCSI_CONSTAT_POWER_DIR_CHANGE ) {typec_set_pwr_role (con->port, role);
@@ -674,6 +676,8 @@ static void ucsi_handle_connector_change(struct work_struct *work)ucsi_register_partner (con); elseucsi_unregister_partner (con ); + +ucsi_port_psy_changed (con); }if (con->status.change &UCSI_CONSTAT_CAM_CHANGE ) {
@@ -994,6 +998,7 @@ static int ucsi_register_port(struct ucsi *ucsi, int index) !!(con->status.flags & UCSI_CONSTAT_PWR_DIR));ucsi_pwr_opmode_change (con);ucsi_register_partner (con); +ucsi_port_psy_changed (con); }if (con->partner) {
drivers/usb/typec/ucsi/ucsi.h +2 -0
@@ -340,9 +340,11 @@ int ucsi_resume(struct ucsi *ucsi);#if IS_ENABLED (CONFIG_POWER_SUPPLY )int ucsi_register_port_psy (struct ucsi_connector *con);void ucsi_unregister_port_psy (struct ucsi_connector *con); +void ucsi_port_psy_changed (struct ucsi_connector *con);#else static inline int ucsi_register_port_psy (struct ucsi_connector *con) {return 0 ; }static inline void ucsi_unregister_port_psy (struct ucsi_connector *con) { } +static inline void ucsi_port_psy_changed (struct ucsi_connector *con) { }#endif /* CONFIG_POWER_SUPPLY */ #if IS_ENABLED (CONFIG_TYPEC_DP_ALTMODE )
Signature · 1 line
2.28.0
Greg Kroah-Hartman
maintainerQuoted 8 lines · Heikki Krogerus
When the ucsi power supply goes online/offline, and when the power levels change, the power supply class needs to be notified so it can inform the user space.
Fixes 992a60ed0d5e ("usb: typec: ucsi: register with power_supply class")Reported-by Vladimir Yerilov <[email protected]>Signed-off-by Heikki Krogerus <[email protected]>
No tested-by tags?
Heikki Krogerus
maintainerQuoted 11 lines · Greg Kroah-Hartman
Quoted 8 lines · Heikki Krogerus
When the ucsi power supply goes online/offline, and when the power levels change, the power supply class needs to be notified so it can inform the user space.
Fixes 992a60ed0d5e ("usb: typec: ucsi: register with power_supply class")Reported-by Vladimir Yerilov <[email protected]>Signed-off-by Heikki Krogerus <[email protected]>No tested-by tags?
Sorry Greg. I'll resend.
Signature · 1 line
heikki