Linux Sound subsystem development
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: linux-sound@vger.kernel.org
Subject: [PATCH 34/54] ALSA: sscape: Use standard print API
Date: Wed,  7 Aug 2024 15:34:24 +0200	[thread overview]
Message-ID: <20240807133452.9424-35-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.

The device pointer is stored in struct soundscape for calling
dev_*().

Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/isa/sscape.c | 96 +++++++++++++++++++++++-----------------------
 1 file changed, 48 insertions(+), 48 deletions(-)

diff --git a/sound/isa/sscape.c b/sound/isa/sscape.c
index cc56fafd27b1..09120e38f4c2 100644
--- a/sound/isa/sscape.c
+++ b/sound/isa/sscape.c
@@ -138,6 +138,7 @@ struct soundscape {
 	struct snd_wss *chip;
 
 	unsigned char midi_vol;
+	struct device *dev;
 };
 
 #define INVALID_IRQ  ((unsigned)-1)
@@ -161,9 +162,9 @@ static struct snd_dma_buffer *get_dmabuf(struct soundscape *s,
 		if (snd_dma_alloc_pages_fallback(SNDRV_DMA_TYPE_DEV,
 						 s->chip->card->dev,
 						 size, buf) < 0) {
-			snd_printk(KERN_ERR "sscape: Failed to allocate "
-					    "%lu bytes for DMA\n",
-					    size);
+			dev_err(s->dev,
+				"sscape: Failed to allocate %lu bytes for DMA\n",
+				size);
 			return NULL;
 		}
 	}
@@ -463,8 +464,7 @@ static int upload_dma_data(struct soundscape *s, const unsigned char *data,
 			 */
 			spin_unlock_irqrestore(&s->lock, flags);
 
-			snd_printk(KERN_ERR
-					"sscape: DMA upload has timed out\n");
+			dev_err(s->dev, "sscape: DMA upload has timed out\n");
 			ret = -EAGAIN;
 			goto _release_dma;
 		}
@@ -487,12 +487,11 @@ static int upload_dma_data(struct soundscape *s, const unsigned char *data,
 	 */
 	ret = 0;
 	if (!obp_startup_ack(s, 5000)) {
-		snd_printk(KERN_ERR "sscape: No response "
-				    "from on-board processor after upload\n");
+		dev_err(s->dev,
+			"sscape: No response from on-board processor after upload\n");
 		ret = -EAGAIN;
 	} else if (!host_startup_ack(s, 5000)) {
-		snd_printk(KERN_ERR
-				"sscape: SoundScape failed to initialise\n");
+		dev_err(s->dev, "sscape: SoundScape failed to initialise\n");
 		ret = -EAGAIN;
 	}
 
@@ -521,7 +520,7 @@ static int sscape_upload_bootblock(struct snd_card *card)
 
 	ret = request_firmware(&init_fw, "scope.cod", card->dev);
 	if (ret < 0) {
-		snd_printk(KERN_ERR "sscape: Error loading scope.cod");
+		dev_err(card->dev, "sscape: Error loading scope.cod");
 		return ret;
 	}
 	ret = upload_dma_data(sscape, init_fw->data, init_fw->size);
@@ -539,8 +538,8 @@ static int sscape_upload_bootblock(struct snd_card *card)
 
 	data &= 0xf;
 	if (ret == 0 && data > 7) {
-		snd_printk(KERN_ERR
-				"sscape: timeout reading firmware version\n");
+		dev_err(card->dev,
+			"sscape: timeout reading firmware version\n");
 		ret = -EAGAIN;
 	}
 
@@ -561,14 +560,14 @@ static int sscape_upload_microcode(struct snd_card *card, int version)
 
 	err = request_firmware(&init_fw, name, card->dev);
 	if (err < 0) {
-		snd_printk(KERN_ERR "sscape: Error loading sndscape.co%d",
-				version);
+		dev_err(card->dev, "sscape: Error loading sndscape.co%d",
+			version);
 		return err;
 	}
 	err = upload_dma_data(sscape, init_fw->data, init_fw->size);
 	if (err == 0)
-		snd_printk(KERN_INFO "sscape: MIDI firmware loaded %zu KBs\n",
-				init_fw->size >> 10);
+		dev_info(card->dev, "sscape: MIDI firmware loaded %zu KBs\n",
+			 init_fw->size >> 10);
 
 	release_firmware(init_fw);
 
@@ -783,8 +782,8 @@ static int detect_sscape(struct soundscape *s, long wss_io)
 static int mpu401_open(struct snd_mpu401 *mpu)
 {
 	if (!verify_mpu401(mpu)) {
-		snd_printk(KERN_ERR "sscape: MIDI disabled, "
-				    "please load firmware\n");
+		dev_err(mpu->rmidi->card->dev,
+			"sscape: MIDI disabled, please load firmware\n");
 		return -ENODEV;
 	}
 
@@ -871,22 +870,22 @@ static int create_ad1845(struct snd_card *card, unsigned port,
 
 		err = snd_wss_pcm(chip, 0);
 		if (err < 0) {
-			snd_printk(KERN_ERR "sscape: No PCM device "
-					    "for AD1845 chip\n");
+			dev_err(card->dev,
+				"sscape: No PCM device for AD1845 chip\n");
 			goto _error;
 		}
 
 		err = snd_wss_mixer(chip);
 		if (err < 0) {
-			snd_printk(KERN_ERR "sscape: No mixer device "
-					    "for AD1845 chip\n");
+			dev_err(card->dev,
+				"sscape: No mixer device for AD1845 chip\n");
 			goto _error;
 		}
 		if (chip->hardware != WSS_HW_AD1848) {
 			err = snd_wss_timer(chip, 0);
 			if (err < 0) {
-				snd_printk(KERN_ERR "sscape: No timer device "
-						    "for AD1845 chip\n");
+				dev_err(card->dev,
+					"sscape: No timer device for AD1845 chip\n");
 				goto _error;
 			}
 		}
@@ -895,8 +894,8 @@ static int create_ad1845(struct snd_card *card, unsigned port,
 			err = snd_ctl_add(card,
 					  snd_ctl_new1(&midi_mixer_ctl, chip));
 			if (err < 0) {
-				snd_printk(KERN_ERR "sscape: Could not create "
-						    "MIDI mixer control\n");
+				dev_err(card->dev,
+					"sscape: Could not create MIDI mixer control\n");
 				goto _error;
 			}
 		}
@@ -932,8 +931,8 @@ static int create_sscape(int dev, struct snd_card *card)
 	 */
 	io_res = devm_request_region(card->dev, port[dev], 8, "SoundScape");
 	if (!io_res) {
-		snd_printk(KERN_ERR
-			   "sscape: can't grab port 0x%lx\n", port[dev]);
+		dev_err(card->dev,
+			"sscape: can't grab port 0x%lx\n", port[dev]);
 		return -EBUSY;
 	}
 	wss_res = NULL;
@@ -941,8 +940,8 @@ static int create_sscape(int dev, struct snd_card *card)
 		wss_res = devm_request_region(card->dev, wss_port[dev], 4,
 					      "SoundScape");
 		if (!wss_res) {
-			snd_printk(KERN_ERR "sscape: can't grab port 0x%lx\n",
-					    wss_port[dev]);
+			dev_err(card->dev, "sscape: can't grab port 0x%lx\n",
+				wss_port[dev]);
 			return -EBUSY;
 		}
 	}
@@ -952,7 +951,7 @@ static int create_sscape(int dev, struct snd_card *card)
 	 */
 	err = snd_devm_request_dma(card->dev, dma[dev], "SoundScape");
 	if (err < 0) {
-		snd_printk(KERN_ERR "sscape: can't grab DMA %d\n", dma[dev]);
+		dev_err(card->dev, "sscape: can't grab DMA %d\n", dma[dev]);
 		return err;
 	}
 
@@ -962,7 +961,7 @@ static int create_sscape(int dev, struct snd_card *card)
 	sscape->io_base = port[dev];
 
 	if (!detect_sscape(sscape, wss_port[dev])) {
-		printk(KERN_ERR "sscape: hardware not detected at 0x%x\n",
+		dev_err(card->dev, "sscape: hardware not detected at 0x%x\n",
 			sscape->io_base);
 		return -ENODEV;
 	}
@@ -985,21 +984,21 @@ static int create_sscape(int dev, struct snd_card *card)
 		break;
 	}
 
-	printk(KERN_INFO "sscape: %s card detected at 0x%x, using IRQ %d, DMA %d\n",
-			 name, sscape->io_base, irq[dev], dma[dev]);
+	dev_info(card->dev, "sscape: %s card detected at 0x%x, using IRQ %d, DMA %d\n",
+		 name, sscape->io_base, irq[dev], dma[dev]);
 
 	/*
 	 * Check that the user didn't pass us garbage data ...
 	 */
 	irq_cfg = get_irq_config(sscape->type, irq[dev]);
 	if (irq_cfg == INVALID_IRQ) {
-		snd_printk(KERN_ERR "sscape: Invalid IRQ %d\n", irq[dev]);
+		dev_err(card->dev, "sscape: Invalid IRQ %d\n", irq[dev]);
 		return -ENXIO;
 	}
 
 	mpu_irq_cfg = get_irq_config(sscape->type, mpu_irq[dev]);
 	if (mpu_irq_cfg == INVALID_IRQ) {
-		snd_printk(KERN_ERR "sscape: Invalid IRQ %d\n", mpu_irq[dev]);
+		dev_err(card->dev, "sscape: Invalid IRQ %d\n", mpu_irq[dev]);
 		return -ENXIO;
 	}
 
@@ -1043,9 +1042,9 @@ static int create_sscape(int dev, struct snd_card *card)
 	err = create_ad1845(card, wss_port[dev], irq[dev],
 			    dma[dev], dma2[dev]);
 	if (err < 0) {
-		snd_printk(KERN_ERR
-				"sscape: No AD1845 device at 0x%lx, IRQ %d\n",
-				wss_port[dev], irq[dev]);
+		dev_err(card->dev,
+			"sscape: No AD1845 device at 0x%lx, IRQ %d\n",
+			wss_port[dev], irq[dev]);
 		return err;
 	}
 	strcpy(card->driver, "SoundScape");
@@ -1065,9 +1064,9 @@ static int create_sscape(int dev, struct snd_card *card)
 			err = create_mpu401(card, MIDI_DEVNUM, port[dev],
 					    mpu_irq[dev]);
 			if (err < 0) {
-				snd_printk(KERN_ERR "sscape: Failed to create "
-						"MPU-401 device at 0x%lx\n",
-						port[dev]);
+				dev_err(card->dev,
+					"sscape: Failed to create MPU-401 device at 0x%lx\n",
+					port[dev]);
 				return err;
 			}
 
@@ -1110,9 +1109,8 @@ static int snd_sscape_match(struct device *pdev, unsigned int i)
 	if (irq[i] == SNDRV_AUTO_IRQ ||
 	    mpu_irq[i] == SNDRV_AUTO_IRQ ||
 	    dma[i] == SNDRV_AUTO_DMA) {
-		printk(KERN_INFO
-		       "sscape: insufficient parameters, "
-		       "need IO, IRQ, MPU-IRQ and DMA\n");
+		dev_info(pdev,
+			 "sscape: insufficient parameters, need IO, IRQ, MPU-IRQ and DMA\n");
 		return 0;
 	}
 
@@ -1131,6 +1129,7 @@ static int snd_sscape_probe(struct device *pdev, unsigned int dev)
 		return ret;
 
 	sscape = get_card_soundscape(card);
+	sscape->dev = pdev;
 	sscape->type = SSCAPE;
 
 	dma[dev] &= 0x03;
@@ -1141,7 +1140,7 @@ static int snd_sscape_probe(struct device *pdev, unsigned int dev)
 
 	ret = snd_card_register(card);
 	if (ret < 0) {
-		snd_printk(KERN_ERR "sscape: Failed to register sound card\n");
+		dev_err(pdev, "sscape: Failed to register sound card\n");
 		return ret;
 	}
 	dev_set_drvdata(pdev, card);
@@ -1194,7 +1193,7 @@ static int sscape_pnp_detect(struct pnp_card_link *pcard,
 
 	if (!pnp_is_active(dev)) {
 		if (pnp_activate_dev(dev) < 0) {
-			snd_printk(KERN_INFO "sscape: device is inactive\n");
+			dev_info(&dev->dev, "sscape: device is inactive\n");
 			return -EBUSY;
 		}
 	}
@@ -1210,6 +1209,7 @@ static int sscape_pnp_detect(struct pnp_card_link *pcard,
 		return ret;
 
 	sscape = get_card_soundscape(card);
+	sscape->dev = card->dev;
 
 	/*
 	 * Identify card model ...
@@ -1240,7 +1240,7 @@ static int sscape_pnp_detect(struct pnp_card_link *pcard,
 
 	ret = snd_card_register(card);
 	if (ret < 0) {
-		snd_printk(KERN_ERR "sscape: Failed to register sound card\n");
+		dev_err(card->dev, "sscape: Failed to register sound card\n");
 		return ret;
 	}
 
-- 
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 ` [PATCH 24/54] ALSA: es1688: " Takashi Iwai
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 ` Takashi Iwai [this message]
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-35-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