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

Reviewed-by: Jaroslav Kysela <perex@perex.cz>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Link: https://patch.msgid.link/20240807133452.9424-50-tiwai@suse.de
This commit is contained in:
Takashi Iwai 2024-08-07 15:34:39 +02:00
parent 7ba0212231
commit 76a6ef90d5
6 changed files with 41 additions and 45 deletions

View File

@ -39,7 +39,7 @@ static void snd_pmac_screamer_wait(struct snd_pmac *chip)
while (!(in_le32(&chip->awacs->codec_stat) & MASK_VALID)) { while (!(in_le32(&chip->awacs->codec_stat) & MASK_VALID)) {
mdelay(1); mdelay(1);
if (! --timeout) { if (! --timeout) {
snd_printd("snd_pmac_screamer_wait timeout\n"); dev_dbg(chip->card->dev, "%s timeout\n", __func__);
break; break;
} }
} }
@ -58,7 +58,7 @@ snd_pmac_awacs_write(struct snd_pmac *chip, int val)
out_le32(&chip->awacs->codec_ctrl, val | (chip->subframe << 22)); out_le32(&chip->awacs->codec_ctrl, val | (chip->subframe << 22));
while (in_le32(&chip->awacs->codec_ctrl) & MASK_NEWECMD) { while (in_le32(&chip->awacs->codec_ctrl) & MASK_NEWECMD) {
if (! --timeout) { if (! --timeout) {
snd_printd("snd_pmac_awacs_write timeout\n"); dev_dbg(chip->card->dev, "%s timeout\n", __func__);
break; break;
} }
} }

View File

@ -69,7 +69,7 @@ static int daca_set_volume(struct pmac_daca *mix)
data[1] |= mix->deemphasis ? 0x40 : 0; data[1] |= mix->deemphasis ? 0x40 : 0;
if (i2c_smbus_write_block_data(mix->i2c.client, DACA_REG_AVOL, if (i2c_smbus_write_block_data(mix->i2c.client, DACA_REG_AVOL,
2, data) < 0) { 2, data) < 0) {
snd_printk(KERN_ERR "failed to set volume \n"); dev_err(&mix->i2c.client->dev, "failed to set volume\n");
return -EINVAL; return -EINVAL;
} }
return 0; return 0;

View File

@ -113,7 +113,8 @@ int snd_pmac_tumbler_post_init(void)
err = keywest_ctx->init_client(keywest_ctx); err = keywest_ctx->init_client(keywest_ctx);
if (err < 0) { if (err < 0) {
snd_printk(KERN_ERR "tumbler: %i :cannot initialize the MCS\n", err); dev_err(&keywest_ctx->client->dev,
"tumbler: %i :cannot initialize the MCS\n", err);
return err; return err;
} }
return 0; return 0;
@ -136,7 +137,7 @@ int snd_pmac_keywest_init(struct pmac_keywest *i2c)
err = i2c_add_driver(&keywest_driver); err = i2c_add_driver(&keywest_driver);
if (err) { if (err) {
snd_printk(KERN_ERR "cannot register keywest i2c driver\n"); dev_err(&i2c->client->dev, "cannot register keywest i2c driver\n");
i2c_put_adapter(adap); i2c_put_adapter(adap);
return err; return err;
} }

View File

@ -269,7 +269,6 @@ static int snd_pmac_pcm_trigger(struct snd_pmac *chip, struct pmac_stream *rec,
case SNDRV_PCM_TRIGGER_SUSPEND: case SNDRV_PCM_TRIGGER_SUSPEND:
spin_lock(&chip->reg_lock); spin_lock(&chip->reg_lock);
rec->running = 0; rec->running = 0;
/*printk(KERN_DEBUG "stopped!!\n");*/
snd_pmac_dma_stop(rec); snd_pmac_dma_stop(rec);
for (i = 0, cp = rec->cmd.cmds; i < rec->nperiods; i++, cp++) for (i = 0, cp = rec->cmd.cmds; i < rec->nperiods; i++, cp++)
out_le16(&cp->command, DBDMA_STOP); out_le16(&cp->command, DBDMA_STOP);
@ -304,7 +303,6 @@ static snd_pcm_uframes_t snd_pmac_pcm_pointer(struct snd_pmac *chip,
} }
#endif #endif
count += rec->cur_period * rec->period_size; count += rec->cur_period * rec->period_size;
/*printk(KERN_DEBUG "pointer=%d\n", count);*/
return bytes_to_frames(subs->runtime, count); return bytes_to_frames(subs->runtime, count);
} }
@ -384,8 +382,6 @@ static inline void snd_pmac_pcm_dead_xfer(struct pmac_stream *rec,
unsigned short req, res ; unsigned short req, res ;
unsigned int phy ; unsigned int phy ;
/* printk(KERN_WARNING "snd-powermac: DMA died - patching it up!\n"); */
/* to clear DEAD status we must first clear RUN /* to clear DEAD status we must first clear RUN
set it to quiescent to be on the safe side */ set it to quiescent to be on the safe side */
(void)in_le32(&rec->dma->status); (void)in_le32(&rec->dma->status);
@ -456,7 +452,6 @@ static void snd_pmac_pcm_update(struct snd_pmac *chip, struct pmac_stream *rec)
if (! (stat & ACTIVE)) if (! (stat & ACTIVE))
break; break;
/*printk(KERN_DEBUG "update frag %d\n", rec->cur_period);*/
cp->xfer_status = cpu_to_le16(0); cp->xfer_status = cpu_to_le16(0);
cp->req_count = cpu_to_le16(rec->period_size); cp->req_count = cpu_to_le16(rec->period_size);
/*cp->res_count = cpu_to_le16(0);*/ /*cp->res_count = cpu_to_le16(0);*/
@ -770,7 +765,6 @@ snd_pmac_ctrl_intr(int irq, void *devid)
struct snd_pmac *chip = devid; struct snd_pmac *chip = devid;
int ctrl = in_le32(&chip->awacs->control); int ctrl = in_le32(&chip->awacs->control);
/*printk(KERN_DEBUG "pmac: control interrupt.. 0x%x\n", ctrl);*/
if (ctrl & MASK_PORTCHG) { if (ctrl & MASK_PORTCHG) {
/* do something when headphone is plugged/unplugged? */ /* do something when headphone is plugged/unplugged? */
if (chip->update_automute) if (chip->update_automute)
@ -779,7 +773,7 @@ snd_pmac_ctrl_intr(int irq, void *devid)
if (ctrl & MASK_CNTLERR) { if (ctrl & MASK_CNTLERR) {
int err = (in_le32(&chip->awacs->codec_stat) & MASK_ERRCODE) >> 16; int err = (in_le32(&chip->awacs->codec_stat) & MASK_ERRCODE) >> 16;
if (err && chip->model <= PMAC_SCREAMER) if (err && chip->model <= PMAC_SCREAMER)
snd_printk(KERN_DEBUG "error %x\n", err); dev_dbg(chip->card->dev, "%s: error %x\n", __func__, err);
} }
/* Writing 1s to the CNTLERR and PORTCHG bits clears them... */ /* Writing 1s to the CNTLERR and PORTCHG bits clears them... */
out_le32(&chip->awacs->control, ctrl); out_le32(&chip->awacs->control, ctrl);
@ -964,9 +958,8 @@ static int snd_pmac_detect(struct snd_pmac *chip)
if (prop) { if (prop) {
/* partly deprecate snd-powermac, for those machines /* partly deprecate snd-powermac, for those machines
* that have a layout-id property for now */ * that have a layout-id property for now */
printk(KERN_INFO "snd-powermac no longer handles any " dev_info(chip->card->dev,
"machines with a layout-id property " "snd-powermac no longer handles any machines with a layout-id property in the device-tree, use snd-aoa.\n");
"in the device-tree, use snd-aoa.\n");
of_node_put(sound); of_node_put(sound);
of_node_put(chip->node); of_node_put(chip->node);
chip->node = NULL; chip->node = NULL;
@ -1021,7 +1014,7 @@ static int snd_pmac_detect(struct snd_pmac *chip)
*/ */
macio = macio_find(chip->node, macio_unknown); macio = macio_find(chip->node, macio_unknown);
if (macio == NULL) if (macio == NULL)
printk(KERN_WARNING "snd-powermac: can't locate macio !\n"); dev_warn(chip->card->dev, "snd-powermac: can't locate macio !\n");
else { else {
struct pci_dev *pdev = NULL; struct pci_dev *pdev = NULL;
@ -1034,8 +1027,8 @@ static int snd_pmac_detect(struct snd_pmac *chip)
} }
} }
if (chip->pdev == NULL) if (chip->pdev == NULL)
printk(KERN_WARNING "snd-powermac: can't locate macio PCI" dev_warn(chip->card->dev,
" device !\n"); "snd-powermac: can't locate macio PCI device !\n");
detect_byte_swap(chip); detect_byte_swap(chip);
@ -1125,7 +1118,8 @@ int snd_pmac_add_automute(struct snd_pmac *chip)
chip->auto_mute = 1; chip->auto_mute = 1;
err = snd_ctl_add(chip->card, snd_ctl_new1(&auto_mute_controls[0], chip)); err = snd_ctl_add(chip->card, snd_ctl_new1(&auto_mute_controls[0], chip));
if (err < 0) { if (err < 0) {
printk(KERN_ERR "snd-powermac: Failed to add automute control\n"); dev_err(chip->card->dev,
"snd-powermac: Failed to add automute control\n");
return err; return err;
} }
chip->hp_detect_ctl = snd_ctl_new1(&auto_mute_controls[1], chip); chip->hp_detect_ctl = snd_ctl_new1(&auto_mute_controls[1], chip);
@ -1180,17 +1174,18 @@ int snd_pmac_new(struct snd_card *card, struct snd_pmac **chip_return)
for (i = 0; i < 2; i ++) { for (i = 0; i < 2; i ++) {
if (of_address_to_resource(np->parent, i, if (of_address_to_resource(np->parent, i,
&chip->rsrc[i])) { &chip->rsrc[i])) {
printk(KERN_ERR "snd: can't translate rsrc " dev_err(chip->card->dev,
" %d (%s)\n", i, rnames[i]); "snd: can't translate rsrc %d (%s)\n",
i, rnames[i]);
err = -ENODEV; err = -ENODEV;
goto __error; goto __error;
} }
if (request_mem_region(chip->rsrc[i].start, if (request_mem_region(chip->rsrc[i].start,
resource_size(&chip->rsrc[i]), resource_size(&chip->rsrc[i]),
rnames[i]) == NULL) { rnames[i]) == NULL) {
printk(KERN_ERR "snd: can't request rsrc " dev_err(chip->card->dev,
" %d (%s: %pR)\n", "snd: can't request rsrc %d (%s: %pR)\n",
i, rnames[i], &chip->rsrc[i]); i, rnames[i], &chip->rsrc[i]);
err = -ENODEV; err = -ENODEV;
goto __error; goto __error;
} }
@ -1205,17 +1200,18 @@ int snd_pmac_new(struct snd_card *card, struct snd_pmac **chip_return)
for (i = 0; i < 3; i ++) { for (i = 0; i < 3; i ++) {
if (of_address_to_resource(np, i, if (of_address_to_resource(np, i,
&chip->rsrc[i])) { &chip->rsrc[i])) {
printk(KERN_ERR "snd: can't translate rsrc " dev_err(chip->card->dev,
" %d (%s)\n", i, rnames[i]); "snd: can't translate rsrc %d (%s)\n",
i, rnames[i]);
err = -ENODEV; err = -ENODEV;
goto __error; goto __error;
} }
if (request_mem_region(chip->rsrc[i].start, if (request_mem_region(chip->rsrc[i].start,
resource_size(&chip->rsrc[i]), resource_size(&chip->rsrc[i]),
rnames[i]) == NULL) { rnames[i]) == NULL) {
printk(KERN_ERR "snd: can't request rsrc " dev_err(chip->card->dev,
" %d (%s: %pR)\n", "snd: can't request rsrc %d (%s: %pR)\n",
i, rnames[i], &chip->rsrc[i]); i, rnames[i], &chip->rsrc[i]);
err = -ENODEV; err = -ENODEV;
goto __error; goto __error;
} }
@ -1233,8 +1229,8 @@ int snd_pmac_new(struct snd_card *card, struct snd_pmac **chip_return)
irq = irq_of_parse_and_map(np, 0); irq = irq_of_parse_and_map(np, 0);
if (request_irq(irq, snd_pmac_ctrl_intr, 0, if (request_irq(irq, snd_pmac_ctrl_intr, 0,
"PMac", (void*)chip)) { "PMac", (void*)chip)) {
snd_printk(KERN_ERR "pmac: unable to grab IRQ %d\n", dev_err(chip->card->dev,
irq); "pmac: unable to grab IRQ %d\n", irq);
err = -EBUSY; err = -EBUSY;
goto __error; goto __error;
} }
@ -1242,14 +1238,14 @@ int snd_pmac_new(struct snd_card *card, struct snd_pmac **chip_return)
} }
irq = irq_of_parse_and_map(np, 1); irq = irq_of_parse_and_map(np, 1);
if (request_irq(irq, snd_pmac_tx_intr, 0, "PMac Output", (void*)chip)){ if (request_irq(irq, snd_pmac_tx_intr, 0, "PMac Output", (void*)chip)){
snd_printk(KERN_ERR "pmac: unable to grab IRQ %d\n", irq); dev_err(chip->card->dev, "pmac: unable to grab IRQ %d\n", irq);
err = -EBUSY; err = -EBUSY;
goto __error; goto __error;
} }
chip->tx_irq = irq; chip->tx_irq = irq;
irq = irq_of_parse_and_map(np, 2); irq = irq_of_parse_and_map(np, 2);
if (request_irq(irq, snd_pmac_rx_intr, 0, "PMac Input", (void*)chip)) { if (request_irq(irq, snd_pmac_rx_intr, 0, "PMac Input", (void*)chip)) {
snd_printk(KERN_ERR "pmac: unable to grab IRQ %d\n", irq); dev_err(chip->card->dev, "pmac: unable to grab IRQ %d\n", irq);
err = -EBUSY; err = -EBUSY;
goto __error; goto __error;
} }

View File

@ -104,7 +104,7 @@ static int snd_pmac_probe(struct platform_device *devptr)
goto __error; goto __error;
break; break;
default: default:
snd_printk(KERN_ERR "unsupported hardware %d\n", chip->model); dev_err(&devptr->dev, "unsupported hardware %d\n", chip->model);
err = -EINVAL; err = -EINVAL;
goto __error; goto __error;
} }

View File

@ -29,7 +29,7 @@
#undef DEBUG #undef DEBUG
#ifdef DEBUG #ifdef DEBUG
#define DBG(fmt...) printk(KERN_DEBUG fmt) #define DBG(fmt...) pr_debug(fmt)
#else #else
#define DBG(fmt...) #define DBG(fmt...)
#endif #endif
@ -230,7 +230,7 @@ static int tumbler_set_master_volume(struct pmac_tumbler *mix)
if (i2c_smbus_write_i2c_block_data(mix->i2c.client, TAS_REG_VOL, 6, if (i2c_smbus_write_i2c_block_data(mix->i2c.client, TAS_REG_VOL, 6,
block) < 0) { block) < 0) {
snd_printk(KERN_ERR "failed to set volume \n"); dev_err(&mix->i2c.client->dev, "failed to set volume\n");
return -EINVAL; return -EINVAL;
} }
DBG("(I) succeeded to set volume (%u, %u)\n", left_vol, right_vol); DBG("(I) succeeded to set volume (%u, %u)\n", left_vol, right_vol);
@ -341,7 +341,7 @@ static int tumbler_set_drc(struct pmac_tumbler *mix)
if (i2c_smbus_write_i2c_block_data(mix->i2c.client, TAS_REG_DRC, if (i2c_smbus_write_i2c_block_data(mix->i2c.client, TAS_REG_DRC,
2, val) < 0) { 2, val) < 0) {
snd_printk(KERN_ERR "failed to set DRC\n"); dev_err(&mix->i2c.client->dev, "failed to set DRC\n");
return -EINVAL; return -EINVAL;
} }
DBG("(I) succeeded to set DRC (%u, %u)\n", val[0], val[1]); DBG("(I) succeeded to set DRC (%u, %u)\n", val[0], val[1]);
@ -378,7 +378,7 @@ static int snapper_set_drc(struct pmac_tumbler *mix)
if (i2c_smbus_write_i2c_block_data(mix->i2c.client, TAS_REG_DRC, if (i2c_smbus_write_i2c_block_data(mix->i2c.client, TAS_REG_DRC,
6, val) < 0) { 6, val) < 0) {
snd_printk(KERN_ERR "failed to set DRC\n"); dev_err(&mix->i2c.client->dev, "failed to set DRC\n");
return -EINVAL; return -EINVAL;
} }
DBG("(I) succeeded to set DRC (%u, %u)\n", val[0], val[1]); DBG("(I) succeeded to set DRC (%u, %u)\n", val[0], val[1]);
@ -503,8 +503,8 @@ static int tumbler_set_mono_volume(struct pmac_tumbler *mix,
block[i] = (vol >> ((info->bytes - i - 1) * 8)) & 0xff; block[i] = (vol >> ((info->bytes - i - 1) * 8)) & 0xff;
if (i2c_smbus_write_i2c_block_data(mix->i2c.client, info->reg, if (i2c_smbus_write_i2c_block_data(mix->i2c.client, info->reg,
info->bytes, block) < 0) { info->bytes, block) < 0) {
snd_printk(KERN_ERR "failed to set mono volume %d\n", dev_err(&mix->i2c.client->dev, "failed to set mono volume %d\n",
info->index); info->index);
return -EINVAL; return -EINVAL;
} }
return 0; return 0;
@ -643,7 +643,8 @@ static int snapper_set_mix_vol1(struct pmac_tumbler *mix, int idx, int ch, int r
} }
if (i2c_smbus_write_i2c_block_data(mix->i2c.client, reg, if (i2c_smbus_write_i2c_block_data(mix->i2c.client, reg,
9, block) < 0) { 9, block) < 0) {
snd_printk(KERN_ERR "failed to set mono volume %d\n", reg); dev_err(&mix->i2c.client->dev,
"failed to set mono volume %d\n", reg);
return -EINVAL; return -EINVAL;
} }
return 0; return 0;
@ -1102,7 +1103,6 @@ static long tumbler_find_device(const char *device, const char *platform,
node = find_audio_device(device); node = find_audio_device(device);
if (! node) { if (! node) {
DBG("(W) cannot find audio device %s !\n", device); DBG("(W) cannot find audio device %s !\n", device);
snd_printdd("cannot find device %s\n", device);
return -ENODEV; return -ENODEV;
} }
@ -1111,7 +1111,6 @@ static long tumbler_find_device(const char *device, const char *platform,
base = of_get_property(node, "reg", NULL); base = of_get_property(node, "reg", NULL);
if (!base) { if (!base) {
DBG("(E) cannot find address for device %s !\n", device); DBG("(E) cannot find address for device %s !\n", device);
snd_printd("cannot find address for device %s\n", device);
of_node_put(node); of_node_put(node);
return -ENODEV; return -ENODEV;
} }
@ -1232,9 +1231,9 @@ static void tumbler_resume(struct snd_pmac *chip)
tumbler_reset_audio(chip); tumbler_reset_audio(chip);
if (mix->i2c.client && mix->i2c.init_client) { if (mix->i2c.client && mix->i2c.init_client) {
if (mix->i2c.init_client(&mix->i2c) < 0) if (mix->i2c.init_client(&mix->i2c) < 0)
printk(KERN_ERR "tumbler_init_client error\n"); dev_err(chip->card->dev, "tumbler_init_client error\n");
} else } else
printk(KERN_ERR "tumbler: i2c is not initialized\n"); dev_err(chip->card->dev, "tumbler: i2c is not initialized\n");
if (chip->model == PMAC_TUMBLER) { if (chip->model == PMAC_TUMBLER) {
tumbler_set_mono_volume(mix, &tumbler_pcm_vol_info); tumbler_set_mono_volume(mix, &tumbler_pcm_vol_info);
tumbler_set_mono_volume(mix, &tumbler_bass_vol_info); tumbler_set_mono_volume(mix, &tumbler_bass_vol_info);