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:   Tue, 8 Feb 2022 09:41:09 +0100
From:   Greg Kroah-Hartman <gregkh@...uxfoundation.org>
To:     Potin Lai <potin.lai@...ntatw.com>
Cc:     Guenter Roeck <linux@...ck-us.net>,
        Heikki Krogerus <heikki.krogerus@...ux.intel.com>,
        linux-usb@...r.kernel.org, linux-kernel@...r.kernel.org,
        Patrick Williams <patrick@...cx.xyz>
Subject: Re: [PATCH 1/2] usb: typec: tcpm: add interface for passing
 supported_pd_rev from tcpc_dev

On Tue, Feb 08, 2022 at 04:20:25PM +0800, 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.
> 
> 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..31770fa8643d 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 (rev > PD_MAX_REV) ? PD_MAX_REV : rev;

Please spell this out in a real if statement to make it obvious:
	if (rev > PD_MAX_REV)
		return PD_MAX_REV
	return rev

Or better yet:
	return min(PD_MAX_REV, rev);

right?

thanks,

greg k-h

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ