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: <Zqov06zsAQOiy4Zt@kuha.fi.intel.com>
Date: Wed, 31 Jul 2024 15:36:35 +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 11/15] usb: typec: tcpm/tcpci_maxim: use GENMASK() for
 TCPC_VENDOR_CC_CTRL2 register

On Wed, Jul 10, 2024 at 11:36:18AM +0100, André Draszik wrote:
> Convert register TCPC_VENDOR_CC_CTRL2 to using GENMASK() and
> FIELD_PREP() so as to keep using a similar approach throughout the code
> base and make it arguably easier to read.
> 
> Signed-off-by: André Draszik <andre.draszik@...aro.org>

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

> ---
>  drivers/usb/typec/tcpm/maxim_contaminant.c | 18 +++++++++++-------
>  drivers/usb/typec/tcpm/tcpci_maxim.h       |  6 +++---
>  2 files changed, 14 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/usb/typec/tcpm/maxim_contaminant.c b/drivers/usb/typec/tcpm/maxim_contaminant.c
> index 8ac8eeade277..f7acaa42329f 100644
> --- a/drivers/usb/typec/tcpm/maxim_contaminant.c
> +++ b/drivers/usb/typec/tcpm/maxim_contaminant.c
> @@ -116,13 +116,14 @@ static int max_contaminant_read_resistance_kohm(struct max_tcpci_chip *chip,
>  	if (channel == CC1_SCALE1 || channel == CC2_SCALE1 || channel == CC1_SCALE2 ||
>  	    channel == CC2_SCALE2) {
>  		/* Enable 1uA current source */
> -		ret = regmap_update_bits(regmap, TCPC_VENDOR_CC_CTRL2, CCLPMODESEL_MASK,
> -					 ULTRA_LOW_POWER_MODE);
> +		ret = regmap_update_bits(regmap, TCPC_VENDOR_CC_CTRL2, CCLPMODESEL,
> +					 FIELD_PREP(CCLPMODESEL, ULTRA_LOW_POWER_MODE));
>  		if (ret < 0)
>  			return ret;
>  
>  		/* Enable 1uA current source */
> -		ret = regmap_update_bits(regmap, TCPC_VENDOR_CC_CTRL2, CCRPCTRL_MASK, UA_1_SRC);
> +		ret = regmap_update_bits(regmap, TCPC_VENDOR_CC_CTRL2, CCRPCTRL,
> +					 FIELD_PREP(CCRPCTRL, UA_1_SRC));
>  		if (ret < 0)
>  			return ret;
>  
> @@ -176,7 +177,8 @@ static int max_contaminant_read_comparators(struct max_tcpci_chip *chip, u8 *ven
>  	int ret;
>  
>  	/* Enable 80uA source */
> -	ret = regmap_update_bits(regmap, TCPC_VENDOR_CC_CTRL2, CCRPCTRL_MASK, UA_80_SRC);
> +	ret = regmap_update_bits(regmap, TCPC_VENDOR_CC_CTRL2, CCRPCTRL,
> +				 FIELD_PREP(CCRPCTRL, UA_80_SRC));
>  	if (ret < 0)
>  		return ret;
>  
> @@ -209,7 +211,8 @@ static int max_contaminant_read_comparators(struct max_tcpci_chip *chip, u8 *ven
>  	if (ret < 0)
>  		return ret;
>  
> -	ret = regmap_update_bits(regmap, TCPC_VENDOR_CC_CTRL2, CCRPCTRL_MASK, 0);
> +	ret = regmap_update_bits(regmap, TCPC_VENDOR_CC_CTRL2, CCRPCTRL,
> +				 FIELD_PREP(CCRPCTRL, 0));
>  	if (ret < 0)
>  		return ret;
>  
> @@ -298,8 +301,9 @@ static int max_contaminant_enable_dry_detection(struct max_tcpci_chip *chip)
>  	if (ret < 0)
>  		return ret;
>  
> -	ret = regmap_update_bits(regmap, TCPC_VENDOR_CC_CTRL2, CCLPMODESEL_MASK,
> -				 ULTRA_LOW_POWER_MODE);
> +	ret = regmap_update_bits(regmap, TCPC_VENDOR_CC_CTRL2, CCLPMODESEL,
> +				 FIELD_PREP(CCLPMODESEL,
> +					    ULTRA_LOW_POWER_MODE));
>  	if (ret < 0)
>  		return ret;
>  	ret = max_tcpci_read8(chip, TCPC_VENDOR_CC_CTRL2, &temp);
> diff --git a/drivers/usb/typec/tcpm/tcpci_maxim.h b/drivers/usb/typec/tcpm/tcpci_maxim.h
> index 78ff3b73ee7e..92c9a628ebe1 100644
> --- a/drivers/usb/typec/tcpm/tcpci_maxim.h
> +++ b/drivers/usb/typec/tcpm/tcpci_maxim.h
> @@ -20,9 +20,9 @@
>  #define SBUOVPDIS                               BIT(7)
>  #define CCOVPDIS                                BIT(6)
>  #define SBURPCTRL                               BIT(5)
> -#define CCLPMODESEL_MASK                        GENMASK(4, 3)
> -#define ULTRA_LOW_POWER_MODE                    BIT(3)
> -#define CCRPCTRL_MASK                           GENMASK(2, 0)
> +#define CCLPMODESEL                             GENMASK(4, 3)
> +#define ULTRA_LOW_POWER_MODE                    1
> +#define CCRPCTRL                                GENMASK(2, 0)
>  #define UA_1_SRC                                1
>  #define UA_80_SRC                               3
>  
> 
> -- 
> 2.45.2.803.g4e1b14247a-goog

-- 
heikki

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ