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]
Message-ID: <106b27d7-6845-ed3c-411e-9ef5aee7f224@roeck-us.net>
Date:   Tue, 8 Feb 2022 07:25:56 -0800
From:   Guenter Roeck <linux@...ck-us.net>
To:     Potin Lai <potin.lai@...ntatw.com>,
        Heikki Krogerus <heikki.krogerus@...ux.intel.com>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc:     linux-usb@...r.kernel.org, linux-kernel@...r.kernel.org,
        Patrick Williams <patrick@...cx.xyz>
Subject: Re: [PATCH v2 1/2] usb: typec: tcpm: add interface for passing
 supported_pd_rev from tcpc_dev

On 2/8/22 03:22, Potin Lai wrote:
> Current TCPM allways assume using PD_MAX_REV for negotiation,
> but for some USB controller only support PD 2.0, adding an interface
> for passing supported_pd_rev from tcpc_dev.
> 

The PD revision supported by the usb controller is a constant.
I don't see why this would need a callback function. Other
capabilitied are passed to tcpm using the fwnode pointer.
I don't see why this capability would have to be handled
differently.

Guenter

> Signed-off-by: Potin Lai <potin.lai@...ntatw.com>
> ---
>   drivers/usb/typec/tcpm/tcpm.c | 14 ++++++++++++--
>   include/linux/usb/tcpm.h      |  4 ++++
>   2 files changed, 16 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
> index 59d4fa2443f2..22e7d226826e 100644
> --- a/drivers/usb/typec/tcpm/tcpm.c
> +++ b/drivers/usb/typec/tcpm/tcpm.c
> @@ -571,6 +571,16 @@ static bool tcpm_port_is_disconnected(struct tcpm_port *port)
>   				    port->cc2 == TYPEC_CC_OPEN)));
>   }
>   
> +static u32 tcpm_pd_supported_rev(struct tcpm_port *port)
> +{
> +	u32 rev = PD_MAX_REV;
> +
> +	if (port->tcpc->supported_pd_rev)
> +		rev = port->tcpc->supported_pd_rev(port->tcpc);
> +
> +	return min(rev, PD_MAX_REV);
> +}
> +
>   /*
>    * Logging
>    */
> @@ -3932,7 +3942,7 @@ static void run_state_machine(struct tcpm_port *port)
>   		typec_set_pwr_opmode(port->typec_port, opmode);
>   		port->pwr_opmode = TYPEC_PWR_MODE_USB;
>   		port->caps_count = 0;
> -		port->negotiated_rev = PD_MAX_REV;
> +		port->negotiated_rev = tcpm_pd_supported_rev(port);
>   		port->message_id = 0;
>   		port->rx_msgid = -1;
>   		port->explicit_contract = false;
> @@ -4167,7 +4177,7 @@ static void run_state_machine(struct tcpm_port *port)
>   					      port->cc2 : port->cc1);
>   		typec_set_pwr_opmode(port->typec_port, opmode);
>   		port->pwr_opmode = TYPEC_PWR_MODE_USB;
> -		port->negotiated_rev = PD_MAX_REV;
> +		port->negotiated_rev = tcpm_pd_supported_rev(port);
>   		port->message_id = 0;
>   		port->rx_msgid = -1;
>   		port->explicit_contract = false;
> diff --git a/include/linux/usb/tcpm.h b/include/linux/usb/tcpm.h
> index bffc8d3e14ad..36282b2a9d9c 100644
> --- a/include/linux/usb/tcpm.h
> +++ b/include/linux/usb/tcpm.h
> @@ -114,6 +114,9 @@ enum tcpm_transmit_type {
>    *              Optional; The USB Communications Capable bit indicates if port
>    *              partner is capable of communication over the USB data lines
>    *              (e.g. D+/- or SS Tx/Rx). Called to notify the status of the bit.
> + * @supported_pd_rev:
> + *              Optional; TCPM call this function to get supported PD revesion
> + *              from lower level driver.
>    */
>   struct tcpc_dev {
>   	struct fwnode_handle *fwnode;
> @@ -148,6 +151,7 @@ struct tcpc_dev {
>   						 bool pps_active, u32 requested_vbus_voltage);
>   	bool (*is_vbus_vsafe0v)(struct tcpc_dev *dev);
>   	void (*set_partner_usb_comm_capable)(struct tcpc_dev *dev, bool enable);
> +	u32 (*supported_pd_rev)(struct tcpc_dev *dev);
>   };
>   
>   struct tcpm_port;

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ