[alsa-devel] [PATCH 00/48] Rewrite kernel messages with standard printk helpers

Takashi Iwai tiwai at suse.de
Fri Feb 28 07:28:06 CET 2014


At Fri, 28 Feb 2014 11:15:36 +0800,
Raymond Yau wrote:
> 
> > >
> > > > this is another long series of patches for trivial cleanups.
> > > > This time, they replace the printk and snd_print*() calls in ALSA PCI
> > > > and USB drivers with dev_err() and co.  This will give nicer and more
> > > > consistent outputs.
> > > >
> > > > The only drawback by these replacements is that alsa-info.sh won't be
> > > > able to catch the dmesg lines because it doesn't contain any longer
> > > > the word "ALSA", but only show the module name like "snd_intel8x0".
> > > >
> > > > I'm going to fix alsa-info.sh on git soon later, but if you guys think
> > > > "oh no it's disaster!", let me know.  We need to reconsider a better
> > > > way to put the known markers (like explicitly putting "ALSA" at the
> > > > beginning.)
> > > >
> > > >
> > > seem missing au88x0
> >
> > Yes, because some driver codes are horrible to work on.
> > Patches are welcome.
> >
> >
> since au8820 , au8830 and au8810 use different mmio address , the source of
> three modules , the driver use CHIP_AU8810 , CHIP_AU8820 and CHIP_AU8830
> for the chip specific code with #ifdef
> 
> 1) how to convert printk(KERN_INFO CARD_NAME ?

For KERN_INFO, use dev_info().  Take the device pointer that can be
reached from that point.  Usually the chip instance has the card
pointer, and the card pointer refers to dev, e.g. chip->card->dev.

The prefix CARD_NAME can be usually dropped since dev_info() prints
already the driver name.

If it's difficult to get the device pointer, you don't have to convert
to dev_info() at all.  But, often, it's easy to modify the function to
get the chip or card object.

> 2) do it need to remove "vortex:" at the beginning if dev_xxx function
> provide the name of the snd-au8830 ?

In most cases, you can drop it.  But this depends on context.
Judge from your common sense.

> 3) as Wavetable DMA is not working and au8820 and au8830 have different
> mmio address , au88x0_synth is not implemented as separate module

You don't have to worry about it; it's either totally irrelevant or
doesn't matter.

> 4) gameport and mput401_uart use card name in getting the resource and midi
> ports

It's only about printk.  Don't convert anything else.

> How do I get the source of topics/ctv-dev-prints ?

I don't understand your question.  What do you mean source?
The git tree is there as usual.
> 
> and
> 
> how do I provide path ?

You mean patch?  Just submit to ML.


thanks,

Takashi

> 
> 
> 
> au88x0_a3d.c-    /*
> au88x0_a3d.c:    printk(KERN_DEBUG "vortex: ZeroState slice: %d, source
> %d\n",
> au88x0_a3d.c-           a->slice, a->source);
> --
> au88x0_a3d.c-    if ((a->vortex) == NULL) {
> au88x0_a3d.c:        printk(KERN_ERR "vortex: ZeroStateA3D: ERROR:
> a->vortex is NULL\n");
> au88x0_a3d.c-        return;
> --
> au88x0_a3d.c-    if (v->mixxtlk[0] < 0) {
> au88x0_a3d.c:        printk
> au88x0_a3d.c-            ("vortex: vortex_Vort3D: ERROR: not enough free
> mixer resources.\n");
> --
> au88x0_a3d.c-    if (v->mixxtlk[1] < 0) {
> au88x0_a3d.c:        printk
> au88x0_a3d.c-            ("vortex: vortex_Vort3D: ERROR: not enough free
> mixer resources.\n");
> --
> au88x0_a3d.c-    if (a->vortex == NULL) {
> au88x0_a3d.c:        printk
> au88x0_a3d.c-            ("vortex: Vort3D_InitializeSource: A3D source not
> initialized\n");
> --
> au88x0.c-    if (!(rc = pci_write_config_byte(vortex, 0x40, 0xff))) {
> au88x0.c:            printk(KERN_INFO CARD_NAME
> au88x0.c-                   ": vortex latency is 0xff\n");
> au88x0.c-    } else {
> au88x0.c:        printk(KERN_WARNING CARD_NAME
> au88x0.c-                ": could not set vortex latency: pci error
> 0x%x\n", rc);
> --
> au88x0.c-                || !(rc = pci_write_config_byte(via, 0x42, value |
> 0x10)))) {
> au88x0.c:        printk(KERN_INFO CARD_NAME
> au88x0.c-                ": bridge config is 0x%x\n", value | 0x10);
> au88x0.c-    } else {
> au88x0.c:        printk(KERN_WARNING CARD_NAME
> au88x0.c-                ": could not set vortex latency: pci error
> 0x%x\n", rc);
> --
> au88x0.c-        if (via) {
> au88x0.c:            printk(KERN_INFO CARD_NAME ": Activating latency
> workaround...\n");
> au88x0.c-            vortex_fix_latency(vortex);
> --
> au88x0.c-        pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(32)) < 0) {
> au88x0.c:        printk(KERN_ERR "error to set DMA mask\n");
> au88x0.c-        pci_disable_device(pci);
> --
> au88x0.c-    if (!chip->mmio) {
> au88x0.c:        printk(KERN_ERR "MMIO area remap failed.\n");
> au88x0.c-        err = -ENOMEM;
> --
> au88x0.c-    if ((err = vortex_core_init(chip)) != 0) {
> au88x0.c:        printk(KERN_ERR "hw core init failed\n");
> au88x0.c-        goto core_out;
> --
> au88x0.c-                           chip)) != 0) {
> au88x0.c:        printk(KERN_ERR "cannot grab irq\n");
> au88x0.c-        goto irq_out;
> --
> au88x0.c-        || wave == NULL) {
> au88x0.c:        snd_printk(KERN_ERR "Can't initialize Aureal wavetable
> synth\n");
> au88x0.c-    } else {
> --
> au88x0.c-    if ((chip->rev) != 0xfe && (chip->rev) != 0xfa) {
> au88x0.c:        printk(KERN_ALERT
> au88x0.c-               "vortex: The revision (%x) of your card has not
> been seen before.\n",
> au88x0.c-               chip->rev);
> au88x0.c:        printk(KERN_ALERT
> au88x0.c-               "vortex: Please email the results of 'lspci -vv' to
> openvortex-dev at nongnu.org.\n");
> --
> au88x0_core.c-        temp = hwread(vortex->mmio, prev);
> au88x0_core.c:        //printk(KERN_INFO "vortex: mixAddWTD: while addr=%x,
> val=%x\n", prev, temp);
> au88x0_core.c-        if ((++lifeboat) > 0xf) {
> au88x0_core.c:            printk(KERN_ERR
> au88x0_core.c-                   "vortex_mixer_addWTD: lifeboat
> overflow\n");
> --
> au88x0_core.c-    if (((1 << ch) & eax) == 0) {
> au88x0_core.c:        printk(KERN_ERR "mix ALARM %x\n", eax);
> au88x0_core.c-        return 0;
> --
> au88x0_core.c-                   VORTEX_MIXER_RTBASE + (ebx << 2));
> au88x0_core.c:            //printk(KERN_INFO "vortex: mixdelWTD: 1 addr=%x,
> val=%x, src=%x\n", ebx, edx, src);
> au88x0_core.c-            while ((edx & 0xf) != mix) {
> au88x0_core.c-                if ((esi) > 0xf) {
> au88x0_core.c:                    printk(KERN_ERR
> au88x0_core.c-                           "vortex: mixdelWTD: error lifeboat
> overflow\n");
> --
> au88x0_core.c-                       VORTEX_MIXER_RTBASE + ebp);
> au88x0_core.c:                //printk(KERN_INFO "vortex: mixdelWTD: while
> addr=%x, val=%x\n", ebp, edx);
> au88x0_core.c-                esi++;
> --
> au88x0_core.c-                hwwrite(vortex->mmio, ebx, 0);
> au88x0_core.c:                //printk(KERN_INFO "vortex mixdelWTD between
> addr= 0x%x, val= 0x%x\n", ebp, edx);
> au88x0_core.c-            } else {    /* Delete last entry */
> --
> au88x0_core.c-                        (esp14 << 2), ebx);
> au88x0_core.c:                    //printk(KERN_INFO "vortex mixdelWTD last
> addr= 0x%x, val= 0x%x\n", esp14, ebx);
> au88x0_core.c-                }
> --
> au88x0_core.c-    } else {
> au88x0_core.c:        //printk(KERN_INFO "removed last mix\n");
> au88x0_core.c-        //7be0
> --
> au88x0_core.c-        if ((++lifeboat) > 0x9) {
> au88x0_core.c:            printk(KERN_ERR "Vortex: Src cvr fail\n");
> au88x0_core.c-            break;
> --
> au88x0_core.c-        if ((lifeboat++) > 15) {
> au88x0_core.c:            printk(KERN_ERR "Vortex: could not set src-%d
> from %d to %d\n",
> au88x0_core.c-                   src, hw_ratio, desired_ratio);
> --
> au88x0_core.c-    /* 0x30f00 e=g=1 esp10=0 ebp=f */
> au88x0_core.c:    //printk(KERN_INFO "vortex: SRC %d, d=0x%x, esi=0x%x,
> esp10=0x%x, ebp=0x%x\n", src, d, esi, esp10, ebp);
> au88x0_core.c-}
> --
> au88x0_core.c-        temp = hwread(vortex->mmio, prev);
> au88x0_core.c:        //printk(KERN_INFO "vortex: srcAddWTD: while addr=%x,
> val=%x\n", prev, temp);
> au88x0_core.c-        if ((++lifeboat) > 0xf) {
> au88x0_core.c:            printk(KERN_ERR
> au88x0_core.c-                   "vortex_src_addWTD: lifeboat overflow\n");
> --
> au88x0_core.c-    if (((1 << ch) & eax) == 0) {
> au88x0_core.c:        printk(KERN_ERR "src alarm\n");
> au88x0_core.c-        return 0;
> --
> au88x0_core.c-                   VORTEX_SRC_RTBASE + (ebx << 2));
> au88x0_core.c:            //printk(KERN_INFO "vortex: srcdelWTD: 1 addr=%x,
> val=%x, src=%x\n", ebx, edx, src);
> au88x0_core.c-            while ((edx & 0xf) != src) {
> au88x0_core.c-                if ((esi) > 0xf) {
> au88x0_core.c:                    printk
> au88x0_core.c-                        ("vortex: srcdelWTD: error, lifeboat
> overflow\n");
> --
> au88x0_core.c-                       VORTEX_SRC_RTBASE + ebp);
> au88x0_core.c:                //printk(KERN_INFO "vortex: srcdelWTD: while
> addr=%x, val=%x\n", ebp, edx);
> au88x0_core.c-                esi++;
> --
> au88x0_core.c-                hwwrite(vortex->mmio, ebx, 0);
> au88x0_core.c:                //printk(KERN_INFO "vortex srcdelWTD between
> addr= 0x%x, val= 0x%x\n", ebp, edx);
> au88x0_core.c-            } else {    /* Delete last entry */
> --
> au88x0_core.c-                        (esp14 << 2), ebx);
> au88x0_core.c:                    //printk(KERN_INFO"vortex srcdelWTD last
> addr= 0x%x, val= 0x%x\n", esp14, ebx);
> au88x0_core.c-                }
> --
> au88x0_core.c-        if (lifeboat++ > 0xbb8) {
> au88x0_core.c:            printk(KERN_ERR
> au88x0_core.c-                   "Vortex: vortex_fifo_setadbctrl fail\n");
> --
> au88x0_core.c-        if (lifeboat++ > 0xbb8) {
> au88x0_core.c:            printk(KERN_ERR "Vortex: vortex_fifo_setwtctrl
> fail\n");
> au88x0_core.c-            break;
> --
> au88x0_core.c-        if (lifeboat++ > 0xbb8) {
> au88x0_core.c:            printk(KERN_ERR "Vortex: vortex_fifo_setwtctrl
> fail (hanging)\n");
> au88x0_core.c-            break;
> --
> au88x0_core.c-        if (hwread(vortex->mmio, addr) != (FIFO_U0 | FIFO_U1))
> au88x0_core.c:            printk(KERN_ERR "bad adb fifo reset!");
> au88x0_core.c-        vortex_fifo_clearadbdata(vortex, x, FIFO_SIZE);
> --
> au88x0_core.c-        if (hwread(vortex->mmio, addr) != FIFO_U0)
> au88x0_core.c:            printk(KERN_ERR
> au88x0_core.c-                   "bad wt fifo reset (0x%08x, 0x%08x)!\n",
> --
> au88x0_core.c-    /*
> au88x0_core.c:    printk(KERN_DEBUG "vortex: cfg0 = 0x%x\nvortex:
> cfg1=0x%x\n",
> au88x0_core.c-           dma->cfg0, dma->cfg1);
> --
> au88x0_core.c-    if (delta != 1)
> au88x0_core.c:        printk(KERN_INFO "vortex: %d virt=%d, real=%d,
> delta=%d\n",
> au88x0_core.c-               adbdma, dma->period_virt, dma->period_real,
> delta);
> --
> au88x0_core.c-    if (delta != 1)
> au88x0_core.c:        printk(KERN_WARNING "vortex: wt virt = %d, delta =
> %d\n",
> au88x0_core.c-               dma->period_virt, delta);
> --
> au88x0_core.c-        if ((lifeboat++) > ADB_MASK) {
> au88x0_core.c:            printk(KERN_ERR
> au88x0_core.c-                   "vortex_adb_addroutes: unending route!
> 0x%x\n",
> --
> au88x0_core.c-        if (((lifeboat++) > ADB_MASK) || (temp == ADB_MASK)) {
> au88x0_core.c:            printk(KERN_ERR
> au88x0_core.c-                   "vortex_adb_delroutes: route not found!
> 0x%x\n",
> --
> au88x0_core.c-                      ADB_CODECOUT(1 + 4));
> au88x0_core.c:        /* printk(KERN_DEBUG "SDAC detected "); */
> au88x0_core.c-    }
> --
> au88x0_core.c-                /*
> au88x0_core.c:                printk(KERN_DEBUG
> au88x0_core.c-                       "vortex: ResManager: type %d out %d\n",
> --
> au88x0_core.c-                /*
> au88x0_core.c:                printk(KERN_DEBUG
> au88x0_core.c-                       "vortex: ResManager: type %d in %d\n",
> --
> au88x0_core.c-    }
> au88x0_core.c:    printk(KERN_ERR "vortex: FATAL: ResManager: resource type
> %d exhausted.\n", restype);
> au88x0_core.c-    return -ENOMEM;
> --
> au88x0_core.c-                       VORTEX_RESOURCE_LAST);
> au88x0_core.c:                printk(KERN_ERR "vortex: out of A3D sources.
> Sorry\n");
> au88x0_core.c-                return -EBUSY;
> --
> au88x0_core.c-    if (source == 0) {
> au88x0_core.c:        printk(KERN_ERR "vortex: missing irq source\n");
> au88x0_core.c-        return IRQ_NONE;
> --
> au88x0_core.c-        if (source & IRQ_FATAL) {
> au88x0_core.c:            printk(KERN_ERR "vortex: IRQ fatal error\n");
> au88x0_core.c-        }
> au88x0_core.c-        if (source & IRQ_PARITY) {
> au88x0_core.c:            printk(KERN_ERR "vortex: IRQ parity error\n");
> au88x0_core.c-        }
> au88x0_core.c-        if (source & IRQ_REG) {
> au88x0_core.c:            printk(KERN_ERR "vortex: IRQ reg error\n");
> au88x0_core.c-        }
> au88x0_core.c-        if (source & IRQ_FIFO) {
> au88x0_core.c:            printk(KERN_ERR "vortex: IRQ fifo error\n");
> au88x0_core.c-        }
> au88x0_core.c-        if (source & IRQ_DMA) {
> au88x0_core.c:            printk(KERN_ERR "vortex: IRQ dma error\n");
> au88x0_core.c-        }
> --
> au88x0_core.c-    if (!handled) {
> au88x0_core.c:        printk(KERN_ERR "vortex: unknown irq source %x\n",
> source);
> au88x0_core.c-    }
> --
> au88x0_core.c-        if (lifeboat++ > POLL_COUNT) {
> au88x0_core.c:            printk(KERN_ERR "vortex: ac97 codec stuck
> busy\n");
> au88x0_core.c-            return;
> --
> au88x0_core.c-        if (lifeboat++ > POLL_COUNT) {
> au88x0_core.c:            printk(KERN_ERR "vortex: ac97 codec stuck
> busy\n");
> au88x0_core.c-            return 0xffff;
> --
> au88x0_core.c-        if (lifeboat++ > POLL_COUNT) {
> au88x0_core.c:            printk(KERN_ERR "vortex: ac97 address never
> arrived\n");
> au88x0_core.c-            return 0xffff;
> --
> au88x0_core.c-
> au88x0_core.c:    printk(KERN_INFO "Vortex: init.... ");
> au88x0_core.c-    /* Hardware Init. */
> --
> au88x0_core.c-
> au88x0_core.c:    printk(KERN_INFO "done.\n");
> au88x0_core.c-    spin_lock_init(&vortex->lock);
> --
> au88x0_core.c-
> au88x0_core.c:    printk(KERN_INFO "Vortex: shutdown...");
> au88x0_core.c-#ifndef CHIP_AU8820
> --
> au88x0_core.c-
> au88x0_core.c:    printk(KERN_INFO "done.\n");
> au88x0_core.c-    return 0;
> --
> au88x0_core.c-        fmt = 0x8;
> au88x0_core.c:        printk(KERN_ERR "vortex: format unsupported %d\n",
> alsafmt);
> au88x0_core.c-        break;
> --
> au88x0_eq.c-    if (count != 20) {
> au88x0_eq.c:        printk(KERN_ERR "vortex: peak count error 20 != %d \n",
> count);
> au88x0_eq.c-        return -1;
> --
> au88x0_game.c-    if (!gp) {
> au88x0_game.c:        printk(KERN_ERR "vortex: cannot allocate memory for
> gameport\n");
> au88x0_game.c-        return -ENOMEM;
> --
> au88x0_mpu401.c-    if (temp != MPU401_ACK /*0xfe */ ) {
> au88x0_mpu401.c:        printk(KERN_ERR "midi port doesn't acknowledge!\n");
> au88x0_mpu401.c-        return -ENODEV;
> --
> au88x0_pcm.c-    if (err < 0) {
> au88x0_pcm.c:        printk(KERN_ERR "Vortex: pcm page alloc failed!\n");
> au88x0_pcm.c-        return err;
> --
> au88x0_pcm.c-    /*
> au88x0_pcm.c:       printk(KERN_INFO "Vortex: periods %d, period_bytes %d,
> channels = %d\n", params_periods(hw_params),
> au88x0_pcm.c-       params_period_bytes(hw_params),
> params_channels(hw_params));
> --
> au88x0_pcm.c-        // do something to start the PCM engine
> au88x0_pcm.c:        //printk(KERN_INFO "vortex: start %d\n", dma);
> au88x0_pcm.c-        stream->fifo_enabled = 1;
> --
> au88x0_pcm.c-        else {
> au88x0_pcm.c:            printk(KERN_INFO "vortex: wt start %d\n", dma);
> au88x0_pcm.c-            vortex_wtdma_startfifo(chip, dma);
> --
> au88x0_pcm.c-        // do something to stop the PCM engine
> au88x0_pcm.c:        //printk(KERN_INFO "vortex: stop %d\n", dma);
> au88x0_pcm.c-        stream->fifo_enabled = 0;
> --
> au88x0_pcm.c-        else {
> au88x0_pcm.c:            printk(KERN_INFO "vortex: wt stop %d\n", dma);
> au88x0_pcm.c-            vortex_wtdma_stopfifo(chip, dma);
> --
> au88x0_pcm.c-    case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
> au88x0_pcm.c:        //printk(KERN_INFO "vortex: pause %d\n", dma);
> au88x0_pcm.c-        if (VORTEX_PCM_TYPE(substream->pcm) != VORTEX_PCM_WT)
> --
> au88x0_pcm.c-    case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
> au88x0_pcm.c:        //printk(KERN_INFO "vortex: resume %d\n", dma);
> au88x0_pcm.c-        if (VORTEX_PCM_TYPE(substream->pcm) != VORTEX_PCM_WT)
> --
> au88x0_pcm.c-#endif
> au88x0_pcm.c:    //printk(KERN_INFO "vortex: pointer = 0x%x\n",
> current_ptr);
> au88x0_pcm.c-    spin_unlock(&chip->lock);
> --
> au88x0_synth.c-    temp = hwread(vortex->mmio, WT_PARM(wt, 3));
> au88x0_synth.c:    printk(KERN_DEBUG "vortex: WT PARM3: %x\n", temp);
> au88x0_synth.c-    //hwwrite(vortex->mmio, WT_PARM(wt, 3), temp);
> --
> au88x0_synth.c-
> au88x0_synth.c:    printk(KERN_DEBUG "vortex: WT GMODE: %x\n",
> hwread(vortex->mmio, WT_GMODE(wt)));
> au88x0_synth.c-
> --
> au88x0_synth.c-    hwwrite(vortex->mmio, WT_PARM(wt, 1), voice->parm1);
> au88x0_synth.c:    printk(KERN_DEBUG "vortex: WT GMODE 2 : %x\n",
> hwread(vortex->mmio, WT_GMODE(wt)));
> au88x0_synth.c-    return 0;
> --
> au88x0_synth.c-        if (wt >= (NR_WT / NR_WT_PB)) {
> au88x0_synth.c:            printk
> au88x0_synth.c-                ("vortex: WT SetReg: bank out of range.
> reg=0x%x, wt=%d\n",
> --
> au88x0_synth.c-        if (wt >= NR_WT) {
> au88x0_synth.c:            printk(KERN_ERR "vortex: WT SetReg: voice out of
> range\n");
> au88x0_synth.c-            return 0;
> --
> au88x0_synth.c-        /*
> au88x0_synth.c:        printk(KERN_DEBUG "vortex: WT SetReg(0x%x) =
> 0x%08x\n",
> au88x0_synth.c-               WT_RUN(wt), (int)val);
> --
> au88x0_synth.c-        /*
> au88x0_synth.c:        printk(KERN_DEBUG "vortex: WT SetReg(0x%x) =
> 0x%08x\n",
> au88x0_synth.c-               WT_PARM(wt,0), (int)val);
> --
> au88x0_synth.c-        /*
> au88x0_synth.c:        printk(KERN_DEBUG "vortex: WT SetReg(0x%x) =
> 0x%08x\n",
> au88x0_synth.c-               WT_PARM(wt,1), (int)val);
> --
> au88x0_synth.c-        /*
> au88x0_synth.c:        printk(KERN_DEBUG "vortex: WT SetReg(0x%x) =
> 0x%08x\n",
> au88x0_synth.c-               WT_PARM(wt,2), (int)val);
> --
> au88x0_synth.c-        /*
> au88x0_synth.c:        printk(KERN_DEBUG "vortex: WT SetReg(0x%x) =
> 0x%08x\n",
> au88x0_synth.c-               WT_PARM(wt,3), (int)val);
> --
> au88x0_synth.c-        /*
> au88x0_synth.c:        printk(KERN_DEBUG "vortex: WT SetReg(0x%x) =
> 0x%08x\n",
> au88x0_synth.c-               WT_MUTE(wt), (int)val);
> --
> au88x0_synth.c-        /*
> au88x0_synth.c:        printk(KERN_DEBUG "vortex: WT SetReg(0x%x) =
> 0x%08x\n",
> au88x0_synth.c-               WT_DELAY(wt,0), (int)val);
> --
> au88x0_synth.c-    /*
> au88x0_synth.c:    printk(KERN_DEBUG "vortex: WT SetReg(0x%x) = 0x%08x\n",
> ecx, (int)val);
> au88x0_synth.c-    */
> [2  <text/html; UTF-8 (base64)>]
> 


More information about the Alsa-devel mailing list