Skip to content

Commit 9d80570

Browse files
tdzardbiesheuvel
authored andcommitted
efi/libstub: gop: Find GOP handle instead of GOP data
The device handle of the GOP device is required to retrieve the correct EDID data. Find the handle instead of the GOP data. Still return the GOP data in the function arguments, as we already looked it up. Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Reviewed-by: Javier Martinez Canillas <javierm@redhat.com> Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
1 parent d85b56a commit 9d80570

1 file changed

Lines changed: 17 additions & 10 deletions

File tree

  • drivers/firmware/efi/libstub

drivers/firmware/efi/libstub/gop.c

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -402,12 +402,13 @@ setup_pixel_info(struct screen_info *si, u32 pixels_per_scan_line,
402402
}
403403
}
404404

405-
static efi_graphics_output_protocol_t *find_gop(unsigned long num,
406-
const efi_handle_t handles[])
405+
static efi_handle_t find_handle_with_primary_gop(unsigned long num, const efi_handle_t handles[],
406+
efi_graphics_output_protocol_t **found_gop)
407407
{
408408
efi_graphics_output_protocol_t *first_gop;
409-
efi_handle_t h;
409+
efi_handle_t h, first_gop_handle;
410410

411+
first_gop_handle = NULL;
411412
first_gop = NULL;
412413

413414
for_each_efi_handle(h, handles, num) {
@@ -442,19 +443,25 @@ static efi_graphics_output_protocol_t *find_gop(unsigned long num,
442443
*/
443444
status = efi_bs_call(handle_protocol, h,
444445
&EFI_CONSOLE_OUT_DEVICE_GUID, &dummy);
445-
if (status == EFI_SUCCESS)
446-
return gop;
447-
448-
if (!first_gop)
446+
if (status == EFI_SUCCESS) {
447+
if (found_gop)
448+
*found_gop = gop;
449+
return h;
450+
} else if (!first_gop_handle) {
451+
first_gop_handle = h;
449452
first_gop = gop;
453+
}
450454
}
451455

452-
return first_gop;
456+
if (found_gop)
457+
*found_gop = first_gop;
458+
return first_gop_handle;
453459
}
454460

455461
efi_status_t efi_setup_gop(struct screen_info *si)
456462
{
457463
efi_handle_t *handles __free(efi_pool) = NULL;
464+
efi_handle_t handle;
458465
efi_graphics_output_protocol_mode_t *mode;
459466
efi_graphics_output_mode_info_t *info;
460467
efi_graphics_output_protocol_t *gop;
@@ -467,8 +474,8 @@ efi_status_t efi_setup_gop(struct screen_info *si)
467474
if (status != EFI_SUCCESS)
468475
return status;
469476

470-
gop = find_gop(num, handles);
471-
if (!gop)
477+
handle = find_handle_with_primary_gop(num, handles, &gop);
478+
if (!handle)
472479
return EFI_NOT_FOUND;
473480

474481
/* Change mode if requested */

0 commit comments

Comments
 (0)