All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bjorn Helgaas <helgaas@kernel.org>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Russell Currey <ruscur@russell.cc>,
	Sam Bobroff <sbobroff@linux.ibm.com>,
	Oliver O'Halloran <oohall@gmail.com>,
	linuxppc-dev@lists.ozlabs.org, linux-pci@vger.kernel.org
Subject: Re: [PATCH v1] PCI/AER: use match_string() helper to simplify the code
Date: Tue, 29 Jan 2019 16:37:35 -0600	[thread overview]
Message-ID: <20190129223735.GD91506@google.com> (raw)
In-Reply-To: <20190128115728.68240-1-andriy.shevchenko@linux.intel.com>

On Mon, Jan 28, 2019 at 01:57:28PM +0200, Andy Shevchenko wrote:
> match_string() returns the index of an array for a matching string,
> which can be used intead of open coded implementation.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Applied to pci/aer for v5.1, thanks!

> ---
>  drivers/pci/pcie/aer.c | 9 +++------
>  1 file changed, 3 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c
> index fed29de783e0..f8fc2114ad39 100644
> --- a/drivers/pci/pcie/aer.c
> +++ b/drivers/pci/pcie/aer.c
> @@ -117,7 +117,7 @@ bool pci_aer_available(void)
>  
>  static int ecrc_policy = ECRC_POLICY_DEFAULT;
>  
> -static const char *ecrc_policy_str[] = {
> +static const char * const ecrc_policy_str[] = {
>  	[ECRC_POLICY_DEFAULT] = "bios",
>  	[ECRC_POLICY_OFF] = "off",
>  	[ECRC_POLICY_ON] = "on"
> @@ -203,11 +203,8 @@ void pcie_ecrc_get_policy(char *str)
>  {
>  	int i;
>  
> -	for (i = 0; i < ARRAY_SIZE(ecrc_policy_str); i++)
> -		if (!strncmp(str, ecrc_policy_str[i],
> -			     strlen(ecrc_policy_str[i])))
> -			break;
> -	if (i >= ARRAY_SIZE(ecrc_policy_str))
> +	i = match_string(ecrc_policy_str, ARRAY_SIZE(ecrc_policy_str), str);
> +	if (i < 0)
>  		return;
>  
>  	ecrc_policy = i;
> -- 
> 2.20.1
> 

WARNING: multiple messages have this Message-ID (diff)
From: Bjorn Helgaas <helgaas@kernel.org>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Sam Bobroff <sbobroff@linux.ibm.com>,
	linuxppc-dev@lists.ozlabs.org,
	Oliver O'Halloran <oohall@gmail.com>,
	linux-pci@vger.kernel.org
Subject: Re: [PATCH v1] PCI/AER: use match_string() helper to simplify the code
Date: Tue, 29 Jan 2019 16:37:35 -0600	[thread overview]
Message-ID: <20190129223735.GD91506@google.com> (raw)
In-Reply-To: <20190128115728.68240-1-andriy.shevchenko@linux.intel.com>

On Mon, Jan 28, 2019 at 01:57:28PM +0200, Andy Shevchenko wrote:
> match_string() returns the index of an array for a matching string,
> which can be used intead of open coded implementation.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Applied to pci/aer for v5.1, thanks!

> ---
>  drivers/pci/pcie/aer.c | 9 +++------
>  1 file changed, 3 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c
> index fed29de783e0..f8fc2114ad39 100644
> --- a/drivers/pci/pcie/aer.c
> +++ b/drivers/pci/pcie/aer.c
> @@ -117,7 +117,7 @@ bool pci_aer_available(void)
>  
>  static int ecrc_policy = ECRC_POLICY_DEFAULT;
>  
> -static const char *ecrc_policy_str[] = {
> +static const char * const ecrc_policy_str[] = {
>  	[ECRC_POLICY_DEFAULT] = "bios",
>  	[ECRC_POLICY_OFF] = "off",
>  	[ECRC_POLICY_ON] = "on"
> @@ -203,11 +203,8 @@ void pcie_ecrc_get_policy(char *str)
>  {
>  	int i;
>  
> -	for (i = 0; i < ARRAY_SIZE(ecrc_policy_str); i++)
> -		if (!strncmp(str, ecrc_policy_str[i],
> -			     strlen(ecrc_policy_str[i])))
> -			break;
> -	if (i >= ARRAY_SIZE(ecrc_policy_str))
> +	i = match_string(ecrc_policy_str, ARRAY_SIZE(ecrc_policy_str), str);
> +	if (i < 0)
>  		return;
>  
>  	ecrc_policy = i;
> -- 
> 2.20.1
> 

  reply	other threads:[~2019-01-29 22:37 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-28 11:57 [PATCH v1] PCI/AER: use match_string() helper to simplify the code Andy Shevchenko
2019-01-29 22:37 ` Bjorn Helgaas [this message]
2019-01-29 22:37   ` Bjorn Helgaas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190129223735.GD91506@google.com \
    --to=helgaas@kernel.org \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=linux-pci@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=oohall@gmail.com \
    --cc=ruscur@russell.cc \
    --cc=sbobroff@linux.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.