linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Borislav Petkov <bp@alien8.de>
To: Toshi Kani <toshi.kani@hpe.com>
Cc: rjw@rjwysocki.net, mchehab@kernel.org, tony.luck@intel.com,
	lenb@kernel.org, linux-acpi@vger.kernel.org,
	linux-edac@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4 1/5] ACPI / blacklist: add acpi_match_platform_list()
Date: Thu, 24 Aug 2017 09:53:48 +0200	[thread overview]
Message-ID: <20170824075348.gqvobmk7mf5ppaip@pd.tnic> (raw)
In-Reply-To: <20170823225447.15608-2-toshi.kani@hpe.com>

On Wed, Aug 23, 2017 at 04:54:43PM -0600, Toshi Kani wrote:
> ACPI OEM ID / OEM Table ID / Revision can be used to identify
> a platform based on ACPI firmware info.  acpi_blacklisted(),
> intel_pstate_platform_pwr_mgmt_exists(), and some other funcs,
> have been using similar check to detect a list of platforms
> that require special handlings.
> 
> Move the platform check in acpi_blacklisted() to a new common
> utility function, acpi_match_platform_list(), so that other
> drivers do not have to implement their own version.
> 
> There is no change in functionality.
> 
> Signed-off-by: Toshi Kani <toshi.kani@hpe.com>
> Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
> Cc: Borislav Petkov <bp@alien8.de>
> ---
>  drivers/acpi/blacklist.c |   83 ++++++++--------------------------------------
>  drivers/acpi/utils.c     |   36 ++++++++++++++++++++
>  include/linux/acpi.h     |   19 +++++++++++
>  3 files changed, 69 insertions(+), 69 deletions(-)

...

> diff --git a/drivers/acpi/utils.c b/drivers/acpi/utils.c
> index b9d956c..0a9e597 100644
> --- a/drivers/acpi/utils.c
> +++ b/drivers/acpi/utils.c
> @@ -816,3 +816,39 @@ static int __init acpi_backlight(char *str)
>  	return 1;
>  }
>  __setup("acpi_backlight=", acpi_backlight);
> +
> +/**
> + * acpi_match_platform_list - Check if the system matches with a given list
> + * @plat: pointer to acpi_platform_list table terminated by a NULL entry
> + *
> + * Return the matched index if the system is found in the platform list.
> + * Otherwise, return a negative error code.
> + */
> +int acpi_match_platform_list(const struct acpi_platform_list *plat)
> +{
> +	struct acpi_table_header hdr;
> +	int idx = 0;
> +
> +	if (acpi_disabled)
> +		return -ENODEV;
> +
> +	for (; plat->oem_id[0]; plat++, idx++) {
> +		if (ACPI_FAILURE(acpi_get_table_header(plat->table, 0, &hdr)))
> +			continue;
> +
> +		if (strncmp(plat->oem_id, hdr.oem_id, ACPI_OEM_ID_SIZE))
> +			continue;
> +
> +		if (strncmp(plat->oem_table_id, hdr.oem_table_id, ACPI_OEM_TABLE_ID_SIZE))
> +			continue;
> +
> +		if ((plat->pred == all_versions) ||
> +		    (plat->pred == less_than_or_equal && hdr.oem_revision <= plat->oem_revision) ||
> +		    (plat->pred == greater_than_or_equal && hdr.oem_revision >= plat->oem_revision) ||
> +		    (plat->pred == equal && hdr.oem_revision == plat->oem_revision))

If you align the second part of the test like this:

             if ((plat->pred == all_versions) ||
                 (plat->pred == less_than_or_equal	&& hdr.oem_revision <= plat->oem_revision) ||
                 (plat->pred == greater_than_or_equal	&& hdr.oem_revision >= plat->oem_revision) ||
                 (plat->pred == equal			&& hdr.oem_revision == plat->oem_revision))

it gets maximally readable. But I'd leave that up to Rafael when committing
- no need to send another version.

Other than that:

Reviewed-by: Borislav Petkov <bp@suse.de>

-- 
Regards/Gruss,
    Boris.

Good mailing practices for 400: avoid top-posting and trim the reply.

  reply	other threads:[~2017-08-24  7:53 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-23 22:54 [PATCH v4 0/5] enable ghes_edac on selected platforms Toshi Kani
2017-08-23 22:54 ` [PATCH v4 1/5] ACPI / blacklist: add acpi_match_platform_list() Toshi Kani
2017-08-24  7:53   ` Borislav Petkov [this message]
2017-08-28 20:55     ` Rafael J. Wysocki
2017-08-28 21:21       ` Borislav Petkov
2017-08-28 21:19         ` Rafael J. Wysocki
2017-08-23 22:54 ` [PATCH v4 2/5] intel_pstate: convert to use acpi_match_platform_list() Toshi Kani
2017-08-23 22:54 ` [PATCH v4 3/5] ghes_edac: add platform check to enable ghes_edac Toshi Kani
2017-08-31 10:56   ` Borislav Petkov
2017-08-31 16:17     ` Kani, Toshimitsu
2017-08-31 16:52       ` Borislav Petkov
2017-08-23 22:54 ` [PATCH v4 4/5] EDAC: add edac_get_owner() to check MC owner Toshi Kani
2017-08-23 22:54 ` [PATCH v4 5/5] edac drivers: add MC owner check in init Toshi Kani
2017-09-01  9:31   ` Borislav Petkov

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=20170824075348.gqvobmk7mf5ppaip@pd.tnic \
    --to=bp@alien8.de \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-edac@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=rjw@rjwysocki.net \
    --cc=tony.luck@intel.com \
    --cc=toshi.kani@hpe.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 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).