From: Corey Minyard <minyard@acm.org>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Corey Minyard <cminyard@mvista.com>,
openipmi-developer@lists.sourceforge.net,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v1 06/10] ipmi_si: Reuse si_to_str array in ipmi_hardcode_init_one()
Date: Fri, 2 Apr 2021 08:53:49 -0500 [thread overview]
Message-ID: <20210402135349.GT507977@minyard.net> (raw)
In-Reply-To: <20210330181649.66496-6-andriy.shevchenko@linux.intel.com>
On Tue, Mar 30, 2021 at 09:16:45PM +0300, Andy Shevchenko wrote:
> Instead of making the comparison one by one, reuse si_to_str array
> in ipmi_hardcode_init_one() in conjunction with match_string() API.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
> drivers/char/ipmi/ipmi_si.h | 3 +++
> drivers/char/ipmi/ipmi_si_hardcode.c | 23 +++++++++--------------
> drivers/char/ipmi/ipmi_si_intf.c | 2 --
> 3 files changed, 12 insertions(+), 16 deletions(-)
>
> diff --git a/drivers/char/ipmi/ipmi_si.h b/drivers/char/ipmi/ipmi_si.h
> index bac0ff86e48e..fd3167d1e1e9 100644
> --- a/drivers/char/ipmi/ipmi_si.h
> +++ b/drivers/char/ipmi/ipmi_si.h
> @@ -22,6 +22,9 @@ enum si_type {
> SI_TYPE_INVALID, SI_KCS, SI_SMIC, SI_BT
> };
>
> +/* 'invalid' to allow a firmware-specified interface to be disabled */
> +static __maybe_unused const char *const si_to_str[] = { "invalid", "kcs", "smic", "bt" };
Can we just make this non-static and leave the definition where it is?
That would save a little space and wouldn't affect performance at all.
-corey
> +
> enum ipmi_addr_space {
> IPMI_IO_ADDR_SPACE, IPMI_MEM_ADDR_SPACE
> };
> diff --git a/drivers/char/ipmi/ipmi_si_hardcode.c b/drivers/char/ipmi/ipmi_si_hardcode.c
> index f6ece7569504..cf3797523469 100644
> --- a/drivers/char/ipmi/ipmi_si_hardcode.c
> +++ b/drivers/char/ipmi/ipmi_si_hardcode.c
> @@ -80,26 +80,21 @@ static void __init ipmi_hardcode_init_one(const char *si_type_str,
> enum ipmi_addr_space addr_space)
> {
> struct ipmi_plat_data p;
> + int t;
>
> memset(&p, 0, sizeof(p));
>
> p.iftype = IPMI_PLAT_IF_SI;
> - if (!si_type_str || !*si_type_str || strcmp(si_type_str, "kcs") == 0) {
> + if (!si_type_str || !*si_type_str) {
> p.type = SI_KCS;
> - } else if (strcmp(si_type_str, "smic") == 0) {
> - p.type = SI_SMIC;
> - } else if (strcmp(si_type_str, "bt") == 0) {
> - p.type = SI_BT;
> - } else if (strcmp(si_type_str, "invalid") == 0) {
> - /*
> - * Allow a firmware-specified interface to be
> - * disabled.
> - */
> - p.type = SI_TYPE_INVALID;
> } else {
> - pr_warn("Interface type specified for interface %d, was invalid: %s\n",
> - i, si_type_str);
> - return;
> + t = match_string(si_to_str, ARRAY_SIZE(si_to_str), si_type_str);
> + if (t < 0) {
> + pr_warn("Interface type specified for interface %d, was invalid: %s\n",
> + i, si_type_str);
> + return;
> + }
> + p.type = t;
> }
>
> p.regsize = regsizes[i];
> diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
> index be41a473e3c2..ff448098f185 100644
> --- a/drivers/char/ipmi/ipmi_si_intf.c
> +++ b/drivers/char/ipmi/ipmi_si_intf.c
> @@ -70,8 +70,6 @@ enum si_intf_state {
> #define IPMI_BT_INTMASK_CLEAR_IRQ_BIT 2
> #define IPMI_BT_INTMASK_ENABLE_IRQ_BIT 1
>
> -static const char * const si_to_str[] = { "invalid", "kcs", "smic", "bt" };
> -
> static bool initialized;
>
> /*
> --
> 2.30.2
>
next prev parent reply other threads:[~2021-04-02 13:53 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-30 18:16 [PATCH v1 01/10] ipmi_si: Switch to use platform_get_mem_or_io() Andy Shevchenko
2021-03-30 18:16 ` [PATCH v1 02/10] ipmi_si: Remove bogus err_free label Andy Shevchenko
2021-03-30 18:16 ` [PATCH v1 03/10] ipmi_si: Utilize temporary variable to hold device pointer Andy Shevchenko
2021-04-02 13:45 ` Corey Minyard
2021-03-30 18:16 ` [PATCH v1 04/10] ipmi_si: Use proper ACPI macros to check error code for failures Andy Shevchenko
2021-03-30 18:16 ` [PATCH v1 05/10] ipmi_si: Introduce panic_event_str array Andy Shevchenko
2021-04-02 13:48 ` Corey Minyard
2021-03-30 18:16 ` [PATCH v1 06/10] ipmi_si: Reuse si_to_str array in ipmi_hardcode_init_one() Andy Shevchenko
2021-04-02 13:53 ` Corey Minyard [this message]
2021-03-30 18:16 ` [PATCH v1 07/10] ipmi_si: Get rid of ->addr_source_cleanup() Andy Shevchenko
2021-03-30 18:16 ` [PATCH v1 08/10] ipmi_si: Use strstrip() to remove surrounding spaces Andy Shevchenko
2021-03-30 18:16 ` [PATCH v1 09/10] ipmi_si: Drop redundant check before calling put_device() Andy Shevchenko
2021-03-30 18:16 ` [PATCH v1 10/10] ipmi_si: Join string literals back Andy Shevchenko
2021-04-02 13:57 ` [PATCH v1 01/10] ipmi_si: Switch to use platform_get_mem_or_io() Corey Minyard
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=20210402135349.GT507977@minyard.net \
--to=minyard@acm.org \
--cc=andriy.shevchenko@linux.intel.com \
--cc=cminyard@mvista.com \
--cc=linux-kernel@vger.kernel.org \
--cc=openipmi-developer@lists.sourceforge.net \
/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.