Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757447Ab1FUUSn (ORCPT ); Tue, 21 Jun 2011 16:18:43 -0400 Received: from smtp-out.google.com ([216.239.44.51]:40529 "EHLO smtp-out.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754621Ab1FUUSj (ORCPT ); Tue, 21 Jun 2011 16:18:39 -0400 DomainKey-Signature: a=rsa-sha1; s=beta; d=google.com; c=nofws; q=dns; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; b=I5Vi2Qy2wW7W81CtEd00JA3vCAlNv8jickc5mNM91I1I2FwoRx++34apDfhvVebKo LWxEOVf+iZqJ+VvYhZu6A== From: Mike Waychison To: Matthew Garrett Cc: tony.luck@intel.com, linux-kernel@vger.kernel.org, Matt_Domsch@dell.com, Mike Waychison Subject: [PATCH 3/4] efivars: Use string functions in pstore_write Date: Tue, 21 Jun 2011 13:18:31 -0700 Message-Id: <1308687512-11649-3-git-send-email-mikew@google.com> X-Mailer: git-send-email 1.7.3.1 In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2625 Lines: 72 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 --- 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 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/