PCI/ASPM: Convert to use match_string() helper
PATCH 1/1 PCI/ASPM: Convert to use match_string() helper
The new helper returns index of the matching string in an array. We are going to use it here.
Signed-off-by Andy Shevchenko <[email protected]>
--- drivers/pci/pcie/aspm.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/pci/pcie/aspm.c +3 -5
@@ -1127,11 +1127,9 @@ static int pcie_aspm_set_policy(const char *val,if (aspm_disabled)return -EPERM ; -for (i =0 ; i <ARRAY_SIZE (policy_str); i++) -if (!strncmp (val, policy_str[i],strlen (policy_str[i]))) -break ; -if (i >=ARRAY_SIZE (policy_str)) -return -EINVAL ; + i =match_string (policy_str,ARRAY_SIZE (policy_str), val); +if (i <0 ) +return i;if (i == aspm_policy)return 0 ;
Signature · 1 line
2.17.0
Bjorn Helgaas
AppliedQuoted 4 lines · Andy Shevchenko
The new helper returns index of the matching string in an array. We are going to use it here.
Signed-off-by Andy Shevchenko <[email protected]>
Applied to pci/aspm for v4.19, thanks!
Quoted 26 lines
--- drivers/pci/pcie/aspm.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)drivers/pci/pcie/aspm.c +3
-5@@ -1127,11 +1127,9 @@ static int pcie_aspm_set_policy(const char *val,if (aspm_disabled)return -EPERM ; -for (i =0 ; i <ARRAY_SIZE (policy_str); i++) -if (!strncmp (val, policy_str[i],strlen (policy_str[i]))) -break ; -if (i >=ARRAY_SIZE (policy_str)) -return -EINVAL ; + i =match_string (policy_str,ARRAY_SIZE (policy_str), val); +if (i <0 ) +return i;if (i == aspm_policy)return 0 ;Signature · 1 line
2.17.0