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: <ZqoT1QW4lG5WjQgw@kuha.fi.intel.com>
Date: Wed, 31 Jul 2024 13:37:09 +0300
From: Heikki Krogerus <heikki.krogerus@...ux.intel.com>
To: André Draszik <andre.draszik@...aro.org>
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	Peter Griffin <peter.griffin@...aro.org>,
	Tudor Ambarus <tudor.ambarus@...aro.org>,
	Will McVicker <willmcvicker@...gle.com>,
	Badhri Jagan Sridharan <badhri@...gle.com>, kernel-team@...roid.com,
	linux-usb@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 05/15] usb: typec: tcpci: use GENMASK() for
 TCPC_ROLE_CTRL_RP_VAL

On Wed, Jul 10, 2024 at 11:36:12AM +0100, André Draszik wrote:
> Align the last remaining field TCPC_ROLE_CTRL_RP_VAL with the other
> fields in the TCPC_ROLE_CTRL register by using GENMASK() and
> FIELD_PREP().
> 
> Signed-off-by: André Draszik <andre.draszik@...aro.org>

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

> ---
>  drivers/usb/typec/tcpm/tcpci.c         | 21 ++++++++++++---------
>  drivers/usb/typec/tcpm/tcpci_rt1711h.c | 12 ++++++------
>  include/linux/usb/tcpci.h              |  3 +--
>  3 files changed, 19 insertions(+), 17 deletions(-)
> 
> diff --git a/drivers/usb/typec/tcpm/tcpci.c b/drivers/usb/typec/tcpm/tcpci.c
> index cd71ece7b956..5ad05a5bbbd1 100644
> --- a/drivers/usb/typec/tcpm/tcpci.c
> +++ b/drivers/usb/typec/tcpm/tcpci.c
> @@ -114,17 +114,20 @@ static int tcpci_set_cc(struct tcpc_dev *tcpc, enum typec_cc_status cc)
>  	case TYPEC_CC_RP_DEF:
>  		reg = (FIELD_PREP(TCPC_ROLE_CTRL_CC1, TCPC_ROLE_CTRL_CC_RP)
>  		       | FIELD_PREP(TCPC_ROLE_CTRL_CC2, TCPC_ROLE_CTRL_CC_RP)
> -		       | (TCPC_ROLE_CTRL_RP_VAL_DEF << TCPC_ROLE_CTRL_RP_VAL_SHIFT));
> +		       | FIELD_PREP(TCPC_ROLE_CTRL_RP_VAL,
> +				    TCPC_ROLE_CTRL_RP_VAL_DEF));
>  		break;
>  	case TYPEC_CC_RP_1_5:
>  		reg = (FIELD_PREP(TCPC_ROLE_CTRL_CC1, TCPC_ROLE_CTRL_CC_RP)
>  		       | FIELD_PREP(TCPC_ROLE_CTRL_CC2, TCPC_ROLE_CTRL_CC_RP)
> -		       | (TCPC_ROLE_CTRL_RP_VAL_1_5 << TCPC_ROLE_CTRL_RP_VAL_SHIFT));
> +		       | FIELD_PREP(TCPC_ROLE_CTRL_RP_VAL,
> +				    TCPC_ROLE_CTRL_RP_VAL_1_5));
>  		break;
>  	case TYPEC_CC_RP_3_0:
>  		reg = (FIELD_PREP(TCPC_ROLE_CTRL_CC1, TCPC_ROLE_CTRL_CC_RP)
>  		       | FIELD_PREP(TCPC_ROLE_CTRL_CC2, TCPC_ROLE_CTRL_CC_RP)
> -		       | (TCPC_ROLE_CTRL_RP_VAL_3_0 << TCPC_ROLE_CTRL_RP_VAL_SHIFT));
> +		       | FIELD_PREP(TCPC_ROLE_CTRL_RP_VAL,
> +				    TCPC_ROLE_CTRL_RP_VAL_3_0));
>  		break;
>  	case TYPEC_CC_OPEN:
>  	default:
> @@ -194,16 +197,16 @@ static int tcpci_start_toggling(struct tcpc_dev *tcpc,
>  	switch (cc) {
>  	default:
>  	case TYPEC_CC_RP_DEF:
> -		reg |= (TCPC_ROLE_CTRL_RP_VAL_DEF <<
> -			TCPC_ROLE_CTRL_RP_VAL_SHIFT);
> +		reg |= FIELD_PREP(TCPC_ROLE_CTRL_RP_VAL,
> +				  TCPC_ROLE_CTRL_RP_VAL_DEF);
>  		break;
>  	case TYPEC_CC_RP_1_5:
> -		reg |= (TCPC_ROLE_CTRL_RP_VAL_1_5 <<
> -			TCPC_ROLE_CTRL_RP_VAL_SHIFT);
> +		reg |= FIELD_PREP(TCPC_ROLE_CTRL_RP_VAL,
> +				  TCPC_ROLE_CTRL_RP_VAL_1_5);
>  		break;
>  	case TYPEC_CC_RP_3_0:
> -		reg |= (TCPC_ROLE_CTRL_RP_VAL_3_0 <<
> -			TCPC_ROLE_CTRL_RP_VAL_SHIFT);
> +		reg |= FIELD_PREP(TCPC_ROLE_CTRL_RP_VAL,
> +				  TCPC_ROLE_CTRL_RP_VAL_3_0);
>  		break;
>  	}
>  
> diff --git a/drivers/usb/typec/tcpm/tcpci_rt1711h.c b/drivers/usb/typec/tcpm/tcpci_rt1711h.c
> index bdb78d08b5b5..64f6dd0dc660 100644
> --- a/drivers/usb/typec/tcpm/tcpci_rt1711h.c
> +++ b/drivers/usb/typec/tcpm/tcpci_rt1711h.c
> @@ -232,16 +232,16 @@ static int rt1711h_start_drp_toggling(struct tcpci *tcpci,
>  	switch (cc) {
>  	default:
>  	case TYPEC_CC_RP_DEF:
> -		reg |= (TCPC_ROLE_CTRL_RP_VAL_DEF <<
> -			TCPC_ROLE_CTRL_RP_VAL_SHIFT);
> +		reg |= FIELD_PREP(TCPC_ROLE_CTRL_RP_VAL,
> +				  TCPC_ROLE_CTRL_RP_VAL_DEF);
>  		break;
>  	case TYPEC_CC_RP_1_5:
> -		reg |= (TCPC_ROLE_CTRL_RP_VAL_1_5 <<
> -			TCPC_ROLE_CTRL_RP_VAL_SHIFT);
> +		reg |= FIELD_PREP(TCPC_ROLE_CTRL_RP_VAL,
> +				  TCPC_ROLE_CTRL_RP_VAL_1_5);
>  		break;
>  	case TYPEC_CC_RP_3_0:
> -		reg |= (TCPC_ROLE_CTRL_RP_VAL_3_0 <<
> -			TCPC_ROLE_CTRL_RP_VAL_SHIFT);
> +		reg |= FIELD_PREP(TCPC_ROLE_CTRL_RP_VAL,
> +				  TCPC_ROLE_CTRL_RP_VAL_3_0);
>  		break;
>  	}
>  
> diff --git a/include/linux/usb/tcpci.h b/include/linux/usb/tcpci.h
> index 552d074429f0..80652d4f722e 100644
> --- a/include/linux/usb/tcpci.h
> +++ b/include/linux/usb/tcpci.h
> @@ -63,8 +63,7 @@
>  
>  #define TCPC_ROLE_CTRL			0x1a
>  #define TCPC_ROLE_CTRL_DRP		BIT(6)
> -#define TCPC_ROLE_CTRL_RP_VAL_SHIFT	4
> -#define TCPC_ROLE_CTRL_RP_VAL_MASK	0x3
> +#define TCPC_ROLE_CTRL_RP_VAL		GENMASK(5, 4)
>  #define TCPC_ROLE_CTRL_RP_VAL_DEF	0x0
>  #define TCPC_ROLE_CTRL_RP_VAL_1_5	0x1
>  #define TCPC_ROLE_CTRL_RP_VAL_3_0	0x2
> 
> -- 
> 2.45.2.803.g4e1b14247a-goog

-- 
heikki

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ