Skip to content

Commit d49fd4b

Browse files
nivedita76ardbiesheuvel
authored andcommitted
efi/gop: Remove unreachable code from setup_pixel_info
pixel_format must be one of PIXEL_RGB_RESERVED_8BIT_PER_COLOR PIXEL_BGR_RESERVED_8BIT_PER_COLOR PIXEL_BIT_MASK since we skip PIXEL_BLT_ONLY when finding a gop. Remove the redundant code and add another check in find_gop to skip any pixel formats that we don't know about, in case a later version of the UEFI spec adds one. Reformat the code a little. Signed-off-by: Arvind Sankar <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Ard Biesheuvel <[email protected]>
1 parent 9867fc9 commit d49fd4b

File tree

1 file changed

+26
-40
lines changed
  • drivers/firmware/efi/libstub

1 file changed

+26
-40
lines changed

drivers/firmware/efi/libstub/gop.c

Lines changed: 26 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -29,49 +29,34 @@ static void
2929
setup_pixel_info(struct screen_info *si, u32 pixels_per_scan_line,
3030
efi_pixel_bitmask_t pixel_info, int pixel_format)
3131
{
32-
if (pixel_format == PIXEL_RGB_RESERVED_8BIT_PER_COLOR) {
33-
si->lfb_depth = 32;
34-
si->lfb_linelength = pixels_per_scan_line * 4;
35-
si->red_size = 8;
36-
si->red_pos = 0;
37-
si->green_size = 8;
38-
si->green_pos = 8;
39-
si->blue_size = 8;
40-
si->blue_pos = 16;
41-
si->rsvd_size = 8;
42-
si->rsvd_pos = 24;
43-
} else if (pixel_format == PIXEL_BGR_RESERVED_8BIT_PER_COLOR) {
44-
si->lfb_depth = 32;
45-
si->lfb_linelength = pixels_per_scan_line * 4;
46-
si->red_size = 8;
47-
si->red_pos = 16;
48-
si->green_size = 8;
49-
si->green_pos = 8;
50-
si->blue_size = 8;
51-
si->blue_pos = 0;
52-
si->rsvd_size = 8;
53-
si->rsvd_pos = 24;
54-
} else if (pixel_format == PIXEL_BIT_MASK) {
55-
find_bits(pixel_info.red_mask, &si->red_pos, &si->red_size);
56-
find_bits(pixel_info.green_mask, &si->green_pos,
57-
&si->green_size);
58-
find_bits(pixel_info.blue_mask, &si->blue_pos, &si->blue_size);
59-
find_bits(pixel_info.reserved_mask, &si->rsvd_pos,
60-
&si->rsvd_size);
32+
if (pixel_format == PIXEL_BIT_MASK) {
33+
find_bits(pixel_info.red_mask,
34+
&si->red_pos, &si->red_size);
35+
find_bits(pixel_info.green_mask,
36+
&si->green_pos, &si->green_size);
37+
find_bits(pixel_info.blue_mask,
38+
&si->blue_pos, &si->blue_size);
39+
find_bits(pixel_info.reserved_mask,
40+
&si->rsvd_pos, &si->rsvd_size);
6141
si->lfb_depth = si->red_size + si->green_size +
6242
si->blue_size + si->rsvd_size;
6343
si->lfb_linelength = (pixels_per_scan_line * si->lfb_depth) / 8;
6444
} else {
65-
si->lfb_depth = 4;
66-
si->lfb_linelength = si->lfb_width / 2;
67-
si->red_size = 0;
68-
si->red_pos = 0;
69-
si->green_size = 0;
70-
si->green_pos = 0;
71-
si->blue_size = 0;
72-
si->blue_pos = 0;
73-
si->rsvd_size = 0;
74-
si->rsvd_pos = 0;
45+
if (pixel_format == PIXEL_RGB_RESERVED_8BIT_PER_COLOR) {
46+
si->red_pos = 0;
47+
si->blue_pos = 16;
48+
} else /* PIXEL_BGR_RESERVED_8BIT_PER_COLOR */ {
49+
si->blue_pos = 0;
50+
si->red_pos = 16;
51+
}
52+
53+
si->green_pos = 8;
54+
si->rsvd_pos = 24;
55+
si->red_size = si->green_size =
56+
si->blue_size = si->rsvd_size = 8;
57+
58+
si->lfb_depth = 32;
59+
si->lfb_linelength = pixels_per_scan_line * 4;
7560
}
7661
}
7762

@@ -100,7 +85,8 @@ find_gop(efi_guid_t *proto, unsigned long size, void **handles)
10085

10186
mode = efi_table_attr(gop, mode);
10287
info = efi_table_attr(mode, info);
103-
if (info->pixel_format == PIXEL_BLT_ONLY)
88+
if (info->pixel_format == PIXEL_BLT_ONLY ||
89+
info->pixel_format >= PIXEL_FORMAT_MAX)
10490
continue;
10591

10692
/*

0 commit comments

Comments
 (0)