Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

sysfb: Fix screen_info type check for VGA

Use the helper screen_info_video_type() to get the framebuffer
type from struct screen_info. Handle supported values in sorted
switch statement.

Reading orig_video_isVGA is unreliable. On most systems it is a
VIDEO_TYPE_ constant. On some systems with VGA it is simply set
to 1 to signal the presence of a VGA output. See vga_probe() for
an example. Retrieving the screen_info type with the helper
screen_info_video_type() detects these cases and returns the
appropriate VIDEO_TYPE_ constant. For VGA, sysfb creates a device
named "vga-framebuffer".

The sysfb code has been taken from vga16fb, where it likely didn't
work correctly either. With this bugfix applied, vga16fb loads for
compatible vga-framebuffer devices.

Fixes: 0db5b61e0dc0 ("fbdev/vga16fb: Create EGA/VGA devices in sysfb code")
Cc: Thomas Zimmermann <tzimmermann@suse.de>
Cc: Javier Martinez Canillas <javierm@redhat.com>
Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: Tzung-Bi Shih <tzungbi@kernel.org>
Cc: Helge Deller <deller@gmx.de>
Cc: "Uwe Kleine-König" <u.kleine-koenig@baylibre.com>
Cc: Zsolt Kajtar <soci@c64.rulez.org>
Cc: <stable@vger.kernel.org> # v6.1+
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org>
Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
Link: https://lore.kernel.org/r/20250603154838.401882-1-tzimmermann@suse.de

+18 -8
+18 -8
drivers/firmware/sysfb.c
··· 143 143 { 144 144 struct screen_info *si = &screen_info; 145 145 struct device *parent; 146 + unsigned int type; 146 147 struct simplefb_platform_data mode; 147 148 const char *name; 148 149 bool compatible; ··· 171 170 goto put_device; 172 171 } 173 172 173 + type = screen_info_video_type(si); 174 + 174 175 /* if the FB is incompatible, create a legacy framebuffer device */ 175 - if (si->orig_video_isVGA == VIDEO_TYPE_EFI) 176 - name = "efi-framebuffer"; 177 - else if (si->orig_video_isVGA == VIDEO_TYPE_VLFB) 178 - name = "vesa-framebuffer"; 179 - else if (si->orig_video_isVGA == VIDEO_TYPE_VGAC) 180 - name = "vga-framebuffer"; 181 - else if (si->orig_video_isVGA == VIDEO_TYPE_EGAC) 176 + switch (type) { 177 + case VIDEO_TYPE_EGAC: 182 178 name = "ega-framebuffer"; 183 - else 179 + break; 180 + case VIDEO_TYPE_VGAC: 181 + name = "vga-framebuffer"; 182 + break; 183 + case VIDEO_TYPE_VLFB: 184 + name = "vesa-framebuffer"; 185 + break; 186 + case VIDEO_TYPE_EFI: 187 + name = "efi-framebuffer"; 188 + break; 189 + default: 184 190 name = "platform-framebuffer"; 191 + break; 192 + } 185 193 186 194 pd = platform_device_alloc(name, 0); 187 195 if (!pd) {