]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
OMAP3: SDTI: Prevent access to sdti writing if module is not initialized.
authorRoman Tereshonkov <roman.tereshonkov@nokia.com>
Thu, 12 Feb 2009 11:39:28 +0000 (11:39 +0000)
committerTony Lindgren <tony@atomide.com>
Tue, 24 Feb 2009 22:11:13 +0000 (14:11 -0800)
The function sti_channel_write_trace can be run from process and interrupt
context. It has to be completed before other sti_channel_write_trace calls.

Prevent sdti writing when SDTI module is not initialized.

Signed-off-by: Roman Tereshonkov <roman.tereshonkov@nokia.com>
Acked-by: Felipe Balbi <felipe.balbi@nokia.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
drivers/misc/sti/sdti.c

index 8c275049ad7d130570c6955b65640a8609d4110d..31780de3e7f47009e9f6773cb2c7f6c333b27c45 100644 (file)
 static struct clk *sdti_fck, *sdti_ick;
 void __iomem *sti_base, *sti_channel_base;
 static DEFINE_SPINLOCK(sdti_lock);
+static int sdti_initialized;
 
 void sti_channel_write_trace(int len, int id, void *data,
                                unsigned int channel)
 {
        const u8 *tpntr = data;
+       unsigned long flags;
 
-       spin_lock_irq(&sdti_lock);
+       spin_lock_irqsave(&sdti_lock, flags);
+
+       if (unlikely(!sdti_initialized))
+               goto skip;
 
        sti_channel_writeb(id, channel);
        while (len--)
                sti_channel_writeb(*tpntr++, channel);
        sti_channel_flush(channel);
-
-       spin_unlock_irq(&sdti_lock);
+ skip:
+       spin_unlock_irqrestore(&sdti_lock, flags);
 }
 EXPORT_SYMBOL(sti_channel_write_trace);
 
@@ -117,6 +122,10 @@ static int __init omap_sdti_init(void)
        /* Enable SDTI */
        sti_writel((1 << 31) | (i & 0x3FFFFFFF), SDTI_WINCTRL);
 
+       spin_lock_irq(&sdti_lock);
+       sdti_initialized = 1;
+       spin_unlock_irq(&sdti_lock);
+
        i = sti_readl(SDTI_REVISION);
        snprintf(buf, sizeof(buf), "OMAP SDTI support loaded (HW v%u.%u)\n",
                (i >> 4) & 0x0f, i & 0x0f);