summaryrefslogtreecommitdiff
path: root/drivers/net/ipa/ipa_reg.h
diff options
context:
space:
mode:
authorAlex Elder <elder@linaro.org>2022-09-27 01:09:21 +0300
committerJakub Kicinski <kuba@kernel.org>2022-09-28 04:42:50 +0300
commit6a244b75cfab95ddd505fc9a80af76bf36071784 (patch)
tree3f036c90ca167cf8de45250aedb139d19f58f121 /drivers/net/ipa/ipa_reg.h
parent82a06807453a6c0c282b3238f28164970100ffcd (diff)
downloadlinux-6a244b75cfab95ddd505fc9a80af76bf36071784.tar.xz
net: ipa: introduce ipa_reg()
Create a new function that returns a register descriptor given its ID. Change ipa_reg_offset() and ipa_reg_n_offset() so they take a register descriptor argument rather than an IPA pointer and register ID. Have them accept null pointers (and return an invalid 0 offset), to avoid the need for excessive error checking. (A warning is issued whenever ipa_reg() returns 0). Call ipa_reg() or ipa_reg_n() to look up information about the register before calls to ipa_reg_offset() and ipa_reg_n_offset(). Delay looking up offsets until they're needed to read or write registers. Signed-off-by: Alex Elder <elder@linaro.org> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'drivers/net/ipa/ipa_reg.h')
-rw-r--r--drivers/net/ipa/ipa_reg.h13
1 files changed, 6 insertions, 7 deletions
diff --git a/drivers/net/ipa/ipa_reg.h b/drivers/net/ipa/ipa_reg.h
index 94c0e9f15e97..49eec53a375e 100644
--- a/drivers/net/ipa/ipa_reg.h
+++ b/drivers/net/ipa/ipa_reg.h
@@ -746,19 +746,18 @@ extern const struct ipa_regs ipa_regs_v4_5;
extern const struct ipa_regs ipa_regs_v4_9;
extern const struct ipa_regs ipa_regs_v4_11;
-u32 __ipa_reg_offset(struct ipa *ipa, enum ipa_reg_id reg_id, u32 n);
-
const struct ipa_reg *ipa_reg(struct ipa *ipa, enum ipa_reg_id reg_id);
-static inline u32 ipa_reg_offset(struct ipa *ipa, enum ipa_reg_id reg_id)
+/* Returns 0 for NULL reg; warning will have already been issued */
+static inline u32 ipa_reg_offset(const struct ipa_reg *reg)
{
- return __ipa_reg_offset(ipa, reg_id, 0);
+ return reg ? reg->offset : 0;
}
-static inline u32
-ipa_reg_n_offset(struct ipa *ipa, enum ipa_reg_id reg_id, u32 n)
+/* Returns 0 for NULL reg; warning will have already been issued */
+static inline u32 ipa_reg_n_offset(const struct ipa_reg *reg, u32 n)
{
- return __ipa_reg_offset(ipa, reg_id, n);
+ return reg ? reg->offset + n * reg->stride : 0;
}
int ipa_reg_init(struct ipa *ipa);