1

ALSA: sscape: Use standard print API

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

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

Reviewed-by: Jaroslav Kysela <perex@perex.cz>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Link: https://patch.msgid.link/20240807133452.9424-35-tiwai@suse.de
This commit is contained in:
Takashi Iwai 2024-08-07 15:34:24 +02:00
parent e7c475b920
commit 610f04ca71

View File

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