* [PATCH v2 04/21] cxgb4: use match_string() helper
[not found] <1527765086-19873-1-git-send-email-xieyisheng1@huawei.com>
@ 2018-05-31 11:11 ` Yisheng Xie
2018-06-05 13:19 ` Andy Shevchenko
2018-05-31 11:11 ` [PATCH v2 05/21] hp100: " Yisheng Xie
2018-05-31 11:11 ` [PATCH v2 06/21] iwlwifi: mvm: " Yisheng Xie
2 siblings, 1 reply; 5+ messages in thread
From: Yisheng Xie @ 2018-05-31 11:11 UTC (permalink / raw)
To: linux-kernel; +Cc: andy.shevchenko, Yisheng Xie, Ganesh Goudar, netdev
match_string() returns the index of an array for a matching string,
which can be used instead of open coded variant.
Cc: Ganesh Goudar <ganeshgr@chelsio.com>
Cc: netdev@vger.kernel.org
Signed-off-by: Yisheng Xie <xieyisheng1@huawei.com>
---
v2:
- no change from v1.
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
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v2 05/21] hp100: use match_string() helper
[not found] <1527765086-19873-1-git-send-email-xieyisheng1@huawei.com>
2018-05-31 11:11 ` [PATCH v2 04/21] cxgb4: use match_string() helper Yisheng Xie
@ 2018-05-31 11:11 ` Yisheng Xie
2018-05-31 11:11 ` [PATCH v2 06/21] iwlwifi: mvm: " Yisheng Xie
2 siblings, 0 replies; 5+ messages in thread
From: Yisheng Xie @ 2018-05-31 11:11 UTC (permalink / raw)
To: linux-kernel; +Cc: andy.shevchenko, Yisheng Xie, Jaroslav Kysela, netdev
match_string() returns the index of an array for a matching string,
which can be used instead of open coded variant.
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Jaroslav Kysela <perex@perex.cz>
Cc: netdev@vger.kernel.org
Signed-off-by: Yisheng Xie <xieyisheng1@huawei.com>
---
v2:
- add Reviewed-by tag.
drivers/net/ethernet/hp/hp100.c | 9 +--------
1 file changed, 1 insertion(+), 8 deletions(-)
diff --git a/drivers/net/ethernet/hp/hp100.c b/drivers/net/ethernet/hp/hp100.c
index c8c7ad2..84501b3 100644
--- a/drivers/net/ethernet/hp/hp100.c
+++ b/drivers/net/ethernet/hp/hp100.c
@@ -335,7 +335,6 @@ static const char *hp100_read_id(int ioaddr)
static __init int hp100_isa_probe1(struct net_device *dev, int ioaddr)
{
const char *sig;
- int i;
if (!request_region(ioaddr, HP100_REGION_SIZE, "hp100"))
goto err;
@@ -351,13 +350,7 @@ static __init int hp100_isa_probe1(struct net_device *dev, int ioaddr)
if (sig == NULL)
goto err;
- for (i = 0; i < ARRAY_SIZE(hp100_isa_tbl); i++) {
- if (!strcmp(hp100_isa_tbl[i], sig))
- break;
-
- }
-
- if (i < ARRAY_SIZE(hp100_isa_tbl))
+ if (match_string(hp100_isa_tbl, ARRAY_SIZE(hp100_isa_tbl), sig) >= 0)
return hp100_probe1(dev, ioaddr, HP100_BUS_ISA, NULL);
err:
return -ENODEV;
--
1.7.12.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v2 06/21] iwlwifi: mvm: use match_string() helper
[not found] <1527765086-19873-1-git-send-email-xieyisheng1@huawei.com>
2018-05-31 11:11 ` [PATCH v2 04/21] cxgb4: use match_string() helper Yisheng Xie
2018-05-31 11:11 ` [PATCH v2 05/21] hp100: " Yisheng Xie
@ 2018-05-31 11:11 ` Yisheng Xie
2018-06-05 13:19 ` Andy Shevchenko
2 siblings, 1 reply; 5+ messages in thread
From: Yisheng Xie @ 2018-05-31 11:11 UTC (permalink / raw)
To: linux-kernel
Cc: andy.shevchenko, Yisheng Xie, Kalle Valo, Intel Linux Wireless,
Johannes Berg, Emmanuel Grumbach, linux-wireless, netdev
match_string() returns the index of an array for a matching string,
which can be used instead of open coded variant.
Cc: Kalle Valo <kvalo@codeaurora.org>
Cc: Intel Linux Wireless <linuxwifi@intel.com>
Cc: Johannes Berg <johannes.berg@intel.com>
Cc: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Cc: linux-wireless@vger.kernel.org
Cc: netdev@vger.kernel.org
Signed-off-by: Yisheng Xie <xieyisheng1@huawei.com>
---
v2:
- let ret get return value of match_string - per Andy
drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c b/drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c
index 0e6401c..d7ac511 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c
@@ -671,16 +671,11 @@ static ssize_t iwl_dbgfs_bt_cmd_read(struct file *file, char __user *user_buf,
};
int ret, bt_force_ant_mode;
- for (bt_force_ant_mode = 0;
- bt_force_ant_mode < ARRAY_SIZE(modes_str);
- bt_force_ant_mode++) {
- if (!strcmp(buf, modes_str[bt_force_ant_mode]))
- break;
- }
-
- if (bt_force_ant_mode >= ARRAY_SIZE(modes_str))
- return -EINVAL;
+ ret = match_string(modes_str, ARRAY_SIZE(modes_str), buf);
+ if (ret < 0)
+ return ret;
+ bt_force_ant_mode = ret;
ret = 0;
mutex_lock(&mvm->mutex);
if (mvm->bt_force_ant_mode == bt_force_ant_mode)
--
1.7.12.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2 06/21] iwlwifi: mvm: use match_string() helper
2018-05-31 11:11 ` [PATCH v2 06/21] iwlwifi: mvm: " Yisheng Xie
@ 2018-06-05 13:19 ` Andy Shevchenko
0 siblings, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2018-06-05 13:19 UTC (permalink / raw)
To: Yisheng Xie
Cc: Linux Kernel Mailing List, Kalle Valo, Intel Linux Wireless,
Johannes Berg, Emmanuel Grumbach, open list:TI WILINK WIRELES...,
netdev
On Thu, May 31, 2018 at 2:11 PM, Yisheng Xie <xieyisheng1@huawei.com> wrote:
> match_string() returns the index of an array for a matching string,
> which can be used instead of open coded variant.
>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
> Cc: Kalle Valo <kvalo@codeaurora.org>
> Cc: Intel Linux Wireless <linuxwifi@intel.com>
> Cc: Johannes Berg <johannes.berg@intel.com>
> Cc: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
> Cc: linux-wireless@vger.kernel.org
> Cc: netdev@vger.kernel.org
> Signed-off-by: Yisheng Xie <xieyisheng1@huawei.com>
> ---
> v2:
> - let ret get return value of match_string - per Andy
>
> drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c | 13 ++++---------
> 1 file changed, 4 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c b/drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c
> index 0e6401c..d7ac511 100644
> --- a/drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c
> +++ b/drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c
> @@ -671,16 +671,11 @@ static ssize_t iwl_dbgfs_bt_cmd_read(struct file *file, char __user *user_buf,
> };
> int ret, bt_force_ant_mode;
>
> - for (bt_force_ant_mode = 0;
> - bt_force_ant_mode < ARRAY_SIZE(modes_str);
> - bt_force_ant_mode++) {
> - if (!strcmp(buf, modes_str[bt_force_ant_mode]))
> - break;
> - }
> -
> - if (bt_force_ant_mode >= ARRAY_SIZE(modes_str))
> - return -EINVAL;
> + ret = match_string(modes_str, ARRAY_SIZE(modes_str), buf);
> + if (ret < 0)
> + return ret;
>
> + bt_force_ant_mode = ret;
> ret = 0;
> mutex_lock(&mvm->mutex);
> if (mvm->bt_force_ant_mode == bt_force_ant_mode)
> --
> 1.7.12.4
>
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2 04/21] cxgb4: use match_string() helper
2018-05-31 11:11 ` [PATCH v2 04/21] cxgb4: use match_string() helper Yisheng Xie
@ 2018-06-05 13:19 ` Andy Shevchenko
0 siblings, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2018-06-05 13:19 UTC (permalink / raw)
To: Yisheng Xie; +Cc: Linux Kernel Mailing List, Ganesh Goudar, netdev
On Thu, May 31, 2018 at 2:11 PM, Yisheng Xie <xieyisheng1@huawei.com> wrote:
> match_string() returns the index of an array for a matching string,
> which can be used instead of open coded variant.
>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
> Cc: Ganesh Goudar <ganeshgr@chelsio.com>
> Cc: netdev@vger.kernel.org
> Signed-off-by: Yisheng Xie <xieyisheng1@huawei.com>
> ---
> v2:
> - no change from v1.
>
> 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
>
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2018-06-05 13:19 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <1527765086-19873-1-git-send-email-xieyisheng1@huawei.com>
2018-05-31 11:11 ` [PATCH v2 04/21] cxgb4: use match_string() helper Yisheng Xie
2018-06-05 13:19 ` Andy Shevchenko
2018-05-31 11:11 ` [PATCH v2 05/21] hp100: " Yisheng Xie
2018-05-31 11:11 ` [PATCH v2 06/21] iwlwifi: mvm: " Yisheng Xie
2018-06-05 13:19 ` Andy Shevchenko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).