Linux Sound subsystem development
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: linux-sound@vger.kernel.org
Subject: [PATCH 24/54] ALSA: es1688: Use standard print API
Date: Wed,  7 Aug 2024 15:34:14 +0200	[thread overview]
Message-ID: <20240807133452.9424-25-tiwai@suse.de> (raw)
In-Reply-To: <20240807133452.9424-1-tiwai@suse.de>

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

For referring to the device, introduce snd_card pointer to struct
snd_es1688.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 include/sound/es1688.h        |  1 +
 sound/isa/es1688/es1688.c     |  2 +-
 sound/isa/es1688/es1688_lib.c | 55 ++++++++++++++++++-----------------
 3 files changed, 31 insertions(+), 27 deletions(-)

diff --git a/include/sound/es1688.h b/include/sound/es1688.h
index 099569c31fbb..425a3717d77a 100644
--- a/include/sound/es1688.h
+++ b/include/sound/es1688.h
@@ -17,6 +17,7 @@
 #define ES1688_HW_UNDEF	0x0003
 
 struct snd_es1688 {
+	struct snd_card *card;
 	unsigned long port;		/* port of ESS chip */
 	struct resource *res_port;
 	unsigned long mpu_port;		/* MPU-401 port of ESS chip */
diff --git a/sound/isa/es1688/es1688.c b/sound/isa/es1688/es1688.c
index 97728bf45474..6a95dfb7600a 100644
--- a/sound/isa/es1688/es1688.c
+++ b/sound/isa/es1688/es1688.c
@@ -213,7 +213,7 @@ static int snd_card_es968_pnp(struct snd_card *card, unsigned int n,
 
 	error = pnp_activate_dev(pdev);
 	if (error < 0) {
-		snd_printk(KERN_ERR "ES968 pnp configure failure\n");
+		dev_err(card->dev, "ES968 pnp configure failure\n");
 		return error;
 	}
 	port[n] = pnp_port_start(pdev, 0);
diff --git a/sound/isa/es1688/es1688_lib.c b/sound/isa/es1688/es1688_lib.c
index 8554cb2263c1..c0c230149a75 100644
--- a/sound/isa/es1688/es1688_lib.c
+++ b/sound/isa/es1688/es1688_lib.c
@@ -30,9 +30,7 @@ static int snd_es1688_dsp_command(struct snd_es1688 *chip, unsigned char val)
 			outb(val, ES1688P(chip, COMMAND));
 			return 1;
 		}
-#ifdef CONFIG_SND_DEBUG
-	printk(KERN_DEBUG "snd_es1688_dsp_command: timeout (0x%x)\n", val);
-#endif
+	dev_dbg(chip->card->dev, "%s: timeout (0x%x)\n", __func__, val);
 	return 0;
 }
 
@@ -43,7 +41,8 @@ static int snd_es1688_dsp_get_byte(struct snd_es1688 *chip)
 	for (i = 1000; i; i--)
 		if (inb(ES1688P(chip, DATA_AVAIL)) & 0x80)
 			return inb(ES1688P(chip, READ));
-	snd_printd("es1688 get byte failed: 0x%lx = 0x%x!!!\n", ES1688P(chip, DATA_AVAIL), inb(ES1688P(chip, DATA_AVAIL)));
+	dev_dbg(chip->card->dev, "es1688 get byte failed: 0x%lx = 0x%x!!!\n",
+		ES1688P(chip, DATA_AVAIL), inb(ES1688P(chip, DATA_AVAIL)));
 	return -ENODEV;
 }
 
@@ -95,7 +94,8 @@ int snd_es1688_reset(struct snd_es1688 *chip)
 	udelay(30);
 	for (i = 0; i < 1000 && !(inb(ES1688P(chip, DATA_AVAIL)) & 0x80); i++);
 	if (inb(ES1688P(chip, READ)) != 0xaa) {
-		snd_printd("ess_reset at 0x%lx: failed!!!\n", chip->port);
+		dev_dbg(chip->card->dev, "ess_reset at 0x%lx: failed!!!\n",
+			chip->port);
 		return -ENODEV;
 	}
 	snd_es1688_dsp_command(chip, 0xc6);	/* enable extended mode */
@@ -127,7 +127,8 @@ static int snd_es1688_probe(struct snd_es1688 *chip)
 	inb(ES1688P(chip, ENABLE0));	/* ENABLE0 */
 
 	if (snd_es1688_reset(chip) < 0) {
-		snd_printdd("ESS: [0x%lx] reset failed... 0x%x\n", chip->port, inb(ES1688P(chip, READ)));
+		dev_dbg(chip->card->dev, "ESS: [0x%lx] reset failed... 0x%x\n",
+			chip->port, inb(ES1688P(chip, READ)));
 		spin_unlock_irqrestore(&chip->reg_lock, flags);
 		return -ENODEV;
 	}
@@ -145,7 +146,9 @@ static int snd_es1688_probe(struct snd_es1688 *chip)
 
 	spin_unlock_irqrestore(&chip->reg_lock, flags);
 
-	snd_printdd("ESS: [0x%lx] found.. major = 0x%x, minor = 0x%x\n", chip->port, major, minor);
+	dev_dbg(chip->card->dev,
+		"ESS: [0x%lx] found.. major = 0x%x, minor = 0x%x\n",
+		chip->port, major, minor);
 
 	chip->version = (major << 8) | minor;
 	if (!chip->version)
@@ -153,15 +156,16 @@ static int snd_es1688_probe(struct snd_es1688 *chip)
 
 	switch (chip->version & 0xfff0) {
 	case 0x4880:
-		snd_printk(KERN_ERR "[0x%lx] ESS: AudioDrive ES488 detected, "
-			   "but driver is in another place\n", chip->port);
+		dev_err(chip->card->dev,
+			"[0x%lx] ESS: AudioDrive ES488 detected, but driver is in another place\n",
+			chip->port);
 		return -ENODEV;
 	case 0x6880:
 		break;
 	default:
-		snd_printk(KERN_ERR "[0x%lx] ESS: unknown AudioDrive chip "
-			   "with version 0x%x (Jazz16 soundcard?)\n",
-			   chip->port, chip->version);
+		dev_err(chip->card->dev,
+			"[0x%lx] ESS: unknown AudioDrive chip with version 0x%x (Jazz16 soundcard?)\n",
+			chip->port, chip->version);
 		return -ENODEV;
 	}
 
@@ -210,9 +214,6 @@ static int snd_es1688_init(struct snd_es1688 * chip, int enable)
 			}
 		}
 	}
-#if 0
-	snd_printk(KERN_DEBUG "mpu cfg = 0x%x\n", cfg);
-#endif
 	spin_lock_irqsave(&chip->reg_lock, flags);
 	snd_es1688_mixer_write(chip, 0x40, cfg);
 	spin_unlock_irqrestore(&chip->reg_lock, flags);
@@ -225,9 +226,9 @@ static int snd_es1688_init(struct snd_es1688 * chip, int enable)
 		cfg = 0xf0;	/* enable only DMA counter interrupt */
 		irq_bits = irqs[chip->irq & 0x0f];
 		if (irq_bits < 0) {
-			snd_printk(KERN_ERR "[0x%lx] ESS: bad IRQ %d "
-				   "for ES1688 chip!!\n",
-				   chip->port, chip->irq);
+			dev_err(chip->card->dev,
+				"[0x%lx] ESS: bad IRQ %d for ES1688 chip!!\n",
+				chip->port, chip->irq);
 #if 0
 			irq_bits = 0;
 			cfg = 0x10;
@@ -240,8 +241,9 @@ static int snd_es1688_init(struct snd_es1688 * chip, int enable)
 		cfg = 0xf0;	/* extended mode DMA enable */
 		dma = chip->dma8;
 		if (dma > 3 || dma == 2) {
-			snd_printk(KERN_ERR "[0x%lx] ESS: bad DMA channel %d "
-				   "for ES1688 chip!!\n", chip->port, dma);
+			dev_err(chip->card->dev,
+				"[0x%lx] ESS: bad DMA channel %d for ES1688 chip!!\n",
+				chip->port, dma);
 #if 0
 			dma_bits = 0;
 			cfg = 0x00;	/* disable all DMA */
@@ -326,9 +328,9 @@ static int snd_es1688_trigger(struct snd_es1688 *chip, int cmd, unsigned char va
 		return -EINVAL;	/* something is wrong */
 	}
 #if 0
-	printk(KERN_DEBUG "trigger: val = 0x%x, value = 0x%x\n", val, value);
-	printk(KERN_DEBUG "trigger: pointer = 0x%x\n",
-	       snd_dma_pointer(chip->dma8, chip->dma_size));
+	dev_dbg(chip->card->dev, "trigger: val = 0x%x, value = 0x%x\n", val, value);
+	dev_dbg(chip->card->dev, "trigger: pointer = 0x%x\n",
+		snd_dma_pointer(chip->dma8, chip->dma_size));
 #endif
 	snd_es1688_write(chip, 0xb8, (val & 0xf0) | value);
 	spin_unlock(&chip->reg_lock);
@@ -620,20 +622,21 @@ int snd_es1688_create(struct snd_card *card,
 
 	if (chip == NULL)
 		return -ENOMEM;
+	chip->card = card;
 	chip->irq = -1;
 	chip->dma8 = -1;
 	chip->hardware = ES1688_HW_UNDEF;
 	
 	chip->res_port = request_region(port + 4, 12, "ES1688");
 	if (chip->res_port == NULL) {
-		snd_printk(KERN_ERR "es1688: can't grab port 0x%lx\n", port + 4);
+		dev_err(card->dev, "es1688: can't grab port 0x%lx\n", port + 4);
 		err = -EBUSY;
 		goto exit;
 	}
 
 	err = request_irq(irq, snd_es1688_interrupt, 0, "ES1688", (void *) chip);
 	if (err < 0) {
-		snd_printk(KERN_ERR "es1688: can't grab IRQ %d\n", irq);
+		dev_err(card->dev, "es1688: can't grab IRQ %d\n", irq);
 		goto exit;
 	}
 
@@ -642,7 +645,7 @@ int snd_es1688_create(struct snd_card *card,
 	err = request_dma(dma8, "ES1688");
 
 	if (err < 0) {
-		snd_printk(KERN_ERR "es1688: can't grab DMA8 %d\n", dma8);
+		dev_err(card->dev, "es1688: can't grab DMA8 %d\n", dma8);
 		goto exit;
 	}
 	chip->dma8 = dma8;
-- 
2.43.0


  parent reply	other threads:[~2024-08-07 13:34 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-07 13:33 [PATCH 00/54] ALSA: Drop legacy snd_print*() Takashi Iwai
2024-08-07 13:33 ` [PATCH 01/54] ALSA: portman2x4: Use standard print API Takashi Iwai
2024-08-07 13:33 ` [PATCH 02/54] ALSA: mts64: " Takashi Iwai
2024-08-07 13:33 ` [PATCH 03/54] ALSA: mpu401: " Takashi Iwai
2024-08-07 13:33 ` [PATCH 04/54] ALSA: mpu401_uart: " Takashi Iwai
2024-08-07 13:33 ` [PATCH 05/54] ALSA: mtpav: " Takashi Iwai
2024-08-07 13:33 ` [PATCH 06/54] ALSA: opl3: " Takashi Iwai
2024-08-07 13:33 ` [PATCH 07/54] ALSA: opl4: " Takashi Iwai
2024-08-07 13:33 ` [PATCH 08/54] ALSA: serial-u16550: " Takashi Iwai
2024-08-07 13:33 ` [PATCH 09/54] ALSA: virmidi: " Takashi Iwai
2024-08-07 13:34 ` [PATCH 10/54] ALSA: vx_core: Drop unused dev field Takashi Iwai
2024-08-07 13:34 ` [PATCH 11/54] ALSA: vx_core: Use standard print API Takashi Iwai
2024-08-07 13:34 ` [PATCH 12/54] ALSA: aloop: " Takashi Iwai
2024-08-07 13:34 ` [PATCH 13/54] ALSA: dummy: " Takashi Iwai
2024-08-07 13:34 ` [PATCH 14/54] ALSA: pcsp: " Takashi Iwai
2024-08-07 13:34 ` [PATCH 15/54] ALSA: i2c: cs8427: " Takashi Iwai
2024-08-07 13:34 ` [PATCH 16/54] ALSA: i2c: pt2258: " Takashi Iwai
2024-08-07 13:34 ` [PATCH 17/54] ALSA: i2c: Drop commented old debug prints Takashi Iwai
2024-08-07 13:34 ` [PATCH 18/54] ALSA: ad1816a: Use standard print API Takashi Iwai
2024-08-07 13:34 ` [PATCH 19/54] ALSA: als100: " Takashi Iwai
2024-08-07 13:34 ` [PATCH 20/54] ALSA: azt2320: " Takashi Iwai
2024-08-07 13:34 ` [PATCH 21/54] ALSA: cmi8328: " Takashi Iwai
2024-08-07 13:34 ` [PATCH 22/54] ALSA: cmi8330: " Takashi Iwai
2024-08-07 13:34 ` [PATCH 23/54] ALSA: cs4236: " Takashi Iwai
2024-08-07 13:34 ` Takashi Iwai [this message]
2024-08-07 13:34 ` [PATCH 25/54] ALSA: es18xx: " Takashi Iwai
2024-08-07 13:34 ` [PATCH 26/54] ALSA: gus: " Takashi Iwai
2024-08-07 13:34 ` [PATCH 27/54] ALSA: msnd: " Takashi Iwai
2024-08-08  6:43   ` Takashi Iwai
2024-08-07 13:34 ` [PATCH 28/54] ALSA: opl3sa2: " Takashi Iwai
2024-08-07 13:34 ` [PATCH 29/54] ALSA: opti9xx: " Takashi Iwai
2024-08-07 13:34 ` [PATCH 30/54] ALSA: sb: " Takashi Iwai
2024-08-07 13:34 ` [PATCH 31/54] ALSA: control_led: Use dev_err() Takashi Iwai
2024-08-07 13:34 ` [PATCH 32/54] ALSA: pcm: oss: Use pr_debug() Takashi Iwai
2024-08-07 13:34 ` [PATCH 33/54] ALSA: sc6000: Use standard print API Takashi Iwai
2024-08-07 13:34 ` [PATCH 34/54] ALSA: sscape: " Takashi Iwai
2024-08-07 13:34 ` [PATCH 35/54] ALSA: wavefront: " Takashi Iwai
2024-08-07 13:34 ` [PATCH 36/54] ALSA: wss: " Takashi Iwai
2024-08-07 13:34 ` [PATCH 37/54] ALSA: riptide: " Takashi Iwai
2024-08-07 13:34 ` [PATCH 38/54] ALSA: korg1212: " Takashi Iwai
2024-08-07 13:34 ` [PATCH 39/54] ALSA: lx6464es: Cleanup the print API usages Takashi Iwai
2024-08-07 13:34 ` [PATCH 40/54] ALSA: azt3328: Use pr_warn() Takashi Iwai
2024-08-07 13:34 ` [PATCH 41/54] ALSA: emu10k1: Use dev_warn() Takashi Iwai
2024-08-07 13:34 ` [PATCH 42/54] ALSA: trident: Use standard print API Takashi Iwai
2024-08-07 13:34 ` [PATCH 43/54] ALSA: emux: " Takashi Iwai
2024-08-07 13:34 ` [PATCH 44/54] ALSA: usx2y: " Takashi Iwai
2024-08-07 13:34 ` [PATCH 45/54] ALSA: usb-audio: " Takashi Iwai
2024-08-07 13:34 ` [PATCH 46/54] ALSA: intel8x0: Drop unused snd_printd() calls Takashi Iwai
2024-08-07 13:34 ` [PATCH 47/54] ALSA: vxpocket: Use standard print API Takashi Iwai
2024-08-07 13:34 ` [PATCH 48/54] ALSA: pdaudiocf: " Takashi Iwai
2024-08-07 13:34 ` [PATCH 49/54] ALSA: ppc: " Takashi Iwai
2024-08-07 13:34 ` [PATCH 50/54] ALSA: sh: " Takashi Iwai
2024-08-07 13:34 ` [PATCH 51/54] ALSA: sparc: " Takashi Iwai
2024-08-07 13:34 ` [PATCH 52/54] ALSA: asihpi: " Takashi Iwai
2024-08-07 13:34 ` [PATCH 53/54] ALSA: docs: Drop snd_print*() stuff Takashi Iwai
2024-08-07 13:34 ` [PATCH 54/54] ALSA: core: Drop snd_print stuff and co Takashi Iwai
2024-08-07 14:30 ` [PATCH 00/54] ALSA: Drop legacy snd_print*() Jaroslav Kysela

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240807133452.9424-25-tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=linux-sound@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox