* [PATCH] thunderbolt: no opencoding FIELD_GET
@ 2024-02-29 13:23 Oliver Neukum
2024-02-29 16:24 ` Mika Westerberg
0 siblings, 1 reply; 3+ messages in thread
From: Oliver Neukum @ 2024-02-29 13:23 UTC (permalink / raw)
To: gregkh, linux-usb, linux-kernel, mika.westerberg; +Cc: Oliver Neukum
We have a macro. It should be used.
Signed-off-by: Oliver Neukum <oneukum@suse.com>
---
include/linux/usb/typec_tbt.h | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/include/linux/usb/typec_tbt.h b/include/linux/usb/typec_tbt.h
index c7a2153bd6f5..fa97d7e00f5c 100644
--- a/include/linux/usb/typec_tbt.h
+++ b/include/linux/usb/typec_tbt.h
@@ -3,6 +3,7 @@
#define __USB_TYPEC_TBT_H
#include <linux/usb/typec_altmode.h>
+#include <linux/bitfield.h>
#define USB_TYPEC_VENDOR_INTEL 0x8087
/* Alias for convenience */
@@ -25,7 +26,7 @@ struct typec_thunderbolt_data {
/* TBT3 Device Discover Mode VDO bits */
#define TBT_MODE BIT(0)
-#define TBT_ADAPTER(_vdo_) (((_vdo_) & BIT(16)) >> 16)
+#define TBT_ADAPTER(_vdo_) FIELD_GET(BIT(16), _vdo_)
#define TBT_ADAPTER_LEGACY 0
#define TBT_ADAPTER_TBT3 1
#define TBT_INTEL_SPECIFIC_B0 BIT(26)
@@ -35,12 +36,12 @@ struct typec_thunderbolt_data {
#define TBT_SET_ADAPTER(a) (((a) & 1) << 16)
/* TBT3 Cable Discover Mode VDO bits */
-#define TBT_CABLE_SPEED(_vdo_) (((_vdo_) & GENMASK(18, 16)) >> 16)
+#define TBT_CABLE_SPEED(_vdo_) FIELD_GET(GENMASK(18, 16), _vdo_)
#define TBT_CABLE_USB3_GEN1 1
#define TBT_CABLE_USB3_PASSIVE 2
#define TBT_CABLE_10_AND_20GBPS 3
-#define TBT_CABLE_ROUNDED_SUPPORT(_vdo_) \
- (((_vdo_) & GENMASK(20, 19)) >> 19)
+#define TBT_CABLE_ROUNDED_SUPPORT(_vdo_) FIELD_GET(GENMASK(20, 19), _vdo_)
+
#define TBT_GEN3_NON_ROUNDED 0
#define TBT_GEN3_GEN4_ROUNDED_NON_ROUNDED 1
#define TBT_CABLE_OPTICAL BIT(21)
--
2.43.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] thunderbolt: no opencoding FIELD_GET
2024-02-29 13:23 [PATCH] thunderbolt: no opencoding FIELD_GET Oliver Neukum
@ 2024-02-29 16:24 ` Mika Westerberg
2024-03-02 19:21 ` Greg KH
0 siblings, 1 reply; 3+ messages in thread
From: Mika Westerberg @ 2024-02-29 16:24 UTC (permalink / raw)
To: Oliver Neukum; +Cc: gregkh, linux-usb, linux-kernel
On Thu, Feb 29, 2024 at 02:23:57PM +0100, Oliver Neukum wrote:
> We have a macro. It should be used.
>
> Signed-off-by: Oliver Neukum <oneukum@suse.com>
Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Although I think the $subject should probably be something like "usb:
typec" or so since this does not relate to USB4/Thunderbolt subsystem in
any way.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] thunderbolt: no opencoding FIELD_GET
2024-02-29 16:24 ` Mika Westerberg
@ 2024-03-02 19:21 ` Greg KH
0 siblings, 0 replies; 3+ messages in thread
From: Greg KH @ 2024-03-02 19:21 UTC (permalink / raw)
To: Mika Westerberg; +Cc: Oliver Neukum, linux-usb, linux-kernel
On Thu, Feb 29, 2024 at 06:24:25PM +0200, Mika Westerberg wrote:
> On Thu, Feb 29, 2024 at 02:23:57PM +0100, Oliver Neukum wrote:
> > We have a macro. It should be used.
> >
> > Signed-off-by: Oliver Neukum <oneukum@suse.com>
>
> Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
>
> Although I think the $subject should probably be something like "usb:
> typec" or so since this does not relate to USB4/Thunderbolt subsystem in
> any way.
I've fixed this up when applying it, thanks.
greg k-h
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-03-02 19:21 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-29 13:23 [PATCH] thunderbolt: no opencoding FIELD_GET Oliver Neukum
2024-02-29 16:24 ` Mika Westerberg
2024-03-02 19:21 ` Greg KH
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.