linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mike Waychison <mikew@google.com>
To: Matthew Garrett <mjg59@srcf.ucam.org>
Cc: tony.luck@intel.com, linux-kernel@vger.kernel.org,
	Matt_Domsch@dell.com, Mike Waychison <mikew@google.com>
Subject: [PATCH 3/4] efivars: Use string functions in pstore_write
Date: Tue, 21 Jun 2011 13:18:31 -0700	[thread overview]
Message-ID: <1308687512-11649-3-git-send-email-mikew@google.com> (raw)
In-Reply-To: <BANLkTi=qmS090MK=sx=xMN95zD5AtNkuLG_g092oVXJezoRCYA@mail.gmail.com>

Instead of open-coding the string operations for comparing the prefix of
the variable names, use the provided utf16_* string functions.

This patch also changes the calls to efi.set_variable to
efivars->ops->set_variable so that the right function gets called in the
case of gsmi (which doesn't have a valid efi structure).

As well, make sure that we only consider variables with the right vendor
string.

Signed-off-by: Mike Waychison <mikew@google.com>
---
 drivers/firmware/efivars.c |   31 +++++++++++++++++--------------
 1 files changed, 17 insertions(+), 14 deletions(-)

diff --git a/drivers/firmware/efivars.c b/drivers/firmware/efivars.c
index fb1219a..f424b10 100644
--- a/drivers/firmware/efivars.c
+++ b/drivers/firmware/efivars.c
@@ -511,17 +511,20 @@ static u64 efi_pstore_write(enum pstore_type_id type, int part, size_t size,
 	list_for_each_entry(entry, &efivars->list, list) {
 		get_var_data_locked(efivars, &entry->var);
 
-		for (i = 0; i < DUMP_NAME_LEN; i++) {
-			if (efi_name[i] == 0) {
-				found = entry;
-				efi.set_variable(entry->var.VariableName, &entry->var.VendorGuid,
-						 EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
-						 0, NULL);
-				break;
-			} else if (efi_name[i] != entry->var.VariableName[i]) {
-				break;
-			}
-		}
+		if (efi_guidcmp(entry->var.VendorGuid, vendor))
+			continue;
+		if (utf16_strncmp(entry->var.VariableName, efi_name,
+				  utf16_strlen(efi_name)))
+			continue;
+		/* Needs to be a prefix */
+		if (entry->var.VariableName[utf16_strlen(efi_name)] == 0)
+			continue;
+
+		/* found */
+		found = entry;
+		efivars->ops->set_variable(entry->var.VariableName, &entry->var.VendorGuid,
+					   EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
+					   0, NULL);
 	}
 
 	if (found)
@@ -530,9 +533,9 @@ static u64 efi_pstore_write(enum pstore_type_id type, int part, size_t size,
 	for (i = 0; i < DUMP_NAME_LEN; i++)
 		efi_name[i] = name[i];
 
-	efi.set_variable(efi_name, &vendor,
-			 EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
-			 size, psi->buf);
+	efivars->ops->set_variable(efi_name, &vendor,
+				   EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
+				   size, psi->buf);
 
 	spin_unlock(&efivars->lock);
 
-- 
1.7.3.1


  parent reply	other threads:[~2011-06-21 20:18 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-06 19:38 [PATCH 1/3] pstore: Extend API Matthew Garrett
2011-06-06 19:38 ` [PATCH 2/3] pstore: Add extra context for writes and erases Matthew Garrett
     [not found]   ` <BANLkTinHYQ14A7vzTxA1c2frxUVE6HWNQg@mail.gmail.com>
2011-06-06 21:43     ` Tony Luck
2011-06-06 21:47       ` Matthew Garrett
2011-06-10  4:00         ` Matt Domsch
2011-06-10  7:12           ` Mike Waychison
2011-06-20 22:27             ` Tony Luck
2011-06-20 22:29               ` Mike Waychison
2011-06-06 19:38 ` [PATCH 3/3] efi: Add support for using efivars as a pstore backend Matthew Garrett
2011-06-06 23:11   ` Tony Luck
2011-06-07 15:47   ` Seiji Aguchi
2011-06-07 15:58     ` Matthew Garrett
2011-06-07 18:04   ` Randy Dunlap
2011-06-21  0:56   ` Mike Waychison
2011-06-21 15:10     ` Matthew Garrett
2011-06-21 17:12       ` Tony Luck
2011-06-21 20:16       ` Mike Waychison
2011-06-21 20:18         ` [PATCH 1/4] efivars: String functions Mike Waychison
2011-06-21 20:18         ` [PATCH 2/4] efivars: introduce utf16_strncmp Mike Waychison
2011-06-21 20:18         ` Mike Waychison [this message]
2011-06-21 20:18         ` [PATCH 4/4] efivars: Introduce PSTORE_EFI_ATTRIBUTES Mike Waychison
2011-06-21 20:22         ` [PATCH 3/3] efi: Add support for using efivars as a pstore backend Matthew Garrett

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=1308687512-11649-3-git-send-email-mikew@google.com \
    --to=mikew@google.com \
    --cc=Matt_Domsch@dell.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mjg59@srcf.ucam.org \
    --cc=tony.luck@intel.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).