diff options
Diffstat (limited to 'drivers/firmware/efi/vars.c')
-rw-r--r-- | drivers/firmware/efi/vars.c | 56 |
1 files changed, 10 insertions, 46 deletions
diff --git a/drivers/firmware/efi/vars.c b/drivers/firmware/efi/vars.c index 34b741940494..d3b751383286 100644 --- a/drivers/firmware/efi/vars.c +++ b/drivers/firmware/efi/vars.c | |||
@@ -329,39 +329,6 @@ check_var_size_nonblocking(u32 attributes, unsigned long size) | |||
329 | return fops->query_variable_store(attributes, size, true); | 329 | return fops->query_variable_store(attributes, size, true); |
330 | } | 330 | } |
331 | 331 | ||
332 | static int efi_status_to_err(efi_status_t status) | ||
333 | { | ||
334 | int err; | ||
335 | |||
336 | switch (status) { | ||
337 | case EFI_SUCCESS: | ||
338 | err = 0; | ||
339 | break; | ||
340 | case EFI_INVALID_PARAMETER: | ||
341 | err = -EINVAL; | ||
342 | break; | ||
343 | case EFI_OUT_OF_RESOURCES: | ||
344 | err = -ENOSPC; | ||
345 | break; | ||
346 | case EFI_DEVICE_ERROR: | ||
347 | err = -EIO; | ||
348 | break; | ||
349 | case EFI_WRITE_PROTECTED: | ||
350 | err = -EROFS; | ||
351 | break; | ||
352 | case EFI_SECURITY_VIOLATION: | ||
353 | err = -EACCES; | ||
354 | break; | ||
355 | case EFI_NOT_FOUND: | ||
356 | err = -ENOENT; | ||
357 | break; | ||
358 | default: | ||
359 | err = -EINVAL; | ||
360 | } | ||
361 | |||
362 | return err; | ||
363 | } | ||
364 | |||
365 | static bool variable_is_present(efi_char16_t *variable_name, efi_guid_t *vendor, | 332 | static bool variable_is_present(efi_char16_t *variable_name, efi_guid_t *vendor, |
366 | struct list_head *head) | 333 | struct list_head *head) |
367 | { | 334 | { |
@@ -452,8 +419,7 @@ static void dup_variable_bug(efi_char16_t *str16, efi_guid_t *vendor_guid, | |||
452 | * Returns 0 on success, or a kernel error code on failure. | 419 | * Returns 0 on success, or a kernel error code on failure. |
453 | */ | 420 | */ |
454 | int efivar_init(int (*func)(efi_char16_t *, efi_guid_t, unsigned long, void *), | 421 | int efivar_init(int (*func)(efi_char16_t *, efi_guid_t, unsigned long, void *), |
455 | void *data, bool atomic, bool duplicates, | 422 | void *data, bool duplicates, struct list_head *head) |
456 | struct list_head *head) | ||
457 | { | 423 | { |
458 | const struct efivar_operations *ops = __efivars->ops; | 424 | const struct efivar_operations *ops = __efivars->ops; |
459 | unsigned long variable_name_size = 1024; | 425 | unsigned long variable_name_size = 1024; |
@@ -483,7 +449,7 @@ int efivar_init(int (*func)(efi_char16_t *, efi_guid_t, unsigned long, void *), | |||
483 | &vendor_guid); | 449 | &vendor_guid); |
484 | switch (status) { | 450 | switch (status) { |
485 | case EFI_SUCCESS: | 451 | case EFI_SUCCESS: |
486 | if (!atomic) | 452 | if (duplicates) |
487 | spin_unlock_irq(&__efivars->lock); | 453 | spin_unlock_irq(&__efivars->lock); |
488 | 454 | ||
489 | variable_name_size = var_name_strnsize(variable_name, | 455 | variable_name_size = var_name_strnsize(variable_name, |
@@ -498,21 +464,19 @@ int efivar_init(int (*func)(efi_char16_t *, efi_guid_t, unsigned long, void *), | |||
498 | * and may end up looping here forever. | 464 | * and may end up looping here forever. |
499 | */ | 465 | */ |
500 | if (duplicates && | 466 | if (duplicates && |
501 | variable_is_present(variable_name, &vendor_guid, head)) { | 467 | variable_is_present(variable_name, &vendor_guid, |
468 | head)) { | ||
502 | dup_variable_bug(variable_name, &vendor_guid, | 469 | dup_variable_bug(variable_name, &vendor_guid, |
503 | variable_name_size); | 470 | variable_name_size); |
504 | if (!atomic) | ||
505 | spin_lock_irq(&__efivars->lock); | ||
506 | |||
507 | status = EFI_NOT_FOUND; | 471 | status = EFI_NOT_FOUND; |
508 | break; | 472 | } else { |
473 | err = func(variable_name, vendor_guid, | ||
474 | variable_name_size, data); | ||
475 | if (err) | ||
476 | status = EFI_NOT_FOUND; | ||
509 | } | 477 | } |
510 | 478 | ||
511 | err = func(variable_name, vendor_guid, variable_name_size, data); | 479 | if (duplicates) |
512 | if (err) | ||
513 | status = EFI_NOT_FOUND; | ||
514 | |||
515 | if (!atomic) | ||
516 | spin_lock_irq(&__efivars->lock); | 480 | spin_lock_irq(&__efivars->lock); |
517 | 481 | ||
518 | break; | 482 | break; |