mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "André Draszik" <andre.draszik@linaro.org>
To: Heikki Krogerus <heikki.krogerus@linux.intel.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Peter Griffin <peter.griffin@linaro.org>,
	Tudor Ambarus <tudor.ambarus@linaro.org>,
	Will McVicker <willmcvicker@google.com>,
	Badhri Jagan Sridharan <badhri@google.com>,
	kernel-team@android.com, linux-usb@vger.kernel.org,
	 linux-kernel@vger.kernel.org
Subject: Re: [PATCH 00/15] usb: typec: tcpci: few TCPCi & TCPCi-Maxim cleanups (mostly genmask())
Date: Fri, 26 Jul 2024 06:59:01 +0100	[thread overview]
Message-ID: <dac4a84c72bba076ea0d3a51a78b6d350732a7a6.camel@linaro.org> (raw)
In-Reply-To: <20240710-tcpc-cleanup-v1-0-0ec1f41f4263@linaro.org>

Hi,

On Wed, 2024-07-10 at 11:36 +0100, André Draszik wrote:
> While looking through the TCPCi drivers, it occurred to me that all of the
> open-coded register bit manipulations can be simplified and made more
> legible by using the standard GENMASK(), FIELD_GET(), and FIELD_PREP()
> macros, which also is less prone to errors: e.g.
> 
> 	if (((reg & (TCPC_ROLE_CTRL_CC2_MASK << TCPC_ROLE_CTRL_CC2_SHIFT)) >>
> 	     TCPC_ROLE_CTRL_CC2_SHIFT) !=
> 	    ((reg & (TCPC_ROLE_CTRL_CC1_MASK << TCPC_ROLE_CTRL_CC1_SHIFT)) >>
> 	     TCPC_ROLE_CTRL_CC1_SHIFT))
> 
> (arguably) is much harder to read and reason about than:
> 
> 	if (FIELD_GET(TCPC_ROLE_CTRL_CC2, reg) != FIELD_GET(TCPC_ROLE_CTRL_CC1, reg))
> 
> and so on.
> 
> These patches do that. In addition, there are a few comment fixes and I
> added in a conversion to using dev_err_probe() and
> devm_add_action_or_reset() in the Maxim TCPCi driver.
> 
> I kept the patches separated by register or register field as appropriate to
> simplify reviewing, allowing to focus on one field/register at a time.
> 
> Signed-off-by: André Draszik <andre.draszik@linaro.org>
> ---
> André Draszik (15):
>       usb: typec: tcpci: fix a comment typo
>       usb: typec: tcpm/tcpci_maxim: clarify a comment
>       usb: typec: tcpci: use GENMASK() for TCPC_CC_STATUS_CC[12]
>       usb: typec: tcpci: use GENMASK() for TCPC_ROLE_CTRL_CC[12]
>       usb: typec: tcpci: use GENMASK() for TCPC_ROLE_CTRL_RP_VAL
>       usb: typec: tcpci: use GENMASK() for TCPC_MSG_HDR_INFO_REV
>       usb: typec: tcpci: use GENMASK() for TCPC_TRANSMIT register fields
>       usb: typec: tcpm/tcpci_maxim: sort TCPC_ALERT_MASK values by bit
>       usb: typec: tcpm/tcpci_maxim: simplify clearing of TCPC_ALERT_RX_BUF_OVF
>       usb: typec: tcpm/tcpci_maxim: drop STATUS_CHECK()
>       usb: typec: tcpm/tcpci_maxim: use GENMASK() for TCPC_VENDOR_CC_CTRL2 register
>       usb: typec: tcpm/tcpci_maxim: use GENMASK() for TCPC_VENDOR_CC_CTRL3 register
>       usb: typec: tcpm/tcpci_maxim: use GENMASK() for TCPC_VENDOR_ADC_CTRL1 register
>       usb: typec: tcpm/tcpci_maxim: convert to dev_err_probe()
>       usb: typec: tcpm/tcpci_maxim: use device managed TCPCI port deregistration
> 
>  drivers/usb/typec/anx7411.c                |   5 +-
>  drivers/usb/typec/tcpm/maxim_contaminant.c |  46 +++++++------
>  drivers/usb/typec/tcpm/tcpci.c             | 104 ++++++++++++++---------------
>  drivers/usb/typec/tcpm/tcpci_maxim.h       |  18 ++---
>  drivers/usb/typec/tcpm/tcpci_maxim_core.c  |  71 ++++++++++----------
>  drivers/usb/typec/tcpm/tcpci_rt1711h.c     |  27 ++++----
>  include/linux/usb/tcpci.h                  |  31 +++------
>  7 files changed, 144 insertions(+), 158 deletions(-)

Any comments on this series?

Cheers,
Andre'


      parent reply	other threads:[~2024-07-26  5:59 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-10 10:36 André Draszik
2024-07-10 10:36 ` [PATCH 01/15] usb: typec: tcpci: fix a comment typo André Draszik
2024-07-31  9:47   ` Heikki Krogerus
2024-07-10 10:36 ` [PATCH 02/15] usb: typec: tcpm/tcpci_maxim: clarify a comment André Draszik
2024-07-31 10:10   ` Heikki Krogerus
2024-07-10 10:36 ` [PATCH 03/15] usb: typec: tcpci: use GENMASK() for TCPC_CC_STATUS_CC[12] André Draszik
2024-07-31 10:26   ` Heikki Krogerus
2024-07-10 10:36 ` [PATCH 04/15] usb: typec: tcpci: use GENMASK() for TCPC_ROLE_CTRL_CC[12] André Draszik
2024-07-31 10:28   ` Heikki Krogerus
2024-07-10 10:36 ` [PATCH 05/15] usb: typec: tcpci: use GENMASK() for TCPC_ROLE_CTRL_RP_VAL André Draszik
2024-07-31 10:37   ` Heikki Krogerus
2024-07-10 10:36 ` [PATCH 06/15] usb: typec: tcpci: use GENMASK() for TCPC_MSG_HDR_INFO_REV André Draszik
2024-07-31 10:39   ` Heikki Krogerus
2024-07-10 10:36 ` [PATCH 07/15] usb: typec: tcpci: use GENMASK() for TCPC_TRANSMIT register fields André Draszik
2024-07-31 11:01   ` Heikki Krogerus
2024-07-10 10:36 ` [PATCH 08/15] usb: typec: tcpm/tcpci_maxim: sort TCPC_ALERT_MASK values by bit André Draszik
2024-07-31 11:09   ` Heikki Krogerus
2024-07-10 10:36 ` [PATCH 09/15] usb: typec: tcpm/tcpci_maxim: simplify clearing of TCPC_ALERT_RX_BUF_OVF André Draszik
2024-07-31 11:12   ` Heikki Krogerus
2024-07-10 10:36 ` [PATCH 10/15] usb: typec: tcpm/tcpci_maxim: drop STATUS_CHECK() André Draszik
2024-07-31 12:29   ` Heikki Krogerus
2024-07-10 10:36 ` [PATCH 11/15] usb: typec: tcpm/tcpci_maxim: use GENMASK() for TCPC_VENDOR_CC_CTRL2 register André Draszik
2024-07-31 12:36   ` Heikki Krogerus
2024-07-10 10:36 ` [PATCH 12/15] usb: typec: tcpm/tcpci_maxim: use GENMASK() for TCPC_VENDOR_CC_CTRL3 register André Draszik
2024-07-31 12:38   ` Heikki Krogerus
2024-07-10 10:36 ` [PATCH 13/15] usb: typec: tcpm/tcpci_maxim: use GENMASK() for TCPC_VENDOR_ADC_CTRL1 register André Draszik
2024-07-31 12:40   ` Heikki Krogerus
2024-07-10 10:36 ` [PATCH 14/15] usb: typec: tcpm/tcpci_maxim: convert to dev_err_probe() André Draszik
2024-07-31 12:44   ` Heikki Krogerus
2024-07-10 10:36 ` [PATCH 15/15] usb: typec: tcpm/tcpci_maxim: use device managed TCPCI port deregistration André Draszik
2024-07-31 12:45   ` Heikki Krogerus
2024-07-26  5:59 ` André Draszik [this message]

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=dac4a84c72bba076ea0d3a51a78b6d350732a7a6.camel@linaro.org \
    --to=andre.draszik@linaro.org \
    --cc=badhri@google.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=heikki.krogerus@linux.intel.com \
    --cc=kernel-team@android.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=peter.griffin@linaro.org \
    --cc=tudor.ambarus@linaro.org \
    --cc=willmcvicker@google.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®