UPSTREAM: usb: typec: tcpm: Invoke power_supply_changed for tcpm-source-psy-
tcpm-source-psy- does not invoke power_supply_changed API when
one of the published power supply properties is changed.
power_supply_changed needs to be called to notify
userspace clients(uevents) and kernel clients.
Fixes: f2a8aa053c
("typec: tcpm: Represent source supply through power_supply")
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Badhri Jagan Sridharan <badhri@google.com>
Cc: stable <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20210317181249.1062995-1-badhri@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 86629e098a077922438efa98dc80917604dfd317)
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: I6c24e258f8fa19357a8c00027b498662cbaeb49b
This commit is contained in:

committed by
Greg Kroah-Hartman

parent
8cf94785bb
commit
6f85b7e0f8
@@ -962,6 +962,7 @@ static int tcpm_set_current_limit(struct tcpm_port *port, u32 max_ma, u32 mv)
|
|||||||
|
|
||||||
port->supply_voltage = mv;
|
port->supply_voltage = mv;
|
||||||
port->current_limit = max_ma;
|
port->current_limit = max_ma;
|
||||||
|
power_supply_changed(port->psy);
|
||||||
|
|
||||||
if (port->tcpc->set_current_limit)
|
if (port->tcpc->set_current_limit)
|
||||||
ret = port->tcpc->set_current_limit(port->tcpc, max_ma, mv);
|
ret = port->tcpc->set_current_limit(port->tcpc, max_ma, mv);
|
||||||
@@ -2948,6 +2949,7 @@ static int tcpm_pd_select_pdo(struct tcpm_port *port, int *sink_pdo,
|
|||||||
|
|
||||||
port->pps_data.supported = false;
|
port->pps_data.supported = false;
|
||||||
port->usb_type = POWER_SUPPLY_USB_TYPE_PD;
|
port->usb_type = POWER_SUPPLY_USB_TYPE_PD;
|
||||||
|
power_supply_changed(port->psy);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Select the source PDO providing the most power which has a
|
* Select the source PDO providing the most power which has a
|
||||||
@@ -2972,6 +2974,7 @@ static int tcpm_pd_select_pdo(struct tcpm_port *port, int *sink_pdo,
|
|||||||
port->pps_data.supported = true;
|
port->pps_data.supported = true;
|
||||||
port->usb_type =
|
port->usb_type =
|
||||||
POWER_SUPPLY_USB_TYPE_PD_PPS;
|
POWER_SUPPLY_USB_TYPE_PD_PPS;
|
||||||
|
power_supply_changed(port->psy);
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
default:
|
default:
|
||||||
@@ -3129,6 +3132,7 @@ static unsigned int tcpm_pd_select_pps_apdo(struct tcpm_port *port)
|
|||||||
port->pps_data.out_volt));
|
port->pps_data.out_volt));
|
||||||
port->pps_data.op_curr = min(port->pps_data.max_curr,
|
port->pps_data.op_curr = min(port->pps_data.max_curr,
|
||||||
port->pps_data.op_curr);
|
port->pps_data.op_curr);
|
||||||
|
power_supply_changed(port->psy);
|
||||||
}
|
}
|
||||||
|
|
||||||
return src_pdo;
|
return src_pdo;
|
||||||
@@ -3364,6 +3368,7 @@ static int tcpm_set_charge(struct tcpm_port *port, bool charge)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
port->vbus_charge = charge;
|
port->vbus_charge = charge;
|
||||||
|
power_supply_changed(port->psy);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3548,6 +3553,7 @@ static void tcpm_reset_port(struct tcpm_port *port)
|
|||||||
port->try_src_count = 0;
|
port->try_src_count = 0;
|
||||||
port->try_snk_count = 0;
|
port->try_snk_count = 0;
|
||||||
port->usb_type = POWER_SUPPLY_USB_TYPE_C;
|
port->usb_type = POWER_SUPPLY_USB_TYPE_C;
|
||||||
|
power_supply_changed(port->psy);
|
||||||
port->nr_sink_caps = 0;
|
port->nr_sink_caps = 0;
|
||||||
port->sink_cap_done = false;
|
port->sink_cap_done = false;
|
||||||
if (port->tcpc->enable_frs)
|
if (port->tcpc->enable_frs)
|
||||||
@@ -6003,7 +6009,7 @@ static int tcpm_psy_get_prop(struct power_supply *psy,
|
|||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
power_supply_changed(port->psy);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -6208,6 +6214,7 @@ struct tcpm_port *tcpm_register_port(struct device *dev, struct tcpc_dev *tcpc)
|
|||||||
err = devm_tcpm_psy_register(port);
|
err = devm_tcpm_psy_register(port);
|
||||||
if (err)
|
if (err)
|
||||||
goto out_role_sw_put;
|
goto out_role_sw_put;
|
||||||
|
power_supply_changed(port->psy);
|
||||||
|
|
||||||
port->typec_port = typec_register_port(port->dev, &port->typec_caps);
|
port->typec_port = typec_register_port(port->dev, &port->typec_caps);
|
||||||
if (IS_ERR(port->typec_port)) {
|
if (IS_ERR(port->typec_port)) {
|
||||||
|
Reference in New Issue
Block a user