linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1] PCI/ASPM: Convert to use match_string() helper
@ 2018-05-29 13:32 Andy Shevchenko
  2018-06-30  1:56 ` Bjorn Helgaas
  0 siblings, 1 reply; 2+ messages in thread
From: Andy Shevchenko @ 2018-05-29 13:32 UTC (permalink / raw)
  To: Bjorn Helgaas, linux-pci; +Cc: 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 <andriy.shevchenko@linux.intel.com>
---
 drivers/pci/pcie/aspm.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
index c687c817b47d..0e88b3ad065f 100644
--- a/drivers/pci/pcie/aspm.c
+++ b/drivers/pci/pcie/aspm.c
@@ -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;
 
-- 
2.17.0

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v1] PCI/ASPM: Convert to use match_string() helper
  2018-05-29 13:32 [PATCH v1] PCI/ASPM: Convert to use match_string() helper Andy Shevchenko
@ 2018-06-30  1:56 ` Bjorn Helgaas
  0 siblings, 0 replies; 2+ messages in thread
From: Bjorn Helgaas @ 2018-06-30  1:56 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: Bjorn Helgaas, linux-pci

On Tue, May 29, 2018 at 04:32:47PM +0300, Andy Shevchenko wrote:
> The new helper returns index of the matching string in an array.
> We are going to use it here.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Applied to pci/aspm for v4.19, thanks!

> ---
>  drivers/pci/pcie/aspm.c | 8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
> index c687c817b47d..0e88b3ad065f 100644
> --- a/drivers/pci/pcie/aspm.c
> +++ b/drivers/pci/pcie/aspm.c
> @@ -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;
>  
> -- 
> 2.17.0
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-06-30  1:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-05-29 13:32 [PATCH v1] PCI/ASPM: Convert to use match_string() helper Andy Shevchenko
2018-06-30  1:56 ` Bjorn Helgaas

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).