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

matroxfb: make CONFIG_FB_MATROX_MULTIHEAD=y mandatory

I would like to get rid of option CONFIG_FB_MATROX_MULTIHEAD and just
always enable it. There are many reasons for doing this:

* CONFIG_FB_MATROX_MULTIHEAD=y is what all x86 distributions do, so it
definitely works or we would know by now.

* Building the matroxfb driver with CONFIG_FB_MATROX_MULTIHEAD not set
results in the following build warning:

drivers/video/matrox/matroxfb_crtc2.c: In function 'matroxfb_dh_open':
drivers/video/matrox/matroxfb_crtc2.c:265: warning: the address of 'matroxfb_global_mxinfo' will always evaluate as 'true'
drivers/video/matrox/matroxfb_crtc2.c: In function 'matroxfb_dh_release':
drivers/video/matrox/matroxfb_crtc2.c:285: warning: the address of 'matroxfb_global_mxinfo' will always evaluate as 'true'

This is nothing to be worried about, the driver will work fine, but build
warnings are still annoying.

* The trick to get multihead support without CONFIG_FB_MATROX_MULTIHEAD,
which is described in the config help text, no longer works: you can't
load the same kernel module more than once.

* I fail to see how CONFIG_FB_MATROX_MULTIHEAD=y would make the code
significantly slower, contrary to what the help text says. A few extra
parameters on the stack here and there can't really slow things down in
comaprison to the rest of the code, and register access.

* The driver built without CONFIG_FB_MATROX_MULTIHEAD is larger than the
driver build with CONFIG_FB_MATROX_MULTIHEAD=y by 8%.

* One less configuration option makes things simpler. We add options
all the time, being able to remove one for once is nice. It improves
testing coverage. And I don't think the Matrox adapters are still
popular enough to warrant overdetailed configuration settings.

* We should be able to unobfuscate the driver code quite a bit after
this change (patches follow.)

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Acked-by: Petr Vandrovec <vandrove@vc.cvut.cz>
Cc: Krzysztof Helt <krzysztof.h1@poczta.fm>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Jean Delvare and committed by
Linus Torvalds
0728bacb 0fcf6ada

+1 -70
+1 -3
Documentation/fb/matroxfb.txt
··· 186 186 dev:X - bind driver to device X. Driver numbers device from 0 up to N, 187 187 where device 0 is first `known' device found, 1 second and so on. 188 188 lspci lists devices in this order. 189 - Default is `every' known device for driver with multihead support 190 - and first working device (usually dev:0) for driver without 191 - multihead support. 189 + Default is `every' known device. 192 190 nohwcursor - disables hardware cursor (use software cursor instead). 193 191 hwcursor - enables hardware cursor. It is default. If you are using 194 192 non-accelerated mode (`noaccel' or `fbset -accel false'), software
-20
drivers/video/Kconfig
··· 1275 1275 painting procedures (the secondary head does not use acceleration 1276 1276 engine). 1277 1277 1278 - config FB_MATROX_MULTIHEAD 1279 - bool "Multihead support" 1280 - depends on FB_MATROX 1281 - ---help--- 1282 - Say Y here if you have more than one (supported) Matrox device in 1283 - your computer and you want to use all of them for different monitors 1284 - ("multihead"). If you have only one device, you should say N because 1285 - the driver compiled with Y is larger and a bit slower, especially on 1286 - ia32 (ix86). 1287 - 1288 - If you said M to "Matrox unified accelerated driver" and N here, you 1289 - will still be able to use several Matrox devices simultaneously: 1290 - insert several instances of the module matroxfb into the kernel 1291 - with insmod, supplying the parameter "dev=N" where N is 0, 1, etc. 1292 - for the different Matrox devices. This method is slightly faster but 1293 - uses 40 KB of kernel memory per Matrox card. 1294 - 1295 - There is no need for enabling 'Matrox multihead support' if you have 1296 - only one Matrox card in the box. 1297 - 1298 1278 config FB_RADEON 1299 1279 tristate "ATI Radeon display support" 1300 1280 depends on FB && PCI
-23
drivers/video/matrox/matroxfb_base.c
··· 379 379 mga_iounmap(ACCESS_FBINFO(video.vbase)); 380 380 release_mem_region(ACCESS_FBINFO(video.base), ACCESS_FBINFO(video.len_maximum)); 381 381 release_mem_region(ACCESS_FBINFO(mmio.base), 16384); 382 - #ifdef CONFIG_FB_MATROX_MULTIHEAD 383 382 kfree(minfo); 384 - #endif 385 383 } 386 384 387 385 /* ··· 642 644 unsigned blue, unsigned transp, 643 645 struct fb_info *fb_info) 644 646 { 645 - #ifdef CONFIG_FB_MATROX_MULTIHEAD 646 647 struct matrox_fb_info* minfo = container_of(fb_info, struct matrox_fb_info, fbcon); 647 - #endif 648 648 649 649 DBG(__func__) 650 650 ··· 2007 2011 struct matrox_fb_info* minfo; 2008 2012 int err; 2009 2013 u_int32_t cmd; 2010 - #ifndef CONFIG_FB_MATROX_MULTIHEAD 2011 - static int registered = 0; 2012 - #endif 2013 2014 DBG(__func__) 2014 2015 2015 2016 svid = pdev->subsystem_vendor; ··· 2030 2037 return -1; 2031 2038 } 2032 2039 2033 - #ifdef CONFIG_FB_MATROX_MULTIHEAD 2034 2040 minfo = kmalloc(sizeof(*minfo), GFP_KERNEL); 2035 2041 if (!minfo) 2036 2042 return -1; 2037 - #else 2038 - if (registered) /* singlehead driver... */ 2039 - return -1; 2040 - minfo = &matroxfb_global_mxinfo; 2041 - #endif 2042 2043 memset(MINFO, 0, sizeof(*MINFO)); 2043 2044 2044 2045 ACCESS_FBINFO(pcidev) = pdev; ··· 2077 2090 2078 2091 err = initMatrox2(PMINFO b); 2079 2092 if (!err) { 2080 - #ifndef CONFIG_FB_MATROX_MULTIHEAD 2081 - registered = 1; 2082 - #endif 2083 2093 matroxfb_register_device(MINFO); 2084 2094 return 0; 2085 2095 } 2086 - #ifdef CONFIG_FB_MATROX_MULTIHEAD 2087 2096 kfree(minfo); 2088 - #endif 2089 2097 return -1; 2090 2098 } 2091 2099 ··· 2492 2510 MODULE_PARM_DESC(inv24, "Inverts clock polarity for 24bpp and loop frequency > 100MHz (default=do not invert polarity)"); 2493 2511 module_param(inverse, int, 0); 2494 2512 MODULE_PARM_DESC(inverse, "Inverse (0 or 1) (default=0)"); 2495 - #ifdef CONFIG_FB_MATROX_MULTIHEAD 2496 2513 module_param(dev, int, 0); 2497 2514 MODULE_PARM_DESC(dev, "Multihead support, attach to device ID (0..N) (default=all working)"); 2498 - #else 2499 - module_param(dev, int, 0); 2500 - MODULE_PARM_DESC(dev, "Multihead support, attach to device ID (0..N) (default=first working)"); 2501 - #endif 2502 2515 module_param(vesa, int, 0); 2503 2516 MODULE_PARM_DESC(vesa, "Startup videomode (0x000-0x1FF) (default=0x101)"); 2504 2517 module_param(xres, int, 0);
-20
drivers/video/matrox/matroxfb_base.h
··· 524 524 525 525 #define info2minfo(info) container_of(info, struct matrox_fb_info, fbcon) 526 526 527 - #ifdef CONFIG_FB_MATROX_MULTIHEAD 528 527 #define ACCESS_FBINFO2(info, x) (info->x) 529 528 #define ACCESS_FBINFO(x) ACCESS_FBINFO2(minfo,x) 530 529 ··· 537 538 #define PMINFO PMINFO2 , 538 539 539 540 #define MINFO_FROM(x) struct matrox_fb_info* minfo = x 540 - #else 541 - 542 - extern struct matrox_fb_info matroxfb_global_mxinfo; 543 - 544 - #define ACCESS_FBINFO(x) (matroxfb_global_mxinfo.x) 545 - #define ACCESS_FBINFO2(info, x) (matroxfb_global_mxinfo.x) 546 - 547 - #define MINFO (&matroxfb_global_mxinfo) 548 - 549 - #define WPMINFO2 void 550 - #define WPMINFO 551 - #define CPMINFO2 void 552 - #define CPMINFO 553 - #define PMINFO2 554 - #define PMINFO 555 - 556 - #define MINFO_FROM(x) 557 - 558 - #endif 559 541 560 542 #define MINFO_FROM_INFO(x) MINFO_FROM(info2minfo(x)) 561 543
-4
drivers/video/matrox/matroxfb_misc.c
··· 784 784 EXPORT_SYMBOL(matroxfb_DAC_out); 785 785 EXPORT_SYMBOL(matroxfb_var2my); 786 786 EXPORT_SYMBOL(matroxfb_PLL_calcclock); 787 - #ifndef CONFIG_FB_MATROX_MULTIHEAD 788 - struct matrox_fb_info matroxfb_global_mxinfo; 789 - EXPORT_SYMBOL(matroxfb_global_mxinfo); 790 - #endif 791 787 EXPORT_SYMBOL(matroxfb_vgaHWinit); /* DAC1064, Ti3026 */ 792 788 EXPORT_SYMBOL(matroxfb_vgaHWrestore); /* DAC1064, Ti3026 */ 793 789 EXPORT_SYMBOL(matroxfb_read_pins);