Skip to content

Commit 6327e6d

Browse files
nivedita76ardbiesheuvel
authored andcommitted
efi/gop: Get mode information outside the loop
Move extraction of the mode information parameters outside the loop to find the gop, and eliminate some redundant variables. Signed-off-by: Arvind Sankar <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Ard Biesheuvel <[email protected]>
1 parent 8cd2079 commit 6327e6d

File tree

1 file changed

+14
-24
lines changed
  • drivers/firmware/efi/libstub

1 file changed

+14
-24
lines changed

drivers/firmware/efi/libstub/gop.c

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,9 @@ static efi_status_t setup_gop(struct screen_info *si, efi_guid_t *proto,
8989
unsigned long size, void **handles)
9090
{
9191
efi_graphics_output_protocol_t *gop, *first_gop;
92-
u16 width, height;
93-
u32 pixels_per_scan_line;
94-
u32 ext_lfb_base;
92+
efi_graphics_output_protocol_mode_t *mode;
93+
efi_graphics_output_mode_info_t *info = NULL;
9594
efi_physical_addr_t fb_base;
96-
efi_pixel_bitmask_t pixel_info;
97-
int pixel_format;
9895
efi_status_t status;
9996
efi_handle_t h;
10097
int i;
@@ -103,8 +100,6 @@ static efi_status_t setup_gop(struct screen_info *si, efi_guid_t *proto,
103100
gop = NULL;
104101

105102
for_each_efi_handle(h, handles, size, i) {
106-
efi_graphics_output_protocol_mode_t *mode;
107-
efi_graphics_output_mode_info_t *info = NULL;
108103
efi_guid_t conout_proto = EFI_CONSOLE_OUT_DEVICE_GUID;
109104
bool conout_found = false;
110105
void *dummy = NULL;
@@ -129,15 +124,7 @@ static efi_status_t setup_gop(struct screen_info *si, efi_guid_t *proto,
129124
* backed by real hardware. The workaround is to search
130125
* for a GOP implementing the ConOut protocol, and if
131126
* one isn't found, to just fall back to the first GOP.
132-
*/
133-
width = info->horizontal_resolution;
134-
height = info->vertical_resolution;
135-
pixel_format = info->pixel_format;
136-
pixel_info = info->pixel_information;
137-
pixels_per_scan_line = info->pixels_per_scan_line;
138-
fb_base = efi_table_attr(mode, frame_buffer_base);
139-
140-
/*
127+
*
141128
* Once we've found a GOP supporting ConOut,
142129
* don't bother looking any further.
143130
*/
@@ -152,21 +139,24 @@ static efi_status_t setup_gop(struct screen_info *si, efi_guid_t *proto,
152139
return EFI_NOT_FOUND;
153140

154141
/* EFI framebuffer */
142+
mode = efi_table_attr(first_gop, mode);
143+
info = efi_table_attr(mode, info);
144+
155145
si->orig_video_isVGA = VIDEO_TYPE_EFI;
156146

157-
si->lfb_width = width;
158-
si->lfb_height = height;
159-
si->lfb_base = fb_base;
147+
si->lfb_width = info->horizontal_resolution;
148+
si->lfb_height = info->vertical_resolution;
160149

161-
ext_lfb_base = (u64)(unsigned long)fb_base >> 32;
162-
if (ext_lfb_base) {
150+
fb_base = efi_table_attr(mode, frame_buffer_base);
151+
si->lfb_base = fb_base;
152+
si->ext_lfb_base = (u64)(unsigned long)fb_base >> 32;
153+
if (si->ext_lfb_base)
163154
si->capabilities |= VIDEO_CAPABILITY_64BIT_BASE;
164-
si->ext_lfb_base = ext_lfb_base;
165-
}
166155

167156
si->pages = 1;
168157

169-
setup_pixel_info(si, pixels_per_scan_line, pixel_info, pixel_format);
158+
setup_pixel_info(si, info->pixels_per_scan_line,
159+
info->pixel_information, info->pixel_format);
170160

171161
si->lfb_size = si->lfb_linelength * si->lfb_height;
172162

0 commit comments

Comments
 (0)