diff options
author | Alex Elder <elder@linaro.org> | 2022-09-27 01:09:21 +0300 |
---|---|---|
committer | Jakub Kicinski <kuba@kernel.org> | 2022-09-28 04:42:50 +0300 |
commit | 6a244b75cfab95ddd505fc9a80af76bf36071784 (patch) | |
tree | 3f036c90ca167cf8de45250aedb139d19f58f121 /drivers/net/ipa/ipa_resource.c | |
parent | 82a06807453a6c0c282b3238f28164970100ffcd (diff) | |
download | linux-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_resource.c')
-rw-r--r-- | drivers/net/ipa/ipa_resource.c | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/drivers/net/ipa/ipa_resource.c b/drivers/net/ipa/ipa_resource.c index 3d8eb8df1f83..bda2f87ca6dc 100644 --- a/drivers/net/ipa/ipa_resource.c +++ b/drivers/net/ipa/ipa_resource.c @@ -91,36 +91,37 @@ static void ipa_resource_config_src(struct ipa *ipa, u32 resource_type, u32 group_count = data->rsrc_group_src_count; const struct ipa_resource_limits *ylimits; const struct ipa_resource *resource; + const struct ipa_reg *reg; u32 offset; resource = &data->resource_src[resource_type]; - offset = ipa_reg_n_offset(ipa, SRC_RSRC_GRP_01_RSRC_TYPE, - resource_type); + reg = ipa_reg(ipa, SRC_RSRC_GRP_01_RSRC_TYPE); + offset = ipa_reg_n_offset(reg, resource_type); ylimits = group_count == 1 ? NULL : &resource->limits[1]; ipa_resource_config_common(ipa, offset, &resource->limits[0], ylimits); if (group_count < 3) return; - offset = ipa_reg_n_offset(ipa, SRC_RSRC_GRP_23_RSRC_TYPE, - resource_type); + reg = ipa_reg(ipa, SRC_RSRC_GRP_23_RSRC_TYPE); + offset = ipa_reg_n_offset(reg, resource_type); ylimits = group_count == 3 ? NULL : &resource->limits[3]; ipa_resource_config_common(ipa, offset, &resource->limits[2], ylimits); if (group_count < 5) return; - offset = ipa_reg_n_offset(ipa, SRC_RSRC_GRP_45_RSRC_TYPE, - resource_type); + reg = ipa_reg(ipa, SRC_RSRC_GRP_45_RSRC_TYPE); + offset = ipa_reg_n_offset(reg, resource_type); ylimits = group_count == 5 ? NULL : &resource->limits[5]; ipa_resource_config_common(ipa, offset, &resource->limits[4], ylimits); if (group_count < 7) return; - offset = ipa_reg_n_offset(ipa, SRC_RSRC_GRP_67_RSRC_TYPE, - resource_type); + reg = ipa_reg(ipa, SRC_RSRC_GRP_67_RSRC_TYPE); + offset = ipa_reg_n_offset(reg, resource_type); ylimits = group_count == 7 ? NULL : &resource->limits[7]; ipa_resource_config_common(ipa, offset, &resource->limits[6], ylimits); } @@ -131,36 +132,37 @@ static void ipa_resource_config_dst(struct ipa *ipa, u32 resource_type, u32 group_count = data->rsrc_group_dst_count; const struct ipa_resource_limits *ylimits; const struct ipa_resource *resource; + const struct ipa_reg *reg; u32 offset; resource = &data->resource_dst[resource_type]; - offset = ipa_reg_n_offset(ipa, DST_RSRC_GRP_01_RSRC_TYPE, - resource_type); + reg = ipa_reg(ipa, DST_RSRC_GRP_01_RSRC_TYPE); + offset = ipa_reg_n_offset(reg, resource_type); ylimits = group_count == 1 ? NULL : &resource->limits[1]; ipa_resource_config_common(ipa, offset, &resource->limits[0], ylimits); if (group_count < 3) return; - offset = ipa_reg_n_offset(ipa, DST_RSRC_GRP_23_RSRC_TYPE, - resource_type); + reg = ipa_reg(ipa, DST_RSRC_GRP_23_RSRC_TYPE); + offset = ipa_reg_n_offset(reg, resource_type); ylimits = group_count == 3 ? NULL : &resource->limits[3]; ipa_resource_config_common(ipa, offset, &resource->limits[2], ylimits); if (group_count < 5) return; - offset = ipa_reg_n_offset(ipa, DST_RSRC_GRP_45_RSRC_TYPE, - resource_type); + reg = ipa_reg(ipa, DST_RSRC_GRP_45_RSRC_TYPE); + offset = ipa_reg_n_offset(reg, resource_type); ylimits = group_count == 5 ? NULL : &resource->limits[5]; ipa_resource_config_common(ipa, offset, &resource->limits[4], ylimits); if (group_count < 7) return; - offset = ipa_reg_n_offset(ipa, DST_RSRC_GRP_67_RSRC_TYPE, - resource_type); + reg = ipa_reg(ipa, DST_RSRC_GRP_67_RSRC_TYPE); + offset = ipa_reg_n_offset(reg, resource_type); ylimits = group_count == 7 ? NULL : &resource->limits[7]; ipa_resource_config_common(ipa, offset, &resource->limits[6], ylimits); } |