diff options
Diffstat (limited to 'sound/ppc/pmac.c')
| -rw-r--r-- | sound/ppc/pmac.c | 142 |
1 files changed, 68 insertions, 74 deletions
diff --git a/sound/ppc/pmac.c b/sound/ppc/pmac.c index 84058bbf9d12..6d7dab26ddf2 100644 --- a/sound/ppc/pmac.c +++ b/sound/ppc/pmac.c @@ -206,32 +206,32 @@ static int snd_pmac_pcm_prepare(struct snd_pmac *chip, struct pmac_stream *rec, * common to many PowerBook G3 systems and random noise otherwise * captured on iBook2's about every third time. -ReneR */ - spin_lock_irq(&chip->reg_lock); - snd_pmac_dma_stop(rec); - chip->extra_dma.cmds->command = cpu_to_le16(DBDMA_STOP); - snd_pmac_dma_set_command(rec, &chip->extra_dma); - snd_pmac_dma_run(rec, RUN); - spin_unlock_irq(&chip->reg_lock); - mdelay(5); - spin_lock_irq(&chip->reg_lock); - /* continuous DMA memory type doesn't provide the physical address, - * so we need to resolve the address here... - */ - offset = runtime->dma_addr; - for (i = 0, cp = rec->cmd.cmds; i < rec->nperiods; i++, cp++) { - cp->phy_addr = cpu_to_le32(offset); - cp->req_count = cpu_to_le16(rec->period_size); - /*cp->res_count = cpu_to_le16(0);*/ - cp->xfer_status = cpu_to_le16(0); - offset += rec->period_size; + scoped_guard(spinlock_irq, &chip->reg_lock) { + snd_pmac_dma_stop(rec); + chip->extra_dma.cmds->command = cpu_to_le16(DBDMA_STOP); + snd_pmac_dma_set_command(rec, &chip->extra_dma); + snd_pmac_dma_run(rec, RUN); } - /* make loop */ - cp->command = cpu_to_le16(DBDMA_NOP | BR_ALWAYS); - cp->cmd_dep = cpu_to_le32(rec->cmd.addr); + mdelay(5); + scoped_guard(spinlock_irq, &chip->reg_lock) { + /* continuous DMA memory type doesn't provide the physical address, + * so we need to resolve the address here... + */ + offset = runtime->dma_addr; + for (i = 0, cp = rec->cmd.cmds; i < rec->nperiods; i++, cp++) { + cp->phy_addr = cpu_to_le32(offset); + cp->req_count = cpu_to_le16(rec->period_size); + /*cp->res_count = cpu_to_le16(0);*/ + cp->xfer_status = cpu_to_le16(0); + offset += rec->period_size; + } + /* make loop */ + cp->command = cpu_to_le16(DBDMA_NOP | BR_ALWAYS); + cp->cmd_dep = cpu_to_le32(rec->cmd.addr); - snd_pmac_dma_stop(rec); - snd_pmac_dma_set_command(rec, &rec->cmd); - spin_unlock_irq(&chip->reg_lock); + snd_pmac_dma_stop(rec); + snd_pmac_dma_set_command(rec, &rec->cmd); + } return 0; } @@ -253,27 +253,26 @@ static int snd_pmac_pcm_trigger(struct snd_pmac *chip, struct pmac_stream *rec, return -EBUSY; command = (subs->stream == SNDRV_PCM_STREAM_PLAYBACK ? OUTPUT_MORE : INPUT_MORE) + INTR_ALWAYS; - spin_lock(&chip->reg_lock); - snd_pmac_beep_stop(chip); - snd_pmac_pcm_set_format(chip); - for (i = 0, cp = rec->cmd.cmds; i < rec->nperiods; i++, cp++) - out_le16(&cp->command, command); - snd_pmac_dma_set_command(rec, &rec->cmd); - (void)in_le32(&rec->dma->status); - snd_pmac_dma_run(rec, RUN|WAKE); - rec->running = 1; - spin_unlock(&chip->reg_lock); + scoped_guard(spinlock, &chip->reg_lock) { + snd_pmac_beep_stop(chip); + snd_pmac_pcm_set_format(chip); + for (i = 0, cp = rec->cmd.cmds; i < rec->nperiods; i++, cp++) + out_le16(&cp->command, command); + snd_pmac_dma_set_command(rec, &rec->cmd); + (void)in_le32(&rec->dma->status); + snd_pmac_dma_run(rec, RUN|WAKE); + rec->running = 1; + } break; case SNDRV_PCM_TRIGGER_STOP: case SNDRV_PCM_TRIGGER_SUSPEND: - spin_lock(&chip->reg_lock); - rec->running = 0; - /*printk(KERN_DEBUG "stopped!!\n");*/ - snd_pmac_dma_stop(rec); - for (i = 0, cp = rec->cmd.cmds; i < rec->nperiods; i++, cp++) - out_le16(&cp->command, DBDMA_STOP); - spin_unlock(&chip->reg_lock); + scoped_guard(spinlock, &chip->reg_lock) { + rec->running = 0; + snd_pmac_dma_stop(rec); + for (i = 0, cp = rec->cmd.cmds; i < rec->nperiods; i++, cp++) + out_le16(&cp->command, DBDMA_STOP); + } break; default: @@ -304,7 +303,6 @@ static snd_pcm_uframes_t snd_pmac_pcm_pointer(struct snd_pmac *chip, } #endif count += rec->cur_period * rec->period_size; - /*printk(KERN_DEBUG "pointer=%d\n", 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 int phy ; - /* printk(KERN_WARNING "snd-powermac: DMA died - patching it up!\n"); */ - /* to clear DEAD status we must first clear RUN set it to quiescent to be on the safe side */ (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)) break; - /*printk(KERN_DEBUG "update frag %d\n", rec->cur_period);*/ cp->xfer_status = cpu_to_le16(0); cp->req_count = cpu_to_le16(rec->period_size); /*cp->res_count = cpu_to_le16(0);*/ @@ -684,7 +679,7 @@ int snd_pmac_pcm_new(struct snd_pmac *chip) pcm->private_data = chip; pcm->info_flags = SNDRV_PCM_INFO_JOINT_DUPLEX; - strcpy(pcm->name, chip->card->shortname); + strscpy(pcm->name, chip->card->shortname); chip->pcm = pcm; chip->formats_ok = SNDRV_PCM_FMTBIT_S16_BE; @@ -770,7 +765,6 @@ snd_pmac_ctrl_intr(int irq, void *devid) struct snd_pmac *chip = devid; int ctrl = in_le32(&chip->awacs->control); - /*printk(KERN_DEBUG "pmac: control interrupt.. 0x%x\n", ctrl);*/ if (ctrl & MASK_PORTCHG) { /* do something when headphone is plugged/unplugged? */ if (chip->update_automute) @@ -779,7 +773,7 @@ snd_pmac_ctrl_intr(int irq, void *devid) if (ctrl & MASK_CNTLERR) { int err = (in_le32(&chip->awacs->codec_stat) & MASK_ERRCODE) >> 16; 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... */ out_le32(&chip->awacs->control, ctrl); @@ -964,9 +958,8 @@ static int snd_pmac_detect(struct snd_pmac *chip) if (prop) { /* partly deprecate snd-powermac, for those machines * that have a layout-id property for now */ - printk(KERN_INFO "snd-powermac no longer handles any " - "machines with a layout-id property " - "in the device-tree, use snd-aoa.\n"); + dev_info(chip->card->dev, + "snd-powermac no longer handles any machines with a layout-id property in the device-tree, use snd-aoa.\n"); of_node_put(sound); of_node_put(chip->node); chip->node = NULL; @@ -1021,7 +1014,7 @@ static int snd_pmac_detect(struct snd_pmac *chip) */ macio = macio_find(chip->node, macio_unknown); 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 { struct pci_dev *pdev = NULL; @@ -1034,8 +1027,8 @@ static int snd_pmac_detect(struct snd_pmac *chip) } } if (chip->pdev == NULL) - printk(KERN_WARNING "snd-powermac: can't locate macio PCI" - " device !\n"); + dev_warn(chip->card->dev, + "snd-powermac: can't locate macio PCI device !\n"); detect_byte_swap(chip); @@ -1125,7 +1118,8 @@ int snd_pmac_add_automute(struct snd_pmac *chip) chip->auto_mute = 1; err = snd_ctl_add(chip->card, snd_ctl_new1(&auto_mute_controls[0], chip)); 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; } 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 ++) { if (of_address_to_resource(np->parent, i, &chip->rsrc[i])) { - printk(KERN_ERR "snd: can't translate rsrc " - " %d (%s)\n", i, rnames[i]); + dev_err(chip->card->dev, + "snd: can't translate rsrc %d (%s)\n", + i, rnames[i]); err = -ENODEV; goto __error; } if (request_mem_region(chip->rsrc[i].start, resource_size(&chip->rsrc[i]), rnames[i]) == NULL) { - printk(KERN_ERR "snd: can't request rsrc " - " %d (%s: %pR)\n", - i, rnames[i], &chip->rsrc[i]); + dev_err(chip->card->dev, + "snd: can't request rsrc %d (%s: %pR)\n", + i, rnames[i], &chip->rsrc[i]); err = -ENODEV; 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 ++) { if (of_address_to_resource(np, i, &chip->rsrc[i])) { - printk(KERN_ERR "snd: can't translate rsrc " - " %d (%s)\n", i, rnames[i]); + dev_err(chip->card->dev, + "snd: can't translate rsrc %d (%s)\n", + i, rnames[i]); err = -ENODEV; goto __error; } if (request_mem_region(chip->rsrc[i].start, resource_size(&chip->rsrc[i]), rnames[i]) == NULL) { - printk(KERN_ERR "snd: can't request rsrc " - " %d (%s: %pR)\n", - i, rnames[i], &chip->rsrc[i]); + dev_err(chip->card->dev, + "snd: can't request rsrc %d (%s: %pR)\n", + i, rnames[i], &chip->rsrc[i]); err = -ENODEV; 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); if (request_irq(irq, snd_pmac_ctrl_intr, 0, "PMac", (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; 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); 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; goto __error; } chip->tx_irq = irq; irq = irq_of_parse_and_map(np, 2); 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; goto __error; } @@ -1325,14 +1321,12 @@ int snd_pmac_new(struct snd_card *card, struct snd_pmac **chip_return) void snd_pmac_suspend(struct snd_pmac *chip) { - unsigned long flags; - snd_power_change_state(chip->card, SNDRV_CTL_POWER_D3hot); if (chip->suspend) chip->suspend(chip); - spin_lock_irqsave(&chip->reg_lock, flags); - snd_pmac_beep_stop(chip); - spin_unlock_irqrestore(&chip->reg_lock, flags); + scoped_guard(spinlock_irqsave, &chip->reg_lock) { + snd_pmac_beep_stop(chip); + } if (chip->irq >= 0) disable_irq(chip->irq); if (chip->tx_irq >= 0) |
