1
0
Fork 0
mirror of https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git synced 2025-01-23 00:20:52 -05:00

ALSA: es18xx: 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.

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

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

View file

@ -82,9 +82,8 @@
#define SNDRV_LEGACY_FIND_FREE_DMA #define SNDRV_LEGACY_FIND_FREE_DMA
#include <sound/initval.h> #include <sound/initval.h>
#define PFX "es18xx: "
struct snd_es18xx { struct snd_es18xx {
struct snd_card *card;
unsigned long port; /* port of ESS chip */ unsigned long port; /* port of ESS chip */
unsigned long ctrl_port; /* Control port of ESS chip */ unsigned long ctrl_port; /* Control port of ESS chip */
int irq; /* IRQ number of ESS chip */ int irq; /* IRQ number of ESS chip */
@ -165,7 +164,7 @@ static int snd_es18xx_dsp_command(struct snd_es18xx *chip, unsigned char val)
outb(val, chip->port + 0x0C); outb(val, chip->port + 0x0C);
return 0; return 0;
} }
snd_printk(KERN_ERR "dsp_command: timeout (0x%x)\n", val); dev_err(chip->card->dev, "dsp_command: timeout (0x%x)\n", val);
return -EINVAL; return -EINVAL;
} }
@ -176,7 +175,7 @@ static int snd_es18xx_dsp_get_byte(struct snd_es18xx *chip)
for(i = MILLISECOND/10; i; i--) for(i = MILLISECOND/10; i; i--)
if (inb(chip->port + 0x0C) & 0x40) if (inb(chip->port + 0x0C) & 0x40)
return inb(chip->port + 0x0A); return inb(chip->port + 0x0A);
snd_printk(KERN_ERR "dsp_get_byte failed: 0x%lx = 0x%x!!!\n", dev_err(chip->card->dev, "dsp_get_byte failed: 0x%lx = 0x%x!!!\n",
chip->port + 0x0A, inb(chip->port + 0x0A)); chip->port + 0x0A, inb(chip->port + 0x0A));
return -ENODEV; return -ENODEV;
} }
@ -197,7 +196,7 @@ static int snd_es18xx_write(struct snd_es18xx *chip,
end: end:
spin_unlock_irqrestore(&chip->reg_lock, flags); spin_unlock_irqrestore(&chip->reg_lock, flags);
#ifdef REG_DEBUG #ifdef REG_DEBUG
snd_printk(KERN_DEBUG "Reg %02x set to %02x\n", reg, data); dev_dbg(chip->card->dev, "Reg %02x set to %02x\n", reg, data);
#endif #endif
return ret; return ret;
} }
@ -216,7 +215,7 @@ static int snd_es18xx_read(struct snd_es18xx *chip, unsigned char reg)
data = snd_es18xx_dsp_get_byte(chip); data = snd_es18xx_dsp_get_byte(chip);
ret = data; ret = data;
#ifdef REG_DEBUG #ifdef REG_DEBUG
snd_printk(KERN_DEBUG "Reg %02x now is %02x (%d)\n", reg, data, ret); dev_dbg(chip->card->dev, "Reg %02x now is %02x (%d)\n", reg, data, ret);
#endif #endif
end: end:
spin_unlock_irqrestore(&chip->reg_lock, flags); spin_unlock_irqrestore(&chip->reg_lock, flags);
@ -252,7 +251,7 @@ static int snd_es18xx_bits(struct snd_es18xx *chip, unsigned char reg,
if (ret < 0) if (ret < 0)
goto end; goto end;
#ifdef REG_DEBUG #ifdef REG_DEBUG
snd_printk(KERN_DEBUG "Reg %02x was %02x, set to %02x (%d)\n", dev_dbg(chip->card->dev, "Reg %02x was %02x, set to %02x (%d)\n",
reg, old, new, ret); reg, old, new, ret);
#endif #endif
} }
@ -271,7 +270,7 @@ static inline void snd_es18xx_mixer_write(struct snd_es18xx *chip,
outb(data, chip->port + 0x05); outb(data, chip->port + 0x05);
spin_unlock_irqrestore(&chip->mixer_lock, flags); spin_unlock_irqrestore(&chip->mixer_lock, flags);
#ifdef REG_DEBUG #ifdef REG_DEBUG
snd_printk(KERN_DEBUG "Mixer reg %02x set to %02x\n", reg, data); dev_dbg(chip->card->dev, "Mixer reg %02x set to %02x\n", reg, data);
#endif #endif
} }
@ -284,7 +283,7 @@ static inline int snd_es18xx_mixer_read(struct snd_es18xx *chip, unsigned char r
data = inb(chip->port + 0x05); data = inb(chip->port + 0x05);
spin_unlock_irqrestore(&chip->mixer_lock, flags); spin_unlock_irqrestore(&chip->mixer_lock, flags);
#ifdef REG_DEBUG #ifdef REG_DEBUG
snd_printk(KERN_DEBUG "Mixer reg %02x now is %02x\n", reg, data); dev_dbg(chip->card->dev, "Mixer reg %02x now is %02x\n", reg, data);
#endif #endif
return data; return data;
} }
@ -303,7 +302,7 @@ static inline int snd_es18xx_mixer_bits(struct snd_es18xx *chip, unsigned char r
new = (old & ~mask) | (val & mask); new = (old & ~mask) | (val & mask);
outb(new, chip->port + 0x05); outb(new, chip->port + 0x05);
#ifdef REG_DEBUG #ifdef REG_DEBUG
snd_printk(KERN_DEBUG "Mixer reg %02x was %02x, set to %02x\n", dev_dbg(chip->card->dev, "Mixer reg %02x was %02x, set to %02x\n",
reg, old, new); reg, old, new);
#endif #endif
} }
@ -324,7 +323,7 @@ static inline int snd_es18xx_mixer_writable(struct snd_es18xx *chip, unsigned ch
new = inb(chip->port + 0x05); new = inb(chip->port + 0x05);
spin_unlock_irqrestore(&chip->mixer_lock, flags); spin_unlock_irqrestore(&chip->mixer_lock, flags);
#ifdef REG_DEBUG #ifdef REG_DEBUG
snd_printk(KERN_DEBUG "Mixer reg %02x was %02x, set to %02x, now is %02x\n", dev_dbg(chip->card->dev, "Mixer reg %02x was %02x, set to %02x, now is %02x\n",
reg, old, expected, new); reg, old, expected, new);
#endif #endif
return expected == new; return expected == new;
@ -1356,7 +1355,7 @@ static void snd_es18xx_config_write(struct snd_es18xx *chip,
outb(reg, chip->ctrl_port); outb(reg, chip->ctrl_port);
outb(data, chip->ctrl_port + 1); outb(data, chip->ctrl_port + 1);
#ifdef REG_DEBUG #ifdef REG_DEBUG
snd_printk(KERN_DEBUG "Config reg %02x set to %02x\n", reg, data); dev_dbg(chip->card->dev, "Config reg %02x set to %02x\n", reg, data);
#endif #endif
} }
@ -1425,7 +1424,7 @@ static int snd_es18xx_initialize(struct snd_es18xx *chip,
irqmask = 3; irqmask = 3;
break; break;
default: default:
snd_printk(KERN_ERR "invalid irq %d\n", chip->irq); dev_err(chip->card->dev, "invalid irq %d\n", chip->irq);
return -ENODEV; return -ENODEV;
} }
switch (chip->dma1) { switch (chip->dma1) {
@ -1439,7 +1438,7 @@ static int snd_es18xx_initialize(struct snd_es18xx *chip,
dma1mask = 3; dma1mask = 3;
break; break;
default: default:
snd_printk(KERN_ERR "invalid dma1 %d\n", chip->dma1); dev_err(chip->card->dev, "invalid dma1 %d\n", chip->dma1);
return -ENODEV; return -ENODEV;
} }
switch (chip->dma2) { switch (chip->dma2) {
@ -1456,7 +1455,7 @@ static int snd_es18xx_initialize(struct snd_es18xx *chip,
dma2mask = 3; dma2mask = 3;
break; break;
default: default:
snd_printk(KERN_ERR "invalid dma2 %d\n", chip->dma2); dev_err(chip->card->dev, "invalid dma2 %d\n", chip->dma2);
return -ENODEV; return -ENODEV;
} }
@ -1531,7 +1530,7 @@ static int snd_es18xx_identify(struct snd_card *card, struct snd_es18xx *chip)
/* reset */ /* reset */
if (snd_es18xx_reset(chip) < 0) { if (snd_es18xx_reset(chip) < 0) {
snd_printk(KERN_ERR "reset at 0x%lx failed!!!\n", chip->port); dev_err(card->dev, "reset at 0x%lx failed!!!\n", chip->port);
return -ENODEV; return -ENODEV;
} }
@ -1569,7 +1568,7 @@ static int snd_es18xx_identify(struct snd_card *card, struct snd_es18xx *chip)
if (!devm_request_region(card->dev, chip->ctrl_port, 8, if (!devm_request_region(card->dev, chip->ctrl_port, 8,
"ES18xx - CTRL")) { "ES18xx - CTRL")) {
snd_printk(KERN_ERR PFX "unable go grab port 0x%lx\n", chip->ctrl_port); dev_err(card->dev, "unable go grab port 0x%lx\n", chip->ctrl_port);
return -EBUSY; return -EBUSY;
} }
@ -1601,7 +1600,7 @@ static int snd_es18xx_probe(struct snd_card *card,
unsigned long fm_port) unsigned long fm_port)
{ {
if (snd_es18xx_identify(card, chip) < 0) { if (snd_es18xx_identify(card, chip) < 0) {
snd_printk(KERN_ERR PFX "[0x%lx] ESS chip not found\n", chip->port); dev_err(card->dev, "[0x%lx] ESS chip not found\n", chip->port);
return -ENODEV; return -ENODEV;
} }
@ -1623,12 +1622,12 @@ static int snd_es18xx_probe(struct snd_card *card,
chip->caps = ES18XX_PCM2 | ES18XX_RECMIX | ES18XX_AUXB | ES18XX_DUPLEX_SAME | ES18XX_GPO_2BIT; chip->caps = ES18XX_PCM2 | ES18XX_RECMIX | ES18XX_AUXB | ES18XX_DUPLEX_SAME | ES18XX_GPO_2BIT;
break; break;
default: default:
snd_printk(KERN_ERR "[0x%lx] unsupported chip ES%x\n", dev_err(card->dev, "[0x%lx] unsupported chip ES%x\n",
chip->port, chip->version); chip->port, chip->version);
return -ENODEV; return -ENODEV;
} }
snd_printd("[0x%lx] ESS%x chip found\n", chip->port, chip->version); dev_dbg(card->dev, "[0x%lx] ESS%x chip found\n", chip->port, chip->version);
if (chip->dma1 == chip->dma2) if (chip->dma1 == chip->dma2)
chip->caps &= ~(ES18XX_PCM2 | ES18XX_DUPLEX_SAME); chip->caps &= ~(ES18XX_PCM2 | ES18XX_DUPLEX_SAME);
@ -1725,6 +1724,7 @@ static int snd_es18xx_new_device(struct snd_card *card,
{ {
struct snd_es18xx *chip = card->private_data; struct snd_es18xx *chip = card->private_data;
chip->card = card;
spin_lock_init(&chip->reg_lock); spin_lock_init(&chip->reg_lock);
spin_lock_init(&chip->mixer_lock); spin_lock_init(&chip->mixer_lock);
chip->port = port; chip->port = port;
@ -1735,27 +1735,27 @@ static int snd_es18xx_new_device(struct snd_card *card,
chip->active = 0; chip->active = 0;
if (!devm_request_region(card->dev, port, 16, "ES18xx")) { if (!devm_request_region(card->dev, port, 16, "ES18xx")) {
snd_printk(KERN_ERR PFX "unable to grap ports 0x%lx-0x%lx\n", port, port + 16 - 1); dev_err(card->dev, "unable to grap ports 0x%lx-0x%lx\n", port, port + 16 - 1);
return -EBUSY; return -EBUSY;
} }
if (devm_request_irq(card->dev, irq, snd_es18xx_interrupt, 0, "ES18xx", if (devm_request_irq(card->dev, irq, snd_es18xx_interrupt, 0, "ES18xx",
(void *) card)) { (void *) card)) {
snd_printk(KERN_ERR PFX "unable to grap IRQ %d\n", irq); dev_err(card->dev, "unable to grap IRQ %d\n", irq);
return -EBUSY; return -EBUSY;
} }
chip->irq = irq; chip->irq = irq;
card->sync_irq = chip->irq; card->sync_irq = chip->irq;
if (snd_devm_request_dma(card->dev, dma1, "ES18xx DMA 1")) { if (snd_devm_request_dma(card->dev, dma1, "ES18xx DMA 1")) {
snd_printk(KERN_ERR PFX "unable to grap DMA1 %d\n", dma1); dev_err(card->dev, "unable to grap DMA1 %d\n", dma1);
return -EBUSY; return -EBUSY;
} }
chip->dma1 = dma1; chip->dma1 = dma1;
if (dma2 != dma1 && if (dma2 != dma1 &&
snd_devm_request_dma(card->dev, dma2, "ES18xx DMA 2")) { snd_devm_request_dma(card->dev, dma2, "ES18xx DMA 2")) {
snd_printk(KERN_ERR PFX "unable to grap DMA2 %d\n", dma2); dev_err(card->dev, "unable to grap DMA2 %d\n", dma2);
return -EBUSY; return -EBUSY;
} }
chip->dma2 = dma2; chip->dma2 = dma2;
@ -1954,7 +1954,7 @@ MODULE_DEVICE_TABLE(pnp, snd_audiodrive_pnpbiosids);
static int snd_audiodrive_pnp_init_main(int dev, struct pnp_dev *pdev) static int snd_audiodrive_pnp_init_main(int dev, struct pnp_dev *pdev)
{ {
if (pnp_activate_dev(pdev) < 0) { if (pnp_activate_dev(pdev) < 0) {
snd_printk(KERN_ERR PFX "PnP configure failure (out of resources?)\n"); dev_err(&pdev->dev, "PnP configure failure (out of resources?)\n");
return -EBUSY; return -EBUSY;
} }
/* ok. hack using Vendor-Defined Card-Level registers */ /* ok. hack using Vendor-Defined Card-Level registers */
@ -1973,8 +1973,12 @@ static int snd_audiodrive_pnp_init_main(int dev, struct pnp_dev *pdev)
dma1[dev] = pnp_dma(pdev, 0); dma1[dev] = pnp_dma(pdev, 0);
dma2[dev] = pnp_dma(pdev, 1); dma2[dev] = pnp_dma(pdev, 1);
irq[dev] = pnp_irq(pdev, 0); irq[dev] = pnp_irq(pdev, 0);
snd_printdd("PnP ES18xx: port=0x%lx, fm port=0x%lx, mpu port=0x%lx\n", port[dev], fm_port[dev], mpu_port[dev]); dev_dbg(&pdev->dev,
snd_printdd("PnP ES18xx: dma1=%i, dma2=%i, irq=%i\n", dma1[dev], dma2[dev], irq[dev]); "PnP ES18xx: port=0x%lx, fm port=0x%lx, mpu port=0x%lx\n",
port[dev], fm_port[dev], mpu_port[dev]);
dev_dbg(&pdev->dev,
"PnP ES18xx: dma1=%i, dma2=%i, irq=%i\n",
dma1[dev], dma2[dev], irq[dev]);
return 0; return 0;
} }
@ -2022,10 +2026,11 @@ static int snd_audiodrive_pnpc(int dev, struct snd_es18xx *chip,
/* Control port initialization */ /* Control port initialization */
if (pnp_activate_dev(chip->devc) < 0) { if (pnp_activate_dev(chip->devc) < 0) {
snd_printk(KERN_ERR PFX "PnP control configure failure (out of resources?)\n"); dev_err(chip->card->dev,
"PnP control configure failure (out of resources?)\n");
return -EAGAIN; return -EAGAIN;
} }
snd_printdd("pnp: port=0x%llx\n", dev_dbg(chip->card->dev, "pnp: port=0x%llx\n",
(unsigned long long)pnp_port_start(chip->devc, 0)); (unsigned long long)pnp_port_start(chip->devc, 0));
if (snd_audiodrive_pnp_init_main(dev, chip->dev) < 0) if (snd_audiodrive_pnp_init_main(dev, chip->dev) < 0)
return -EBUSY; return -EBUSY;
@ -2084,7 +2089,7 @@ static int snd_audiodrive_probe(struct snd_card *card, int dev)
if (fm_port[dev] > 0 && fm_port[dev] != SNDRV_AUTO_PORT) { if (fm_port[dev] > 0 && fm_port[dev] != SNDRV_AUTO_PORT) {
if (snd_opl3_create(card, fm_port[dev], fm_port[dev] + 2, if (snd_opl3_create(card, fm_port[dev], fm_port[dev] + 2,
OPL3_HW_OPL3, 0, &opl3) < 0) { OPL3_HW_OPL3, 0, &opl3) < 0) {
snd_printk(KERN_WARNING PFX dev_warn(card->dev,
"opl3 not detected at 0x%lx\n", "opl3 not detected at 0x%lx\n",
fm_port[dev]); fm_port[dev]);
} else { } else {
@ -2134,21 +2139,21 @@ static int snd_es18xx_isa_probe(struct device *pdev, unsigned int dev)
if (irq[dev] == SNDRV_AUTO_IRQ) { if (irq[dev] == SNDRV_AUTO_IRQ) {
irq[dev] = snd_legacy_find_free_irq(possible_irqs); irq[dev] = snd_legacy_find_free_irq(possible_irqs);
if (irq[dev] < 0) { if (irq[dev] < 0) {
snd_printk(KERN_ERR PFX "unable to find a free IRQ\n"); dev_err(pdev, "unable to find a free IRQ\n");
return -EBUSY; return -EBUSY;
} }
} }
if (dma1[dev] == SNDRV_AUTO_DMA) { if (dma1[dev] == SNDRV_AUTO_DMA) {
dma1[dev] = snd_legacy_find_free_dma(possible_dmas); dma1[dev] = snd_legacy_find_free_dma(possible_dmas);
if (dma1[dev] < 0) { if (dma1[dev] < 0) {
snd_printk(KERN_ERR PFX "unable to find a free DMA1\n"); dev_err(pdev, "unable to find a free DMA1\n");
return -EBUSY; return -EBUSY;
} }
} }
if (dma2[dev] == SNDRV_AUTO_DMA) { if (dma2[dev] == SNDRV_AUTO_DMA) {
dma2[dev] = snd_legacy_find_free_dma(possible_dmas); dma2[dev] = snd_legacy_find_free_dma(possible_dmas);
if (dma2[dev] < 0) { if (dma2[dev] < 0) {
snd_printk(KERN_ERR PFX "unable to find a free DMA2\n"); dev_err(pdev, "unable to find a free DMA2\n");
return -EBUSY; return -EBUSY;
} }
} }