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

fbdev/vga16fb: Create EGA/VGA devices in sysfb code

Move the device-creation from vga16fb to sysfb code. The driver's
videomode checks are independent from device creation, so move them
into vga16fb's probe function. This will allow to create the module
init/exit code automatically.

The vga16fb driver requires a screen_info for type VIDEO_TYPE_VGAC
or VIDEO_TYPE_EGAC. Such code is nowhere present in the kernel, except
for some MIPS systems. It's not clear if the vga16fb driver actually
works in practice.

v2:
* keep driver name to "vga16fb" (Javier)
* give rational for moving mode checks (Javier)

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20220718072322.8927-3-tzimmermann@suse.de

+31 -30
+4
drivers/firmware/sysfb.c
··· 94 94 name = "efi-framebuffer"; 95 95 else if (si->orig_video_isVGA == VIDEO_TYPE_VLFB) 96 96 name = "vesa-framebuffer"; 97 + else if (si->orig_video_isVGA == VIDEO_TYPE_VGAC) 98 + name = "vga-framebuffer"; 99 + else if (si->orig_video_isVGA == VIDEO_TYPE_EGAC) 100 + name = "ega-framebuffer"; 97 101 else 98 102 name = "platform-framebuffer"; 99 103
+27 -30
drivers/video/fbdev/vga16fb.c
··· 185 185 } 186 186 187 187 /* Check if the video mode is supported by the driver */ 188 - static inline int check_mode_supported(void) 188 + static inline int check_mode_supported(const struct screen_info *si) 189 189 { 190 190 /* non-x86 architectures treat orig_video_isVGA as a boolean flag */ 191 191 #if defined(CONFIG_X86) 192 192 /* only EGA and VGA in 16 color graphic mode are supported */ 193 - if (screen_info.orig_video_isVGA != VIDEO_TYPE_EGAC && 194 - screen_info.orig_video_isVGA != VIDEO_TYPE_VGAC) 193 + if (si->orig_video_isVGA != VIDEO_TYPE_EGAC && 194 + si->orig_video_isVGA != VIDEO_TYPE_VGAC) 195 195 return -ENODEV; 196 196 197 - if (screen_info.orig_video_mode != 0x0D && /* 320x200/4 (EGA) */ 198 - screen_info.orig_video_mode != 0x0E && /* 640x200/4 (EGA) */ 199 - screen_info.orig_video_mode != 0x10 && /* 640x350/4 (EGA) */ 200 - screen_info.orig_video_mode != 0x12) /* 640x480/4 (VGA) */ 197 + if (si->orig_video_mode != 0x0D && /* 320x200/4 (EGA) */ 198 + si->orig_video_mode != 0x0E && /* 640x200/4 (EGA) */ 199 + si->orig_video_mode != 0x10 && /* 640x350/4 (EGA) */ 200 + si->orig_video_mode != 0x12) /* 640x480/4 (VGA) */ 201 201 return -ENODEV; 202 202 #endif 203 203 return 0; ··· 1321 1321 1322 1322 static int vga16fb_probe(struct platform_device *dev) 1323 1323 { 1324 + struct screen_info *si; 1324 1325 struct fb_info *info; 1325 1326 struct vga16fb_par *par; 1326 1327 int i; 1327 1328 int ret = 0; 1329 + 1330 + si = dev_get_platdata(&dev->dev); 1331 + if (!si) 1332 + return -ENODEV; 1333 + 1334 + ret = check_mode_supported(si); 1335 + if (ret) 1336 + return ret; 1328 1337 1329 1338 printk(KERN_DEBUG "vga16fb: initializing\n"); 1330 1339 info = framebuffer_alloc(sizeof(struct vga16fb_par), &dev->dev); ··· 1361 1352 par = info->par; 1362 1353 1363 1354 #if defined(CONFIG_X86) 1364 - par->isVGA = screen_info.orig_video_isVGA == VIDEO_TYPE_VGAC; 1355 + par->isVGA = si->orig_video_isVGA == VIDEO_TYPE_VGAC; 1365 1356 #else 1366 1357 /* non-x86 architectures treat orig_video_isVGA as a boolean flag */ 1367 - par->isVGA = screen_info.orig_video_isVGA; 1358 + par->isVGA = si->orig_video_isVGA; 1368 1359 #endif 1369 1360 par->palette_blanked = 0; 1370 1361 par->vesa_blanked = 0; ··· 1434 1425 return 0; 1435 1426 } 1436 1427 1428 + static const struct platform_device_id vga16fb_driver_id_table[] = { 1429 + {"ega-framebuffer", 0}, 1430 + {"vga-framebuffer", 0}, 1431 + { } 1432 + }; 1433 + 1437 1434 static struct platform_driver vga16fb_driver = { 1438 1435 .probe = vga16fb_probe, 1439 1436 .remove = vga16fb_remove, 1440 1437 .driver = { 1441 1438 .name = "vga16fb", 1442 1439 }, 1440 + .id_table = vga16fb_driver_id_table, 1443 1441 }; 1444 - 1445 - static struct platform_device *vga16fb_device; 1446 1442 1447 1443 static int __init vga16fb_init(void) 1448 1444 { ··· 1461 1447 vga16fb_setup(option); 1462 1448 #endif 1463 1449 1464 - ret = check_mode_supported(); 1450 + ret = platform_driver_register(&vga16fb_driver); 1465 1451 if (ret) 1466 1452 return ret; 1467 1453 1468 - ret = platform_driver_register(&vga16fb_driver); 1469 - 1470 - if (!ret) { 1471 - vga16fb_device = platform_device_alloc("vga16fb", 0); 1472 - 1473 - if (vga16fb_device) 1474 - ret = platform_device_add(vga16fb_device); 1475 - else 1476 - ret = -ENOMEM; 1477 - 1478 - if (ret) { 1479 - platform_device_put(vga16fb_device); 1480 - platform_driver_unregister(&vga16fb_driver); 1481 - } 1482 - } 1483 - 1484 - return ret; 1454 + return 0; 1485 1455 } 1486 1456 1487 1457 static void __exit vga16fb_exit(void) 1488 1458 { 1489 - platform_device_unregister(vga16fb_device); 1490 1459 platform_driver_unregister(&vga16fb_driver); 1491 1460 } 1492 1461