[alsa-devel] [PATCH v2] ALSA: korg1212: cleanup of printk
From: Sudip Mukherjee sudip@vectorindia.org
replaced all references of the debug messages via printk with dev_* macro (mostly dev_dbg). one reference was changed to pr_err as there the card might have been uninitialized.
this patch will generate warning from checkpatch about broken quoted strings. but that was not fixed intentionally to improve the readability.
Signed-off-by: Sudip Mukherjee sudip@vectorindia.org ---
change in v2: the build warnings of v1 are fixed.
hi Takashi, in your review of v1, you said about some lines which are not ending with \n. but i was not able to find them. did i miss them somewhere?
sound/pci/korg1212/korg1212.c | 407 +++++++++++++++++++++++------------------- 1 file changed, 220 insertions(+), 187 deletions(-)
diff --git a/sound/pci/korg1212/korg1212.c b/sound/pci/korg1212/korg1212.c index 59d21c9..faebe81 100644 --- a/sound/pci/korg1212/korg1212.c +++ b/sound/pci/korg1212/korg1212.c @@ -39,21 +39,6 @@ #include <asm/io.h>
// ---------------------------------------------------------------------------- -// Debug Stuff -// ---------------------------------------------------------------------------- -#define K1212_DEBUG_LEVEL 0 -#if K1212_DEBUG_LEVEL > 0 -#define K1212_DEBUG_PRINTK(fmt,args...) printk(KERN_DEBUG fmt,##args) -#else -#define K1212_DEBUG_PRINTK(fmt,...) -#endif -#if K1212_DEBUG_LEVEL > 1 -#define K1212_DEBUG_PRINTK_VERBOSE(fmt,args...) printk(KERN_DEBUG fmt,##args) -#else -#define K1212_DEBUG_PRINTK_VERBOSE(fmt,...) -#endif - -// ---------------------------------------------------------------------------- // Record/Play Buffer Allocation Method. If K1212_LARGEALLOC is defined all // buffers are alocated as a large piece inside KorgSharedBuffer. // ---------------------------------------------------------------------------- @@ -530,12 +515,12 @@ static int snd_korg1212_Send1212Command(struct snd_korg1212 *korg1212, int rc = K1212_CMDRET_Success;
if (!korg1212->outDoorbellPtr) { - K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: CardUninitialized\n"); + pr_err("K1212_DEBUG: CardUninitialized\n"); return K1212_CMDRET_CardUninitialized; }
- K1212_DEBUG_PRINTK("K1212_DEBUG: Card <- 0x%08x 0x%08x [%s]\n", - doorbellVal, mailBox0Val, stateName[korg1212->cardState]); + dev_dbg(korg1212->card->dev, "Card <- 0x%08x 0x%08x [%s]\n", + doorbellVal, mailBox0Val, stateName[korg1212->cardState]); for (retryCount = 0; retryCount < MAX_COMMAND_RETRIES; retryCount++) { writel(mailBox3Val, korg1212->mailbox3Ptr); writel(mailBox2Val, korg1212->mailbox2Ptr); @@ -562,7 +547,8 @@ static int snd_korg1212_Send1212Command(struct snd_korg1212 *korg1212, mailBox3Lo = readl(korg1212->mailbox3Ptr); if (mailBox3Lo & COMMAND_ACK_MASK) { if ((mailBox3Lo & DOORBELL_VAL_MASK) == (doorbellVal & DOORBELL_VAL_MASK)) { - K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: Card <- Success\n"); + dev_dbg(korg1212->card->dev, + "Card <- Success\n"); rc = K1212_CMDRET_Success; break; } @@ -571,7 +557,7 @@ static int snd_korg1212_Send1212Command(struct snd_korg1212 *korg1212, korg1212->cmdRetryCount += retryCount;
if (retryCount >= MAX_COMMAND_RETRIES) { - K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: Card <- NoAckFromCard\n"); + dev_dbg(korg1212->card->dev, "Card <- NoAckFromCard\n"); rc = K1212_CMDRET_NoAckFromCard; }
@@ -612,20 +598,21 @@ static void snd_korg1212_timer_func(unsigned long data) korg1212->stop_pending_cnt = 0; korg1212->dsp_stop_is_processed = 1; wake_up(&korg1212->wait); - K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: Stop ack'ed [%s]\n", - stateName[korg1212->cardState]); + dev_dbg(korg1212->card->dev, "Stop ack'ed [%s]\n", + stateName[korg1212->cardState]); } else { if (--korg1212->stop_pending_cnt > 0) { /* reprogram timer */ korg1212->timer.expires = jiffies + 1; add_timer(&korg1212->timer); } else { - snd_printd("korg1212_timer_func timeout\n"); + dev_dbg(korg1212->card->dev, + "korg1212_timer_func timeout\n"); korg1212->sharedBufferPtr->cardCommand = 0; korg1212->dsp_stop_is_processed = 1; wake_up(&korg1212->wait); - K1212_DEBUG_PRINTK("K1212_DEBUG: Stop timeout [%s]\n", - stateName[korg1212->cardState]); + dev_dbg(korg1212->card->dev, "Stop timeout [%s]\n", + stateName[korg1212->cardState]); } } spin_unlock_irqrestore(&korg1212->lock, flags); @@ -660,8 +647,8 @@ static inline void snd_korg1212_setCardState(struct snd_korg1212 * korg1212, enu
static int snd_korg1212_OpenCard(struct snd_korg1212 * korg1212) { - K1212_DEBUG_PRINTK("K1212_DEBUG: OpenCard [%s] %d\n", - stateName[korg1212->cardState], korg1212->opencnt); + dev_dbg(korg1212->card->dev, "OpenCard [%s] %d\n", + stateName[korg1212->cardState], korg1212->opencnt); mutex_lock(&korg1212->open_mutex); if (korg1212->opencnt++ == 0) { snd_korg1212_TurnOffIdleMonitor(korg1212); @@ -674,8 +661,8 @@ static int snd_korg1212_OpenCard(struct snd_korg1212 * korg1212)
static int snd_korg1212_CloseCard(struct snd_korg1212 * korg1212) { - K1212_DEBUG_PRINTK("K1212_DEBUG: CloseCard [%s] %d\n", - stateName[korg1212->cardState], korg1212->opencnt); + dev_dbg(korg1212->card->dev, "CloseCard [%s] %d\n", + stateName[korg1212->cardState], korg1212->opencnt);
mutex_lock(&korg1212->open_mutex); if (--(korg1212->opencnt)) { @@ -687,8 +674,9 @@ static int snd_korg1212_CloseCard(struct snd_korg1212 * korg1212) int rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_SelectPlayMode, K1212_MODE_StopPlay, 0, 0, 0); if (rc) - K1212_DEBUG_PRINTK("K1212_DEBUG: CloseCard - RC = %d [%s]\n", - rc, stateName[korg1212->cardState]); + dev_dbg(korg1212->card->dev, + "CloseCard - RC = %d [%s]\n", + rc, stateName[korg1212->cardState]); if (rc != K1212_CMDRET_Success) { mutex_unlock(&korg1212->open_mutex); return 0; @@ -711,8 +699,8 @@ static int snd_korg1212_SetupForPlay(struct snd_korg1212 * korg1212) { int rc;
- K1212_DEBUG_PRINTK("K1212_DEBUG: SetupForPlay [%s] %d\n", - stateName[korg1212->cardState], korg1212->setcnt); + dev_dbg(korg1212->card->dev, "SetupForPlay [%s] %d\n", + stateName[korg1212->cardState], korg1212->setcnt);
if (korg1212->setcnt++) return 0; @@ -721,8 +709,8 @@ static int snd_korg1212_SetupForPlay(struct snd_korg1212 * korg1212) rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_SelectPlayMode, K1212_MODE_SetupPlay, 0, 0, 0); if (rc) - K1212_DEBUG_PRINTK("K1212_DEBUG: SetupForPlay - RC = %d [%s]\n", - rc, stateName[korg1212->cardState]); + dev_dbg(korg1212->card->dev, "SetupForPlay - RC = %d [%s]\n", + rc, stateName[korg1212->cardState]); if (rc != K1212_CMDRET_Success) { return 1; } @@ -734,8 +722,8 @@ static int snd_korg1212_TriggerPlay(struct snd_korg1212 * korg1212) { int rc;
- K1212_DEBUG_PRINTK("K1212_DEBUG: TriggerPlay [%s] %d\n", - stateName[korg1212->cardState], korg1212->playcnt); + dev_dbg(korg1212->card->dev, "K1212_DEBUG: TriggerPlay [%s] %d\n", + stateName[korg1212->cardState], korg1212->playcnt);
if (korg1212->playcnt++) return 0; @@ -743,8 +731,8 @@ static int snd_korg1212_TriggerPlay(struct snd_korg1212 * korg1212) snd_korg1212_setCardState(korg1212, K1212_STATE_PLAYING); rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_TriggerPlay, 0, 0, 0, 0); if (rc) - K1212_DEBUG_PRINTK("K1212_DEBUG: TriggerPlay - RC = %d [%s]\n", - rc, stateName[korg1212->cardState]); + dev_dbg(korg1212->card->dev, "TriggerPlay - RC = %d [%s]\n", + rc, stateName[korg1212->cardState]); if (rc != K1212_CMDRET_Success) { return 1; } @@ -754,8 +742,8 @@ static int snd_korg1212_TriggerPlay(struct snd_korg1212 * korg1212) /* spinlock already held */ static int snd_korg1212_StopPlay(struct snd_korg1212 * korg1212) { - K1212_DEBUG_PRINTK("K1212_DEBUG: StopPlay [%s] %d\n", - stateName[korg1212->cardState], korg1212->playcnt); + dev_dbg(korg1212->card->dev, "StopPlay [%s] %d\n", + stateName[korg1212->cardState], korg1212->playcnt);
if (--(korg1212->playcnt)) return 0; @@ -866,8 +854,9 @@ static int snd_korg1212_SetRate(struct snd_korg1212 *korg1212, int rate) ClockSourceSelector[korg1212->clkSrcRate], 0, 0, 0); if (rc) - K1212_DEBUG_PRINTK("K1212_DEBUG: Set Clock Source Selector - RC = %d [%s]\n", - rc, stateName[korg1212->cardState]); + dev_dbg(korg1212->card->dev, + "Set Clock Source Selector - RC = %d [%s]\n", + rc, stateName[korg1212->cardState]);
return 0; } @@ -902,8 +891,8 @@ static int snd_korg1212_WriteADCSensitivity(struct snd_korg1212 *korg1212) u16 count; unsigned long flags;
- K1212_DEBUG_PRINTK("K1212_DEBUG: WriteADCSensivity [%s]\n", - stateName[korg1212->cardState]); + dev_dbg(korg1212->card->dev, "WriteADCSensivity [%s]\n", + stateName[korg1212->cardState]);
// ---------------------------------------------------------------------------- // initialize things. The local init bit is always set when writing to the @@ -1026,8 +1015,9 @@ static int snd_korg1212_WriteADCSensitivity(struct snd_korg1212 *korg1212) int rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_SelectPlayMode, K1212_MODE_MonitorOn, 0, 0, 0); if (rc) - K1212_DEBUG_PRINTK("K1212_DEBUG: WriteADCSensivity - RC = %d [%s]\n", - rc, stateName[korg1212->cardState]); + dev_dbg(korg1212->card->dev, + "WriteADCSensivity - RC = %d [%s]\n", + rc, stateName[korg1212->cardState]); }
spin_unlock_irqrestore(&korg1212->lock, flags); @@ -1039,8 +1029,8 @@ static void snd_korg1212_OnDSPDownloadComplete(struct snd_korg1212 *korg1212) { int channel, rc;
- K1212_DEBUG_PRINTK("K1212_DEBUG: DSP download is complete. [%s]\n", - stateName[korg1212->cardState]); + dev_dbg(korg1212->card->dev, "DSP download is complete. [%s]\n", + stateName[korg1212->cardState]);
// ---------------------------------------------------- // tell the card to boot @@ -1048,8 +1038,9 @@ static void snd_korg1212_OnDSPDownloadComplete(struct snd_korg1212 *korg1212) rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_BootFromDSPPage4, 0, 0, 0, 0);
if (rc) - K1212_DEBUG_PRINTK("K1212_DEBUG: Boot from Page 4 - RC = %d [%s]\n", - rc, stateName[korg1212->cardState]); + dev_dbg(korg1212->card->dev, + "Boot from Page 4 - RC = %d [%s]\n", + rc, stateName[korg1212->cardState]); msleep(DSP_BOOT_DELAY_IN_MS);
// -------------------------------------------------------------------------------- @@ -1065,8 +1056,9 @@ static void snd_korg1212_OnDSPDownloadComplete(struct snd_korg1212 *korg1212) );
if (rc) - K1212_DEBUG_PRINTK("K1212_DEBUG: Configure Buffer Memory - RC = %d [%s]\n", - rc, stateName[korg1212->cardState]); + dev_dbg(korg1212->card->dev, + "Configure Buffer Memory - RC = %d [%s]\n", + rc, stateName[korg1212->cardState]);
udelay(INTERCOMMAND_DELAY);
@@ -1079,8 +1071,8 @@ static void snd_korg1212_OnDSPDownloadComplete(struct snd_korg1212 *korg1212) );
if (rc) - K1212_DEBUG_PRINTK("K1212_DEBUG: Configure Misc Memory - RC = %d [%s]\n", - rc, stateName[korg1212->cardState]); + dev_dbg(korg1212->card->dev, "Configure Misc Memory - RC = %d [%s]\n", + rc, stateName[korg1212->cardState]);
// -------------------------------------------------------------------------------- // Initialize the routing and volume tables, then update the card's state. @@ -1100,15 +1092,16 @@ static void snd_korg1212_OnDSPDownloadComplete(struct snd_korg1212 *korg1212) ClockSourceSelector[korg1212->clkSrcRate], 0, 0, 0); if (rc) - K1212_DEBUG_PRINTK("K1212_DEBUG: Set Clock Source Selector - RC = %d [%s]\n", - rc, stateName[korg1212->cardState]); + dev_dbg(korg1212->card->dev, + "Set Clock Source Selector - RC = %d [%s]\n", + rc, stateName[korg1212->cardState]);
rc = snd_korg1212_TurnOnIdleMonitor(korg1212); snd_korg1212_setCardState(korg1212, K1212_STATE_READY);
if (rc) - K1212_DEBUG_PRINTK("K1212_DEBUG: Set Monitor On - RC = %d [%s]\n", - rc, stateName[korg1212->cardState]); + dev_dbg(korg1212->card->dev, "Set Monitor On - RC = %d [%s]\n", + rc, stateName[korg1212->cardState]);
snd_korg1212_setCardState(korg1212, K1212_STATE_DSP_COMPLETE); } @@ -1133,9 +1126,10 @@ static irqreturn_t snd_korg1212_interrupt(int irq, void *dev_id)
switch (doorbellValue) { case K1212_DB_DSPDownloadDone: - K1212_DEBUG_PRINTK("K1212_DEBUG: IRQ DNLD count - %ld, %x, [%s].\n", - korg1212->irqcount, doorbellValue, - stateName[korg1212->cardState]); + dev_dbg(korg1212->card->dev, + "IRQ DNLD count - %ld, %x, [%s].\n", + korg1212->irqcount, doorbellValue, + stateName[korg1212->cardState]); if (korg1212->cardState == K1212_STATE_DSP_IN_PROCESS) { korg1212->dsp_is_loaded = 1; wake_up(&korg1212->wait); @@ -1146,10 +1140,11 @@ static irqreturn_t snd_korg1212_interrupt(int irq, void *dev_id) // an error occurred - stop the card // ------------------------------------------------------------------------ case K1212_DB_DMAERROR: - K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: IRQ DMAE count - %ld, %x, [%s].\n", - korg1212->irqcount, doorbellValue, - stateName[korg1212->cardState]); - snd_printk(KERN_ERR "korg1212: DMA Error\n"); + dev_dbg(korg1212->card->dev, + "IRQ DMAE count - %ld, %x, [%s].\n", + korg1212->irqcount, doorbellValue, + stateName[korg1212->cardState]); + dev_err(korg1212->card->dev, "DMA Error\n"); korg1212->errorcnt++; korg1212->totalerrorcnt++; korg1212->sharedBufferPtr->cardCommand = 0; @@ -1161,16 +1156,19 @@ static irqreturn_t snd_korg1212_interrupt(int irq, void *dev_id) // the semaphore in case someone is waiting for this. // ------------------------------------------------------------------------ case K1212_DB_CARDSTOPPED: - K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: IRQ CSTP count - %ld, %x, [%s].\n", - korg1212->irqcount, doorbellValue, - stateName[korg1212->cardState]); + dev_dbg(korg1212->card->dev, + "IRQ CSTP count - %ld, %x, [%s].\n", + korg1212->irqcount, doorbellValue, + stateName[korg1212->cardState]); korg1212->sharedBufferPtr->cardCommand = 0; break;
default: - K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: IRQ DFLT count - %ld, %x, cpos=%d [%s].\n", - korg1212->irqcount, doorbellValue, - korg1212->currentBuffer, stateName[korg1212->cardState]); + dev_dbg(korg1212->card->dev, + "IRQ DFLT count - %ld, %x, cpos=%d [%s].\n", + korg1212->irqcount, doorbellValue, + korg1212->currentBuffer, + stateName[korg1212->cardState]); if ((korg1212->cardState > K1212_STATE_SETUP) || korg1212->idleMonitorOn) { korg1212->currentBuffer++;
@@ -1206,8 +1204,8 @@ static int snd_korg1212_downloadDSPCode(struct snd_korg1212 *korg1212) { int rc;
- K1212_DEBUG_PRINTK("K1212_DEBUG: DSP download is starting... [%s]\n", - stateName[korg1212->cardState]); + dev_dbg(korg1212->card->dev, "DSP download is starting... [%s]\n", + stateName[korg1212->cardState]);
// --------------------------------------------------------------- // verify the state of the card before proceeding. @@ -1221,8 +1219,9 @@ static int snd_korg1212_downloadDSPCode(struct snd_korg1212 *korg1212) UpperWordSwap(korg1212->dma_dsp.addr), 0, 0, 0); if (rc) - K1212_DEBUG_PRINTK("K1212_DEBUG: Start DSP Download RC = %d [%s]\n", - rc, stateName[korg1212->cardState]); + dev_dbg(korg1212->card->dev, + "Start DSP Download RC = %d [%s]\n", + rc, stateName[korg1212->cardState]);
korg1212->dsp_is_loaded = 0; wait_event_timeout(korg1212->wait, korg1212->dsp_is_loaded, HZ * CARD_BOOT_TIMEOUT); @@ -1281,20 +1280,20 @@ static int snd_korg1212_silence(struct snd_korg1212 *korg1212, int pos, int coun struct KorgAudioFrame * dst = korg1212->playDataBufsPtr[0].bufferData + pos; int i;
- K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: snd_korg1212_silence pos=%d offset=%d size=%d count=%d\n", - pos, offset, size, count); + dev_dbg(korg1212->card->dev, + "snd_korg1212_silence pos=%d offset=%d size=%d count=%d\n", + pos, offset, size, count); if (snd_BUG_ON(pos + count > K1212_MAX_SAMPLES)) return -EINVAL;
for (i=0; i < count; i++) { -#if K1212_DEBUG_LEVEL > 0 if ( (void *) dst < (void *) korg1212->playDataBufsPtr || (void *) dst > (void *) korg1212->playDataBufsPtr[8].bufferData ) { - printk(KERN_DEBUG "K1212_DEBUG: snd_korg1212_silence KERNEL EFAULT dst=%p iter=%d\n", - dst, i); + dev_dbg(korg1212->card->dev, + "snd_korg1212_silence KERNEL EFAULT dst=%p iter=%d\n", + dst, i); return -EFAULT; } -#endif memset((void*) dst + offset, 0, size); dst++; } @@ -1307,22 +1306,25 @@ static int snd_korg1212_copy_to(struct snd_korg1212 *korg1212, void __user *dst, struct KorgAudioFrame * src = korg1212->recordDataBufsPtr[0].bufferData + pos; int i, rc;
- K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: snd_korg1212_copy_to pos=%d offset=%d size=%d\n", - pos, offset, size); + dev_dbg(korg1212->card->dev, + "snd_korg1212_copy_to pos=%d offset=%d size=%d\n", + pos, offset, size); if (snd_BUG_ON(pos + count > K1212_MAX_SAMPLES)) return -EINVAL;
for (i=0; i < count; i++) { -#if K1212_DEBUG_LEVEL > 0 if ( (void *) src < (void *) korg1212->recordDataBufsPtr || (void *) src > (void *) korg1212->recordDataBufsPtr[8].bufferData ) { - printk(KERN_DEBUG "K1212_DEBUG: snd_korg1212_copy_to KERNEL EFAULT, src=%p dst=%p iter=%d\n", src, dst, i); + dev_dbg(korg1212->card->dev, + "snd_korg1212_copy_to KERNEL EFAULT, src=%p dst=%p iter=%d\n", + src, dst, i); return -EFAULT; } -#endif rc = copy_to_user(dst + offset, src, size); if (rc) { - K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_copy_to USER EFAULT src=%p dst=%p iter=%d\n", src, dst, i); + dev_dbg(korg1212->card->dev, + "snd_korg1212_copy_to USER EFAULT src=%p dst=%p iter=%d\n", + src, dst, i); return -EFAULT; } src++; @@ -1337,23 +1339,26 @@ static int snd_korg1212_copy_from(struct snd_korg1212 *korg1212, void __user *sr struct KorgAudioFrame * dst = korg1212->playDataBufsPtr[0].bufferData + pos; int i, rc;
- K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: snd_korg1212_copy_from pos=%d offset=%d size=%d count=%d\n", - pos, offset, size, count); + dev_dbg(korg1212->card->dev, + "snd_korg1212_copy_from pos=%d offset=%d size=%d count=%d\n", + pos, offset, size, count);
if (snd_BUG_ON(pos + count > K1212_MAX_SAMPLES)) return -EINVAL;
for (i=0; i < count; i++) { -#if K1212_DEBUG_LEVEL > 0 if ( (void *) dst < (void *) korg1212->playDataBufsPtr || (void *) dst > (void *) korg1212->playDataBufsPtr[8].bufferData ) { - printk(KERN_DEBUG "K1212_DEBUG: snd_korg1212_copy_from KERNEL EFAULT, src=%p dst=%p iter=%d\n", src, dst, i); + dev_dbg(korg1212->card->dev, + "snd_korg1212_copy_from KERNEL EFAULT, src=%p dst=%p iter=%d\n", + src, dst, i); return -EFAULT; } -#endif rc = copy_from_user((void*) dst + offset, src, size); if (rc) { - K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_copy_from USER EFAULT src=%p dst=%p iter=%d\n", src, dst, i); + dev_dbg(korg1212->card->dev, + "snd_korg1212_copy_from USER EFAULT src=%p dst=%p iter=%d\n", + src, dst, i); return -EFAULT; } dst++; @@ -1367,8 +1372,8 @@ static void snd_korg1212_free_pcm(struct snd_pcm *pcm) { struct snd_korg1212 *korg1212 = pcm->private_data;
- K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_free_pcm [%s]\n", - stateName[korg1212->cardState]); + dev_dbg(korg1212->card->dev, "snd_korg1212_free_pcm [%s]\n", + stateName[korg1212->cardState]);
korg1212->pcm = NULL; } @@ -1379,8 +1384,8 @@ static int snd_korg1212_playback_open(struct snd_pcm_substream *substream) struct snd_korg1212 *korg1212 = snd_pcm_substream_chip(substream); struct snd_pcm_runtime *runtime = substream->runtime;
- K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_playback_open [%s]\n", - stateName[korg1212->cardState]); + dev_dbg(korg1212->card->dev, "snd_korg1212_playback_open [%s]\n", + stateName[korg1212->cardState]);
snd_korg1212_OpenCard(korg1212);
@@ -1408,8 +1413,8 @@ static int snd_korg1212_capture_open(struct snd_pcm_substream *substream) struct snd_korg1212 *korg1212 = snd_pcm_substream_chip(substream); struct snd_pcm_runtime *runtime = substream->runtime;
- K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_capture_open [%s]\n", - stateName[korg1212->cardState]); + dev_dbg(korg1212->card->dev, "snd_korg1212_capture_open [%s]\n", + stateName[korg1212->cardState]);
snd_korg1212_OpenCard(korg1212);
@@ -1435,8 +1440,8 @@ static int snd_korg1212_playback_close(struct snd_pcm_substream *substream) unsigned long flags; struct snd_korg1212 *korg1212 = snd_pcm_substream_chip(substream);
- K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_playback_close [%s]\n", - stateName[korg1212->cardState]); + dev_dbg(korg1212->card->dev, "snd_korg1212_playback_close [%s]\n", + stateName[korg1212->cardState]);
snd_korg1212_silence(korg1212, 0, K1212_MAX_SAMPLES, 0, korg1212->channels * 2);
@@ -1457,8 +1462,8 @@ static int snd_korg1212_capture_close(struct snd_pcm_substream *substream) unsigned long flags; struct snd_korg1212 *korg1212 = snd_pcm_substream_chip(substream);
- K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_capture_close [%s]\n", - stateName[korg1212->cardState]); + dev_dbg(korg1212->card->dev, "snd_korg1212_capture_close [%s]\n", + stateName[korg1212->cardState]);
spin_lock_irqsave(&korg1212->lock, flags);
@@ -1475,14 +1480,18 @@ static int snd_korg1212_capture_close(struct snd_pcm_substream *substream) static int snd_korg1212_ioctl(struct snd_pcm_substream *substream, unsigned int cmd, void *arg) { - K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_ioctl: cmd=%d\n", cmd); + struct snd_korg1212 *korg1212 = snd_pcm_substream_chip(substream); + + dev_dbg(korg1212->card->dev, "snd_korg1212_ioctl: cmd=%d\n", cmd);
if (cmd == SNDRV_PCM_IOCTL1_CHANNEL_INFO ) { struct snd_pcm_channel_info *info = arg; info->offset = 0; info->first = info->channel * 16; info->step = 256; - K1212_DEBUG_PRINTK("K1212_DEBUG: channel_info %d:, offset=%ld, first=%d, step=%d\n", info->channel, info->offset, info->first, info->step); + dev_dbg(korg1212->card->dev, + "channel_info %d:, offset=%ld, first=%d, step=%d\n", + info->channel, info->offset, info->first, info->step); return 0; }
@@ -1498,8 +1507,8 @@ static int snd_korg1212_hw_params(struct snd_pcm_substream *substream, pid_t this_pid; pid_t other_pid;
- K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_hw_params [%s]\n", - stateName[korg1212->cardState]); + dev_dbg(korg1212->card->dev, "snd_korg1212_hw_params [%s]\n", + stateName[korg1212->cardState]);
spin_lock_irqsave(&korg1212->lock, flags);
@@ -1546,15 +1555,16 @@ static int snd_korg1212_prepare(struct snd_pcm_substream *substream) struct snd_korg1212 *korg1212 = snd_pcm_substream_chip(substream); int rc;
- K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_prepare [%s]\n", - stateName[korg1212->cardState]); + dev_dbg(korg1212->card->dev, "snd_korg1212_prepare [%s]\n", + stateName[korg1212->cardState]);
spin_lock_irq(&korg1212->lock);
/* FIXME: we should wait for ack! */ if (korg1212->stop_pending_cnt > 0) { - K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_prepare - Stop is pending... [%s]\n", - stateName[korg1212->cardState]); + dev_dbg(korg1212->card->dev, + "snd_korg1212_prepare - Stop is pending... [%s]\n", + stateName[korg1212->cardState]); spin_unlock_irq(&korg1212->lock); return -EAGAIN; /* @@ -1579,8 +1589,8 @@ static int snd_korg1212_trigger(struct snd_pcm_substream *substream, struct snd_korg1212 *korg1212 = snd_pcm_substream_chip(substream); int rc;
- K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_trigger [%s] cmd=%d\n", - stateName[korg1212->cardState], cmd); + dev_dbg(korg1212->card->dev, "snd_korg1212_trigger [%s] cmd=%d\n", + stateName[korg1212->cardState], cmd);
spin_lock(&korg1212->lock); switch (cmd) { @@ -1621,8 +1631,9 @@ static snd_pcm_uframes_t snd_korg1212_playback_pointer(struct snd_pcm_substream
pos = korg1212->currentBuffer * kPlayBufferFrames;
- K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: snd_korg1212_playback_pointer [%s] %ld\n", - stateName[korg1212->cardState], pos); + dev_dbg(korg1212->card->dev, + "snd_korg1212_playback_pointer [%s] %ld\n", + stateName[korg1212->cardState], pos);
return pos; } @@ -1634,8 +1645,8 @@ static snd_pcm_uframes_t snd_korg1212_capture_pointer(struct snd_pcm_substream *
pos = korg1212->currentBuffer * kPlayBufferFrames;
- K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: snd_korg1212_capture_pointer [%s] %ld\n", - stateName[korg1212->cardState], pos); + dev_dbg(korg1212->card->dev, "snd_korg1212_capture_pointer [%s] %ld\n", + stateName[korg1212->cardState], pos);
return pos; } @@ -1648,8 +1659,9 @@ static int snd_korg1212_playback_copy(struct snd_pcm_substream *substream, { struct snd_korg1212 *korg1212 = snd_pcm_substream_chip(substream);
- K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: snd_korg1212_playback_copy [%s] %ld %ld\n", - stateName[korg1212->cardState], pos, count); + dev_dbg(korg1212->card->dev, + "snd_korg1212_playback_copy [%s] %ld %ld\n", + stateName[korg1212->cardState], pos, count);
return snd_korg1212_copy_from(korg1212, src, pos, count, 0, korg1212->channels * 2);
@@ -1662,8 +1674,8 @@ static int snd_korg1212_playback_silence(struct snd_pcm_substream *substream, { struct snd_korg1212 *korg1212 = snd_pcm_substream_chip(substream);
- K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: snd_korg1212_playback_silence [%s]\n", - stateName[korg1212->cardState]); + dev_dbg(korg1212->card->dev, "snd_korg1212_playback_silence [%s]\n", + stateName[korg1212->cardState]);
return snd_korg1212_silence(korg1212, pos, count, 0, korg1212->channels * 2); } @@ -1676,8 +1688,9 @@ static int snd_korg1212_capture_copy(struct snd_pcm_substream *substream, { struct snd_korg1212 *korg1212 = snd_pcm_substream_chip(substream);
- K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: snd_korg1212_capture_copy [%s] %ld %ld\n", - stateName[korg1212->cardState], pos, count); + dev_dbg(korg1212->card->dev, + "snd_korg1212_capture_copy [%s] %ld %ld\n", + stateName[korg1212->cardState], pos, count);
return snd_korg1212_copy_to(korg1212, dst, pos, count, 0, korg1212->channels * 2); } @@ -2138,7 +2151,7 @@ snd_korg1212_free(struct snd_korg1212 *korg1212) static int snd_korg1212_dev_free(struct snd_device *device) { struct snd_korg1212 *korg1212 = device->device_data; - K1212_DEBUG_PRINTK("K1212_DEBUG: Freeing device\n"); + dev_dbg(korg1212->card->dev, "Freeing device\n"); return snd_korg1212_free(korg1212); }
@@ -2210,19 +2223,17 @@ static int snd_korg1212_create(struct snd_card *card, struct pci_dev *pci, ioport_size = pci_resource_len(korg1212->pci, 1); iomem2_size = pci_resource_len(korg1212->pci, 2);
- K1212_DEBUG_PRINTK("K1212_DEBUG: resources:\n" - " iomem = 0x%lx (%d)\n" - " ioport = 0x%lx (%d)\n" - " iomem = 0x%lx (%d)\n" - " [%s]\n", - korg1212->iomem, iomem_size, - korg1212->ioport, ioport_size, - korg1212->iomem2, iomem2_size, - stateName[korg1212->cardState]); + dev_dbg(korg1212->card->dev, + "resources:\n\tiomem = 0x%lx (%d)\n\tioport = 0x%lx (%d)\n\tiomem = 0x%lx (%d)\n\t[%s]\n", + korg1212->iomem, iomem_size, + korg1212->ioport, ioport_size, + korg1212->iomem2, iomem2_size, + stateName[korg1212->cardState]);
if ((korg1212->iobase = ioremap(korg1212->iomem, iomem_size)) == NULL) { - snd_printk(KERN_ERR "korg1212: unable to remap memory region 0x%lx-0x%lx\n", korg1212->iomem, - korg1212->iomem + iomem_size - 1); + dev_err(korg1212->card->dev, + "unable to remap memory region 0x%lx-0x%lx\n", + korg1212->iomem, korg1212->iomem + iomem_size - 1); snd_korg1212_free(korg1212); return -EBUSY; } @@ -2232,7 +2243,8 @@ static int snd_korg1212_create(struct snd_card *card, struct pci_dev *pci, KBUILD_MODNAME, korg1212);
if (err) { - snd_printk(KERN_ERR "korg1212: unable to grab IRQ %d\n", pci->irq); + dev_err(korg1212->card->dev, "unable to grab IRQ %d\n", + pci->irq); snd_korg1212_free(korg1212); return -EBUSY; } @@ -2252,40 +2264,45 @@ static int snd_korg1212_create(struct snd_card *card, struct pci_dev *pci, korg1212->sensRegPtr = (u16 __iomem *) (korg1212->iobase + SENS_CONTROL_OFFSET); korg1212->idRegPtr = (u32 __iomem *) (korg1212->iobase + DEV_VEND_ID_OFFSET);
- K1212_DEBUG_PRINTK("K1212_DEBUG: card registers:\n" - " Status register = 0x%p\n" - " OutDoorbell = 0x%p\n" - " InDoorbell = 0x%p\n" - " Mailbox0 = 0x%p\n" - " Mailbox1 = 0x%p\n" - " Mailbox2 = 0x%p\n" - " Mailbox3 = 0x%p\n" - " ControlReg = 0x%p\n" - " SensReg = 0x%p\n" - " IDReg = 0x%p\n" - " [%s]\n", - korg1212->statusRegPtr, - korg1212->outDoorbellPtr, - korg1212->inDoorbellPtr, - korg1212->mailbox0Ptr, - korg1212->mailbox1Ptr, - korg1212->mailbox2Ptr, - korg1212->mailbox3Ptr, - korg1212->controlRegPtr, - korg1212->sensRegPtr, - korg1212->idRegPtr, - stateName[korg1212->cardState]); + dev_dbg(korg1212->card->dev, "card registers:\n" + " Status register = 0x%p\n" + " OutDoorbell = 0x%p\n" + " InDoorbell = 0x%p\n" + " Mailbox0 = 0x%p\n" + " Mailbox1 = 0x%p\n" + " Mailbox2 = 0x%p\n" + " Mailbox3 = 0x%p\n" + " ControlReg = 0x%p\n" + " SensReg = 0x%p\n" + " IDReg = 0x%p\n" + " [%s]\n", + korg1212->statusRegPtr, + korg1212->outDoorbellPtr, + korg1212->inDoorbellPtr, + korg1212->mailbox0Ptr, + korg1212->mailbox1Ptr, + korg1212->mailbox2Ptr, + korg1212->mailbox3Ptr, + korg1212->controlRegPtr, + korg1212->sensRegPtr, + korg1212->idRegPtr, + stateName[korg1212->cardState]);
if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci), sizeof(struct KorgSharedBuffer), &korg1212->dma_shared) < 0) { - snd_printk(KERN_ERR "korg1212: can not allocate shared buffer memory (%Zd bytes)\n", sizeof(struct KorgSharedBuffer)); + dev_err(korg1212->card->dev, + "can not allocate shared buffer memory (%Zd bytes)\n", + sizeof(struct KorgSharedBuffer)); snd_korg1212_free(korg1212); return -ENOMEM; } korg1212->sharedBufferPtr = (struct KorgSharedBuffer *)korg1212->dma_shared.area; korg1212->sharedBufferPhy = korg1212->dma_shared.addr;
- K1212_DEBUG_PRINTK("K1212_DEBUG: Shared Buffer Area = 0x%p (0x%08lx), %d bytes\n", korg1212->sharedBufferPtr, korg1212->sharedBufferPhy, sizeof(struct KorgSharedBuffer)); + dev_dbg(korg1212->card->dev, + "Shared Buffer Area = 0x%p (0x%08lx), %lu bytes\n", + korg1212->sharedBufferPtr, korg1212->sharedBufferPhy, + sizeof(struct KorgSharedBuffer));
#ifndef K1212_LARGEALLOC
@@ -2293,27 +2310,35 @@ static int snd_korg1212_create(struct snd_card *card, struct pci_dev *pci,
if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci), korg1212->DataBufsSize, &korg1212->dma_play) < 0) { - snd_printk(KERN_ERR "korg1212: can not allocate play data buffer memory (%d bytes)\n", korg1212->DataBufsSize); + dev_err(korg1212->card->dev, + "can not allocate play data buffer memory (%d bytes)\n", + korg1212->DataBufsSize); snd_korg1212_free(korg1212); return -ENOMEM; } korg1212->playDataBufsPtr = (struct KorgAudioBuffer *)korg1212->dma_play.area; korg1212->PlayDataPhy = korg1212->dma_play.addr;
- K1212_DEBUG_PRINTK("K1212_DEBUG: Play Data Area = 0x%p (0x%08x), %d bytes\n", - korg1212->playDataBufsPtr, korg1212->PlayDataPhy, korg1212->DataBufsSize); + dev_dbg(korg1212->card->dev, + "Play Data Area = 0x%p (0x%08x), %d bytes\n", + korg1212->playDataBufsPtr, korg1212->PlayDataPhy, + korg1212->DataBufsSize);
if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci), korg1212->DataBufsSize, &korg1212->dma_rec) < 0) { - snd_printk(KERN_ERR "korg1212: can not allocate record data buffer memory (%d bytes)\n", korg1212->DataBufsSize); + dev_err(korg1212->card->dev, + "can not allocate record data buffer memory (%d bytes)\n", + korg1212->DataBufsSize); snd_korg1212_free(korg1212); return -ENOMEM; } korg1212->recordDataBufsPtr = (struct KorgAudioBuffer *)korg1212->dma_rec.area; korg1212->RecDataPhy = korg1212->dma_rec.addr;
- K1212_DEBUG_PRINTK("K1212_DEBUG: Record Data Area = 0x%p (0x%08x), %d bytes\n", - korg1212->recordDataBufsPtr, korg1212->RecDataPhy, korg1212->DataBufsSize); + dev_dbg(korg1212->card->dev, + "Record Data Area = 0x%p (0x%08x), %d bytes\n", + korg1212->recordDataBufsPtr, korg1212->RecDataPhy, + korg1212->DataBufsSize);
#else // K1212_LARGEALLOC
@@ -2334,22 +2359,25 @@ static int snd_korg1212_create(struct snd_card *card, struct pci_dev *pci, err = request_firmware(&dsp_code, "korg/k1212.dsp", &pci->dev); if (err < 0) { release_firmware(dsp_code); - snd_printk(KERN_ERR "firmware not available\n"); + dev_err(korg1212->card->dev, "firmware not available\n"); snd_korg1212_free(korg1212); return err; }
if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci), dsp_code->size, &korg1212->dma_dsp) < 0) { - snd_printk(KERN_ERR "korg1212: cannot allocate dsp code memory (%zd bytes)\n", dsp_code->size); + dev_err(korg1212->card->dev, + "cannot allocate dsp code memory (%zd bytes)\n", + dsp_code->size); snd_korg1212_free(korg1212); release_firmware(dsp_code); return -ENOMEM; }
- K1212_DEBUG_PRINTK("K1212_DEBUG: DSP Code area = 0x%p (0x%08x) %d bytes [%s]\n", - korg1212->dma_dsp.area, korg1212->dma_dsp.addr, dsp_code->size, - stateName[korg1212->cardState]); + dev_dbg(korg1212->card->dev, + "DSP Code area = 0x%p (0x%08x) %d bytes [%s]\n", + korg1212->dma_dsp.area, (int)korg1212->dma_dsp.addr, + (int)dsp_code->size, stateName[korg1212->cardState]);
memcpy(korg1212->dma_dsp.area, dsp_code->data, dsp_code->size);
@@ -2358,7 +2386,8 @@ static int snd_korg1212_create(struct snd_card *card, struct pci_dev *pci, rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_RebootCard, 0, 0, 0, 0);
if (rc) - K1212_DEBUG_PRINTK("K1212_DEBUG: Reboot Card - RC = %d [%s]\n", rc, stateName[korg1212->cardState]); + dev_dbg(korg1212->card->dev, "Reboot Card - RC = %d [%s]\n", + rc, stateName[korg1212->cardState]);
if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, korg1212, &ops)) < 0) { snd_korg1212_free(korg1212); @@ -2372,18 +2401,22 @@ static int snd_korg1212_create(struct snd_card *card, struct pci_dev *pci, if (snd_korg1212_downloadDSPCode(korg1212)) return -EBUSY;
- K1212_DEBUG_PRINTK("korg1212: dspMemPhy = %08x U[%08x], " - "PlayDataPhy = %08x L[%08x]\n" - "korg1212: RecDataPhy = %08x L[%08x], " - "VolumeTablePhy = %08x L[%08x]\n" - "korg1212: RoutingTablePhy = %08x L[%08x], " - "AdatTimeCodePhy = %08x L[%08x]\n", - (int)korg1212->dma_dsp.addr, UpperWordSwap(korg1212->dma_dsp.addr), - korg1212->PlayDataPhy, LowerWordSwap(korg1212->PlayDataPhy), - korg1212->RecDataPhy, LowerWordSwap(korg1212->RecDataPhy), - korg1212->VolumeTablePhy, LowerWordSwap(korg1212->VolumeTablePhy), - korg1212->RoutingTablePhy, LowerWordSwap(korg1212->RoutingTablePhy), - korg1212->AdatTimeCodePhy, LowerWordSwap(korg1212->AdatTimeCodePhy)); + dev_dbg(korg1212->card->dev, "dspMemPhy = %08x U[%08x], " + "PlayDataPhy = %08x L[%08x]\n" + "korg1212: RecDataPhy = %08x L[%08x], " + "VolumeTablePhy = %08x L[%08x]\n" + "korg1212: RoutingTablePhy = %08x L[%08x], " + "AdatTimeCodePhy = %08x L[%08x]\n", + (int)korg1212->dma_dsp.addr, + UpperWordSwap(korg1212->dma_dsp.addr), + korg1212->PlayDataPhy, LowerWordSwap(korg1212->PlayDataPhy), + korg1212->RecDataPhy, LowerWordSwap(korg1212->RecDataPhy), + korg1212->VolumeTablePhy, + LowerWordSwap(korg1212->VolumeTablePhy), + korg1212->RoutingTablePhy, + LowerWordSwap(korg1212->RoutingTablePhy), + korg1212->AdatTimeCodePhy, + LowerWordSwap(korg1212->AdatTimeCodePhy));
if ((err = snd_pcm_new(korg1212->card, "korg1212", 0, 1, 1, &korg1212->pcm)) < 0) return err; @@ -2446,7 +2479,7 @@ snd_korg1212_probe(struct pci_dev *pci, sprintf(card->longname, "%s at 0x%lx, irq %d", card->shortname, korg1212->iomem, korg1212->irq);
- K1212_DEBUG_PRINTK("K1212_DEBUG: %s\n", card->longname); + dev_dbg(&pci->dev, "%s\n", card->longname);
if ((err = snd_card_register(card)) < 0) { snd_card_free(card);
At Sun, 23 Nov 2014 13:40:51 +0530, Sudip Mukherjee wrote:
From: Sudip Mukherjee sudip@vectorindia.org
replaced all references of the debug messages via printk with dev_* macro (mostly dev_dbg). one reference was changed to pr_err as there the card might have been uninitialized.
this patch will generate warning from checkpatch about broken quoted strings. but that was not fixed intentionally to improve the readability.
Signed-off-by: Sudip Mukherjee sudip@vectorindia.org
change in v2: the build warnings of v1 are fixed.
hi Takashi, in your review of v1, you said about some lines which are not ending with \n. but i was not able to find them. did i miss them somewhere?
The problem is the one with multiple "\n", for example:
dev_dbg(korg1212->card->dev, "dspMemPhy = %08x U[%08x], " "PlayDataPhy = %08x L[%08x]\n" "korg1212: RecDataPhy = %08x L[%08x], " "VolumeTablePhy = %08x L[%08x]\n" "korg1212: RoutingTablePhy = %08x L[%08x], " "AdatTimeCodePhy = %08x L[%08x]\n",
My biggest concern right now is, however, about the unnecessary code increase by this patch. Currently, most of debug prints were simply not built, because of:
// ---------------------------------------------------------------------------- -// Debug Stuff -// ---------------------------------------------------------------------------- -#define K1212_DEBUG_LEVEL 0 -#if K1212_DEBUG_LEVEL > 0 -#define K1212_DEBUG_PRINTK(fmt,args...) printk(KERN_DEBUG fmt,##args) -#else -#define K1212_DEBUG_PRINTK(fmt,...) -#endif -#if K1212_DEBUG_LEVEL > 1 -#define K1212_DEBUG_PRINTK_VERBOSE(fmt,args...) printk(KERN_DEBUG fmt,##args) -#else -#define K1212_DEBUG_PRINTK_VERBOSE(fmt,...) -#endif
With your patch, now all these codes are compiled.
I have no clear answer what would be the best in such a case. I'd say it really depends. If they are just silly messages that can be covered in a better way (like ftrace), just get rid of them. If they are intended for some good register dumps, then dev_dbg() might make sense.
Takashi
On Mon, 2014-11-24 at 18:08 +0100, Takashi Iwai wrote:
At Sun, 23 Nov 2014 13:40:51 +0530, Sudip Mukherjee wrote:
[]
replaced all references of the debug messages via printk with dev_* macro (mostly dev_dbg). one reference was changed to pr_err as there the card might have been uninitialized.
this patch will generate warning from checkpatch about broken quoted strings. but that was not fixed intentionally to improve the readability.
I think it'd be easier to read and grep coalesced.
[]
in your review of v1, you said about some lines which are not ending with \n. but i was not able to find them. did i miss them somewhere?
[]
The problem is the one with multiple "\n", for example:
dev_dbg(korg1212->card->dev, "dspMemPhy = %08x U[%08x], " "PlayDataPhy = %08x L[%08x]\n" "korg1212: RecDataPhy = %08x L[%08x], " "VolumeTablePhy = %08x L[%08x]\n" "korg1212: RoutingTablePhy = %08x L[%08x], " "AdatTimeCodePhy = %08x L[%08x]\n",
I think these should be individual dev_dbg calls
dev_dbg(korg1212->card->dev, "dspMemPhy = %08x U[%08x]\n", val, val2) dev_dbg(korg1212->card->dev, "PhyDataPhy = %08x L[%08x]\n", val, val2); dev_dbg(korg1212->card->dev, "RecDataPhy = %08x L[%08x]\n", val, val2); dev_dbg(korg1212->card->dev, "VolumeTablePhy = %08x L[%08x]\n", val, val2);
etc..
Another possibility is to use another macro like:
#define k1212_dbg(k1212, fmt, ...) \ dev_dbg((k)->card->dev, fmt, ##__VA_ARGS__)
and change all these to
k1212_dbg(korg1212, "dspMemPhy = %08x U[%08x]\n", val, val2) k1212_dbg(korg1212, "PhyDataPhy = %08x L[%08x]\n", val, val2); k1212_dbg(korg1212, "RecDataPhy = %08x L[%08x]\n", val, val2); k1212_dbg(korg1212, "VolumeTablePhy = %08x L[%08x]\n", val, val2);
etc.
My biggest concern right now is, however, about the unnecessary code increase by this patch. Currently, most of debug prints were simply not built, because of:
// ---------------------------------------------------------------------------- -// Debug Stuff -// ---------------------------------------------------------------------------- -#define K1212_DEBUG_LEVEL 0 -#if K1212_DEBUG_LEVEL > 0 -#define K1212_DEBUG_PRINTK(fmt,args...) printk(KERN_DEBUG fmt,##args) -#else -#define K1212_DEBUG_PRINTK(fmt,...) -#endif -#if K1212_DEBUG_LEVEL > 1 -#define K1212_DEBUG_PRINTK_VERBOSE(fmt,args...) printk(KERN_DEBUG fmt,##args) -#else -#define K1212_DEBUG_PRINTK_VERBOSE(fmt,...) -#endif
With your patch, now all these codes are compiled.
Not really.
dev_dbg is a no-op unless DEBUG is #defined or CONFIG_DYNAMIC_DEBUG is set.
I have no clear answer what would be the best in such a case. I'd say it really depends. If they are just silly messages that can be covered in a better way (like ftrace), just get rid of them. If they are intended for some good register dumps, then dev_dbg() might make sense.
very true.
On Mon, Nov 24, 2014 at 09:25:10AM -0800, Joe Perches wrote:
On Mon, 2014-11-24 at 18:08 +0100, Takashi Iwai wrote:
At Sun, 23 Nov 2014 13:40:51 +0530, Sudip Mukherjee wrote:
[]
replaced all references of the debug messages via printk with dev_* macro (mostly dev_dbg). one reference was changed to pr_err as there the card might have been uninitialized.
this patch will generate warning from checkpatch about broken quoted strings. but that was not fixed intentionally to improve the readability.
I think it'd be easier to read and grep coalesced.
or maybe better will be individual dev_dbg calls ....
[]
in your review of v1, you said about some lines which are not ending with \n. but i was not able to find them. did i miss them somewhere?
[]
The problem is the one with multiple "\n", for example:
dev_dbg(korg1212->card->dev, "dspMemPhy = %08x U[%08x], " "PlayDataPhy = %08x L[%08x]\n" "korg1212: RecDataPhy = %08x L[%08x], " "VolumeTablePhy = %08x L[%08x]\n" "korg1212: RoutingTablePhy = %08x L[%08x], " "AdatTimeCodePhy = %08x L[%08x]\n",
I think these should be individual dev_dbg calls
dev_dbg(korg1212->card->dev, "dspMemPhy = %08x U[%08x]\n", val, val2) dev_dbg(korg1212->card->dev, "PhyDataPhy = %08x L[%08x]\n", val, val2); dev_dbg(korg1212->card->dev, "RecDataPhy = %08x L[%08x]\n", val, val2); dev_dbg(korg1212->card->dev, "VolumeTablePhy = %08x L[%08x]\n", val, val2);
etc..
Another possibility is to use another macro like:
#define k1212_dbg(k1212, fmt, ...) \ dev_dbg((k)->card->dev, fmt, ##__VA_ARGS__)
and change all these to
k1212_dbg(korg1212, "dspMemPhy = %08x U[%08x]\n", val, val2) k1212_dbg(korg1212, "PhyDataPhy = %08x L[%08x]\n", val, val2); k1212_dbg(korg1212, "RecDataPhy = %08x L[%08x]\n", val, val2); k1212_dbg(korg1212, "VolumeTablePhy = %08x L[%08x]\n", val, val2);
etc.
My biggest concern right now is, however, about the unnecessary code increase by this patch. Currently, most of debug prints were simply not built, because of:
// ---------------------------------------------------------------------------- -// Debug Stuff -// ---------------------------------------------------------------------------- -#define K1212_DEBUG_LEVEL 0 -#if K1212_DEBUG_LEVEL > 0 -#define K1212_DEBUG_PRINTK(fmt,args...) printk(KERN_DEBUG fmt,##args) -#else -#define K1212_DEBUG_PRINTK(fmt,...) -#endif -#if K1212_DEBUG_LEVEL > 1 -#define K1212_DEBUG_PRINTK_VERBOSE(fmt,args...) printk(KERN_DEBUG fmt,##args) -#else -#define K1212_DEBUG_PRINTK_VERBOSE(fmt,...) -#endif
With your patch, now all these codes are compiled.
Not really.
dev_dbg is a no-op unless DEBUG is #defined or CONFIG_DYNAMIC_DEBUG is set.
I have no clear answer what would be the best in such a case. I'd say it really depends. If they are just silly messages that can be covered in a better way (like ftrace), just get rid of them. If they are intended for some good register dumps, then dev_dbg() might make sense.
very true.
there are many dev_dbg which can be removed, they are just printing status message along with the statename of the card, and some dev_dbg is printing the arguments that the function has received.
in the exising file we already have the macro: #define K1212_DEBUG_PRINTK(fmt,args...) printk(KERN_DEBUG fmt,##args)
we can just modify the macro to: #define K1212_DEBUG_PRINTK(fmt,args...) dev_dbg(korg1212->card->dev, fmt,##args)
then we will have very little thing to change in the code. and concerns of Takashi about size will also be taken care of, and at the same time all printk will be cleared.
problems with this way: 1) macro name is little misleading - macro says printk, but we are using dev_dbg 2) if some one later wants to add something to this file, and doesnot want to use the variable name korg1212 in his function.
any suggestions ?
thanks sudip
On Tue, 2014-11-25 at 11:51 +0530, Sudip Mukherjee wrote:
problems with this way:
- macro name is little misleading - macro says printk, but we are using dev_dbg
- if some one later wants to add something to this file, and doesnot want to use the variable name korg1212 in his function.
any suggestions ?
Some code is so old and unlikely to be ever used again, it may be better to move it to an "ancient and crufty" folder and forget about it.
This may be one of those.
If the debugging was written in a more current style, it might look like this: (with various format/argument mismatches fixed, formatting changes, etc)
I don't have this card (does anyone?), so it's compiled but untested. --- sound/pci/korg1212/korg1212.c | 363 +++++++++++++++++++++--------------------- 1 file changed, 184 insertions(+), 179 deletions(-)
diff --git a/sound/pci/korg1212/korg1212.c b/sound/pci/korg1212/korg1212.c index 59d21c9..9dd7f96 100644 --- a/sound/pci/korg1212/korg1212.c +++ b/sound/pci/korg1212/korg1212.c @@ -38,20 +38,9 @@
#include <asm/io.h>
-// ---------------------------------------------------------------------------- -// Debug Stuff -// ---------------------------------------------------------------------------- -#define K1212_DEBUG_LEVEL 0 -#if K1212_DEBUG_LEVEL > 0 -#define K1212_DEBUG_PRINTK(fmt,args...) printk(KERN_DEBUG fmt,##args) -#else -#define K1212_DEBUG_PRINTK(fmt,...) -#endif -#if K1212_DEBUG_LEVEL > 1 -#define K1212_DEBUG_PRINTK_VERBOSE(fmt,args...) printk(KERN_DEBUG fmt,##args) -#else -#define K1212_DEBUG_PRINTK_VERBOSE(fmt,...) -#endif +/* #define K1212_DEBUG_MEMORY_RANGES */ +#define k1212_dbg(k1212, fmt, ...) \ + dev_dbg((k1212)->card->dev, fmt, ##__VA_ARGS__)
// ---------------------------------------------------------------------------- // Record/Play Buffer Allocation Method. If K1212_LARGEALLOC is defined all @@ -530,12 +519,12 @@ static int snd_korg1212_Send1212Command(struct snd_korg1212 *korg1212, int rc = K1212_CMDRET_Success;
if (!korg1212->outDoorbellPtr) { - K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: CardUninitialized\n"); + k1212_dbg(korg1212, "CardUninitialized\n"); return K1212_CMDRET_CardUninitialized; }
- K1212_DEBUG_PRINTK("K1212_DEBUG: Card <- 0x%08x 0x%08x [%s]\n", - doorbellVal, mailBox0Val, stateName[korg1212->cardState]); + k1212_dbg(korg1212, "Card <- 0x%08x 0x%08x [%s]\n", + doorbellVal, mailBox0Val, stateName[korg1212->cardState]); for (retryCount = 0; retryCount < MAX_COMMAND_RETRIES; retryCount++) { writel(mailBox3Val, korg1212->mailbox3Ptr); writel(mailBox2Val, korg1212->mailbox2Ptr); @@ -562,7 +551,7 @@ static int snd_korg1212_Send1212Command(struct snd_korg1212 *korg1212, mailBox3Lo = readl(korg1212->mailbox3Ptr); if (mailBox3Lo & COMMAND_ACK_MASK) { if ((mailBox3Lo & DOORBELL_VAL_MASK) == (doorbellVal & DOORBELL_VAL_MASK)) { - K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: Card <- Success\n"); + k1212_dbg(korg1212, "Card <- Success\n"); rc = K1212_CMDRET_Success; break; } @@ -571,7 +560,7 @@ static int snd_korg1212_Send1212Command(struct snd_korg1212 *korg1212, korg1212->cmdRetryCount += retryCount;
if (retryCount >= MAX_COMMAND_RETRIES) { - K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: Card <- NoAckFromCard\n"); + k1212_dbg(korg1212, "Card <- NoAckFromCard\n"); rc = K1212_CMDRET_NoAckFromCard; }
@@ -612,8 +601,8 @@ static void snd_korg1212_timer_func(unsigned long data) korg1212->stop_pending_cnt = 0; korg1212->dsp_stop_is_processed = 1; wake_up(&korg1212->wait); - K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: Stop ack'ed [%s]\n", - stateName[korg1212->cardState]); + k1212_dbg(korg1212, "Stop ack'ed [%s]\n", + stateName[korg1212->cardState]); } else { if (--korg1212->stop_pending_cnt > 0) { /* reprogram timer */ @@ -624,8 +613,8 @@ static void snd_korg1212_timer_func(unsigned long data) korg1212->sharedBufferPtr->cardCommand = 0; korg1212->dsp_stop_is_processed = 1; wake_up(&korg1212->wait); - K1212_DEBUG_PRINTK("K1212_DEBUG: Stop timeout [%s]\n", - stateName[korg1212->cardState]); + k1212_dbg(korg1212, "Stop timeout [%s]\n", + stateName[korg1212->cardState]); } } spin_unlock_irqrestore(&korg1212->lock, flags); @@ -660,8 +649,8 @@ static inline void snd_korg1212_setCardState(struct snd_korg1212 * korg1212, enu
static int snd_korg1212_OpenCard(struct snd_korg1212 * korg1212) { - K1212_DEBUG_PRINTK("K1212_DEBUG: OpenCard [%s] %d\n", - stateName[korg1212->cardState], korg1212->opencnt); + k1212_dbg(korg1212, "OpenCard [%s] %d\n", + stateName[korg1212->cardState], korg1212->opencnt); mutex_lock(&korg1212->open_mutex); if (korg1212->opencnt++ == 0) { snd_korg1212_TurnOffIdleMonitor(korg1212); @@ -674,8 +663,8 @@ static int snd_korg1212_OpenCard(struct snd_korg1212 * korg1212)
static int snd_korg1212_CloseCard(struct snd_korg1212 * korg1212) { - K1212_DEBUG_PRINTK("K1212_DEBUG: CloseCard [%s] %d\n", - stateName[korg1212->cardState], korg1212->opencnt); + k1212_dbg(korg1212, "CloseCard [%s] %d\n", + stateName[korg1212->cardState], korg1212->opencnt);
mutex_lock(&korg1212->open_mutex); if (--(korg1212->opencnt)) { @@ -687,8 +676,8 @@ static int snd_korg1212_CloseCard(struct snd_korg1212 * korg1212) int rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_SelectPlayMode, K1212_MODE_StopPlay, 0, 0, 0); if (rc) - K1212_DEBUG_PRINTK("K1212_DEBUG: CloseCard - RC = %d [%s]\n", - rc, stateName[korg1212->cardState]); + k1212_dbg(korg1212, "CloseCard - RC = %d [%s]\n", + rc, stateName[korg1212->cardState]); if (rc != K1212_CMDRET_Success) { mutex_unlock(&korg1212->open_mutex); return 0; @@ -711,8 +700,8 @@ static int snd_korg1212_SetupForPlay(struct snd_korg1212 * korg1212) { int rc;
- K1212_DEBUG_PRINTK("K1212_DEBUG: SetupForPlay [%s] %d\n", - stateName[korg1212->cardState], korg1212->setcnt); + k1212_dbg(korg1212, "SetupForPlay [%s] %d\n", + stateName[korg1212->cardState], korg1212->setcnt);
if (korg1212->setcnt++) return 0; @@ -721,8 +710,8 @@ static int snd_korg1212_SetupForPlay(struct snd_korg1212 * korg1212) rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_SelectPlayMode, K1212_MODE_SetupPlay, 0, 0, 0); if (rc) - K1212_DEBUG_PRINTK("K1212_DEBUG: SetupForPlay - RC = %d [%s]\n", - rc, stateName[korg1212->cardState]); + k1212_dbg(korg1212, "SetupForPlay - RC = %d [%s]\n", + rc, stateName[korg1212->cardState]); if (rc != K1212_CMDRET_Success) { return 1; } @@ -734,8 +723,8 @@ static int snd_korg1212_TriggerPlay(struct snd_korg1212 * korg1212) { int rc;
- K1212_DEBUG_PRINTK("K1212_DEBUG: TriggerPlay [%s] %d\n", - stateName[korg1212->cardState], korg1212->playcnt); + k1212_dbg(korg1212, "TriggerPlay [%s] %d\n", + stateName[korg1212->cardState], korg1212->playcnt);
if (korg1212->playcnt++) return 0; @@ -743,8 +732,8 @@ static int snd_korg1212_TriggerPlay(struct snd_korg1212 * korg1212) snd_korg1212_setCardState(korg1212, K1212_STATE_PLAYING); rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_TriggerPlay, 0, 0, 0, 0); if (rc) - K1212_DEBUG_PRINTK("K1212_DEBUG: TriggerPlay - RC = %d [%s]\n", - rc, stateName[korg1212->cardState]); + k1212_dbg(korg1212, "TriggerPlay - RC = %d [%s]\n", + rc, stateName[korg1212->cardState]); if (rc != K1212_CMDRET_Success) { return 1; } @@ -754,8 +743,8 @@ static int snd_korg1212_TriggerPlay(struct snd_korg1212 * korg1212) /* spinlock already held */ static int snd_korg1212_StopPlay(struct snd_korg1212 * korg1212) { - K1212_DEBUG_PRINTK("K1212_DEBUG: StopPlay [%s] %d\n", - stateName[korg1212->cardState], korg1212->playcnt); + k1212_dbg(korg1212, "StopPlay [%s] %d\n", + stateName[korg1212->cardState], korg1212->playcnt);
if (--(korg1212->playcnt)) return 0; @@ -784,8 +773,8 @@ static void snd_korg1212_EnableCardInterrupts(struct snd_korg1212 * korg1212) static int snd_korg1212_SetMonitorMode(struct snd_korg1212 *korg1212, enum MonitorModeSelector mode) { - K1212_DEBUG_PRINTK("K1212_DEBUG: SetMonitorMode [%s]\n", - stateName[korg1212->cardState]); + k1212_dbg(korg1212, "SetMonitorMode [%s]\n", + stateName[korg1212->cardState]);
switch (mode) { case K1212_MONMODE_Off: @@ -866,8 +855,8 @@ static int snd_korg1212_SetRate(struct snd_korg1212 *korg1212, int rate) ClockSourceSelector[korg1212->clkSrcRate], 0, 0, 0); if (rc) - K1212_DEBUG_PRINTK("K1212_DEBUG: Set Clock Source Selector - RC = %d [%s]\n", - rc, stateName[korg1212->cardState]); + k1212_dbg(korg1212, "Set Clock Source Selector - RC = %d [%s]\n", + rc, stateName[korg1212->cardState]);
return 0; } @@ -902,8 +891,8 @@ static int snd_korg1212_WriteADCSensitivity(struct snd_korg1212 *korg1212) u16 count; unsigned long flags;
- K1212_DEBUG_PRINTK("K1212_DEBUG: WriteADCSensivity [%s]\n", - stateName[korg1212->cardState]); + k1212_dbg(korg1212, "WriteADCSensivity [%s]\n", + stateName[korg1212->cardState]);
// ---------------------------------------------------------------------------- // initialize things. The local init bit is always set when writing to the @@ -1026,8 +1015,8 @@ static int snd_korg1212_WriteADCSensitivity(struct snd_korg1212 *korg1212) int rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_SelectPlayMode, K1212_MODE_MonitorOn, 0, 0, 0); if (rc) - K1212_DEBUG_PRINTK("K1212_DEBUG: WriteADCSensivity - RC = %d [%s]\n", - rc, stateName[korg1212->cardState]); + k1212_dbg(korg1212, "WriteADCSensivity - RC = %d [%s]\n", + rc, stateName[korg1212->cardState]); }
spin_unlock_irqrestore(&korg1212->lock, flags); @@ -1039,8 +1028,8 @@ static void snd_korg1212_OnDSPDownloadComplete(struct snd_korg1212 *korg1212) { int channel, rc;
- K1212_DEBUG_PRINTK("K1212_DEBUG: DSP download is complete. [%s]\n", - stateName[korg1212->cardState]); + k1212_dbg(korg1212, "DSP download is complete. [%s]\n", + stateName[korg1212->cardState]);
// ---------------------------------------------------- // tell the card to boot @@ -1048,8 +1037,8 @@ static void snd_korg1212_OnDSPDownloadComplete(struct snd_korg1212 *korg1212) rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_BootFromDSPPage4, 0, 0, 0, 0);
if (rc) - K1212_DEBUG_PRINTK("K1212_DEBUG: Boot from Page 4 - RC = %d [%s]\n", - rc, stateName[korg1212->cardState]); + k1212_dbg(korg1212, "Boot from Page 4 - RC = %d [%s]\n", + rc, stateName[korg1212->cardState]); msleep(DSP_BOOT_DELAY_IN_MS);
// -------------------------------------------------------------------------------- @@ -1065,8 +1054,8 @@ static void snd_korg1212_OnDSPDownloadComplete(struct snd_korg1212 *korg1212) );
if (rc) - K1212_DEBUG_PRINTK("K1212_DEBUG: Configure Buffer Memory - RC = %d [%s]\n", - rc, stateName[korg1212->cardState]); + k1212_dbg(korg1212, "Configure Buffer Memory - RC = %d [%s]\n", + rc, stateName[korg1212->cardState]);
udelay(INTERCOMMAND_DELAY);
@@ -1079,8 +1068,8 @@ static void snd_korg1212_OnDSPDownloadComplete(struct snd_korg1212 *korg1212) );
if (rc) - K1212_DEBUG_PRINTK("K1212_DEBUG: Configure Misc Memory - RC = %d [%s]\n", - rc, stateName[korg1212->cardState]); + k1212_dbg(korg1212, "Configure Misc Memory - RC = %d [%s]\n", + rc, stateName[korg1212->cardState]);
// -------------------------------------------------------------------------------- // Initialize the routing and volume tables, then update the card's state. @@ -1100,15 +1089,15 @@ static void snd_korg1212_OnDSPDownloadComplete(struct snd_korg1212 *korg1212) ClockSourceSelector[korg1212->clkSrcRate], 0, 0, 0); if (rc) - K1212_DEBUG_PRINTK("K1212_DEBUG: Set Clock Source Selector - RC = %d [%s]\n", - rc, stateName[korg1212->cardState]); + k1212_dbg(korg1212, "Set Clock Source Selector - RC = %d [%s]\n", + rc, stateName[korg1212->cardState]);
rc = snd_korg1212_TurnOnIdleMonitor(korg1212); snd_korg1212_setCardState(korg1212, K1212_STATE_READY);
if (rc) - K1212_DEBUG_PRINTK("K1212_DEBUG: Set Monitor On - RC = %d [%s]\n", - rc, stateName[korg1212->cardState]); + k1212_dbg(korg1212, "Set Monitor On - RC = %d [%s]\n", + rc, stateName[korg1212->cardState]);
snd_korg1212_setCardState(korg1212, K1212_STATE_DSP_COMPLETE); } @@ -1133,9 +1122,9 @@ static irqreturn_t snd_korg1212_interrupt(int irq, void *dev_id)
switch (doorbellValue) { case K1212_DB_DSPDownloadDone: - K1212_DEBUG_PRINTK("K1212_DEBUG: IRQ DNLD count - %ld, %x, [%s].\n", - korg1212->irqcount, doorbellValue, - stateName[korg1212->cardState]); + k1212_dbg(korg1212, "IRQ DNLD count - %ld, %x, [%s]\n", + korg1212->irqcount, doorbellValue, + stateName[korg1212->cardState]); if (korg1212->cardState == K1212_STATE_DSP_IN_PROCESS) { korg1212->dsp_is_loaded = 1; wake_up(&korg1212->wait); @@ -1146,9 +1135,9 @@ static irqreturn_t snd_korg1212_interrupt(int irq, void *dev_id) // an error occurred - stop the card // ------------------------------------------------------------------------ case K1212_DB_DMAERROR: - K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: IRQ DMAE count - %ld, %x, [%s].\n", - korg1212->irqcount, doorbellValue, - stateName[korg1212->cardState]); + k1212_dbg(korg1212, "IRQ DMAE count - %ld, %x, [%s].\n", + korg1212->irqcount, doorbellValue, + stateName[korg1212->cardState]); snd_printk(KERN_ERR "korg1212: DMA Error\n"); korg1212->errorcnt++; korg1212->totalerrorcnt++; @@ -1161,16 +1150,17 @@ static irqreturn_t snd_korg1212_interrupt(int irq, void *dev_id) // the semaphore in case someone is waiting for this. // ------------------------------------------------------------------------ case K1212_DB_CARDSTOPPED: - K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: IRQ CSTP count - %ld, %x, [%s].\n", - korg1212->irqcount, doorbellValue, - stateName[korg1212->cardState]); + k1212_dbg(korg1212, "IRQ CSTP count - %ld, %x, [%s]\n", + korg1212->irqcount, doorbellValue, + stateName[korg1212->cardState]); korg1212->sharedBufferPtr->cardCommand = 0; break;
default: - K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: IRQ DFLT count - %ld, %x, cpos=%d [%s].\n", - korg1212->irqcount, doorbellValue, - korg1212->currentBuffer, stateName[korg1212->cardState]); + k1212_dbg(korg1212, "IRQ DFLT count - %ld, %x, cpos=%d [%s]\n", + korg1212->irqcount, doorbellValue, + korg1212->currentBuffer, + stateName[korg1212->cardState]); if ((korg1212->cardState > K1212_STATE_SETUP) || korg1212->idleMonitorOn) { korg1212->currentBuffer++;
@@ -1206,8 +1196,8 @@ static int snd_korg1212_downloadDSPCode(struct snd_korg1212 *korg1212) { int rc;
- K1212_DEBUG_PRINTK("K1212_DEBUG: DSP download is starting... [%s]\n", - stateName[korg1212->cardState]); + k1212_dbg(korg1212, "DSP download is starting... [%s]\n", + stateName[korg1212->cardState]);
// --------------------------------------------------------------- // verify the state of the card before proceeding. @@ -1221,8 +1211,8 @@ static int snd_korg1212_downloadDSPCode(struct snd_korg1212 *korg1212) UpperWordSwap(korg1212->dma_dsp.addr), 0, 0, 0); if (rc) - K1212_DEBUG_PRINTK("K1212_DEBUG: Start DSP Download RC = %d [%s]\n", - rc, stateName[korg1212->cardState]); + k1212_dbg(korg1212, "Start DSP Download RC = %d [%s]\n", + rc, stateName[korg1212->cardState]);
korg1212->dsp_is_loaded = 0; wait_event_timeout(korg1212->wait, korg1212->dsp_is_loaded, HZ * CARD_BOOT_TIMEOUT); @@ -1281,16 +1271,16 @@ static int snd_korg1212_silence(struct snd_korg1212 *korg1212, int pos, int coun struct KorgAudioFrame * dst = korg1212->playDataBufsPtr[0].bufferData + pos; int i;
- K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: snd_korg1212_silence pos=%d offset=%d size=%d count=%d\n", - pos, offset, size, count); + k1212_dbg(korg1212, "snd_korg1212_silence pos=%d offset=%d size=%d count=%d\n", + pos, offset, size, count); if (snd_BUG_ON(pos + count > K1212_MAX_SAMPLES)) return -EINVAL;
for (i=0; i < count; i++) { -#if K1212_DEBUG_LEVEL > 0 +#ifdef K1212_DEBUG_MEMORY_RANGES if ( (void *) dst < (void *) korg1212->playDataBufsPtr || (void *) dst > (void *) korg1212->playDataBufsPtr[8].bufferData ) { - printk(KERN_DEBUG "K1212_DEBUG: snd_korg1212_silence KERNEL EFAULT dst=%p iter=%d\n", + printk(KERN_DEBUG "snd_korg1212_silence KERNEL EFAULT dst=%p iter=%d\n", dst, i); return -EFAULT; } @@ -1307,22 +1297,24 @@ static int snd_korg1212_copy_to(struct snd_korg1212 *korg1212, void __user *dst, struct KorgAudioFrame * src = korg1212->recordDataBufsPtr[0].bufferData + pos; int i, rc;
- K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: snd_korg1212_copy_to pos=%d offset=%d size=%d\n", - pos, offset, size); + k1212_dbg(korg1212, "snd_korg1212_copy_to pos=%d offset=%d size=%d\n", + pos, offset, size); if (snd_BUG_ON(pos + count > K1212_MAX_SAMPLES)) return -EINVAL;
for (i=0; i < count; i++) { -#if K1212_DEBUG_LEVEL > 0 +#ifdef K1212_DEBUG_MEMORY_RANGES if ( (void *) src < (void *) korg1212->recordDataBufsPtr || (void *) src > (void *) korg1212->recordDataBufsPtr[8].bufferData ) { - printk(KERN_DEBUG "K1212_DEBUG: snd_korg1212_copy_to KERNEL EFAULT, src=%p dst=%p iter=%d\n", src, dst, i); + printk(KERN_DEBUG "snd_korg1212_copy_to KERNEL EFAULT, src=%p dst=%p iter=%d\n", + src, dst, i); return -EFAULT; } #endif rc = copy_to_user(dst + offset, src, size); if (rc) { - K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_copy_to USER EFAULT src=%p dst=%p iter=%d\n", src, dst, i); + k1212_dbg(korg1212, "snd_korg1212_copy_to USER EFAULT src=%p dst=%p iter=%d\n", + src, dst, i); return -EFAULT; } src++; @@ -1337,23 +1329,25 @@ static int snd_korg1212_copy_from(struct snd_korg1212 *korg1212, void __user *sr struct KorgAudioFrame * dst = korg1212->playDataBufsPtr[0].bufferData + pos; int i, rc;
- K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: snd_korg1212_copy_from pos=%d offset=%d size=%d count=%d\n", - pos, offset, size, count); + k1212_dbg(korg1212, "snd_korg1212_copy_from pos=%d offset=%d size=%d count=%d\n", + pos, offset, size, count);
if (snd_BUG_ON(pos + count > K1212_MAX_SAMPLES)) return -EINVAL;
for (i=0; i < count; i++) { -#if K1212_DEBUG_LEVEL > 0 +#ifdef K1212_DEBUG_MEMORY_RANGES if ( (void *) dst < (void *) korg1212->playDataBufsPtr || (void *) dst > (void *) korg1212->playDataBufsPtr[8].bufferData ) { - printk(KERN_DEBUG "K1212_DEBUG: snd_korg1212_copy_from KERNEL EFAULT, src=%p dst=%p iter=%d\n", src, dst, i); + printk(KERN_DEBUG "snd_korg1212_copy_from KERNEL EFAULT, src=%p dst=%p iter=%d\n", + src, dst, i); return -EFAULT; } #endif rc = copy_from_user((void*) dst + offset, src, size); if (rc) { - K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_copy_from USER EFAULT src=%p dst=%p iter=%d\n", src, dst, i); + k1212_dbg(korg1212, "snd_korg1212_copy_from USER EFAULT src=%p dst=%p iter=%d\n", + src, dst, i); return -EFAULT; } dst++; @@ -1367,8 +1361,8 @@ static void snd_korg1212_free_pcm(struct snd_pcm *pcm) { struct snd_korg1212 *korg1212 = pcm->private_data;
- K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_free_pcm [%s]\n", - stateName[korg1212->cardState]); + k1212_dbg(korg1212, "snd_korg1212_free_pcm [%s]\n", + stateName[korg1212->cardState]);
korg1212->pcm = NULL; } @@ -1379,8 +1373,8 @@ static int snd_korg1212_playback_open(struct snd_pcm_substream *substream) struct snd_korg1212 *korg1212 = snd_pcm_substream_chip(substream); struct snd_pcm_runtime *runtime = substream->runtime;
- K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_playback_open [%s]\n", - stateName[korg1212->cardState]); + k1212_dbg(korg1212, "snd_korg1212_playback_open [%s]\n", + stateName[korg1212->cardState]);
snd_korg1212_OpenCard(korg1212);
@@ -1408,8 +1402,8 @@ static int snd_korg1212_capture_open(struct snd_pcm_substream *substream) struct snd_korg1212 *korg1212 = snd_pcm_substream_chip(substream); struct snd_pcm_runtime *runtime = substream->runtime;
- K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_capture_open [%s]\n", - stateName[korg1212->cardState]); + k1212_dbg(korg1212, "snd_korg1212_capture_open [%s]\n", + stateName[korg1212->cardState]);
snd_korg1212_OpenCard(korg1212);
@@ -1435,8 +1429,8 @@ static int snd_korg1212_playback_close(struct snd_pcm_substream *substream) unsigned long flags; struct snd_korg1212 *korg1212 = snd_pcm_substream_chip(substream);
- K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_playback_close [%s]\n", - stateName[korg1212->cardState]); + k1212_dbg(korg1212, "snd_korg1212_playback_close [%s]\n", + stateName[korg1212->cardState]);
snd_korg1212_silence(korg1212, 0, K1212_MAX_SAMPLES, 0, korg1212->channels * 2);
@@ -1457,8 +1451,8 @@ static int snd_korg1212_capture_close(struct snd_pcm_substream *substream) unsigned long flags; struct snd_korg1212 *korg1212 = snd_pcm_substream_chip(substream);
- K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_capture_close [%s]\n", - stateName[korg1212->cardState]); + k1212_dbg(korg1212, "snd_korg1212_capture_close [%s]\n", + stateName[korg1212->cardState]);
spin_lock_irqsave(&korg1212->lock, flags);
@@ -1475,14 +1469,14 @@ static int snd_korg1212_capture_close(struct snd_pcm_substream *substream) static int snd_korg1212_ioctl(struct snd_pcm_substream *substream, unsigned int cmd, void *arg) { - K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_ioctl: cmd=%d\n", cmd); - if (cmd == SNDRV_PCM_IOCTL1_CHANNEL_INFO ) { + struct snd_korg1212 *korg1212 = snd_pcm_substream_chip(substream); struct snd_pcm_channel_info *info = arg; info->offset = 0; info->first = info->channel * 16; info->step = 256; - K1212_DEBUG_PRINTK("K1212_DEBUG: channel_info %d:, offset=%ld, first=%d, step=%d\n", info->channel, info->offset, info->first, info->step); + k1212_dbg(korg1212, "channel_info %d:, offset=%ld, first=%d, step=%d\n", + info->channel, info->offset, info->first, info->step); return 0; }
@@ -1498,8 +1492,8 @@ static int snd_korg1212_hw_params(struct snd_pcm_substream *substream, pid_t this_pid; pid_t other_pid;
- K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_hw_params [%s]\n", - stateName[korg1212->cardState]); + k1212_dbg(korg1212, "snd_korg1212_hw_params [%s]\n", + stateName[korg1212->cardState]);
spin_lock_irqsave(&korg1212->lock, flags);
@@ -1546,15 +1540,15 @@ static int snd_korg1212_prepare(struct snd_pcm_substream *substream) struct snd_korg1212 *korg1212 = snd_pcm_substream_chip(substream); int rc;
- K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_prepare [%s]\n", - stateName[korg1212->cardState]); + k1212_dbg(korg1212, "snd_korg1212_prepare [%s]\n", + stateName[korg1212->cardState]);
spin_lock_irq(&korg1212->lock);
/* FIXME: we should wait for ack! */ if (korg1212->stop_pending_cnt > 0) { - K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_prepare - Stop is pending... [%s]\n", - stateName[korg1212->cardState]); + k1212_dbg(korg1212, "snd_korg1212_prepare - Stop is pending... [%s]\n", + stateName[korg1212->cardState]); spin_unlock_irq(&korg1212->lock); return -EAGAIN; /* @@ -1579,16 +1573,16 @@ static int snd_korg1212_trigger(struct snd_pcm_substream *substream, struct snd_korg1212 *korg1212 = snd_pcm_substream_chip(substream); int rc;
- K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_trigger [%s] cmd=%d\n", - stateName[korg1212->cardState], cmd); + k1212_dbg(korg1212, "snd_korg1212_trigger [%s] cmd=%d\n", + stateName[korg1212->cardState], cmd);
spin_lock(&korg1212->lock); switch (cmd) { case SNDRV_PCM_TRIGGER_START: /* if (korg1212->running) { - K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: snd_korg1212_trigger: Already running?\n"); - break; + k1212_dbg(korg1212, "snd_korg1212_trigger: Already running?\n"); + break; } */ korg1212->running++; @@ -1598,8 +1592,8 @@ static int snd_korg1212_trigger(struct snd_pcm_substream *substream, case SNDRV_PCM_TRIGGER_STOP: /* if (!korg1212->running) { - K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: snd_korg1212_trigger: Already stopped?\n"); - break; + k1212_dbg(korg1212, "snd_korg1212_trigger: Already stopped?\n"); + break; } */ korg1212->running--; @@ -1621,8 +1615,8 @@ static snd_pcm_uframes_t snd_korg1212_playback_pointer(struct snd_pcm_substream
pos = korg1212->currentBuffer * kPlayBufferFrames;
- K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: snd_korg1212_playback_pointer [%s] %ld\n", - stateName[korg1212->cardState], pos); + k1212_dbg(korg1212, "snd_korg1212_playback_pointer [%s] %ld\n", + stateName[korg1212->cardState], pos);
return pos; } @@ -1634,8 +1628,8 @@ static snd_pcm_uframes_t snd_korg1212_capture_pointer(struct snd_pcm_substream *
pos = korg1212->currentBuffer * kPlayBufferFrames;
- K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: snd_korg1212_capture_pointer [%s] %ld\n", - stateName[korg1212->cardState], pos); + k1212_dbg(korg1212, "snd_korg1212_capture_pointer [%s] %ld\n", + stateName[korg1212->cardState], pos);
return pos; } @@ -1648,8 +1642,8 @@ static int snd_korg1212_playback_copy(struct snd_pcm_substream *substream, { struct snd_korg1212 *korg1212 = snd_pcm_substream_chip(substream);
- K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: snd_korg1212_playback_copy [%s] %ld %ld\n", - stateName[korg1212->cardState], pos, count); + k1212_dbg(korg1212, "snd_korg1212_playback_copy [%s] %ld %ld\n", + stateName[korg1212->cardState], pos, count);
return snd_korg1212_copy_from(korg1212, src, pos, count, 0, korg1212->channels * 2);
@@ -1662,8 +1656,8 @@ static int snd_korg1212_playback_silence(struct snd_pcm_substream *substream, { struct snd_korg1212 *korg1212 = snd_pcm_substream_chip(substream);
- K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: snd_korg1212_playback_silence [%s]\n", - stateName[korg1212->cardState]); + k1212_dbg(korg1212, "snd_korg1212_playback_silence [%s]\n", + stateName[korg1212->cardState]);
return snd_korg1212_silence(korg1212, pos, count, 0, korg1212->channels * 2); } @@ -1676,8 +1670,8 @@ static int snd_korg1212_capture_copy(struct snd_pcm_substream *substream, { struct snd_korg1212 *korg1212 = snd_pcm_substream_chip(substream);
- K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: snd_korg1212_capture_copy [%s] %ld %ld\n", - stateName[korg1212->cardState], pos, count); + k1212_dbg(korg1212, "snd_korg1212_capture_copy [%s] %ld %ld\n", + stateName[korg1212->cardState], pos, count);
return snd_korg1212_copy_to(korg1212, dst, pos, count, 0, korg1212->channels * 2); } @@ -2138,7 +2132,7 @@ snd_korg1212_free(struct snd_korg1212 *korg1212) static int snd_korg1212_dev_free(struct snd_device *device) { struct snd_korg1212 *korg1212 = device->device_data; - K1212_DEBUG_PRINTK("K1212_DEBUG: Freeing device\n"); + k1212_dbg(korg1212, "Freeing device\n"); return snd_korg1212_free(korg1212); }
@@ -2210,15 +2204,15 @@ static int snd_korg1212_create(struct snd_card *card, struct pci_dev *pci, ioport_size = pci_resource_len(korg1212->pci, 1); iomem2_size = pci_resource_len(korg1212->pci, 2);
- K1212_DEBUG_PRINTK("K1212_DEBUG: resources:\n" - " iomem = 0x%lx (%d)\n" - " ioport = 0x%lx (%d)\n" - " iomem = 0x%lx (%d)\n" - " [%s]\n", - korg1212->iomem, iomem_size, - korg1212->ioport, ioport_size, - korg1212->iomem2, iomem2_size, - stateName[korg1212->cardState]); + k1212_dbg(korg1212, "resources:\n" + " iomem = 0x%lx (%d)\n" + " ioport = 0x%lx (%d)\n" + " iomem = 0x%lx (%d)\n" + " [%s]\n", + korg1212->iomem, iomem_size, + korg1212->ioport, ioport_size, + korg1212->iomem2, iomem2_size, + stateName[korg1212->cardState]);
if ((korg1212->iobase = ioremap(korg1212->iomem, iomem_size)) == NULL) { snd_printk(KERN_ERR "korg1212: unable to remap memory region 0x%lx-0x%lx\n", korg1212->iomem, @@ -2252,29 +2246,29 @@ static int snd_korg1212_create(struct snd_card *card, struct pci_dev *pci, korg1212->sensRegPtr = (u16 __iomem *) (korg1212->iobase + SENS_CONTROL_OFFSET); korg1212->idRegPtr = (u32 __iomem *) (korg1212->iobase + DEV_VEND_ID_OFFSET);
- K1212_DEBUG_PRINTK("K1212_DEBUG: card registers:\n" - " Status register = 0x%p\n" - " OutDoorbell = 0x%p\n" - " InDoorbell = 0x%p\n" - " Mailbox0 = 0x%p\n" - " Mailbox1 = 0x%p\n" - " Mailbox2 = 0x%p\n" - " Mailbox3 = 0x%p\n" - " ControlReg = 0x%p\n" - " SensReg = 0x%p\n" - " IDReg = 0x%p\n" - " [%s]\n", - korg1212->statusRegPtr, - korg1212->outDoorbellPtr, - korg1212->inDoorbellPtr, - korg1212->mailbox0Ptr, - korg1212->mailbox1Ptr, - korg1212->mailbox2Ptr, - korg1212->mailbox3Ptr, - korg1212->controlRegPtr, - korg1212->sensRegPtr, - korg1212->idRegPtr, - stateName[korg1212->cardState]); + k1212_dbg(korg1212, "card registers:\n" + " Status register = 0x%p\n" + " OutDoorbell = 0x%p\n" + " InDoorbell = 0x%p\n" + " Mailbox0 = 0x%p\n" + " Mailbox1 = 0x%p\n" + " Mailbox2 = 0x%p\n" + " Mailbox3 = 0x%p\n" + " ControlReg = 0x%p\n" + " SensReg = 0x%p\n" + " IDReg = 0x%p\n" + " [%s]\n", + korg1212->statusRegPtr, + korg1212->outDoorbellPtr, + korg1212->inDoorbellPtr, + korg1212->mailbox0Ptr, + korg1212->mailbox1Ptr, + korg1212->mailbox2Ptr, + korg1212->mailbox3Ptr, + korg1212->controlRegPtr, + korg1212->sensRegPtr, + korg1212->idRegPtr, + stateName[korg1212->cardState]);
if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci), sizeof(struct KorgSharedBuffer), &korg1212->dma_shared) < 0) { @@ -2285,7 +2279,9 @@ static int snd_korg1212_create(struct snd_card *card, struct pci_dev *pci, korg1212->sharedBufferPtr = (struct KorgSharedBuffer *)korg1212->dma_shared.area; korg1212->sharedBufferPhy = korg1212->dma_shared.addr;
- K1212_DEBUG_PRINTK("K1212_DEBUG: Shared Buffer Area = 0x%p (0x%08lx), %d bytes\n", korg1212->sharedBufferPtr, korg1212->sharedBufferPhy, sizeof(struct KorgSharedBuffer)); + k1212_dbg(korg1212, "Shared Buffer Area = 0x%p (0x%08lx), %zu bytes\n", + korg1212->sharedBufferPtr, korg1212->sharedBufferPhy, + sizeof(struct KorgSharedBuffer));
#ifndef K1212_LARGEALLOC
@@ -2300,8 +2296,9 @@ static int snd_korg1212_create(struct snd_card *card, struct pci_dev *pci, korg1212->playDataBufsPtr = (struct KorgAudioBuffer *)korg1212->dma_play.area; korg1212->PlayDataPhy = korg1212->dma_play.addr;
- K1212_DEBUG_PRINTK("K1212_DEBUG: Play Data Area = 0x%p (0x%08x), %d bytes\n", - korg1212->playDataBufsPtr, korg1212->PlayDataPhy, korg1212->DataBufsSize); + k1212_dbg(korg1212, "Play Data Area = 0x%p (0x%08x), %d bytes\n", + korg1212->playDataBufsPtr, korg1212->PlayDataPhy, + korg1212->DataBufsSize);
if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci), korg1212->DataBufsSize, &korg1212->dma_rec) < 0) { @@ -2312,8 +2309,9 @@ static int snd_korg1212_create(struct snd_card *card, struct pci_dev *pci, korg1212->recordDataBufsPtr = (struct KorgAudioBuffer *)korg1212->dma_rec.area; korg1212->RecDataPhy = korg1212->dma_rec.addr;
- K1212_DEBUG_PRINTK("K1212_DEBUG: Record Data Area = 0x%p (0x%08x), %d bytes\n", - korg1212->recordDataBufsPtr, korg1212->RecDataPhy, korg1212->DataBufsSize); + k1212_dbg(korg1212, "Record Data Area = 0x%p (0x%08x), %d bytes\n", + korg1212->recordDataBufsPtr, korg1212->RecDataPhy, + korg1212->DataBufsSize);
#else // K1212_LARGEALLOC
@@ -2347,9 +2345,9 @@ static int snd_korg1212_create(struct snd_card *card, struct pci_dev *pci, return -ENOMEM; }
- K1212_DEBUG_PRINTK("K1212_DEBUG: DSP Code area = 0x%p (0x%08x) %d bytes [%s]\n", - korg1212->dma_dsp.area, korg1212->dma_dsp.addr, dsp_code->size, - stateName[korg1212->cardState]); + k1212_dbg(korg1212, "DSP Code area = 0x%p (%pad) %zu bytes [%s]\n", + korg1212->dma_dsp.area, &korg1212->dma_dsp.addr, + dsp_code->size, stateName[korg1212->cardState]);
memcpy(korg1212->dma_dsp.area, dsp_code->data, dsp_code->size);
@@ -2358,7 +2356,8 @@ static int snd_korg1212_create(struct snd_card *card, struct pci_dev *pci, rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_RebootCard, 0, 0, 0, 0);
if (rc) - K1212_DEBUG_PRINTK("K1212_DEBUG: Reboot Card - RC = %d [%s]\n", rc, stateName[korg1212->cardState]); + k1212_dbg(korg1212, "Reboot Card - RC = %d [%s]\n", + rc, stateName[korg1212->cardState]);
if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, korg1212, &ops)) < 0) { snd_korg1212_free(korg1212); @@ -2372,18 +2371,24 @@ static int snd_korg1212_create(struct snd_card *card, struct pci_dev *pci, if (snd_korg1212_downloadDSPCode(korg1212)) return -EBUSY;
- K1212_DEBUG_PRINTK("korg1212: dspMemPhy = %08x U[%08x], " - "PlayDataPhy = %08x L[%08x]\n" - "korg1212: RecDataPhy = %08x L[%08x], " - "VolumeTablePhy = %08x L[%08x]\n" - "korg1212: RoutingTablePhy = %08x L[%08x], " - "AdatTimeCodePhy = %08x L[%08x]\n", - (int)korg1212->dma_dsp.addr, UpperWordSwap(korg1212->dma_dsp.addr), - korg1212->PlayDataPhy, LowerWordSwap(korg1212->PlayDataPhy), - korg1212->RecDataPhy, LowerWordSwap(korg1212->RecDataPhy), - korg1212->VolumeTablePhy, LowerWordSwap(korg1212->VolumeTablePhy), - korg1212->RoutingTablePhy, LowerWordSwap(korg1212->RoutingTablePhy), - korg1212->AdatTimeCodePhy, LowerWordSwap(korg1212->AdatTimeCodePhy)); + k1212_dbg(korg1212, "dspMemPhy = %08x U[%08x]\n", + (int)korg1212->dma_dsp.addr, + UpperWordSwap(korg1212->dma_dsp.addr)); + k1212_dbg(korg1212, "PlayDataPhy = %08x L[%08x]\n", + korg1212->PlayDataPhy, + LowerWordSwap(korg1212->PlayDataPhy)); + k1212_dbg(korg1212, "RecDataPhy = %08x L[%08x]\n", + korg1212->RecDataPhy, + LowerWordSwap(korg1212->RecDataPhy)); + k1212_dbg(korg1212, "VolumeTablePhy = %08x L[%08x]\n", + korg1212->VolumeTablePhy, + LowerWordSwap(korg1212->VolumeTablePhy)); + k1212_dbg(korg1212, "RoutingTablePhy = %08x L[%08x]\n", + korg1212->RoutingTablePhy, + LowerWordSwap(korg1212->RoutingTablePhy)); + k1212_dbg(korg1212, "AdatTimeCodePhy = %08x L[%08x]\n", + korg1212->AdatTimeCodePhy, + LowerWordSwap(korg1212->AdatTimeCodePhy));
if ((err = snd_pcm_new(korg1212->card, "korg1212", 0, 1, 1, &korg1212->pcm)) < 0) return err; @@ -2446,7 +2451,7 @@ snd_korg1212_probe(struct pci_dev *pci, sprintf(card->longname, "%s at 0x%lx, irq %d", card->shortname, korg1212->iomem, korg1212->irq);
- K1212_DEBUG_PRINTK("K1212_DEBUG: %s\n", card->longname); + k1212_dbg(korg1212, "%s\n", card->longname);
if ((err = snd_card_register(card)) < 0) { snd_card_free(card);
On Tue, Nov 25, 2014 at 10:59:25AM -0800, Joe Perches wrote:
On Tue, 2014-11-25 at 11:51 +0530, Sudip Mukherjee wrote:
problems with this way:
- macro name is little misleading - macro says printk, but we are using dev_dbg
- if some one later wants to add something to this file, and doesnot want to use the variable name korg1212 in his function.
any suggestions ?
Some code is so old and unlikely to be ever used again, it may be better to move it to an "ancient and crufty" folder and forget about it.
This may be one of those.
If the debugging was written in a more current style, it might look like this: (with various format/argument mismatches fixed, formatting changes, etc)
ok. and can't we delete some of the messages like "DSP download is complete." and then printing the statename. there are lots of messages like that which is just printing the function name and the statename ..
and, even if i modify it a little and send it, most of the work has been done by you. so how do i send the patch in your name or add your name in the patch ? I have not done anything so my name should not be there.
thanks sudip
I don't have this card (does anyone?), so it's compiled but untested.
sound/pci/korg1212/korg1212.c | 363 +++++++++++++++++++++--------------------- 1 file changed, 184 insertions(+), 179 deletions(-)
diff --git a/sound/pci/korg1212/korg1212.c b/sound/pci/korg1212/korg1212.c index 59d21c9..9dd7f96 100644 --- a/sound/pci/korg1212/korg1212.c +++ b/sound/pci/korg1212/korg1212.c @@ -38,20 +38,9 @@
#include <asm/io.h>
-// ---------------------------------------------------------------------------- -// Debug Stuff -// ---------------------------------------------------------------------------- -#define K1212_DEBUG_LEVEL 0 -#if K1212_DEBUG_LEVEL > 0 -#define K1212_DEBUG_PRINTK(fmt,args...) printk(KERN_DEBUG fmt,##args) -#else -#define K1212_DEBUG_PRINTK(fmt,...) -#endif -#if K1212_DEBUG_LEVEL > 1 -#define K1212_DEBUG_PRINTK_VERBOSE(fmt,args...) printk(KERN_DEBUG fmt,##args) -#else -#define K1212_DEBUG_PRINTK_VERBOSE(fmt,...) -#endif +/* #define K1212_DEBUG_MEMORY_RANGES */ +#define k1212_dbg(k1212, fmt, ...) \
- dev_dbg((k1212)->card->dev, fmt, ##__VA_ARGS__)
// ---------------------------------------------------------------------------- // Record/Play Buffer Allocation Method. If K1212_LARGEALLOC is defined all @@ -530,12 +519,12 @@ static int snd_korg1212_Send1212Command(struct snd_korg1212 *korg1212, int rc = K1212_CMDRET_Success;
if (!korg1212->outDoorbellPtr) {
K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: CardUninitialized\n");
}k1212_dbg(korg1212, "CardUninitialized\n"); return K1212_CMDRET_CardUninitialized;
- K1212_DEBUG_PRINTK("K1212_DEBUG: Card <- 0x%08x 0x%08x [%s]\n",
doorbellVal, mailBox0Val, stateName[korg1212->cardState]);
- k1212_dbg(korg1212, "Card <- 0x%08x 0x%08x [%s]\n",
writel(mailBox3Val, korg1212->mailbox3Ptr); writel(mailBox2Val, korg1212->mailbox2Ptr);doorbellVal, mailBox0Val, stateName[korg1212->cardState]); for (retryCount = 0; retryCount < MAX_COMMAND_RETRIES; retryCount++) {
@@ -562,7 +551,7 @@ static int snd_korg1212_Send1212Command(struct snd_korg1212 *korg1212, mailBox3Lo = readl(korg1212->mailbox3Ptr); if (mailBox3Lo & COMMAND_ACK_MASK) { if ((mailBox3Lo & DOORBELL_VAL_MASK) == (doorbellVal & DOORBELL_VAL_MASK)) {
K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: Card <- Success\n");
k1212_dbg(korg1212, "Card <- Success\n"); rc = K1212_CMDRET_Success; break; }
@@ -571,7 +560,7 @@ static int snd_korg1212_Send1212Command(struct snd_korg1212 *korg1212, korg1212->cmdRetryCount += retryCount;
if (retryCount >= MAX_COMMAND_RETRIES) {
K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: Card <- NoAckFromCard\n");
}k1212_dbg(korg1212, "Card <- NoAckFromCard\n"); rc = K1212_CMDRET_NoAckFromCard;
@@ -612,8 +601,8 @@ static void snd_korg1212_timer_func(unsigned long data) korg1212->stop_pending_cnt = 0; korg1212->dsp_stop_is_processed = 1; wake_up(&korg1212->wait);
K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: Stop ack'ed [%s]\n",
stateName[korg1212->cardState]);
k1212_dbg(korg1212, "Stop ack'ed [%s]\n",
} else { if (--korg1212->stop_pending_cnt > 0) { /* reprogram timer */stateName[korg1212->cardState]);
@@ -624,8 +613,8 @@ static void snd_korg1212_timer_func(unsigned long data) korg1212->sharedBufferPtr->cardCommand = 0; korg1212->dsp_stop_is_processed = 1; wake_up(&korg1212->wait);
K1212_DEBUG_PRINTK("K1212_DEBUG: Stop timeout [%s]\n",
stateName[korg1212->cardState]);
k1212_dbg(korg1212, "Stop timeout [%s]\n",
} } spin_unlock_irqrestore(&korg1212->lock, flags);stateName[korg1212->cardState]);
@@ -660,8 +649,8 @@ static inline void snd_korg1212_setCardState(struct snd_korg1212 * korg1212, enu
static int snd_korg1212_OpenCard(struct snd_korg1212 * korg1212) {
- K1212_DEBUG_PRINTK("K1212_DEBUG: OpenCard [%s] %d\n",
stateName[korg1212->cardState], korg1212->opencnt);
- k1212_dbg(korg1212, "OpenCard [%s] %d\n",
mutex_lock(&korg1212->open_mutex); if (korg1212->opencnt++ == 0) { snd_korg1212_TurnOffIdleMonitor(korg1212);stateName[korg1212->cardState], korg1212->opencnt);
@@ -674,8 +663,8 @@ static int snd_korg1212_OpenCard(struct snd_korg1212 * korg1212)
static int snd_korg1212_CloseCard(struct snd_korg1212 * korg1212) {
- K1212_DEBUG_PRINTK("K1212_DEBUG: CloseCard [%s] %d\n",
stateName[korg1212->cardState], korg1212->opencnt);
k1212_dbg(korg1212, "CloseCard [%s] %d\n",
stateName[korg1212->cardState], korg1212->opencnt);
mutex_lock(&korg1212->open_mutex); if (--(korg1212->opencnt)) {
@@ -687,8 +676,8 @@ static int snd_korg1212_CloseCard(struct snd_korg1212 * korg1212) int rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_SelectPlayMode, K1212_MODE_StopPlay, 0, 0, 0); if (rc)
K1212_DEBUG_PRINTK("K1212_DEBUG: CloseCard - RC = %d [%s]\n",
rc, stateName[korg1212->cardState]);
k1212_dbg(korg1212, "CloseCard - RC = %d [%s]\n",
if (rc != K1212_CMDRET_Success) { mutex_unlock(&korg1212->open_mutex); return 0;rc, stateName[korg1212->cardState]);
@@ -711,8 +700,8 @@ static int snd_korg1212_SetupForPlay(struct snd_korg1212 * korg1212) { int rc;
- K1212_DEBUG_PRINTK("K1212_DEBUG: SetupForPlay [%s] %d\n",
stateName[korg1212->cardState], korg1212->setcnt);
k1212_dbg(korg1212, "SetupForPlay [%s] %d\n",
stateName[korg1212->cardState], korg1212->setcnt); if (korg1212->setcnt++)
return 0;
@@ -721,8 +710,8 @@ static int snd_korg1212_SetupForPlay(struct snd_korg1212 * korg1212) rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_SelectPlayMode, K1212_MODE_SetupPlay, 0, 0, 0); if (rc)
K1212_DEBUG_PRINTK("K1212_DEBUG: SetupForPlay - RC = %d [%s]\n",
rc, stateName[korg1212->cardState]);
k1212_dbg(korg1212, "SetupForPlay - RC = %d [%s]\n",
rc, stateName[korg1212->cardState]); if (rc != K1212_CMDRET_Success) { return 1; }
@@ -734,8 +723,8 @@ static int snd_korg1212_TriggerPlay(struct snd_korg1212 * korg1212) { int rc;
- K1212_DEBUG_PRINTK("K1212_DEBUG: TriggerPlay [%s] %d\n",
stateName[korg1212->cardState], korg1212->playcnt);
k1212_dbg(korg1212, "TriggerPlay [%s] %d\n",
stateName[korg1212->cardState], korg1212->playcnt); if (korg1212->playcnt++)
return 0;
@@ -743,8 +732,8 @@ static int snd_korg1212_TriggerPlay(struct snd_korg1212 * korg1212) snd_korg1212_setCardState(korg1212, K1212_STATE_PLAYING); rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_TriggerPlay, 0, 0, 0, 0); if (rc)
K1212_DEBUG_PRINTK("K1212_DEBUG: TriggerPlay - RC = %d [%s]\n",
rc, stateName[korg1212->cardState]);
k1212_dbg(korg1212, "TriggerPlay - RC = %d [%s]\n",
rc, stateName[korg1212->cardState]); if (rc != K1212_CMDRET_Success) { return 1; }
@@ -754,8 +743,8 @@ static int snd_korg1212_TriggerPlay(struct snd_korg1212 * korg1212) /* spinlock already held */ static int snd_korg1212_StopPlay(struct snd_korg1212 * korg1212) {
- K1212_DEBUG_PRINTK("K1212_DEBUG: StopPlay [%s] %d\n",
stateName[korg1212->cardState], korg1212->playcnt);
k1212_dbg(korg1212, "StopPlay [%s] %d\n",
stateName[korg1212->cardState], korg1212->playcnt); if (--(korg1212->playcnt))
return 0;
@@ -784,8 +773,8 @@ static void snd_korg1212_EnableCardInterrupts(struct snd_korg1212 * korg1212) static int snd_korg1212_SetMonitorMode(struct snd_korg1212 *korg1212, enum MonitorModeSelector mode) {
- K1212_DEBUG_PRINTK("K1212_DEBUG: SetMonitorMode [%s]\n",
stateName[korg1212->cardState]);
k1212_dbg(korg1212, "SetMonitorMode [%s]\n",
stateName[korg1212->cardState]); switch (mode) {
case K1212_MONMODE_Off:
@@ -866,8 +855,8 @@ static int snd_korg1212_SetRate(struct snd_korg1212 *korg1212, int rate) ClockSourceSelector[korg1212->clkSrcRate], 0, 0, 0); if (rc)
K1212_DEBUG_PRINTK("K1212_DEBUG: Set Clock Source Selector - RC = %d [%s]\n",
rc, stateName[korg1212->cardState]);
k1212_dbg(korg1212, "Set Clock Source Selector - RC = %d [%s]\n",
rc, stateName[korg1212->cardState]); return 0;
} @@ -902,8 +891,8 @@ static int snd_korg1212_WriteADCSensitivity(struct snd_korg1212 *korg1212) u16 count; unsigned long flags;
- K1212_DEBUG_PRINTK("K1212_DEBUG: WriteADCSensivity [%s]\n",
stateName[korg1212->cardState]);
k1212_dbg(korg1212, "WriteADCSensivity [%s]\n",
stateName[korg1212->cardState]); // ---------------------------------------------------------------------------- // initialize things. The local init bit is always set when writing to the
@@ -1026,8 +1015,8 @@ static int snd_korg1212_WriteADCSensitivity(struct snd_korg1212 *korg1212) int rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_SelectPlayMode, K1212_MODE_MonitorOn, 0, 0, 0); if (rc)
K1212_DEBUG_PRINTK("K1212_DEBUG: WriteADCSensivity - RC = %d [%s]\n",
rc, stateName[korg1212->cardState]);
k1212_dbg(korg1212, "WriteADCSensivity - RC = %d [%s]\n",
rc, stateName[korg1212->cardState]); }
spin_unlock_irqrestore(&korg1212->lock, flags);
@@ -1039,8 +1028,8 @@ static void snd_korg1212_OnDSPDownloadComplete(struct snd_korg1212 *korg1212) { int channel, rc;
K1212_DEBUG_PRINTK("K1212_DEBUG: DSP download is complete. [%s]\n",
stateName[korg1212->cardState]);
k1212_dbg(korg1212, "DSP download is complete. [%s]\n",
stateName[korg1212->cardState]); // ---------------------------------------------------- // tell the card to boot
@@ -1048,8 +1037,8 @@ static void snd_korg1212_OnDSPDownloadComplete(struct snd_korg1212 *korg1212) rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_BootFromDSPPage4, 0, 0, 0, 0);
if (rc)
K1212_DEBUG_PRINTK("K1212_DEBUG: Boot from Page 4 - RC = %d [%s]\n",
rc, stateName[korg1212->cardState]);
k1212_dbg(korg1212, "Boot from Page 4 - RC = %d [%s]\n",
rc, stateName[korg1212->cardState]);
msleep(DSP_BOOT_DELAY_IN_MS);
// --------------------------------------------------------------------------------
@@ -1065,8 +1054,8 @@ static void snd_korg1212_OnDSPDownloadComplete(struct snd_korg1212 *korg1212) );
if (rc)
K1212_DEBUG_PRINTK("K1212_DEBUG: Configure Buffer Memory - RC = %d [%s]\n",
rc, stateName[korg1212->cardState]);
k1212_dbg(korg1212, "Configure Buffer Memory - RC = %d [%s]\n",
rc, stateName[korg1212->cardState]); udelay(INTERCOMMAND_DELAY);
@@ -1079,8 +1068,8 @@ static void snd_korg1212_OnDSPDownloadComplete(struct snd_korg1212 *korg1212) );
if (rc)
K1212_DEBUG_PRINTK("K1212_DEBUG: Configure Misc Memory - RC = %d [%s]\n",
rc, stateName[korg1212->cardState]);
k1212_dbg(korg1212, "Configure Misc Memory - RC = %d [%s]\n",
rc, stateName[korg1212->cardState]); // -------------------------------------------------------------------------------- // Initialize the routing and volume tables, then update the card's state.
@@ -1100,15 +1089,15 @@ static void snd_korg1212_OnDSPDownloadComplete(struct snd_korg1212 *korg1212) ClockSourceSelector[korg1212->clkSrcRate], 0, 0, 0); if (rc)
K1212_DEBUG_PRINTK("K1212_DEBUG: Set Clock Source Selector - RC = %d [%s]\n",
rc, stateName[korg1212->cardState]);
k1212_dbg(korg1212, "Set Clock Source Selector - RC = %d [%s]\n",
rc, stateName[korg1212->cardState]);
rc = snd_korg1212_TurnOnIdleMonitor(korg1212); snd_korg1212_setCardState(korg1212, K1212_STATE_READY);
if (rc)
K1212_DEBUG_PRINTK("K1212_DEBUG: Set Monitor On - RC = %d [%s]\n",
rc, stateName[korg1212->cardState]);
k1212_dbg(korg1212, "Set Monitor On - RC = %d [%s]\n",
rc, stateName[korg1212->cardState]);
snd_korg1212_setCardState(korg1212, K1212_STATE_DSP_COMPLETE);
} @@ -1133,9 +1122,9 @@ static irqreturn_t snd_korg1212_interrupt(int irq, void *dev_id)
switch (doorbellValue) { case K1212_DB_DSPDownloadDone:
K1212_DEBUG_PRINTK("K1212_DEBUG: IRQ DNLD count - %ld, %x, [%s].\n",
korg1212->irqcount, doorbellValue,
stateName[korg1212->cardState]);
k1212_dbg(korg1212, "IRQ DNLD count - %ld, %x, [%s]\n",
korg1212->irqcount, doorbellValue,
stateName[korg1212->cardState]); if (korg1212->cardState == K1212_STATE_DSP_IN_PROCESS) { korg1212->dsp_is_loaded = 1; wake_up(&korg1212->wait);
@@ -1146,9 +1135,9 @@ static irqreturn_t snd_korg1212_interrupt(int irq, void *dev_id) // an error occurred - stop the card // ------------------------------------------------------------------------ case K1212_DB_DMAERROR:
K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: IRQ DMAE count - %ld, %x, [%s].\n",
korg1212->irqcount, doorbellValue,
stateName[korg1212->cardState]);
k1212_dbg(korg1212, "IRQ DMAE count - %ld, %x, [%s].\n",
korg1212->irqcount, doorbellValue,
stateName[korg1212->cardState]); snd_printk(KERN_ERR "korg1212: DMA Error\n"); korg1212->errorcnt++; korg1212->totalerrorcnt++;
@@ -1161,16 +1150,17 @@ static irqreturn_t snd_korg1212_interrupt(int irq, void *dev_id) // the semaphore in case someone is waiting for this. // ------------------------------------------------------------------------ case K1212_DB_CARDSTOPPED:
K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: IRQ CSTP count - %ld, %x, [%s].\n",
korg1212->irqcount, doorbellValue,
stateName[korg1212->cardState]);
k1212_dbg(korg1212, "IRQ CSTP count - %ld, %x, [%s]\n",
korg1212->irqcount, doorbellValue,
stateName[korg1212->cardState]); korg1212->sharedBufferPtr->cardCommand = 0; break; default:
K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: IRQ DFLT count - %ld, %x, cpos=%d [%s].\n",
korg1212->irqcount, doorbellValue,
korg1212->currentBuffer, stateName[korg1212->cardState]);
k1212_dbg(korg1212, "IRQ DFLT count - %ld, %x, cpos=%d [%s]\n",
korg1212->irqcount, doorbellValue,
korg1212->currentBuffer,
stateName[korg1212->cardState]); if ((korg1212->cardState > K1212_STATE_SETUP) || korg1212->idleMonitorOn) { korg1212->currentBuffer++;
@@ -1206,8 +1196,8 @@ static int snd_korg1212_downloadDSPCode(struct snd_korg1212 *korg1212) { int rc;
K1212_DEBUG_PRINTK("K1212_DEBUG: DSP download is starting... [%s]\n",
stateName[korg1212->cardState]);
k1212_dbg(korg1212, "DSP download is starting... [%s]\n",
stateName[korg1212->cardState]); // --------------------------------------------------------------- // verify the state of the card before proceeding.
@@ -1221,8 +1211,8 @@ static int snd_korg1212_downloadDSPCode(struct snd_korg1212 *korg1212) UpperWordSwap(korg1212->dma_dsp.addr), 0, 0, 0); if (rc)
K1212_DEBUG_PRINTK("K1212_DEBUG: Start DSP Download RC = %d [%s]\n",
rc, stateName[korg1212->cardState]);
k1212_dbg(korg1212, "Start DSP Download RC = %d [%s]\n",
rc, stateName[korg1212->cardState]);
korg1212->dsp_is_loaded = 0; wait_event_timeout(korg1212->wait, korg1212->dsp_is_loaded, HZ * CARD_BOOT_TIMEOUT);
@@ -1281,16 +1271,16 @@ static int snd_korg1212_silence(struct snd_korg1212 *korg1212, int pos, int coun struct KorgAudioFrame * dst = korg1212->playDataBufsPtr[0].bufferData + pos; int i;
- K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: snd_korg1212_silence pos=%d offset=%d size=%d count=%d\n",
pos, offset, size, count);
k1212_dbg(korg1212, "snd_korg1212_silence pos=%d offset=%d size=%d count=%d\n",
pos, offset, size, count);
if (snd_BUG_ON(pos + count > K1212_MAX_SAMPLES)) return -EINVAL;
for (i=0; i < count; i++) {
-#if K1212_DEBUG_LEVEL > 0 +#ifdef K1212_DEBUG_MEMORY_RANGES if ( (void *) dst < (void *) korg1212->playDataBufsPtr || (void *) dst > (void *) korg1212->playDataBufsPtr[8].bufferData ) {
printk(KERN_DEBUG "K1212_DEBUG: snd_korg1212_silence KERNEL EFAULT dst=%p iter=%d\n",
}printk(KERN_DEBUG "snd_korg1212_silence KERNEL EFAULT dst=%p iter=%d\n", dst, i); return -EFAULT;
@@ -1307,22 +1297,24 @@ static int snd_korg1212_copy_to(struct snd_korg1212 *korg1212, void __user *dst, struct KorgAudioFrame * src = korg1212->recordDataBufsPtr[0].bufferData + pos; int i, rc;
- K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: snd_korg1212_copy_to pos=%d offset=%d size=%d\n",
pos, offset, size);
k1212_dbg(korg1212, "snd_korg1212_copy_to pos=%d offset=%d size=%d\n",
pos, offset, size);
if (snd_BUG_ON(pos + count > K1212_MAX_SAMPLES)) return -EINVAL;
for (i=0; i < count; i++) {
-#if K1212_DEBUG_LEVEL > 0 +#ifdef K1212_DEBUG_MEMORY_RANGES if ( (void *) src < (void *) korg1212->recordDataBufsPtr || (void *) src > (void *) korg1212->recordDataBufsPtr[8].bufferData ) {
printk(KERN_DEBUG "K1212_DEBUG: snd_korg1212_copy_to KERNEL EFAULT, src=%p dst=%p iter=%d\n", src, dst, i);
printk(KERN_DEBUG "snd_korg1212_copy_to KERNEL EFAULT, src=%p dst=%p iter=%d\n",
}src, dst, i); return -EFAULT;
#endif rc = copy_to_user(dst + offset, src, size); if (rc) {
K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_copy_to USER EFAULT src=%p dst=%p iter=%d\n", src, dst, i);
k1212_dbg(korg1212, "snd_korg1212_copy_to USER EFAULT src=%p dst=%p iter=%d\n",
} src++;src, dst, i); return -EFAULT;
@@ -1337,23 +1329,25 @@ static int snd_korg1212_copy_from(struct snd_korg1212 *korg1212, void __user *sr struct KorgAudioFrame * dst = korg1212->playDataBufsPtr[0].bufferData + pos; int i, rc;
- K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: snd_korg1212_copy_from pos=%d offset=%d size=%d count=%d\n",
pos, offset, size, count);
k1212_dbg(korg1212, "snd_korg1212_copy_from pos=%d offset=%d size=%d count=%d\n",
pos, offset, size, count);
if (snd_BUG_ON(pos + count > K1212_MAX_SAMPLES)) return -EINVAL;
for (i=0; i < count; i++) {
-#if K1212_DEBUG_LEVEL > 0 +#ifdef K1212_DEBUG_MEMORY_RANGES if ( (void *) dst < (void *) korg1212->playDataBufsPtr || (void *) dst > (void *) korg1212->playDataBufsPtr[8].bufferData ) {
printk(KERN_DEBUG "K1212_DEBUG: snd_korg1212_copy_from KERNEL EFAULT, src=%p dst=%p iter=%d\n", src, dst, i);
printk(KERN_DEBUG "snd_korg1212_copy_from KERNEL EFAULT, src=%p dst=%p iter=%d\n",
}src, dst, i); return -EFAULT;
#endif rc = copy_from_user((void*) dst + offset, src, size); if (rc) {
K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_copy_from USER EFAULT src=%p dst=%p iter=%d\n", src, dst, i);
k1212_dbg(korg1212, "snd_korg1212_copy_from USER EFAULT src=%p dst=%p iter=%d\n",
} dst++;src, dst, i); return -EFAULT;
@@ -1367,8 +1361,8 @@ static void snd_korg1212_free_pcm(struct snd_pcm *pcm) { struct snd_korg1212 *korg1212 = pcm->private_data;
- K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_free_pcm [%s]\n",
stateName[korg1212->cardState]);
k1212_dbg(korg1212, "snd_korg1212_free_pcm [%s]\n",
stateName[korg1212->cardState]); korg1212->pcm = NULL;
} @@ -1379,8 +1373,8 @@ static int snd_korg1212_playback_open(struct snd_pcm_substream *substream) struct snd_korg1212 *korg1212 = snd_pcm_substream_chip(substream); struct snd_pcm_runtime *runtime = substream->runtime;
- K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_playback_open [%s]\n",
stateName[korg1212->cardState]);
k1212_dbg(korg1212, "snd_korg1212_playback_open [%s]\n",
stateName[korg1212->cardState]);
snd_korg1212_OpenCard(korg1212);
@@ -1408,8 +1402,8 @@ static int snd_korg1212_capture_open(struct snd_pcm_substream *substream) struct snd_korg1212 *korg1212 = snd_pcm_substream_chip(substream); struct snd_pcm_runtime *runtime = substream->runtime;
- K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_capture_open [%s]\n",
stateName[korg1212->cardState]);
k1212_dbg(korg1212, "snd_korg1212_capture_open [%s]\n",
stateName[korg1212->cardState]);
snd_korg1212_OpenCard(korg1212);
@@ -1435,8 +1429,8 @@ static int snd_korg1212_playback_close(struct snd_pcm_substream *substream) unsigned long flags; struct snd_korg1212 *korg1212 = snd_pcm_substream_chip(substream);
- K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_playback_close [%s]\n",
stateName[korg1212->cardState]);
k1212_dbg(korg1212, "snd_korg1212_playback_close [%s]\n",
stateName[korg1212->cardState]);
snd_korg1212_silence(korg1212, 0, K1212_MAX_SAMPLES, 0, korg1212->channels * 2);
@@ -1457,8 +1451,8 @@ static int snd_korg1212_capture_close(struct snd_pcm_substream *substream) unsigned long flags; struct snd_korg1212 *korg1212 = snd_pcm_substream_chip(substream);
- K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_capture_close [%s]\n",
stateName[korg1212->cardState]);
k1212_dbg(korg1212, "snd_korg1212_capture_close [%s]\n",
stateName[korg1212->cardState]); spin_lock_irqsave(&korg1212->lock, flags);
@@ -1475,14 +1469,14 @@ static int snd_korg1212_capture_close(struct snd_pcm_substream *substream) static int snd_korg1212_ioctl(struct snd_pcm_substream *substream, unsigned int cmd, void *arg) {
- K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_ioctl: cmd=%d\n", cmd);
- if (cmd == SNDRV_PCM_IOCTL1_CHANNEL_INFO ) {
struct snd_pcm_channel_info *info = arg; info->offset = 0; info->first = info->channel * 16; info->step = 256;struct snd_korg1212 *korg1212 = snd_pcm_substream_chip(substream);
K1212_DEBUG_PRINTK("K1212_DEBUG: channel_info %d:, offset=%ld, first=%d, step=%d\n", info->channel, info->offset, info->first, info->step);
k1212_dbg(korg1212, "channel_info %d:, offset=%ld, first=%d, step=%d\n",
return 0; }info->channel, info->offset, info->first, info->step);
@@ -1498,8 +1492,8 @@ static int snd_korg1212_hw_params(struct snd_pcm_substream *substream, pid_t this_pid; pid_t other_pid;
- K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_hw_params [%s]\n",
stateName[korg1212->cardState]);
k1212_dbg(korg1212, "snd_korg1212_hw_params [%s]\n",
stateName[korg1212->cardState]); spin_lock_irqsave(&korg1212->lock, flags);
@@ -1546,15 +1540,15 @@ static int snd_korg1212_prepare(struct snd_pcm_substream *substream) struct snd_korg1212 *korg1212 = snd_pcm_substream_chip(substream); int rc;
- K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_prepare [%s]\n",
stateName[korg1212->cardState]);
k1212_dbg(korg1212, "snd_korg1212_prepare [%s]\n",
stateName[korg1212->cardState]);
spin_lock_irq(&korg1212->lock);
/* FIXME: we should wait for ack! */ if (korg1212->stop_pending_cnt > 0) {
K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_prepare - Stop is pending... [%s]\n",
stateName[korg1212->cardState]);
k1212_dbg(korg1212, "snd_korg1212_prepare - Stop is pending... [%s]\n",
return -EAGAIN; /*stateName[korg1212->cardState]); spin_unlock_irq(&korg1212->lock);
@@ -1579,16 +1573,16 @@ static int snd_korg1212_trigger(struct snd_pcm_substream *substream, struct snd_korg1212 *korg1212 = snd_pcm_substream_chip(substream); int rc;
- K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_trigger [%s] cmd=%d\n",
stateName[korg1212->cardState], cmd);
k1212_dbg(korg1212, "snd_korg1212_trigger [%s] cmd=%d\n",
stateName[korg1212->cardState], cmd);
spin_lock(&korg1212->lock); switch (cmd) { case SNDRV_PCM_TRIGGER_START:
/* if (korg1212->running) {
K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: snd_korg1212_trigger: Already running?\n");
break;
k1212_dbg(korg1212, "snd_korg1212_trigger: Already running?\n");
break; }
*/ korg1212->running++; @@ -1598,8 +1592,8 @@ static int snd_korg1212_trigger(struct snd_pcm_substream *substream, case SNDRV_PCM_TRIGGER_STOP: /* if (!korg1212->running) {
K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: snd_korg1212_trigger: Already stopped?\n");
break;
k1212_dbg(korg1212, "snd_korg1212_trigger: Already stopped?\n");
break; }
*/ korg1212->running--; @@ -1621,8 +1615,8 @@ static snd_pcm_uframes_t snd_korg1212_playback_pointer(struct snd_pcm_substream
pos = korg1212->currentBuffer * kPlayBufferFrames;
- K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: snd_korg1212_playback_pointer [%s] %ld\n",
stateName[korg1212->cardState], pos);
k1212_dbg(korg1212, "snd_korg1212_playback_pointer [%s] %ld\n",
stateName[korg1212->cardState], pos); return pos;
} @@ -1634,8 +1628,8 @@ static snd_pcm_uframes_t snd_korg1212_capture_pointer(struct snd_pcm_substream *
pos = korg1212->currentBuffer * kPlayBufferFrames;
- K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: snd_korg1212_capture_pointer [%s] %ld\n",
stateName[korg1212->cardState], pos);
k1212_dbg(korg1212, "snd_korg1212_capture_pointer [%s] %ld\n",
stateName[korg1212->cardState], pos); return pos;
} @@ -1648,8 +1642,8 @@ static int snd_korg1212_playback_copy(struct snd_pcm_substream *substream, { struct snd_korg1212 *korg1212 = snd_pcm_substream_chip(substream);
- K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: snd_korg1212_playback_copy [%s] %ld %ld\n",
stateName[korg1212->cardState], pos, count);
k1212_dbg(korg1212, "snd_korg1212_playback_copy [%s] %ld %ld\n",
stateName[korg1212->cardState], pos, count);
return snd_korg1212_copy_from(korg1212, src, pos, count, 0, korg1212->channels * 2);
@@ -1662,8 +1656,8 @@ static int snd_korg1212_playback_silence(struct snd_pcm_substream *substream, { struct snd_korg1212 *korg1212 = snd_pcm_substream_chip(substream);
- K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: snd_korg1212_playback_silence [%s]\n",
stateName[korg1212->cardState]);
k1212_dbg(korg1212, "snd_korg1212_playback_silence [%s]\n",
stateName[korg1212->cardState]);
return snd_korg1212_silence(korg1212, pos, count, 0, korg1212->channels * 2);
} @@ -1676,8 +1670,8 @@ static int snd_korg1212_capture_copy(struct snd_pcm_substream *substream, { struct snd_korg1212 *korg1212 = snd_pcm_substream_chip(substream);
- K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: snd_korg1212_capture_copy [%s] %ld %ld\n",
stateName[korg1212->cardState], pos, count);
k1212_dbg(korg1212, "snd_korg1212_capture_copy [%s] %ld %ld\n",
stateName[korg1212->cardState], pos, count);
return snd_korg1212_copy_to(korg1212, dst, pos, count, 0, korg1212->channels * 2);
} @@ -2138,7 +2132,7 @@ snd_korg1212_free(struct snd_korg1212 *korg1212) static int snd_korg1212_dev_free(struct snd_device *device) { struct snd_korg1212 *korg1212 = device->device_data;
K1212_DEBUG_PRINTK("K1212_DEBUG: Freeing device\n");
- k1212_dbg(korg1212, "Freeing device\n"); return snd_korg1212_free(korg1212);
}
@@ -2210,15 +2204,15 @@ static int snd_korg1212_create(struct snd_card *card, struct pci_dev *pci, ioport_size = pci_resource_len(korg1212->pci, 1); iomem2_size = pci_resource_len(korg1212->pci, 2);
K1212_DEBUG_PRINTK("K1212_DEBUG: resources:\n"
" iomem = 0x%lx (%d)\n"
" ioport = 0x%lx (%d)\n"
" iomem = 0x%lx (%d)\n"
" [%s]\n",
korg1212->iomem, iomem_size,
korg1212->ioport, ioport_size,
korg1212->iomem2, iomem2_size,
stateName[korg1212->cardState]);
k1212_dbg(korg1212, "resources:\n"
" iomem = 0x%lx (%d)\n"
" ioport = 0x%lx (%d)\n"
" iomem = 0x%lx (%d)\n"
" [%s]\n",
korg1212->iomem, iomem_size,
korg1212->ioport, ioport_size,
korg1212->iomem2, iomem2_size,
stateName[korg1212->cardState]); if ((korg1212->iobase = ioremap(korg1212->iomem, iomem_size)) == NULL) {
snd_printk(KERN_ERR "korg1212: unable to remap memory region 0x%lx-0x%lx\n", korg1212->iomem,
@@ -2252,29 +2246,29 @@ static int snd_korg1212_create(struct snd_card *card, struct pci_dev *pci, korg1212->sensRegPtr = (u16 __iomem *) (korg1212->iobase + SENS_CONTROL_OFFSET); korg1212->idRegPtr = (u32 __iomem *) (korg1212->iobase + DEV_VEND_ID_OFFSET);
K1212_DEBUG_PRINTK("K1212_DEBUG: card registers:\n"
" Status register = 0x%p\n"
" OutDoorbell = 0x%p\n"
" InDoorbell = 0x%p\n"
" Mailbox0 = 0x%p\n"
" Mailbox1 = 0x%p\n"
" Mailbox2 = 0x%p\n"
" Mailbox3 = 0x%p\n"
" ControlReg = 0x%p\n"
" SensReg = 0x%p\n"
" IDReg = 0x%p\n"
" [%s]\n",
korg1212->statusRegPtr,
korg1212->outDoorbellPtr,
korg1212->inDoorbellPtr,
korg1212->mailbox0Ptr,
korg1212->mailbox1Ptr,
korg1212->mailbox2Ptr,
korg1212->mailbox3Ptr,
korg1212->controlRegPtr,
korg1212->sensRegPtr,
korg1212->idRegPtr,
stateName[korg1212->cardState]);
k1212_dbg(korg1212, "card registers:\n"
" Status register = 0x%p\n"
" OutDoorbell = 0x%p\n"
" InDoorbell = 0x%p\n"
" Mailbox0 = 0x%p\n"
" Mailbox1 = 0x%p\n"
" Mailbox2 = 0x%p\n"
" Mailbox3 = 0x%p\n"
" ControlReg = 0x%p\n"
" SensReg = 0x%p\n"
" IDReg = 0x%p\n"
" [%s]\n",
korg1212->statusRegPtr,
korg1212->outDoorbellPtr,
korg1212->inDoorbellPtr,
korg1212->mailbox0Ptr,
korg1212->mailbox1Ptr,
korg1212->mailbox2Ptr,
korg1212->mailbox3Ptr,
korg1212->controlRegPtr,
korg1212->sensRegPtr,
korg1212->idRegPtr,
stateName[korg1212->cardState]);
if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci), sizeof(struct KorgSharedBuffer), &korg1212->dma_shared) < 0) {
@@ -2285,7 +2279,9 @@ static int snd_korg1212_create(struct snd_card *card, struct pci_dev *pci, korg1212->sharedBufferPtr = (struct KorgSharedBuffer *)korg1212->dma_shared.area; korg1212->sharedBufferPhy = korg1212->dma_shared.addr;
K1212_DEBUG_PRINTK("K1212_DEBUG: Shared Buffer Area = 0x%p (0x%08lx), %d bytes\n", korg1212->sharedBufferPtr, korg1212->sharedBufferPhy, sizeof(struct KorgSharedBuffer));
- k1212_dbg(korg1212, "Shared Buffer Area = 0x%p (0x%08lx), %zu bytes\n",
korg1212->sharedBufferPtr, korg1212->sharedBufferPhy,
sizeof(struct KorgSharedBuffer));
#ifndef K1212_LARGEALLOC
@@ -2300,8 +2296,9 @@ static int snd_korg1212_create(struct snd_card *card, struct pci_dev *pci, korg1212->playDataBufsPtr = (struct KorgAudioBuffer *)korg1212->dma_play.area; korg1212->PlayDataPhy = korg1212->dma_play.addr;
K1212_DEBUG_PRINTK("K1212_DEBUG: Play Data Area = 0x%p (0x%08x), %d bytes\n",
korg1212->playDataBufsPtr, korg1212->PlayDataPhy, korg1212->DataBufsSize);
k1212_dbg(korg1212, "Play Data Area = 0x%p (0x%08x), %d bytes\n",
korg1212->playDataBufsPtr, korg1212->PlayDataPhy,
korg1212->DataBufsSize);
if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci), korg1212->DataBufsSize, &korg1212->dma_rec) < 0) {
@@ -2312,8 +2309,9 @@ static int snd_korg1212_create(struct snd_card *card, struct pci_dev *pci, korg1212->recordDataBufsPtr = (struct KorgAudioBuffer *)korg1212->dma_rec.area; korg1212->RecDataPhy = korg1212->dma_rec.addr;
K1212_DEBUG_PRINTK("K1212_DEBUG: Record Data Area = 0x%p (0x%08x), %d bytes\n",
korg1212->recordDataBufsPtr, korg1212->RecDataPhy, korg1212->DataBufsSize);
- k1212_dbg(korg1212, "Record Data Area = 0x%p (0x%08x), %d bytes\n",
korg1212->recordDataBufsPtr, korg1212->RecDataPhy,
korg1212->DataBufsSize);
#else // K1212_LARGEALLOC
@@ -2347,9 +2345,9 @@ static int snd_korg1212_create(struct snd_card *card, struct pci_dev *pci, return -ENOMEM; }
K1212_DEBUG_PRINTK("K1212_DEBUG: DSP Code area = 0x%p (0x%08x) %d bytes [%s]\n",
korg1212->dma_dsp.area, korg1212->dma_dsp.addr, dsp_code->size,
stateName[korg1212->cardState]);
k1212_dbg(korg1212, "DSP Code area = 0x%p (%pad) %zu bytes [%s]\n",
korg1212->dma_dsp.area, &korg1212->dma_dsp.addr,
dsp_code->size, stateName[korg1212->cardState]);
memcpy(korg1212->dma_dsp.area, dsp_code->data, dsp_code->size);
@@ -2358,7 +2356,8 @@ static int snd_korg1212_create(struct snd_card *card, struct pci_dev *pci, rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_RebootCard, 0, 0, 0, 0);
if (rc)
K1212_DEBUG_PRINTK("K1212_DEBUG: Reboot Card - RC = %d [%s]\n", rc, stateName[korg1212->cardState]);
k1212_dbg(korg1212, "Reboot Card - RC = %d [%s]\n",
rc, stateName[korg1212->cardState]); if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, korg1212, &ops)) < 0) { snd_korg1212_free(korg1212);
@@ -2372,18 +2371,24 @@ static int snd_korg1212_create(struct snd_card *card, struct pci_dev *pci, if (snd_korg1212_downloadDSPCode(korg1212)) return -EBUSY;
K1212_DEBUG_PRINTK("korg1212: dspMemPhy = %08x U[%08x], "
"PlayDataPhy = %08x L[%08x]\n"
"korg1212: RecDataPhy = %08x L[%08x], "
"VolumeTablePhy = %08x L[%08x]\n"
"korg1212: RoutingTablePhy = %08x L[%08x], "
"AdatTimeCodePhy = %08x L[%08x]\n",
(int)korg1212->dma_dsp.addr, UpperWordSwap(korg1212->dma_dsp.addr),
korg1212->PlayDataPhy, LowerWordSwap(korg1212->PlayDataPhy),
korg1212->RecDataPhy, LowerWordSwap(korg1212->RecDataPhy),
korg1212->VolumeTablePhy, LowerWordSwap(korg1212->VolumeTablePhy),
korg1212->RoutingTablePhy, LowerWordSwap(korg1212->RoutingTablePhy),
korg1212->AdatTimeCodePhy, LowerWordSwap(korg1212->AdatTimeCodePhy));
k1212_dbg(korg1212, "dspMemPhy = %08x U[%08x]\n",
(int)korg1212->dma_dsp.addr,
UpperWordSwap(korg1212->dma_dsp.addr));
k1212_dbg(korg1212, "PlayDataPhy = %08x L[%08x]\n",
korg1212->PlayDataPhy,
LowerWordSwap(korg1212->PlayDataPhy));
k1212_dbg(korg1212, "RecDataPhy = %08x L[%08x]\n",
korg1212->RecDataPhy,
LowerWordSwap(korg1212->RecDataPhy));
k1212_dbg(korg1212, "VolumeTablePhy = %08x L[%08x]\n",
korg1212->VolumeTablePhy,
LowerWordSwap(korg1212->VolumeTablePhy));
k1212_dbg(korg1212, "RoutingTablePhy = %08x L[%08x]\n",
korg1212->RoutingTablePhy,
LowerWordSwap(korg1212->RoutingTablePhy));
k1212_dbg(korg1212, "AdatTimeCodePhy = %08x L[%08x]\n",
korg1212->AdatTimeCodePhy,
LowerWordSwap(korg1212->AdatTimeCodePhy)); if ((err = snd_pcm_new(korg1212->card, "korg1212", 0, 1, 1, &korg1212->pcm)) < 0) return err;
@@ -2446,7 +2451,7 @@ snd_korg1212_probe(struct pci_dev *pci, sprintf(card->longname, "%s at 0x%lx, irq %d", card->shortname, korg1212->iomem, korg1212->irq);
K1212_DEBUG_PRINTK("K1212_DEBUG: %s\n", card->longname);
k1212_dbg(korg1212, "%s\n", card->longname);
if ((err = snd_card_register(card)) < 0) { snd_card_free(card);
On Wed, 2014-11-26 at 16:19 +0530, Sudip Mukherjee wrote:
On Tue, Nov 25, 2014 at 10:59:25AM -0800, Joe Perches wrote:
On Tue, 2014-11-25 at 11:51 +0530, Sudip Mukherjee wrote:
problems with this way:
- macro name is little misleading - macro says printk, but we are using dev_dbg
- if some one later wants to add something to this file, and doesnot want to use the variable name korg1212 in his function.
any suggestions ?
Some code is so old and unlikely to be ever used again, it may be better to move it to an "ancient and crufty" folder and forget about it.
This may be one of those.
If the debugging was written in a more current style, it might look like this: (with various format/argument mismatches fixed, formatting changes, etc)
ok. and can't we delete some of the messages like "DSP download is complete." and then printing the statename. there are lots of messages like that which is just printing the function name and the statename ..
Dunno. Maybe somebody cares about the state of the dsp download, but I doubt it as I suspect the hardware isn't used much.
and, even if i modify it a little and send it, most of the work has been done by you. so how do i send the patch in your name or add your name in the patch ? I have not done anything so my name should not be there.
<shrug> you started it.
I spend a couple minutes running a couple scripts.
I don't have the hardware, I've never looked at that code before, do what you think appropriate.
participants (3)
-
Joe Perches
-
Sudip Mukherjee
-
Takashi Iwai