summaryrefslogtreecommitdiff
path: root/sound/mips/snd-n64.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/mips/snd-n64.c')
-rw-r--r--sound/mips/snd-n64.c35
1 files changed, 14 insertions, 21 deletions
diff --git a/sound/mips/snd-n64.c b/sound/mips/snd-n64.c
index 463a6fe589eb..f17e63f2ff5a 100644
--- a/sound/mips/snd-n64.c
+++ b/sound/mips/snd-n64.c
@@ -13,6 +13,7 @@
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/spinlock.h>
+#include <linux/string.h>
#include <sound/control.h>
#include <sound/core.h>
@@ -80,10 +81,9 @@ static u32 n64mi_read_reg(struct n64audio *priv, const u8 reg)
static void n64audio_push(struct n64audio *priv)
{
struct snd_pcm_runtime *runtime = priv->chan.substream->runtime;
- unsigned long flags;
u32 count;
- spin_lock_irqsave(&priv->chan.lock, flags);
+ guard(spinlock_irqsave)(&priv->chan.lock);
count = priv->chan.writesize;
@@ -103,15 +103,12 @@ static void n64audio_push(struct n64audio *priv)
priv->chan.nextpos %= priv->chan.bufsize;
runtime->delay = runtime->period_size;
-
- spin_unlock_irqrestore(&priv->chan.lock, flags);
}
static irqreturn_t n64audio_isr(int irq, void *dev_id)
{
struct n64audio *priv = dev_id;
const u32 intrs = n64mi_read_reg(priv, MI_INTR_REG);
- unsigned long flags;
// Check it's ours
if (!(intrs & MI_INTR_AI))
@@ -120,11 +117,9 @@ static irqreturn_t n64audio_isr(int irq, void *dev_id)
n64audio_write_reg(priv, AI_STATUS_REG, 1);
if (priv->chan.substream && snd_pcm_running(priv->chan.substream)) {
- spin_lock_irqsave(&priv->chan.lock, flags);
-
- priv->chan.pos = priv->chan.nextpos;
-
- spin_unlock_irqrestore(&priv->chan.lock, flags);
+ scoped_guard(spinlock_irqsave, &priv->chan.lock) {
+ priv->chan.pos = priv->chan.nextpos;
+ }
snd_pcm_period_elapsed(priv->chan.substream);
if (priv->chan.substream && snd_pcm_running(priv->chan.substream))
@@ -220,7 +215,7 @@ static int n64audio_pcm_prepare(struct snd_pcm_substream *substream)
rate = 16;
n64audio_write_reg(priv, AI_BITCLOCK_REG, rate - 1);
- spin_lock_irq(&priv->chan.lock);
+ guard(spinlock_irq)(&priv->chan.lock);
/* Setup the pseudo-dma transfer pointers. */
priv->chan.pos = 0;
@@ -229,7 +224,6 @@ static int n64audio_pcm_prepare(struct snd_pcm_substream *substream)
priv->chan.writesize = snd_pcm_lib_period_bytes(substream);
priv->chan.bufsize = snd_pcm_lib_buffer_bytes(substream);
- spin_unlock_irq(&priv->chan.lock);
return 0;
}
@@ -289,8 +283,7 @@ static int __init n64audio_probe(struct platform_device *pdev)
struct snd_card *card;
struct snd_pcm *pcm;
struct n64audio *priv;
- struct resource *res;
- int err;
+ int err, irq;
err = snd_card_new(&pdev->dev, SNDRV_DEFAULT_IDX1,
SNDRV_DEFAULT_STR1,
@@ -328,21 +321,21 @@ static int __init n64audio_probe(struct platform_device *pdev)
goto fail_dma_alloc;
pcm->private_data = priv;
- strcpy(pcm->name, "N64 Audio");
+ strscpy(pcm->name, "N64 Audio");
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &n64audio_pcm_ops);
snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_VMALLOC, card->dev, 0, 0);
- strcpy(card->driver, "N64 Audio");
- strcpy(card->shortname, "N64 Audio");
- strcpy(card->longname, "N64 Audio");
+ strscpy(card->driver, "N64 Audio");
+ strscpy(card->shortname, "N64 Audio");
+ strscpy(card->longname, "N64 Audio");
- res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
- if (!res) {
+ irq = platform_get_irq(pdev, 0);
+ if (irq < 0) {
err = -EINVAL;
goto fail_dma_alloc;
}
- if (devm_request_irq(&pdev->dev, res->start, n64audio_isr,
+ if (devm_request_irq(&pdev->dev, irq, n64audio_isr,
IRQF_SHARED, "N64 Audio", priv)) {
err = -EBUSY;
goto fail_dma_alloc;