2018-05-31 11:22:41

by Yisheng Xie

[permalink] [raw]
Subject: [PATCH v2 06/21] iwlwifi: mvm: use match_string() helper

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

Cc: Kalle Valo <[email protected]>
Cc: Intel Linux Wireless <[email protected]>
Cc: Johannes Berg <[email protected]>
Cc: Emmanuel Grumbach <[email protected]>
Cc: [email protected]
Cc: [email protected]
Signed-off-by: Yisheng Xie <[email protected]>
---
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


2018-06-05 13:19:21

by Andy Shevchenko

[permalink] [raw]
Subject: Re: [PATCH v2 06/21] iwlwifi: mvm: use match_string() helper

On Thu, May 31, 2018 at 2:11 PM, Yisheng Xie <[email protected]> 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 <[email protected]>

> Cc: Kalle Valo <[email protected]>
> Cc: Intel Linux Wireless <[email protected]>
> Cc: Johannes Berg <[email protected]>
> Cc: Emmanuel Grumbach <[email protected]>
> Cc: [email protected]
> Cc: [email protected]
> Signed-off-by: Yisheng Xie <[email protected]>
> ---
> 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