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

V4L/DVB (5884): zr36067: clean up debug function

Debugging cleanups to the zr36067 driver:

* Use module_param_named() to declare the debug parameter, so we can
use a single global variable to handle the debug level. This makes
the driver a bit smaller (by 648 bytes on x86_64), thanks to one
less level of indirection on every use.

* Change the debug parameter sysfs permissions, so that the debug
level can be adjusted at runtime, as is done in many other
media/video drivers.

* The debug level is between 0 and 5, not 0 and 4.

* Move the zr_debug export and dprintk macro definition to a header
file so that we don't have to define them in each source file.

* Simplify a duplicate test on zr_debug.

Note that zr_debug was subsequently renamed to debug_zr36067 to avoid
possible conflicts with other Zoran device drivers, on a suggestion
by Trent Piepho.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Trent Piepho <xyzzy@speakeasy.org>
Acked-by: Ronald S. Bultje <rbultje@ronald.bitfreak.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>

authored by

Jean Delvare and committed by
Mauro Carvalho Chehab
18b548ca 63116feb

+25 -48
+6 -13
drivers/media/video/zoran_card.c
··· 145 145 MODULE_PARM_DESC(pass_through, 146 146 "Pass TV signal through to TV-out when idling"); 147 147 148 - static int debug = 1; 149 - int *zr_debug = &debug; 150 - module_param(debug, int, 0); 151 - MODULE_PARM_DESC(debug, "Debug level (0-4)"); 148 + int zr36067_debug = 1; 149 + module_param_named(debug, zr36067_debug, int, 0644); 150 + MODULE_PARM_DESC(debug, "Debug level (0-5)"); 152 151 153 152 MODULE_DESCRIPTION("Zoran-36057/36067 JPEG codec driver"); 154 153 MODULE_AUTHOR("Serguei Miridonov"); ··· 159 160 {0} 160 161 }; 161 162 MODULE_DEVICE_TABLE(pci, zr36067_pci_tbl); 162 - 163 - #define dprintk(num, format, args...) \ 164 - do { \ 165 - if (*zr_debug >= num) \ 166 - printk(format, ##args); \ 167 - } while (0) 168 163 169 164 int zoran_num; /* number of Buzs in use */ 170 165 struct zoran zoran[BUZ_MAX]; ··· 1068 1075 if (timeout) { 1069 1076 dprintk(1, ": time spent: %d\n", 1 * HZ - timeout); 1070 1077 } 1071 - if (*zr_debug > 1) 1078 + if (zr36067_debug > 1) 1072 1079 print_interrupts(zr); 1073 1080 btwrite(icr, ZR36057_ICR); 1074 1081 } ··· 1151 1158 goto exit_unregister; 1152 1159 1153 1160 zoran_init_hardware(zr); 1154 - if (*zr_debug > 2) 1161 + if (zr36067_debug > 2) 1155 1162 detect_guest_activity(zr); 1156 1163 test_interrupts(zr); 1157 1164 if (!pass_through) { ··· 1613 1620 } 1614 1621 1615 1622 /* random nonsense */ 1616 - dprintk(5, KERN_DEBUG "Jotti is een held!\n"); 1623 + dprintk(6, KERN_DEBUG "Jotti is een held!\n"); 1617 1624 1618 1625 /* some mainboards might not do PCI-PCI data transfer well */ 1619 1626 if (pci_pci_problems & (PCIPCI_FAIL|PCIAGP_FAIL|PCIPCI_ALIMAGIK)) {
+8
drivers/media/video/zoran_card.h
··· 30 30 #ifndef __ZORAN_CARD_H__ 31 31 #define __ZORAN_CARD_H__ 32 32 33 + extern int zr36067_debug; 34 + 35 + #define dprintk(num, format, args...) \ 36 + do { \ 37 + if (zr36067_debug >= num) \ 38 + printk(format, ##args); \ 39 + } while (0) 40 + 33 41 /* Anybody who uses more than four? */ 34 42 #define BUZ_MAX 4 35 43 extern int zoran_num;
+5 -12
drivers/media/video/zoran_device.c
··· 52 52 #include "videocodec.h" 53 53 #include "zoran.h" 54 54 #include "zoran_device.h" 55 + #include "zoran_card.h" 55 56 56 57 #define IRQ_MASK ( ZR36057_ISR_GIRQ0 | \ 57 58 ZR36057_ISR_GIRQ1 | \ 58 59 ZR36057_ISR_JPEGRepIRQ ) 59 60 60 61 extern const struct zoran_format zoran_formats[]; 61 - 62 - extern int *zr_debug; 63 - 64 - #define dprintk(num, format, args...) \ 65 - do { \ 66 - if (*zr_debug >= num) \ 67 - printk(format, ##args); \ 68 - } while (0) 69 62 70 63 static int lml33dpath = 0; /* 1 will use digital path in capture 71 64 * mode instead of analog. It can be ··· 167 174 static void 168 175 dump_guests (struct zoran *zr) 169 176 { 170 - if (*zr_debug > 2) { 177 + if (zr36067_debug > 2) { 171 178 int i, guest[8]; 172 179 173 180 for (i = 1; i < 8; i++) { // Don't read jpeg codec here ··· 1264 1271 zr->num_errors++; 1265 1272 1266 1273 /* Report error */ 1267 - if (*zr_debug > 1 && zr->num_errors <= 8) { 1274 + if (zr36067_debug > 1 && zr->num_errors <= 8) { 1268 1275 long frame; 1269 1276 frame = 1270 1277 zr->jpg_pend[zr->jpg_dma_tail & BUZ_MASK_FRAME]; ··· 1524 1531 1525 1532 if (zr->codec_mode == BUZ_MODE_MOTION_DECOMPRESS || 1526 1533 zr->codec_mode == BUZ_MODE_MOTION_COMPRESS) { 1527 - if (*zr_debug > 1 && 1534 + if (zr36067_debug > 1 && 1528 1535 (!zr->frame_num || zr->JPEG_error)) { 1529 1536 printk(KERN_INFO 1530 1537 "%s: first frame ready: state=0x%08x odd_even=%d field_per_buff=%d delay=%d\n", ··· 1561 1568 zr->JPEG_missed; 1562 1569 } 1563 1570 1564 - if (*zr_debug > 2 && zr->frame_num < 6) { 1571 + if (zr36067_debug > 2 && zr->frame_num < 6) { 1565 1572 int i; 1566 1573 printk("%s: seq=%ld stat_com:", 1567 1574 ZR_DEVNAME(zr), zr->jpg_seq_num);
+5 -15
drivers/media/video/zoran_driver.c
··· 200 200 // RJ: Test only - want to test BUZ_USE_HIMEM even when CONFIG_BIGPHYS_AREA is defined 201 201 202 202 203 - extern int *zr_debug; 204 - 205 - #define dprintk(num, format, args...) \ 206 - do { \ 207 - if (*zr_debug >= num) \ 208 - printk(format, ##args); \ 209 - } while (0) 210 - 211 203 extern int v4l_nbufs; 212 204 extern int v4l_bufsize; 213 205 extern int jpg_nbufs; ··· 1098 1106 frame = zr->jpg_pend[zr->jpg_que_tail & BUZ_MASK_FRAME]; 1099 1107 1100 1108 /* buffer should now be in BUZ_STATE_DONE */ 1101 - if (*zr_debug > 0) 1102 - if (zr->jpg_buffers.buffer[frame].state != BUZ_STATE_DONE) 1103 - dprintk(2, 1104 - KERN_ERR 1105 - "%s: jpg_sync() - internal state error\n", 1106 - ZR_DEVNAME(zr)); 1109 + if (zr->jpg_buffers.buffer[frame].state != BUZ_STATE_DONE) 1110 + dprintk(2, 1111 + KERN_ERR "%s: jpg_sync() - internal state error\n", 1112 + ZR_DEVNAME(zr)); 1107 1113 1108 1114 *bs = zr->jpg_buffers.buffer[frame].bs; 1109 1115 bs->frame = frame; ··· 1379 1389 /* disable interrupts */ 1380 1390 btand(~ZR36057_ICR_IntPinEn, ZR36057_ICR); 1381 1391 1382 - if (*zr_debug > 1) 1392 + if (zr36067_debug > 1) 1383 1393 print_interrupts(zr); 1384 1394 1385 1395 /* Overlay off */
+1 -8
drivers/media/video/zoran_procfs.c
··· 48 48 #include "videocodec.h" 49 49 #include "zoran.h" 50 50 #include "zoran_procfs.h" 51 - 52 - extern int *zr_debug; 53 - 54 - #define dprintk(num, format, args...) \ 55 - do { \ 56 - if (*zr_debug >= num) \ 57 - printk(format, ##args); \ 58 - } while (0) 51 + #include "zoran_card.h" 59 52 60 53 #ifdef CONFIG_PROC_FS 61 54 struct procfs_params_zr36067 {