From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Potin Lai <potin.lai@quantatw.com>
Cc: Guenter Roeck <linux@roeck-us.net>,
Heikki Krogerus <heikki.krogerus@linux.intel.com>,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
Patrick Williams <patrick@stwcx.xyz>
Subject: Re: [PATCH 1/2] usb: typec: tcpm: add interface for passing supported_pd_rev from tcpc_dev
Date: Tue, 8 Feb 2022 09:41:09 +0100 [thread overview]
Message-ID: <YgIspfW4hdPBA15m@kroah.com> (raw)
In-Reply-To: <20220208082026.4855-2-potin.lai@quantatw.com>
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@quantatw.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
next prev parent reply other threads:[~2022-02-08 8:42 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-08 8:20 [PATCH 0/2] Add a interface for passing supported PD rev from TCPC Potin Lai
2022-02-08 8:20 ` [PATCH 1/2] usb: typec: tcpm: add interface for passing supported_pd_rev from tcpc_dev Potin Lai
2022-02-08 8:41 ` Greg Kroah-Hartman [this message]
2022-02-08 8:20 ` [PATCH 2/2] usb: typec: fusb302: add support of supported_pd_rev Potin Lai
2022-02-08 11:22 ` [PATCH v2 0/2] Add a interface for passing supported PD rev from TCPC Potin Lai
2022-02-08 11:22 ` [PATCH v2 1/2] usb: typec: tcpm: add interface for passing supported_pd_rev from tcpc_dev Potin Lai
2022-02-08 15:25 ` Guenter Roeck
2022-02-08 16:41 ` kernel test robot
2022-02-08 16:41 ` kernel test robot
2022-02-09 6:53 ` kernel test robot
2022-02-09 6:53 ` kernel test robot
2022-02-08 11:22 ` [PATCH v2 2/2] usb: typec: fusb302: add support of supported_pd_rev Potin Lai
2022-02-08 15:22 ` Guenter Roeck
2022-02-09 3:34 ` Potin Lai
2022-02-09 17:50 ` Guenter Roeck
2022-02-11 8:35 ` Potin Lai (賴柏廷)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YgIspfW4hdPBA15m@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=heikki.krogerus@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=patrick@stwcx.xyz \
--cc=potin.lai@quantatw.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.