aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/firmware/google/gsmi.c
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@linux.intel.com>2013-04-20 12:16:44 -0400
committerH. Peter Anvin <hpa@linux.intel.com>2013-04-20 12:16:44 -0400
commitf53f292eeaa234615c31a1306babe703fc4263f2 (patch)
tree707b0933a20f7dc05495e974243a23b5c9f8c918 /drivers/firmware/google/gsmi.c
parent15b9c359f288b09003cb70f7ed204affc0c6614d (diff)
parenta9499fa7cd3fd4824a7202d00c766b269fa3bda6 (diff)
Merge remote-tracking branch 'efi/chainsaw' into x86/efi
Resolved Conflicts: drivers/firmware/efivars.c fs/efivarsfs/file.c Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Diffstat (limited to 'drivers/firmware/google/gsmi.c')
-rw-r--r--drivers/firmware/google/gsmi.c30
1 files changed, 13 insertions, 17 deletions
diff --git a/drivers/firmware/google/gsmi.c b/drivers/firmware/google/gsmi.c
index 91ddf0f7a1b9..757b2d92d5b0 100644
--- a/drivers/firmware/google/gsmi.c
+++ b/drivers/firmware/google/gsmi.c
@@ -288,17 +288,6 @@ static int gsmi_exec(u8 func, u8 sub)
288 return rc; 288 return rc;
289} 289}
290 290
291/* Return the number of unicode characters in data */
292static size_t
293utf16_strlen(efi_char16_t *data, unsigned long maxlength)
294{
295 unsigned long length = 0;
296
297 while (*data++ != 0 && length < maxlength)
298 length++;
299 return length;
300}
301
302static efi_status_t gsmi_get_variable(efi_char16_t *name, 291static efi_status_t gsmi_get_variable(efi_char16_t *name,
303 efi_guid_t *vendor, u32 *attr, 292 efi_guid_t *vendor, u32 *attr,
304 unsigned long *data_size, 293 unsigned long *data_size,
@@ -311,7 +300,7 @@ static efi_status_t gsmi_get_variable(efi_char16_t *name,
311 }; 300 };
312 efi_status_t ret = EFI_SUCCESS; 301 efi_status_t ret = EFI_SUCCESS;
313 unsigned long flags; 302 unsigned long flags;
314 size_t name_len = utf16_strlen(name, GSMI_BUF_SIZE / 2); 303 size_t name_len = utf16_strnlen(name, GSMI_BUF_SIZE / 2);
315 int rc; 304 int rc;
316 305
317 if (name_len >= GSMI_BUF_SIZE / 2) 306 if (name_len >= GSMI_BUF_SIZE / 2)
@@ -380,7 +369,7 @@ static efi_status_t gsmi_get_next_variable(unsigned long *name_size,
380 return EFI_BAD_BUFFER_SIZE; 369 return EFI_BAD_BUFFER_SIZE;
381 370
382 /* Let's make sure the thing is at least null-terminated */ 371 /* Let's make sure the thing is at least null-terminated */
383 if (utf16_strlen(name, GSMI_BUF_SIZE / 2) == GSMI_BUF_SIZE / 2) 372 if (utf16_strnlen(name, GSMI_BUF_SIZE / 2) == GSMI_BUF_SIZE / 2)
384 return EFI_INVALID_PARAMETER; 373 return EFI_INVALID_PARAMETER;
385 374
386 spin_lock_irqsave(&gsmi_dev.lock, flags); 375 spin_lock_irqsave(&gsmi_dev.lock, flags);
@@ -408,7 +397,7 @@ static efi_status_t gsmi_get_next_variable(unsigned long *name_size,
408 397
409 /* Copy the name back */ 398 /* Copy the name back */
410 memcpy(name, gsmi_dev.name_buf->start, GSMI_BUF_SIZE); 399 memcpy(name, gsmi_dev.name_buf->start, GSMI_BUF_SIZE);
411 *name_size = utf16_strlen(name, GSMI_BUF_SIZE / 2) * 2; 400 *name_size = utf16_strnlen(name, GSMI_BUF_SIZE / 2) * 2;
412 401
413 /* copy guid to return buffer */ 402 /* copy guid to return buffer */
414 memcpy(vendor, &param.guid, sizeof(param.guid)); 403 memcpy(vendor, &param.guid, sizeof(param.guid));
@@ -434,7 +423,7 @@ static efi_status_t gsmi_set_variable(efi_char16_t *name,
434 EFI_VARIABLE_BOOTSERVICE_ACCESS | 423 EFI_VARIABLE_BOOTSERVICE_ACCESS |
435 EFI_VARIABLE_RUNTIME_ACCESS, 424 EFI_VARIABLE_RUNTIME_ACCESS,
436 }; 425 };
437 size_t name_len = utf16_strlen(name, GSMI_BUF_SIZE / 2); 426 size_t name_len = utf16_strnlen(name, GSMI_BUF_SIZE / 2);
438 efi_status_t ret = EFI_SUCCESS; 427 efi_status_t ret = EFI_SUCCESS;
439 int rc; 428 int rc;
440 unsigned long flags; 429 unsigned long flags;
@@ -893,12 +882,19 @@ static __init int gsmi_init(void)
893 goto out_remove_bin_file; 882 goto out_remove_bin_file;
894 } 883 }
895 884
896 ret = register_efivars(&efivars, &efivar_ops, gsmi_kobj); 885 ret = efivars_register(&efivars, &efivar_ops, gsmi_kobj);
897 if (ret) { 886 if (ret) {
898 printk(KERN_INFO "gsmi: Failed to register efivars\n"); 887 printk(KERN_INFO "gsmi: Failed to register efivars\n");
899 goto out_remove_sysfs_files; 888 goto out_remove_sysfs_files;
900 } 889 }
901 890
891 ret = efivars_sysfs_init();
892 if (ret) {
893 printk(KERN_INFO "gsmi: Failed to create efivars files\n");
894 efivars_unregister(&efivars);
895 goto out_remove_sysfs_files;
896 }
897
902 register_reboot_notifier(&gsmi_reboot_notifier); 898 register_reboot_notifier(&gsmi_reboot_notifier);
903 register_die_notifier(&gsmi_die_notifier); 899 register_die_notifier(&gsmi_die_notifier);
904 atomic_notifier_chain_register(&panic_notifier_list, 900 atomic_notifier_chain_register(&panic_notifier_list,
@@ -930,7 +926,7 @@ static void __exit gsmi_exit(void)
930 unregister_die_notifier(&gsmi_die_notifier); 926 unregister_die_notifier(&gsmi_die_notifier);
931 atomic_notifier_chain_unregister(&panic_notifier_list, 927 atomic_notifier_chain_unregister(&panic_notifier_list,
932 &gsmi_panic_notifier); 928 &gsmi_panic_notifier);
933 unregister_efivars(&efivars); 929 efivars_unregister(&efivars);
934 930
935 sysfs_remove_files(gsmi_kobj, gsmi_attrs); 931 sysfs_remove_files(gsmi_kobj, gsmi_attrs);
936 sysfs_remove_bin_file(gsmi_kobj, &eventlog_bin_attr); 932 sysfs_remove_bin_file(gsmi_kobj, &eventlog_bin_attr);