diff options
author | Alex Elder <elder@linaro.org> | 2021-06-10 14:23:07 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2021-06-10 14:50:08 -0700 |
commit | 5e3bc1e5d0021c2efcbc8ba7da7b96c6a502d8bf (patch) | |
tree | 318480594466e478e5e245e8160906107ffa9751 /drivers/net/ipa/ipa_cmd.c | |
parent | e9f5b2766e706f3020b3d975fee3b42d056b0849 (diff) | |
download | lwn-5e3bc1e5d0021c2efcbc8ba7da7b96c6a502d8bf.tar.gz lwn-5e3bc1e5d0021c2efcbc8ba7da7b96c6a502d8bf.zip |
net: ipa: introduce ipa_mem_find()
Introduce a new function that abstracts finding information about a
region in IPA-local memory, given its memory region ID. For now it
simply uses the region ID as an index into the IPA memory array.
If the region is not defined, ipa_mem_find() returns a null pointer.
Update all code that accesses the ipa->mem[] array directly to use
ipa_mem_find() instead. The return value must be checked for null
when optional memory regions are sought.
Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ipa/ipa_cmd.c')
-rw-r--r-- | drivers/net/ipa/ipa_cmd.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/drivers/net/ipa/ipa_cmd.c b/drivers/net/ipa/ipa_cmd.c index 3e5f10d3c131..af44ca41189e 100644 --- a/drivers/net/ipa/ipa_cmd.c +++ b/drivers/net/ipa/ipa_cmd.c @@ -218,7 +218,7 @@ static bool ipa_cmd_header_valid(struct ipa *ipa) /* The header memory area contains both the modem and AP header * regions. The modem portion defines the address of the region. */ - mem = &ipa->mem[IPA_MEM_MODEM_HEADER]; + mem = ipa_mem_find(ipa, IPA_MEM_MODEM_HEADER); offset = mem->offset; size = mem->size; @@ -231,8 +231,10 @@ static bool ipa_cmd_header_valid(struct ipa *ipa) return false; } - /* Add the size of the AP portion to the combined size */ - size += ipa->mem[IPA_MEM_AP_HEADER].size; + /* Add the size of the AP portion (if defined) to the combined size */ + mem = ipa_mem_find(ipa, IPA_MEM_AP_HEADER); + if (mem) + size += mem->size; /* Make sure the combined size fits in the IPA command */ if (size > size_max) { |