All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] usb: typec: tcpm: Invoke power_supply_changed for tcpm-source-psy-
@ 2021-03-16 21:56 Badhri Jagan Sridharan
  2021-03-16 22:52 ` Guenter Roeck
  2021-03-17  7:56 ` Heikki Krogerus
  0 siblings, 2 replies; 3+ messages in thread
From: Badhri Jagan Sridharan @ 2021-03-16 21:56 UTC (permalink / raw)
  To: Guenter Roeck, Heikki Krogerus, Greg Kroah-Hartman
  Cc: linux-usb, linux-kernel, Adam Thomson, Badhri Jagan Sridharan

tcpm-source-psy- does not invoke power_supply_changed API when
one of the published power supply property is changed.
power_supply_changed needs to be called to notify
userspace clients(uevents) and kernel clients.

Fixes: f2a8aa053c176("typec: tcpm: Represent source supply through
power_supply")
Signed-off-by: Badhri Jagan Sridharan <badhri@google.com>
---
 drivers/usb/typec/tcpm/tcpm.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
index 11d0c40bc47d..e8936ea17f80 100644
--- a/drivers/usb/typec/tcpm/tcpm.c
+++ b/drivers/usb/typec/tcpm/tcpm.c
@@ -945,6 +945,7 @@ static int tcpm_set_current_limit(struct tcpm_port *port, u32 max_ma, u32 mv)
 
 	port->supply_voltage = mv;
 	port->current_limit = max_ma;
+	power_supply_changed(port->psy);
 
 	if (port->tcpc->set_current_limit)
 		ret = port->tcpc->set_current_limit(port->tcpc, max_ma, mv);
@@ -2931,6 +2932,7 @@ static int tcpm_pd_select_pdo(struct tcpm_port *port, int *sink_pdo,
 
 	port->pps_data.supported = false;
 	port->usb_type = POWER_SUPPLY_USB_TYPE_PD;
+	power_supply_changed(port->psy);
 
 	/*
 	 * Select the source PDO providing the most power which has a
@@ -2955,6 +2957,7 @@ static int tcpm_pd_select_pdo(struct tcpm_port *port, int *sink_pdo,
 				port->pps_data.supported = true;
 				port->usb_type =
 					POWER_SUPPLY_USB_TYPE_PD_PPS;
+				power_supply_changed(port->psy);
 			}
 			continue;
 		default:
@@ -3112,6 +3115,7 @@ static unsigned int tcpm_pd_select_pps_apdo(struct tcpm_port *port)
 						  port->pps_data.out_volt));
 		port->pps_data.op_curr = min(port->pps_data.max_curr,
 					     port->pps_data.op_curr);
+		power_supply_changed(port->psy);
 	}
 
 	return src_pdo;
@@ -3347,6 +3351,7 @@ static int tcpm_set_charge(struct tcpm_port *port, bool charge)
 			return ret;
 	}
 	port->vbus_charge = charge;
+	power_supply_changed(port->psy);
 	return 0;
 }
 
@@ -3530,6 +3535,7 @@ static void tcpm_reset_port(struct tcpm_port *port)
 	port->try_src_count = 0;
 	port->try_snk_count = 0;
 	port->usb_type = POWER_SUPPLY_USB_TYPE_C;
+	power_supply_changed(port->psy);
 	port->nr_sink_caps = 0;
 	port->sink_cap_done = false;
 	if (port->tcpc->enable_frs)
@@ -5957,7 +5963,7 @@ static int tcpm_psy_set_prop(struct power_supply *psy,
 		ret = -EINVAL;
 		break;
 	}
-
+	power_supply_changed(port->psy);
 	return ret;
 }
 
@@ -6110,6 +6116,7 @@ struct tcpm_port *tcpm_register_port(struct device *dev, struct tcpc_dev *tcpc)
 	err = devm_tcpm_psy_register(port);
 	if (err)
 		goto out_role_sw_put;
+	power_supply_changed(port->psy);
 
 	port->typec_port = typec_register_port(port->dev, &port->typec_caps);
 	if (IS_ERR(port->typec_port)) {
-- 
2.31.0.rc2.261.g7f71774620-goog


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] usb: typec: tcpm: Invoke power_supply_changed for tcpm-source-psy-
  2021-03-16 21:56 [PATCH] usb: typec: tcpm: Invoke power_supply_changed for tcpm-source-psy- Badhri Jagan Sridharan
@ 2021-03-16 22:52 ` Guenter Roeck
  2021-03-17  7:56 ` Heikki Krogerus
  1 sibling, 0 replies; 3+ messages in thread
From: Guenter Roeck @ 2021-03-16 22:52 UTC (permalink / raw)
  To: Badhri Jagan Sridharan, Heikki Krogerus, Greg Kroah-Hartman
  Cc: linux-usb, linux-kernel, Adam Thomson

On 3/16/21 2:56 PM, Badhri Jagan Sridharan wrote:
> tcpm-source-psy- does not invoke power_supply_changed API when
> one of the published power supply property is changed.

properties

> power_supply_changed needs to be called to notify
> userspace clients(uevents) and kernel clients.
> 
> Fixes: f2a8aa053c176("typec: tcpm: Represent source supply through
> power_supply")

Is that supposed to be split ?

> Signed-off-by: Badhri Jagan Sridharan <badhri@google.com>

Otherwise

Reviewed-by: Guenter Roeck <linux@roeck-us.net>

> ---
>  drivers/usb/typec/tcpm/tcpm.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
> index 11d0c40bc47d..e8936ea17f80 100644
> --- a/drivers/usb/typec/tcpm/tcpm.c
> +++ b/drivers/usb/typec/tcpm/tcpm.c
> @@ -945,6 +945,7 @@ static int tcpm_set_current_limit(struct tcpm_port *port, u32 max_ma, u32 mv)
>  
>  	port->supply_voltage = mv;
>  	port->current_limit = max_ma;
> +	power_supply_changed(port->psy);
>  
>  	if (port->tcpc->set_current_limit)
>  		ret = port->tcpc->set_current_limit(port->tcpc, max_ma, mv);
> @@ -2931,6 +2932,7 @@ static int tcpm_pd_select_pdo(struct tcpm_port *port, int *sink_pdo,
>  
>  	port->pps_data.supported = false;
>  	port->usb_type = POWER_SUPPLY_USB_TYPE_PD;
> +	power_supply_changed(port->psy);
>  
>  	/*
>  	 * Select the source PDO providing the most power which has a
> @@ -2955,6 +2957,7 @@ static int tcpm_pd_select_pdo(struct tcpm_port *port, int *sink_pdo,
>  				port->pps_data.supported = true;
>  				port->usb_type =
>  					POWER_SUPPLY_USB_TYPE_PD_PPS;
> +				power_supply_changed(port->psy);
>  			}
>  			continue;
>  		default:
> @@ -3112,6 +3115,7 @@ static unsigned int tcpm_pd_select_pps_apdo(struct tcpm_port *port)
>  						  port->pps_data.out_volt));
>  		port->pps_data.op_curr = min(port->pps_data.max_curr,
>  					     port->pps_data.op_curr);
> +		power_supply_changed(port->psy);
>  	}
>  
>  	return src_pdo;
> @@ -3347,6 +3351,7 @@ static int tcpm_set_charge(struct tcpm_port *port, bool charge)
>  			return ret;
>  	}
>  	port->vbus_charge = charge;
> +	power_supply_changed(port->psy);
>  	return 0;
>  }
>  
> @@ -3530,6 +3535,7 @@ static void tcpm_reset_port(struct tcpm_port *port)
>  	port->try_src_count = 0;
>  	port->try_snk_count = 0;
>  	port->usb_type = POWER_SUPPLY_USB_TYPE_C;
> +	power_supply_changed(port->psy);
>  	port->nr_sink_caps = 0;
>  	port->sink_cap_done = false;
>  	if (port->tcpc->enable_frs)
> @@ -5957,7 +5963,7 @@ static int tcpm_psy_set_prop(struct power_supply *psy,
>  		ret = -EINVAL;
>  		break;
>  	}
> -
> +	power_supply_changed(port->psy);
>  	return ret;
>  }
>  
> @@ -6110,6 +6116,7 @@ struct tcpm_port *tcpm_register_port(struct device *dev, struct tcpc_dev *tcpc)
>  	err = devm_tcpm_psy_register(port);
>  	if (err)
>  		goto out_role_sw_put;
> +	power_supply_changed(port->psy);
>  
>  	port->typec_port = typec_register_port(port->dev, &port->typec_caps);
>  	if (IS_ERR(port->typec_port)) {
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] usb: typec: tcpm: Invoke power_supply_changed for tcpm-source-psy-
  2021-03-16 21:56 [PATCH] usb: typec: tcpm: Invoke power_supply_changed for tcpm-source-psy- Badhri Jagan Sridharan
  2021-03-16 22:52 ` Guenter Roeck
@ 2021-03-17  7:56 ` Heikki Krogerus
  1 sibling, 0 replies; 3+ messages in thread
From: Heikki Krogerus @ 2021-03-17  7:56 UTC (permalink / raw)
  To: Badhri Jagan Sridharan
  Cc: Guenter Roeck, Greg Kroah-Hartman, linux-usb, linux-kernel, Adam Thomson

On Tue, Mar 16, 2021 at 02:56:57PM -0700, Badhri Jagan Sridharan wrote:
> tcpm-source-psy- does not invoke power_supply_changed API when
> one of the published power supply property is changed.
> power_supply_changed needs to be called to notify
> userspace clients(uevents) and kernel clients.
> 
> Fixes: f2a8aa053c176("typec: tcpm: Represent source supply through
> power_supply")
> Signed-off-by: Badhri Jagan Sridharan <badhri@google.com>

Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>

> ---
>  drivers/usb/typec/tcpm/tcpm.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
> index 11d0c40bc47d..e8936ea17f80 100644
> --- a/drivers/usb/typec/tcpm/tcpm.c
> +++ b/drivers/usb/typec/tcpm/tcpm.c
> @@ -945,6 +945,7 @@ static int tcpm_set_current_limit(struct tcpm_port *port, u32 max_ma, u32 mv)
>  
>  	port->supply_voltage = mv;
>  	port->current_limit = max_ma;
> +	power_supply_changed(port->psy);
>  
>  	if (port->tcpc->set_current_limit)
>  		ret = port->tcpc->set_current_limit(port->tcpc, max_ma, mv);
> @@ -2931,6 +2932,7 @@ static int tcpm_pd_select_pdo(struct tcpm_port *port, int *sink_pdo,
>  
>  	port->pps_data.supported = false;
>  	port->usb_type = POWER_SUPPLY_USB_TYPE_PD;
> +	power_supply_changed(port->psy);
>  
>  	/*
>  	 * Select the source PDO providing the most power which has a
> @@ -2955,6 +2957,7 @@ static int tcpm_pd_select_pdo(struct tcpm_port *port, int *sink_pdo,
>  				port->pps_data.supported = true;
>  				port->usb_type =
>  					POWER_SUPPLY_USB_TYPE_PD_PPS;
> +				power_supply_changed(port->psy);
>  			}
>  			continue;
>  		default:
> @@ -3112,6 +3115,7 @@ static unsigned int tcpm_pd_select_pps_apdo(struct tcpm_port *port)
>  						  port->pps_data.out_volt));
>  		port->pps_data.op_curr = min(port->pps_data.max_curr,
>  					     port->pps_data.op_curr);
> +		power_supply_changed(port->psy);
>  	}
>  
>  	return src_pdo;
> @@ -3347,6 +3351,7 @@ static int tcpm_set_charge(struct tcpm_port *port, bool charge)
>  			return ret;
>  	}
>  	port->vbus_charge = charge;
> +	power_supply_changed(port->psy);
>  	return 0;
>  }
>  
> @@ -3530,6 +3535,7 @@ static void tcpm_reset_port(struct tcpm_port *port)
>  	port->try_src_count = 0;
>  	port->try_snk_count = 0;
>  	port->usb_type = POWER_SUPPLY_USB_TYPE_C;
> +	power_supply_changed(port->psy);
>  	port->nr_sink_caps = 0;
>  	port->sink_cap_done = false;
>  	if (port->tcpc->enable_frs)
> @@ -5957,7 +5963,7 @@ static int tcpm_psy_set_prop(struct power_supply *psy,
>  		ret = -EINVAL;
>  		break;
>  	}
> -
> +	power_supply_changed(port->psy);
>  	return ret;
>  }
>  
> @@ -6110,6 +6116,7 @@ struct tcpm_port *tcpm_register_port(struct device *dev, struct tcpc_dev *tcpc)
>  	err = devm_tcpm_psy_register(port);
>  	if (err)
>  		goto out_role_sw_put;
> +	power_supply_changed(port->psy);
>  
>  	port->typec_port = typec_register_port(port->dev, &port->typec_caps);
>  	if (IS_ERR(port->typec_port)) {
> -- 
> 2.31.0.rc2.261.g7f71774620-goog

-- 
heikki

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-03-17  7:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-16 21:56 [PATCH] usb: typec: tcpm: Invoke power_supply_changed for tcpm-source-psy- Badhri Jagan Sridharan
2021-03-16 22:52 ` Guenter Roeck
2021-03-17  7:56 ` Heikki Krogerus

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.