From: Vasanthakumar Thiagarajan <vthiagar@codeaurora.org>
To: ath11k@lists.infradead.org
Subject: [PATCH bringup 4/5] ath11k: Avoid code duplication in set/clear of a register bit values
Date: Wed, 25 Sep 2019 10:13:58 +0530 [thread overview]
Message-ID: <1569386639-1242-4-git-send-email-vthiagar@codeaurora.org> (raw)
In-Reply-To: <1569386639-1242-1-git-send-email-vthiagar@codeaurora.org>
Define helpers to set/clear a particular bit in a register.
Signed-off-by: Vasanthakumar Thiagarajan <vthiagar@codeaurora.org>
---
drivers/net/wireless/ath/ath11k/ahb.c | 52 +++++++++++++++++------------------
1 file changed, 26 insertions(+), 26 deletions(-)
diff --git a/drivers/net/wireless/ath/ath11k/ahb.c b/drivers/net/wireless/ath/ath11k/ahb.c
index 0f26979..29157fb 100644
--- a/drivers/net/wireless/ath/ath11k/ahb.c
+++ b/drivers/net/wireless/ath/ath11k/ahb.c
@@ -482,49 +482,49 @@ static void ath11k_ahb_ext_grp_enable(struct ath11k_ext_irq_grp *irq_grp)
enable_irq(irq_grp->ab->irq_num[irq_grp->irqs[i]]);
}
+static void ath11k_ahb_setbit32(struct ath11k_base *ab, u8 bit, u32 offset)
+{
+ u32 val;
+
+ val = ath11k_ahb_read32(ab, offset);
+ ath11k_ahb_write32(ab, offset, val | BIT(bit));
+}
+
+static void ath11k_ahb_clearbit32(struct ath11k_base *ab, u8 bit, u32 offset)
+{
+ u32 val;
+
+ val = ath11k_ahb_read32(ab, offset);
+ ath11k_ahb_write32(ab, offset, val & ~BIT(bit));
+}
+
static void ath11k_ahb_ce_irq_enable(struct ath11k_base *ab, u16 ce_id)
{
const struct ce_pipe_config *ce_config;
- u32 val;
ce_config = &target_ce_config_wlan[ce_id];
- if (__le32_to_cpu(ce_config->pipedir) & PIPEDIR_OUT) {
- val = ath11k_ahb_read32(ab, CE_HOST_IE_ADDRESS);
- val |= BIT(ce_id);
- ath11k_ahb_write32(ab, CE_HOST_IE_ADDRESS, val);
- }
+ if (__le32_to_cpu(ce_config->pipedir) & PIPEDIR_OUT)
+ ath11k_ahb_setbit32(ab, ce_id, CE_HOST_IE_ADDRESS);
if (__le32_to_cpu(ce_config->pipedir) & PIPEDIR_IN) {
- val = ath11k_ahb_read32(ab, CE_HOST_IE_2_ADDRESS);
- val |= BIT(ce_id);
- ath11k_ahb_write32(ab, CE_HOST_IE_2_ADDRESS, val);
-
- val = ath11k_ahb_read32(ab, CE_HOST_IE_3_ADDRESS);
- val |= BIT(ce_id + CE_HOST_IE_3_SHIFT);
- ath11k_ahb_write32(ab, CE_HOST_IE_3_ADDRESS, val);
+ ath11k_ahb_setbit32(ab, ce_id, CE_HOST_IE_2_ADDRESS);
+ ath11k_ahb_setbit32(ab, ce_id + CE_HOST_IE_3_SHIFT,
+ CE_HOST_IE_3_ADDRESS);
}
}
static void ath11k_ahb_ce_irq_disable(struct ath11k_base *ab, u16 ce_id)
{
const struct ce_pipe_config *ce_config;
- u32 val;
ce_config = &target_ce_config_wlan[ce_id];
- if (__le32_to_cpu(ce_config->pipedir) & PIPEDIR_OUT) {
- val = ath11k_ahb_read32(ab, CE_HOST_IE_ADDRESS);
- val &= ~BIT(ce_id);
- ath11k_ahb_write32(ab, CE_HOST_IE_ADDRESS, val);
- }
+ if (__le32_to_cpu(ce_config->pipedir) & PIPEDIR_OUT)
+ ath11k_ahb_clearbit32(ab, ce_id, CE_HOST_IE_ADDRESS);
if (__le32_to_cpu(ce_config->pipedir) & PIPEDIR_IN) {
- val = ath11k_ahb_read32(ab, CE_HOST_IE_2_ADDRESS);
- val &= ~BIT(ce_id);
- ath11k_ahb_write32(ab, CE_HOST_IE_2_ADDRESS, val);
-
- val = ath11k_ahb_read32(ab, CE_HOST_IE_3_ADDRESS);
- val &= ~BIT(ce_id + CE_HOST_IE_3_SHIFT);
- ath11k_ahb_write32(ab, CE_HOST_IE_3_ADDRESS, val);
+ ath11k_ahb_clearbit32(ab, ce_id, CE_HOST_IE_2_ADDRESS);
+ ath11k_ahb_clearbit32(ab, ce_id + CE_HOST_IE_3_SHIFT,
+ CE_HOST_IE_3_ADDRESS);
}
}
--
1.9.1
_______________________________________________
ath11k mailing list
ath11k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath11k
next prev parent reply other threads:[~2019-09-25 4:47 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-25 4:43 [PATCH bringup 1/5] ath11k: Use C99 structure initialization for target_service_to_ce_map_wlan[] Vasanthakumar Thiagarajan
2019-09-25 4:43 ` [PATCH bringup 2/5] ath11k: Remove ring mask macros defined for 0 Vasanthakumar Thiagarajan
2019-09-25 4:43 ` [PATCH bringup 3/5] ath11k: Move ath11k_ahb_read32() and ath11k_ahb_write32() to ahb.h Vasanthakumar Thiagarajan
2019-09-25 4:43 ` Vasanthakumar Thiagarajan [this message]
2019-09-25 4:43 ` [PATCH bringup 5/5] ath11k: Few clean ups in comments Vasanthakumar Thiagarajan
2019-09-27 14:48 ` [PATCH bringup 1/5] ath11k: Use C99 structure initialization for target_service_to_ce_map_wlan[] Kalle Valo
2019-09-27 14:56 ` Kalle Valo
2019-09-27 15:05 ` Kalle Valo
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=1569386639-1242-4-git-send-email-vthiagar@codeaurora.org \
--to=vthiagar@codeaurora.org \
--cc=ath11k@lists.infradead.org \
/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