[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZqoZogC9vYg6vSOS@kuha.fi.intel.com>
Date: Wed, 31 Jul 2024 14:01:54 +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 07/15] usb: typec: tcpci: use GENMASK() for TCPC_TRANSMIT
register fields
On Wed, Jul 10, 2024 at 11:36:14AM +0100, André Draszik wrote:
> Convert all fields from register TCPC_TRANSMIT 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/tcpci.c | 7 +++++--
> include/linux/usb/tcpci.h | 6 ++----
> 2 files changed, 7 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/usb/typec/tcpm/tcpci.c b/drivers/usb/typec/tcpm/tcpci.c
> index ad5c9d5bf6a9..b9ee9ccff99b 100644
> --- a/drivers/usb/typec/tcpm/tcpci.c
> +++ b/drivers/usb/typec/tcpm/tcpci.c
> @@ -607,8 +607,11 @@ static int tcpci_pd_transmit(struct tcpc_dev *tcpc, enum tcpm_transmit_type type
> }
>
> /* nRetryCount is 3 in PD2.0 spec where 2 in PD3.0 spec */
> - reg = ((negotiated_rev > PD_REV20 ? PD_RETRY_COUNT_3_0_OR_HIGHER : PD_RETRY_COUNT_DEFAULT)
> - << TCPC_TRANSMIT_RETRY_SHIFT) | (type << TCPC_TRANSMIT_TYPE_SHIFT);
> + reg = FIELD_PREP(TCPC_TRANSMIT_RETRY,
> + (negotiated_rev > PD_REV20
> + ? PD_RETRY_COUNT_3_0_OR_HIGHER
> + : PD_RETRY_COUNT_DEFAULT));
> + reg |= FIELD_PREP(TCPC_TRANSMIT_TYPE, type);
> ret = regmap_write(tcpci->regmap, TCPC_TRANSMIT, reg);
> if (ret < 0)
> return ret;
> diff --git a/include/linux/usb/tcpci.h b/include/linux/usb/tcpci.h
> index 3cd61e9f73b3..f7f5cfbdef12 100644
> --- a/include/linux/usb/tcpci.h
> +++ b/include/linux/usb/tcpci.h
> @@ -148,10 +148,8 @@
> #define TCPC_RX_DATA 0x34 /* through 0x4f */
>
> #define TCPC_TRANSMIT 0x50
> -#define TCPC_TRANSMIT_RETRY_SHIFT 4
> -#define TCPC_TRANSMIT_RETRY_MASK 0x3
> -#define TCPC_TRANSMIT_TYPE_SHIFT 0
> -#define TCPC_TRANSMIT_TYPE_MASK 0x7
> +#define TCPC_TRANSMIT_RETRY GENMASK(5, 4)
> +#define TCPC_TRANSMIT_TYPE GENMASK(2, 0)
>
> #define TCPC_TX_BYTE_CNT 0x51
> #define TCPC_TX_HDR 0x52
>
> --
> 2.45.2.803.g4e1b14247a-goog
--
heikki
Powered by blists - more mailing lists