[PATCH 05/33] cxgb4: use match_string() helper

From: Yisheng Xie
Date: Mon May 21 2018 - 07:19:43 EST


match_string() returns the index of an array for a matching string,
which can be used intead of open coded variant.

Cc: Ganesh Goudar <ganeshgr@xxxxxxxxxxx>
Cc: netdev@xxxxxxxxxxxxxxx
Signed-off-by: Yisheng Xie <xieyisheng1@xxxxxxxxxx>
---
drivers/net/ethernet/chelsio/cxgb4/cudbg_lib.c | 14 ++++----------
1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cudbg_lib.c b/drivers/net/ethernet/chelsio/cxgb4/cudbg_lib.c
index 9da6f57..bd61610 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cudbg_lib.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cudbg_lib.c
@@ -782,17 +782,11 @@ static int cudbg_get_mem_region(struct adapter *padap,
if (rc)
return rc;

- for (i = 0; i < ARRAY_SIZE(cudbg_region); i++) {
- if (!strcmp(cudbg_region[i], region_name)) {
- found = 1;
- idx = i;
- break;
- }
- }
- if (!found)
- return -EINVAL;
+ rc = match_string(cudbg_region, ARRAY_SIZE(cudbg_region), region_name);
+ if (rc < 0)
+ return rc;

- found = 0;
+ idx = rc;
for (i = 0; i < meminfo->mem_c; i++) {
if (meminfo->mem[i].idx >= ARRAY_SIZE(cudbg_region))
continue; /* Skip holes */
--
1.7.12.4