* [RFC][PATCH 1/2] Duplicate a shared code between write and erase callbacks
@ 2012-07-03 23:34 Seiji Aguchi
2012-07-05 13:18 ` Don Zickus
0 siblings, 1 reply; 2+ messages in thread
From: Seiji Aguchi @ 2012-07-03 23:34 UTC (permalink / raw)
To: linux-kernel@vger.kernel.org, Luck, Tony (tony.luck@intel.com),
mikew@google.com, Matthew Garrett (mjg@redhat.com),
dzickus@redhat.com
Cc: dle-develop@lists.sourceforge.net, Satoru Moriya
This patch duplicates a code of erase callback shared with write callback so that they work independently.
Signed-off-by: Seiji Aguchi <seiji.aguchi@hds.com>
---
drivers/firmware/efivars.c | 46 +++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 45 insertions(+), 1 deletions(-)
diff --git a/drivers/firmware/efivars.c b/drivers/firmware/efivars.c index 47408e8..4929254 100644
--- a/drivers/firmware/efivars.c
+++ b/drivers/firmware/efivars.c
@@ -756,7 +756,51 @@ static int efi_pstore_write(enum pstore_type_id type, static int efi_pstore_erase(enum pstore_type_id type, u64 id,
struct pstore_info *psi)
{
- efi_pstore_write(type, 0, &id, (unsigned int)id, 0, psi);
+ char stub_name[DUMP_NAME_LEN];
+ efi_char16_t efi_name[DUMP_NAME_LEN];
+ efi_guid_t vendor = LINUX_EFI_CRASH_GUID;
+ struct efivars *efivars = psi->data;
+ struct efivar_entry *entry, *found = NULL;
+ int i;
+
+ sprintf(stub_name, "dump-type%u-%llu-", type, id);
+
+ spin_lock(&efivars->lock);
+
+ for (i = 0; i < DUMP_NAME_LEN; i++)
+ efi_name[i] = stub_name[i];
+
+ /*
+ * Clean up any entries with the same name
+ */
+
+ list_for_each_entry(entry, &efivars->list, list) {
+ get_var_data_locked(efivars, &entry->var);
+
+ 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,
+ PSTORE_EFI_ATTRIBUTES,
+ 0, NULL);
+ }
+
+ if (found)
+ list_del(&found->list);
+
+ spin_unlock(&efivars->lock);
+
+ if (found)
+ efivar_unregister(found);
return 0;
}
--
1.7.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [RFC][PATCH 1/2] Duplicate a shared code between write and erase callbacks
2012-07-03 23:34 [RFC][PATCH 1/2] Duplicate a shared code between write and erase callbacks Seiji Aguchi
@ 2012-07-05 13:18 ` Don Zickus
0 siblings, 0 replies; 2+ messages in thread
From: Don Zickus @ 2012-07-05 13:18 UTC (permalink / raw)
To: Seiji Aguchi
Cc: linux-kernel@vger.kernel.org, Luck, Tony (tony.luck@intel.com),
mikew@google.com, Matthew Garrett (mjg@redhat.com),
dle-develop@lists.sourceforge.net, Satoru Moriya
On Tue, Jul 03, 2012 at 11:34:58PM +0000, Seiji Aguchi wrote:
> This patch duplicates a code of erase callback shared with write callback so that they work independently.
Can you expand this changelog to explain why this is needed and what
problem you are trying to fix? I know you talked about it in the patch
series header, but the header doesn't get committed.
Cheers,
Don
>
> Signed-off-by: Seiji Aguchi <seiji.aguchi@hds.com>
> ---
> drivers/firmware/efivars.c | 46 +++++++++++++++++++++++++++++++++++++++++++-
> 1 files changed, 45 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/firmware/efivars.c b/drivers/firmware/efivars.c index 47408e8..4929254 100644
> --- a/drivers/firmware/efivars.c
> +++ b/drivers/firmware/efivars.c
> @@ -756,7 +756,51 @@ static int efi_pstore_write(enum pstore_type_id type, static int efi_pstore_erase(enum pstore_type_id type, u64 id,
> struct pstore_info *psi)
> {
> - efi_pstore_write(type, 0, &id, (unsigned int)id, 0, psi);
> + char stub_name[DUMP_NAME_LEN];
> + efi_char16_t efi_name[DUMP_NAME_LEN];
> + efi_guid_t vendor = LINUX_EFI_CRASH_GUID;
> + struct efivars *efivars = psi->data;
> + struct efivar_entry *entry, *found = NULL;
> + int i;
> +
> + sprintf(stub_name, "dump-type%u-%llu-", type, id);
> +
> + spin_lock(&efivars->lock);
> +
> + for (i = 0; i < DUMP_NAME_LEN; i++)
> + efi_name[i] = stub_name[i];
> +
> + /*
> + * Clean up any entries with the same name
> + */
> +
> + list_for_each_entry(entry, &efivars->list, list) {
> + get_var_data_locked(efivars, &entry->var);
> +
> + 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,
> + PSTORE_EFI_ATTRIBUTES,
> + 0, NULL);
> + }
> +
> + if (found)
> + list_del(&found->list);
> +
> + spin_unlock(&efivars->lock);
> +
> + if (found)
> + efivar_unregister(found);
>
> return 0;
> }
> --
> 1.7.1
>
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-07-05 13:18 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-07-03 23:34 [RFC][PATCH 1/2] Duplicate a shared code between write and erase callbacks Seiji Aguchi
2012-07-05 13:18 ` Don Zickus
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.