diff options
| -rw-r--r-- | drivers/firmware/Kconfig | 9 | ||||
| -rw-r--r-- | drivers/firmware/efivars.c | 64 |
2 files changed, 29 insertions, 44 deletions
diff --git a/drivers/firmware/Kconfig b/drivers/firmware/Kconfig index 9b00072a020f..898023d8e486 100644 --- a/drivers/firmware/Kconfig +++ b/drivers/firmware/Kconfig | |||
| @@ -53,6 +53,15 @@ config EFI_VARS | |||
| 53 | Subsequent efibootmgr releases may be found at: | 53 | Subsequent efibootmgr releases may be found at: |
| 54 | <http://linux.dell.com/efibootmgr> | 54 | <http://linux.dell.com/efibootmgr> |
| 55 | 55 | ||
| 56 | config EFI_VARS_PSTORE | ||
| 57 | bool "Register efivars backend for pstore" | ||
| 58 | depends on EFI_VARS && PSTORE | ||
| 59 | default y | ||
| 60 | help | ||
| 61 | Say Y here to enable use efivars as a backend to pstore. This | ||
| 62 | will allow writing console messages, crash dumps, or anything | ||
| 63 | else supported by pstore to EFI variables. | ||
| 64 | |||
| 56 | config EFI_PCDP | 65 | config EFI_PCDP |
| 57 | bool "Console device selection via EFI PCDP or HCDP table" | 66 | bool "Console device selection via EFI PCDP or HCDP table" |
| 58 | depends on ACPI && EFI && IA64 | 67 | depends on ACPI && EFI && IA64 |
diff --git a/drivers/firmware/efivars.c b/drivers/firmware/efivars.c index fe62aa392239..37b6f247399e 100644 --- a/drivers/firmware/efivars.c +++ b/drivers/firmware/efivars.c | |||
| @@ -1309,9 +1309,7 @@ static const struct inode_operations efivarfs_dir_inode_operations = { | |||
| 1309 | .create = efivarfs_create, | 1309 | .create = efivarfs_create, |
| 1310 | }; | 1310 | }; |
| 1311 | 1311 | ||
| 1312 | static struct pstore_info efi_pstore_info; | 1312 | #ifdef CONFIG_EFI_VARS_PSTORE |
| 1313 | |||
| 1314 | #ifdef CONFIG_PSTORE | ||
| 1315 | 1313 | ||
| 1316 | static int efi_pstore_open(struct pstore_info *psi) | 1314 | static int efi_pstore_open(struct pstore_info *psi) |
| 1317 | { | 1315 | { |
| @@ -1514,38 +1512,6 @@ static int efi_pstore_erase(enum pstore_type_id type, u64 id, int count, | |||
| 1514 | 1512 | ||
| 1515 | return 0; | 1513 | return 0; |
| 1516 | } | 1514 | } |
| 1517 | #else | ||
| 1518 | static int efi_pstore_open(struct pstore_info *psi) | ||
| 1519 | { | ||
| 1520 | return 0; | ||
| 1521 | } | ||
| 1522 | |||
| 1523 | static int efi_pstore_close(struct pstore_info *psi) | ||
| 1524 | { | ||
| 1525 | return 0; | ||
| 1526 | } | ||
| 1527 | |||
| 1528 | static ssize_t efi_pstore_read(u64 *id, enum pstore_type_id *type, int *count, | ||
| 1529 | struct timespec *timespec, | ||
| 1530 | char **buf, struct pstore_info *psi) | ||
| 1531 | { | ||
| 1532 | return -1; | ||
| 1533 | } | ||
| 1534 | |||
| 1535 | static int efi_pstore_write(enum pstore_type_id type, | ||
| 1536 | enum kmsg_dump_reason reason, u64 *id, | ||
| 1537 | unsigned int part, int count, size_t size, | ||
| 1538 | struct pstore_info *psi) | ||
| 1539 | { | ||
| 1540 | return 0; | ||
| 1541 | } | ||
| 1542 | |||
| 1543 | static int efi_pstore_erase(enum pstore_type_id type, u64 id, int count, | ||
| 1544 | struct timespec time, struct pstore_info *psi) | ||
| 1545 | { | ||
| 1546 | return 0; | ||
| 1547 | } | ||
| 1548 | #endif | ||
| 1549 | 1515 | ||
| 1550 | static struct pstore_info efi_pstore_info = { | 1516 | static struct pstore_info efi_pstore_info = { |
| 1551 | .owner = THIS_MODULE, | 1517 | .owner = THIS_MODULE, |
| @@ -1557,6 +1523,24 @@ static struct pstore_info efi_pstore_info = { | |||
| 1557 | .erase = efi_pstore_erase, | 1523 | .erase = efi_pstore_erase, |
| 1558 | }; | 1524 | }; |
| 1559 | 1525 | ||
| 1526 | static void efivar_pstore_register(struct efivars *efivars) | ||
| 1527 | { | ||
| 1528 | efivars->efi_pstore_info = efi_pstore_info; | ||
| 1529 | efivars->efi_pstore_info.buf = kmalloc(4096, GFP_KERNEL); | ||
| 1530 | if (efivars->efi_pstore_info.buf) { | ||
| 1531 | efivars->efi_pstore_info.bufsize = 1024; | ||
| 1532 | efivars->efi_pstore_info.data = efivars; | ||
| 1533 | spin_lock_init(&efivars->efi_pstore_info.buf_lock); | ||
| 1534 | pstore_register(&efivars->efi_pstore_info); | ||
| 1535 | } | ||
| 1536 | } | ||
| 1537 | #else | ||
| 1538 | static void efivar_pstore_register(struct efivars *efivars) | ||
| 1539 | { | ||
| 1540 | return; | ||
| 1541 | } | ||
| 1542 | #endif | ||
| 1543 | |||
| 1560 | static ssize_t efivar_create(struct file *filp, struct kobject *kobj, | 1544 | static ssize_t efivar_create(struct file *filp, struct kobject *kobj, |
| 1561 | struct bin_attribute *bin_attr, | 1545 | struct bin_attribute *bin_attr, |
| 1562 | char *buf, loff_t pos, size_t count) | 1546 | char *buf, loff_t pos, size_t count) |
| @@ -2025,15 +2009,7 @@ int register_efivars(struct efivars *efivars, | |||
| 2025 | if (error) | 2009 | if (error) |
| 2026 | unregister_efivars(efivars); | 2010 | unregister_efivars(efivars); |
| 2027 | 2011 | ||
| 2028 | efivars->efi_pstore_info = efi_pstore_info; | 2012 | efivar_pstore_register(efivars); |
| 2029 | |||
| 2030 | efivars->efi_pstore_info.buf = kmalloc(4096, GFP_KERNEL); | ||
| 2031 | if (efivars->efi_pstore_info.buf) { | ||
| 2032 | efivars->efi_pstore_info.bufsize = 1024; | ||
| 2033 | efivars->efi_pstore_info.data = efivars; | ||
| 2034 | spin_lock_init(&efivars->efi_pstore_info.buf_lock); | ||
| 2035 | pstore_register(&efivars->efi_pstore_info); | ||
| 2036 | } | ||
| 2037 | 2013 | ||
| 2038 | register_filesystem(&efivarfs_type); | 2014 | register_filesystem(&efivarfs_type); |
| 2039 | 2015 | ||
