summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorAndré Draszik <andre.draszik@linaro.org>2024-07-10 11:36:10 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2024-08-07 12:49:30 +0200
commitf523aa6d72598bcd2946c7e02d29f33f94806a15 (patch)
tree7b646b0f3b14c9f805a87095910b31f7983113cf /include
parent0943ce2b764310efeffc58fbc09a9105cf02a8ea (diff)
usb: typec: tcpci: use GENMASK() for TCPC_CC_STATUS_CC[12]
The existing code here, particularly in maxim_contaminant.c, is arguably quite hard to read due to the open-coded masking and shifting spanning multiple lines. Use GENMASK() and FIELD_GET() instead, which arguably make the code much easier to follow. While at it, use the symbolic name TCPC_CC_STATE_SRC_OPEN for one instance of open-coded 0x0. Signed-off-by: André Draszik <andre.draszik@linaro.org> Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Link: https://lore.kernel.org/r/20240710-tcpc-cleanup-v1-3-0ec1f41f4263@linaro.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'include')
-rw-r--r--include/linux/usb/tcpci.h8
1 files changed, 3 insertions, 5 deletions
diff --git a/include/linux/usb/tcpci.h b/include/linux/usb/tcpci.h
index d27fe0c22a8b..31d21ccf662b 100644
--- a/include/linux/usb/tcpci.h
+++ b/include/linux/usb/tcpci.h
@@ -92,11 +92,9 @@
#define TCPC_CC_STATUS_TERM BIT(4)
#define TCPC_CC_STATUS_TERM_RP 0
#define TCPC_CC_STATUS_TERM_RD 1
+#define TCPC_CC_STATUS_CC2 GENMASK(3, 2)
+#define TCPC_CC_STATUS_CC1 GENMASK(1, 0)
#define TCPC_CC_STATE_SRC_OPEN 0
-#define TCPC_CC_STATUS_CC2_SHIFT 2
-#define TCPC_CC_STATUS_CC2_MASK 0x3
-#define TCPC_CC_STATUS_CC1_SHIFT 0
-#define TCPC_CC_STATUS_CC1_MASK 0x3
#define TCPC_POWER_STATUS 0x1e
#define TCPC_POWER_STATUS_DBG_ACC_CON BIT(7)
@@ -256,7 +254,7 @@ static inline enum typec_cc_status tcpci_to_typec_cc(unsigned int cc, bool sink)
if (sink)
return TYPEC_CC_RP_3_0;
fallthrough;
- case 0x0:
+ case TCPC_CC_STATE_SRC_OPEN:
default:
return TYPEC_CC_OPEN;
}