From patchwork Thu Feb 12 11:39:28 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Tereshonkov X-Patchwork-Id: 6808 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n1CBeaEB022071 for ; Thu, 12 Feb 2009 11:40:36 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751681AbZBLLke (ORCPT ); Thu, 12 Feb 2009 06:40:34 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1755754AbZBLLke (ORCPT ); Thu, 12 Feb 2009 06:40:34 -0500 Received: from smtp.nokia.com ([192.100.122.230]:27154 "EHLO mgw-mx03.nokia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751681AbZBLLke (ORCPT ); Thu, 12 Feb 2009 06:40:34 -0500 Received: from esebh106.NOE.Nokia.com (esebh106.ntc.nokia.com [172.21.138.213]) by mgw-mx03.nokia.com (Switch-3.2.6/Switch-3.2.6) with ESMTP id n1CBeE4c005173 for ; Thu, 12 Feb 2009 13:40:31 +0200 Received: from vaebh104.NOE.Nokia.com ([10.160.244.30]) by esebh106.NOE.Nokia.com with Microsoft SMTPSVC(6.0.3790.3959); Thu, 12 Feb 2009 13:39:32 +0200 Received: from mgw-int01.ntc.nokia.com ([172.21.143.96]) by vaebh104.NOE.Nokia.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.3959); Thu, 12 Feb 2009 13:39:30 +0200 Received: from localhost.localdomain (ramses.research.nokia.com [172.21.51.130]) by mgw-int01.ntc.nokia.com (Switch-3.2.5/Switch-3.2.5) with ESMTP id n1CBdSnU000329; Thu, 12 Feb 2009 13:39:29 +0200 From: Roman Tereshonkov To: linux-omap@vger.kernel.org Cc: Roman Tereshonkov Subject: [PATCH] OMAP3: SDTI: Prevent access to sdti writing if module is not initialized. Date: Thu, 12 Feb 2009 13:39:28 +0200 Message-Id: <1234438768-20697-1-git-send-email-roman.tereshonkov@nokia.com> X-Mailer: git-send-email 1.5.5.1 X-OriginalArrivalTime: 12 Feb 2009 11:39:31.0037 (UTC) FILETIME=[91B0C0D0:01C98D06] X-Nokia-AV: Clean Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org 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 Acked-by: Felipe Balbi --- drivers/misc/sti/sdti.c | 15 ++++++++++++--- 1 files changed, 12 insertions(+), 3 deletions(-) diff --git a/drivers/misc/sti/sdti.c b/drivers/misc/sti/sdti.c index 8c27504..31780de 100644 --- a/drivers/misc/sti/sdti.c +++ b/drivers/misc/sti/sdti.c @@ -37,20 +37,25 @@ 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);