* [PATCH 0/2] improve mt76 led code readability
@ 2019-12-15 8:54 Lorenzo Bianconi
2019-12-15 8:54 ` [PATCH 1/2] mt76: mt76x02: simplify led reg definitions Lorenzo Bianconi
2019-12-15 8:54 ` [PATCH 2/2] mt76: mt7603: " Lorenzo Bianconi
0 siblings, 2 replies; 4+ messages in thread
From: Lorenzo Bianconi @ 2019-12-15 8:54 UTC (permalink / raw)
To: nbd; +Cc: linux-wireless, lorenzo.bianconi
Improve code readability relying on FIELD_PREP macro for led register
definitions and remove open coding
Lorenzo Bianconi (2):
mt76: mt76x02: simplify led reg definitions
mt76: mt7603: simplify led reg definitions
drivers/net/wireless/mediatek/mt76/mt7603/regs.h | 12 +++---------
drivers/net/wireless/mediatek/mt76/mt76x02_regs.h | 9 +++------
2 files changed, 6 insertions(+), 15 deletions(-)
--
2.21.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] mt76: mt76x02: simplify led reg definitions
2019-12-15 8:54 [PATCH 0/2] improve mt76 led code readability Lorenzo Bianconi
@ 2019-12-15 8:54 ` Lorenzo Bianconi
2019-12-15 8:54 ` [PATCH 2/2] mt76: mt7603: " Lorenzo Bianconi
1 sibling, 0 replies; 4+ messages in thread
From: Lorenzo Bianconi @ 2019-12-15 8:54 UTC (permalink / raw)
To: nbd; +Cc: linux-wireless, lorenzo.bianconi
Rely on FIELD_PREP macro for led register definitions and
remove open coding
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
drivers/net/wireless/mediatek/mt76/mt76x02_regs.h | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_regs.h b/drivers/net/wireless/mediatek/mt76/mt76x02_regs.h
index 21c0f351fa09..b69a495d0b9a 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x02_regs.h
+++ b/drivers/net/wireless/mediatek/mt76/mt76x02_regs.h
@@ -236,14 +236,11 @@
#define MT_LED_S1_BASE 0x0780
#define MT_LED_S1(_n) (MT_LED_S1_BASE + 8 * (_n))
#define MT_LED_STATUS_OFF_MASK GENMASK(31, 24)
-#define MT_LED_STATUS_OFF(_v) (((_v) << __ffs(MT_LED_STATUS_OFF_MASK)) & \
- MT_LED_STATUS_OFF_MASK)
+#define MT_LED_STATUS_OFF(_v) FIELD_PREP(MT_LED_STATUS_OFF_MASK, (_v))
#define MT_LED_STATUS_ON_MASK GENMASK(23, 16)
-#define MT_LED_STATUS_ON(_v) (((_v) << __ffs(MT_LED_STATUS_ON_MASK)) & \
- MT_LED_STATUS_ON_MASK)
+#define MT_LED_STATUS_ON(_v) FIELD_PREP(MT_LED_STATUS_ON_MASK, (_v))
#define MT_LED_STATUS_DURATION_MASK GENMASK(15, 8)
-#define MT_LED_STATUS_DURATION(_v) (((_v) << __ffs(MT_LED_STATUS_DURATION_MASK)) & \
- MT_LED_STATUS_DURATION_MASK)
+#define MT_LED_STATUS_DURATION(_v) FIELD_PREP(MT_LED_STATUS_DURATION_MASK, (_v))
#define MT_FCE_PSE_CTRL 0x0800
#define MT_FCE_PARAMETERS 0x0804
--
2.21.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] mt76: mt7603: simplify led reg definitions
2019-12-15 8:54 [PATCH 0/2] improve mt76 led code readability Lorenzo Bianconi
2019-12-15 8:54 ` [PATCH 1/2] mt76: mt76x02: simplify led reg definitions Lorenzo Bianconi
@ 2019-12-15 8:54 ` Lorenzo Bianconi
2019-12-15 15:25 ` Felix Fietkau
1 sibling, 1 reply; 4+ messages in thread
From: Lorenzo Bianconi @ 2019-12-15 8:54 UTC (permalink / raw)
To: nbd; +Cc: linux-wireless, lorenzo.bianconi
Rely on FIELD_PREP macro for led register definitions and
remove open coding
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
drivers/net/wireless/mediatek/mt76/mt7603/regs.h | 12 +++---------
1 file changed, 3 insertions(+), 9 deletions(-)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7603/regs.h b/drivers/net/wireless/mediatek/mt76/mt7603/regs.h
index 6e23ed3dfdff..52425eb187f6 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7603/regs.h
+++ b/drivers/net/wireless/mediatek/mt76/mt7603/regs.h
@@ -586,17 +586,11 @@ enum {
#define MT_LED_STATUS_0(_n) MT_LED_PHYS(0x10 + ((_n) * 8))
#define MT_LED_STATUS_1(_n) MT_LED_PHYS(0x14 + ((_n) * 8))
#define MT_LED_STATUS_OFF_MASK GENMASK(31, 24)
-#define MT_LED_STATUS_OFF(_v) (((_v) << \
- __ffs(MT_LED_STATUS_OFF_MASK)) & \
- MT_LED_STATUS_OFF_MASK)
+#define MT_LED_STATUS_OFF(_v) FIELD_PREP(MT_LED_STATUS_OFF_MASK, (_v))
#define MT_LED_STATUS_ON_MASK GENMASK(23, 16)
-#define MT_LED_STATUS_ON(_v) (((_v) << \
- __ffs(MT_LED_STATUS_ON_MASK)) & \
- MT_LED_STATUS_ON_MASK)
+#define MT_LED_STATUS_ON(_v) FIELD_PREP(MT_LED_STATUS_ON_MASK, (_v))
#define MT_LED_STATUS_DURATION_MASK GENMASK(15, 0)
-#define MT_LED_STATUS_DURATION(_v) (((_v) << \
- __ffs(MT_LED_STATUS_DURATION_MASK)) &\
- MT_LED_STATUS_DURATION_MASK)
+#define MT_LED_STATUS_DURATION(_v) FIELD_PREP(MT_LED_STATUS_DURATION_MASK, (_v))
#define MT_CLIENT_BASE_PHYS_ADDR 0x800c0000
--
2.21.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] mt76: mt7603: simplify led reg definitions
2019-12-15 8:54 ` [PATCH 2/2] mt76: mt7603: " Lorenzo Bianconi
@ 2019-12-15 15:25 ` Felix Fietkau
0 siblings, 0 replies; 4+ messages in thread
From: Felix Fietkau @ 2019-12-15 15:25 UTC (permalink / raw)
To: Lorenzo Bianconi; +Cc: linux-wireless, lorenzo.bianconi
On 2019-12-15 09:54, Lorenzo Bianconi wrote:
> Rely on FIELD_PREP macro for led register definitions and
> remove open coding
>
> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Please move the FIELD_PREP from the header files to the source file to
be consistent with the rest of the code. Same applies to the mt7615 patch.
- Felix
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-12-15 15:25 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-15 8:54 [PATCH 0/2] improve mt76 led code readability Lorenzo Bianconi
2019-12-15 8:54 ` [PATCH 1/2] mt76: mt76x02: simplify led reg definitions Lorenzo Bianconi
2019-12-15 8:54 ` [PATCH 2/2] mt76: mt7603: " Lorenzo Bianconi
2019-12-15 15:25 ` Felix Fietkau
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).