[alsa-devel] [PATCH v3 08/11] ASoC: fsl: make fsl_ssi driver compilable on ARM/IMX

Shawn Guo shawn.guo at linaro.org
Fri Mar 9 02:26:55 CET 2012


On Thu, Mar 08, 2012 at 02:13:04PM -0600, Timur Tabi wrote:
> Shawn Guo wrote:
> > +static DEFINE_SPINLOCK(ssi_reg_lock);
> > +static inline void write_ssi_mask(u32 __iomem *addr, u32 clear, u32 set)
> > +{
> > +	u32 val;
> > +	unsigned long flags;
> > +
> > +	spin_lock_irqsave(&ssi_reg_lock, flags);
> > +	val = readl(addr);
> > +	val = (val & ~clear) | set;
> > +	writel(val, addr);
> > +	spin_unlock_irqrestore(&ssi_reg_lock, flags);
> > +}
> > +#endif
> 
> I think this spinlock is the wrong approach.  The problem with
> read-modify-write is on the function level, not the register level.
> 
Something like this:

@@ -496,6 +494,10 @@ static int fsl_ssi_trigger(struct snd_pcm_substream *substream, int cmd,
        struct snd_soc_pcm_runtime *rtd = substream->private_data;
        struct fsl_ssi_private *ssi_private = snd_soc_dai_get_drvdata(rtd->cpu_dai);
        struct ccsr_ssi __iomem *ssi = ssi_private->ssi;
+       unsigned long flags;
+       int ret = 0;
+
+       spin_lock_irqsave(&ssi_lock, flags);

        switch (cmd) {
        case SNDRV_PCM_TRIGGER_START:
@@ -517,10 +519,12 @@ static int fsl_ssi_trigger(struct snd_pcm_substream *substream, int cmd,
                break;

        default:
-               return -EINVAL;
+               ret = -EINVAL;
        }

-       return 0;
+       spin_unlock_irqrestore(&ssi_lock, flags);
+
+       return ret;
 }

-- 
Regards,
Shawn


More information about the Alsa-devel mailing list