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

ALSA: opl3: Use standard print API

Use the standard print API with dev_*() instead of the old house-baked
one. It gives better information and allows dynamically control of
debug prints.

Some debug prints are cleaned up with a macro, too.

Reviewed-by: Jaroslav Kysela <perex@perex.cz>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Link: https://patch.msgid.link/20240807133452.9424-7-tiwai@suse.de

+56 -73
+8 -10
sound/drivers/opl3/opl3_lib.c
··· 92 92 opl3->command(opl3, OPL3_LEFT | OPL3_REG_TIMER_CONTROL, OPL3_IRQ_RESET); 93 93 signature = stat1 = inb(opl3->l_port); /* Status register */ 94 94 if ((stat1 & 0xe0) != 0x00) { /* Should be 0x00 */ 95 - snd_printd("OPL3: stat1 = 0x%x\n", stat1); 95 + dev_dbg(opl3->card->dev, "OPL3: stat1 = 0x%x\n", stat1); 96 96 return -ENODEV; 97 97 } 98 98 /* Set timer1 to 0xff */ ··· 108 108 /* Reset the IRQ of the FM chip */ 109 109 opl3->command(opl3, OPL3_LEFT | OPL3_REG_TIMER_CONTROL, OPL3_IRQ_RESET); 110 110 if ((stat2 & 0xe0) != 0xc0) { /* There is no YM3812 */ 111 - snd_printd("OPL3: stat2 = 0x%x\n", stat2); 111 + dev_dbg(opl3->card->dev, "OPL3: stat2 = 0x%x\n", stat2); 112 112 return -ENODEV; 113 113 } 114 114 ··· 289 289 290 290 opl3 = hw->private_data; 291 291 status = inb(opl3->l_port); 292 - #if 0 293 - snd_printk(KERN_DEBUG "AdLib IRQ status = 0x%x\n", status); 294 - #endif 295 292 if (!(status & 0x80)) 296 293 return; 297 294 ··· 362 365 int snd_opl3_init(struct snd_opl3 *opl3) 363 366 { 364 367 if (! opl3->command) { 365 - printk(KERN_ERR "snd_opl3_init: command not defined!\n"); 368 + dev_err(opl3->card->dev, 369 + "snd_opl3_init: command not defined!\n"); 366 370 return -EINVAL; 367 371 } 368 372 ··· 403 405 if (! integrated) { 404 406 opl3->res_l_port = request_region(l_port, 2, "OPL2/3 (left)"); 405 407 if (!opl3->res_l_port) { 406 - snd_printk(KERN_ERR "opl3: can't grab left port 0x%lx\n", l_port); 408 + dev_err(card->dev, "opl3: can't grab left port 0x%lx\n", l_port); 407 409 snd_device_free(card, opl3); 408 410 return -EBUSY; 409 411 } 410 412 if (r_port != 0) { 411 413 opl3->res_r_port = request_region(r_port, 2, "OPL2/3 (right)"); 412 414 if (!opl3->res_r_port) { 413 - snd_printk(KERN_ERR "opl3: can't grab right port 0x%lx\n", r_port); 415 + dev_err(card->dev, "opl3: can't grab right port 0x%lx\n", r_port); 414 416 snd_device_free(card, opl3); 415 417 return -EBUSY; 416 418 } ··· 430 432 opl3->command = &snd_opl2_command; 431 433 err = snd_opl3_detect(opl3); 432 434 if (err < 0) { 433 - snd_printd("OPL2/3 chip not detected at 0x%lx/0x%lx\n", 434 - opl3->l_port, opl3->r_port); 435 + dev_dbg(card->dev, "OPL2/3 chip not detected at 0x%lx/0x%lx\n", 436 + opl3->l_port, opl3->r_port); 435 437 snd_device_free(card, opl3); 436 438 return err; 437 439 }
+40 -55
sound/drivers/opl3/opl3_midi.c
··· 11 11 #include "opl3_voice.h" 12 12 #include <sound/asoundef.h> 13 13 14 + #ifdef DEBUG_MIDI 15 + #define opl3_dbg(opl3, fmt, ...) \ 16 + dev_dbg(((struct snd_opl3 *)(opl3))->card->dev, fmt, ##__VA_ARGS__) 17 + #else 18 + #define opl3_dbg(opl3, fmt, ...) do {} while (0) 19 + #endif 20 + 14 21 static void snd_opl3_note_off_unsafe(void *p, int note, int vel, 15 22 struct snd_midi_channel *chan); 16 23 /* ··· 114 107 115 108 116 109 #ifdef DEBUG_ALLOC 117 - static void debug_alloc(struct snd_opl3 *opl3, char *s, int voice) { 110 + static void debug_alloc(struct snd_opl3 *opl3, char *s, int voice) 111 + { 118 112 int i; 119 - char *str = "x.24"; 113 + const char *str = "x.24"; 114 + char buf[MAX_OPL3_VOICES + 1]; 120 115 121 - printk(KERN_DEBUG "time %.5i: %s [%.2i]: ", opl3->use_time, s, voice); 122 116 for (i = 0; i < opl3->max_voices; i++) 123 - printk(KERN_CONT "%c", *(str + opl3->voices[i].state + 1)); 124 - printk(KERN_CONT "\n"); 117 + buf[i] = str[opl3->voices[i].state + 1]; 118 + buf[i] = 0; 119 + dev_dbg(opl3->card->dev, "time %.5i: %s [%.2i]: %s\n", 120 + opl3->use_time, s, voice, buf); 125 121 } 126 122 #endif 127 123 ··· 213 203 for (i = 0; i < END; i++) { 214 204 if (best[i].voice >= 0) { 215 205 #ifdef DEBUG_ALLOC 216 - printk(KERN_DEBUG "%s %iop allocation on voice %i\n", 217 - alloc_type[i], instr_4op ? 4 : 2, 218 - best[i].voice); 206 + dev_dbg(opl3->card->dev, 207 + "%s %iop allocation on voice %i\n", 208 + alloc_type[i], instr_4op ? 4 : 2, 209 + best[i].voice); 219 210 #endif 220 211 return best[i].voice; 221 212 } ··· 313 302 314 303 opl3 = p; 315 304 316 - #ifdef DEBUG_MIDI 317 - snd_printk(KERN_DEBUG "Note on, ch %i, inst %i, note %i, vel %i\n", 318 - chan->number, chan->midi_program, note, vel); 319 - #endif 305 + opl3_dbg(opl3, "Note on, ch %i, inst %i, note %i, vel %i\n", 306 + chan->number, chan->midi_program, note, vel); 320 307 321 308 /* in SYNTH mode, application takes care of voices */ 322 309 /* in SEQ mode, drum voice numbers are notes on drum channel */ ··· 367 358 spin_unlock_irqrestore(&opl3->voice_lock, flags); 368 359 return; 369 360 } 370 - #ifdef DEBUG_MIDI 371 - snd_printk(KERN_DEBUG " --> OPL%i instrument: %s\n", 372 - instr_4op ? 3 : 2, patch->name); 373 - #endif 361 + opl3_dbg(opl3, " --> OPL%i instrument: %s\n", 362 + instr_4op ? 3 : 2, patch->name); 374 363 /* in SYNTH mode, application takes care of voices */ 375 364 /* in SEQ mode, allocate voice on free OPL3 channel */ 376 365 if (opl3->synth_mode == SNDRV_OPL3_MODE_SEQ) { ··· 429 422 } 430 423 } 431 424 432 - #ifdef DEBUG_MIDI 433 - snd_printk(KERN_DEBUG " --> setting OPL3 connection: 0x%x\n", 434 - opl3->connection_reg); 435 - #endif 425 + opl3_dbg(opl3, " --> setting OPL3 connection: 0x%x\n", 426 + opl3->connection_reg); 436 427 /* 437 428 * calculate volume depending on connection 438 429 * between FM operators (see include/opl3.h) ··· 462 457 463 458 /* Program the FM voice characteristics */ 464 459 for (i = 0; i < (instr_4op ? 4 : 2); i++) { 465 - #ifdef DEBUG_MIDI 466 - snd_printk(KERN_DEBUG " --> programming operator %i\n", i); 467 - #endif 460 + opl3_dbg(opl3, " --> programming operator %i\n", i); 468 461 op_offset = snd_opl3_regmap[voice_offset][i]; 469 462 470 463 /* Set OPL3 AM_VIB register of requested voice/operator */ ··· 540 537 /* Set output sound flag */ 541 538 blocknum |= OPL3_KEYON_BIT; 542 539 543 - #ifdef DEBUG_MIDI 544 - snd_printk(KERN_DEBUG " --> trigger voice %i\n", voice); 545 - #endif 540 + opl3_dbg(opl3, " --> trigger voice %i\n", voice); 546 541 /* Set OPL3 KEYON_BLOCK register of requested voice */ 547 542 opl3_reg = reg_side | (OPL3_REG_KEYON_BLOCK + voice_offset); 548 543 opl3->command(opl3, opl3_reg, blocknum); ··· 594 593 bank = 0; 595 594 prg = extra_prg - 1; 596 595 } 597 - #ifdef DEBUG_MIDI 598 - snd_printk(KERN_DEBUG " *** allocating extra program\n"); 599 - #endif 596 + opl3_dbg(opl3, " *** allocating extra program\n"); 600 597 goto __extra_prg; 601 598 } 602 599 spin_unlock_irqrestore(&opl3->voice_lock, flags); ··· 623 624 } 624 625 625 626 /* kill voice */ 626 - #ifdef DEBUG_MIDI 627 - snd_printk(KERN_DEBUG " --> kill voice %i\n", voice); 628 - #endif 627 + opl3_dbg(opl3, " --> kill voice %i\n", voice); 629 628 opl3_reg = reg_side | (OPL3_REG_KEYON_BLOCK + voice_offset); 630 629 /* clear Key ON bit */ 631 630 opl3->command(opl3, opl3_reg, vp->keyon_reg); ··· 657 660 658 661 opl3 = p; 659 662 660 - #ifdef DEBUG_MIDI 661 - snd_printk(KERN_DEBUG "Note off, ch %i, inst %i, note %i\n", 662 - chan->number, chan->midi_program, note); 663 - #endif 663 + opl3_dbg(opl3, "Note off, ch %i, inst %i, note %i\n", 664 + chan->number, chan->midi_program, note); 664 665 665 666 if (opl3->synth_mode == SNDRV_OPL3_MODE_SEQ) { 666 667 if (chan->drum_channel && use_internal_drums) { ··· 698 703 */ 699 704 void snd_opl3_key_press(void *p, int note, int vel, struct snd_midi_channel *chan) 700 705 { 701 - #ifdef DEBUG_MIDI 702 - snd_printk(KERN_DEBUG "Key pressure, ch#: %i, inst#: %i\n", 703 - chan->number, chan->midi_program); 704 - #endif 706 + opl3_dbg(p, "Key pressure, ch#: %i, inst#: %i\n", 707 + chan->number, chan->midi_program); 705 708 } 706 709 707 710 /* ··· 707 714 */ 708 715 void snd_opl3_terminate_note(void *p, int note, struct snd_midi_channel *chan) 709 716 { 710 - #ifdef DEBUG_MIDI 711 - snd_printk(KERN_DEBUG "Terminate note, ch#: %i, inst#: %i\n", 712 - chan->number, chan->midi_program); 713 - #endif 717 + opl3_dbg(p, "Terminate note, ch#: %i, inst#: %i\n", 718 + chan->number, chan->midi_program); 714 719 } 715 720 716 721 static void snd_opl3_update_pitch(struct snd_opl3 *opl3, int voice) ··· 794 803 struct snd_opl3 *opl3; 795 804 796 805 opl3 = p; 797 - #ifdef DEBUG_MIDI 798 - snd_printk(KERN_DEBUG "Controller, TYPE = %i, ch#: %i, inst#: %i\n", 799 - type, chan->number, chan->midi_program); 800 - #endif 806 + opl3_dbg(opl3, "Controller, TYPE = %i, ch#: %i, inst#: %i\n", 807 + type, chan->number, chan->midi_program); 801 808 802 809 switch (type) { 803 810 case MIDI_CTL_MSB_MODWHEEL: ··· 826 837 void snd_opl3_nrpn(void *p, struct snd_midi_channel *chan, 827 838 struct snd_midi_channel_set *chset) 828 839 { 829 - #ifdef DEBUG_MIDI 830 - snd_printk(KERN_DEBUG "NRPN, ch#: %i, inst#: %i\n", 831 - chan->number, chan->midi_program); 832 - #endif 840 + opl3_dbg(p, "NRPN, ch#: %i, inst#: %i\n", 841 + chan->number, chan->midi_program); 833 842 } 834 843 835 844 /* ··· 836 849 void snd_opl3_sysex(void *p, unsigned char *buf, int len, 837 850 int parsed, struct snd_midi_channel_set *chset) 838 851 { 839 - #ifdef DEBUG_MIDI 840 - snd_printk(KERN_DEBUG "SYSEX\n"); 841 - #endif 852 + opl3_dbg(p, "SYSEX\n"); 842 853 }
+7 -5
sound/drivers/opl3/opl3_oss.c
··· 193 193 return -EINVAL; 194 194 195 195 if (count < (int)sizeof(sbi)) { 196 - snd_printk(KERN_ERR "FM Error: Patch record too short\n"); 196 + dev_err(opl3->card->dev, "FM Error: Patch record too short\n"); 197 197 return -EINVAL; 198 198 } 199 199 if (copy_from_user(&sbi, buf, sizeof(sbi))) 200 200 return -EFAULT; 201 201 202 202 if (sbi.channel < 0 || sbi.channel >= SBFM_MAXINSTR) { 203 - snd_printk(KERN_ERR "FM Error: Invalid instrument number %d\n", 203 + dev_err(opl3->card->dev, "FM Error: Invalid instrument number %d\n", 204 204 sbi.channel); 205 205 return -EINVAL; 206 206 } ··· 220 220 static int snd_opl3_ioctl_seq_oss(struct snd_seq_oss_arg *arg, unsigned int cmd, 221 221 unsigned long ioarg) 222 222 { 223 + struct snd_opl3 *opl3; 224 + 223 225 if (snd_BUG_ON(!arg)) 224 226 return -ENXIO; 227 + opl3 = arg->private_data; 225 228 switch (cmd) { 226 229 case SNDCTL_FM_LOAD_INSTR: 227 - snd_printk(KERN_ERR "OPL3: " 228 - "Obsolete ioctl(SNDCTL_FM_LOAD_INSTR) used. " 229 - "Fix the program.\n"); 230 + dev_err(opl3->card->dev, 231 + "OPL3: Obsolete ioctl(SNDCTL_FM_LOAD_INSTR) used. Fix the program.\n"); 230 232 return -EINVAL; 231 233 232 234 case SNDCTL_SYNTH_MEMAVL:
+1 -3
sound/drivers/opl3/opl3_synth.c
··· 158 158 return 0; 159 159 #endif 160 160 161 - #ifdef CONFIG_SND_DEBUG 162 161 default: 163 - snd_printk(KERN_WARNING "unknown IOCTL: 0x%x\n", cmd); 164 - #endif 162 + dev_dbg(opl3->card->dev, "unknown IOCTL: 0x%x\n", cmd); 165 163 } 166 164 return -ENOTTY; 167 165 }