lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Sun, 16 Sep 2018 13:08:36 +0200
From:   Sebastian Reichel <sebastian.reichel@...labora.com>
To:     Fabien Parent <fparent@...libre.com>
Cc:     Lee Jones <lee.jones@...aro.org>, linux-pm@...r.kernel.org,
        linux-kernel@...r.kernel.org, gpain@...libre.com
Subject: Re: [PATCH v2 3/3] power: supply: cros: add property to detect
 connected ports

Hi,

On Fri, Aug 10, 2018 at 03:13:49PM +0200, Fabien Parent wrote:
> When a port is connected but acting as a source, its 'online' and
> 'status' properties are identical to a port that is not connected. This
> makes it tedious for userspace to know for sure whether a port is
> connected or not.
> 
> This commit adds a new property 'present' to reflect whether a port
> is connected or not.
> 
> Signed-off-by: Fabien Parent <fparent@...libre.com>
> ---

I think it's better to just set use POWER_SUPPLY_STATUS_DISCHARGING
for USB_PD_PORT_POWER_SOURCE.

-- Sebastian

> 
> V1 -> V2:
>   * No change
> 
> ---
>  drivers/power/supply/cros_usbpd-charger.c | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/drivers/power/supply/cros_usbpd-charger.c b/drivers/power/supply/cros_usbpd-charger.c
> index fe1502715e46..6307424f36ec 100644
> --- a/drivers/power/supply/cros_usbpd-charger.c
> +++ b/drivers/power/supply/cros_usbpd-charger.c
> @@ -32,6 +32,7 @@ struct port_data {
>  	struct power_supply_desc psy_desc;
>  	int psy_usb_type;
>  	int psy_online;
> +	int psy_present;
>  	int psy_status;
>  	int psy_current_max;
>  	int psy_voltage_max_design;
> @@ -54,6 +55,7 @@ struct charger_data {
>  
>  static enum power_supply_property cros_usbpd_charger_props[] = {
>  	POWER_SUPPLY_PROP_ONLINE,
> +	POWER_SUPPLY_PROP_PRESENT,
>  	POWER_SUPPLY_PROP_STATUS,
>  	POWER_SUPPLY_PROP_CURRENT_MAX,
>  	POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN,
> @@ -65,6 +67,7 @@ static enum power_supply_property cros_usbpd_charger_props[] = {
>  
>  static enum power_supply_property cros_usbpd_dedicated_charger_props[] = {
>  	POWER_SUPPLY_PROP_ONLINE,
> +	POWER_SUPPLY_PROP_PRESENT,
>  	POWER_SUPPLY_PROP_STATUS,
>  	POWER_SUPPLY_PROP_VOLTAGE_NOW,
>  };
> @@ -205,18 +208,22 @@ static int cros_usbpd_charger_get_power_info(struct port_data *port)
>  	case USB_PD_PORT_POWER_DISCONNECTED:
>  		port->psy_status = POWER_SUPPLY_STATUS_NOT_CHARGING;
>  		port->psy_online = 0;
> +		port->psy_present = 0;
>  		break;
>  	case USB_PD_PORT_POWER_SOURCE:
>  		port->psy_status = POWER_SUPPLY_STATUS_NOT_CHARGING;
>  		port->psy_online = 0;
> +		port->psy_present = 1;
>  		break;
>  	case USB_PD_PORT_POWER_SINK:
>  		port->psy_status = POWER_SUPPLY_STATUS_CHARGING;
>  		port->psy_online = 1;
> +		port->psy_present = 1;
>  		break;
>  	case USB_PD_PORT_POWER_SINK_NOT_CHARGING:
>  		port->psy_status = POWER_SUPPLY_STATUS_NOT_CHARGING;
>  		port->psy_online = 1;
> +		port->psy_present = 1;
>  		break;
>  	default:
>  		dev_err(dev, "Unknown role %d\n", resp.role);
> @@ -363,6 +370,7 @@ static int cros_usbpd_charger_get_prop(struct power_supply *psy,
>  		if (ec_device->mkbp_event_supported || port->psy_online)
>  			break;
>  		/* fall through */
> +	case POWER_SUPPLY_PROP_PRESENT:
>  	case POWER_SUPPLY_PROP_CURRENT_MAX:
>  	case POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN:
>  	case POWER_SUPPLY_PROP_VOLTAGE_NOW:
> @@ -381,6 +389,9 @@ static int cros_usbpd_charger_get_prop(struct power_supply *psy,
>  	case POWER_SUPPLY_PROP_ONLINE:
>  		val->intval = port->psy_online;
>  		break;
> +	case POWER_SUPPLY_PROP_PRESENT:
> +		val->intval = port->psy_present;
> +		break;
>  	case POWER_SUPPLY_PROP_STATUS:
>  		val->intval = port->psy_status;
>  		break;
> -- 
> 2.18.0
> 

Download attachment "signature.asc" of type "application/pgp-signature" (834 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ