From patchwork Fri Jul 15 12:04:58 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tarun Kanti DebBarma X-Patchwork-Id: 978692 Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p6FH9xlR010484 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Fri, 15 Jul 2011 17:10:20 GMT Received: from canuck.infradead.org ([2001:4978:20e::1]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1Qhlte-0002VL-80; Fri, 15 Jul 2011 17:09:50 +0000 Received: from localhost ([127.0.0.1] helo=canuck.infradead.org) by canuck.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1QhhC8-0007mE-MS; Fri, 15 Jul 2011 12:08:36 +0000 Received: from bear.ext.ti.com ([192.94.94.41]) by canuck.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1Qhh9e-0007O4-WC for linux-arm-kernel@lists.infradead.org; Fri, 15 Jul 2011 12:06:07 +0000 Received: from dlep33.itg.ti.com ([157.170.170.112]) by bear.ext.ti.com (8.13.7/8.13.7) with ESMTP id p6FC61Ti018162 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 15 Jul 2011 07:06:01 -0500 Received: from dlep26.itg.ti.com (smtp-le.itg.ti.com [157.170.170.27]) by dlep33.itg.ti.com (8.13.7/8.13.8) with ESMTP id p6FC61Vq003802; Fri, 15 Jul 2011 07:06:01 -0500 (CDT) Received: from dbde70.ent.ti.com (localhost [127.0.0.1]) by dlep26.itg.ti.com (8.13.8/8.13.8) with ESMTP id p6FC5ndt001641; Fri, 15 Jul 2011 07:06:00 -0500 (CDT) Received: from dbdp31.itg.ti.com (172.24.170.98) by DBDE70.ent.ti.com (172.24.170.148) with Microsoft SMTP Server id 8.3.106.1; Fri, 15 Jul 2011 17:35:25 +0530 Received: from localhost.localdomain ([172.24.190.145]) by dbdp31.itg.ti.com (8.13.8/8.13.8) with ESMTP id p6FC51Zg017050; Fri, 15 Jul 2011 17:35:22 +0530 (IST) From: Tarun Kanti DebBarma To: Subject: [PATCH v14 REPOST 09/12] OMAP: dmtimer: use mutex instead of spinlock Date: Fri, 15 Jul 2011 17:34:58 +0530 Message-ID: <1310731501-13078-10-git-send-email-tarun.kanti@ti.com> X-Mailer: git-send-email 1.6.0.4 In-Reply-To: <1310731501-13078-1-git-send-email-tarun.kanti@ti.com> References: <1310731501-13078-1-git-send-email-tarun.kanti@ti.com> MIME-Version: 1.0 X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20110715_080603_300563_88551CA5 X-CRM114-Status: GOOD ( 14.59 ) X-Spam-Score: -2.3 (--) X-Spam-Report: SpamAssassin version 3.3.1 on canuck.infradead.org summary: Content analysis details: (-2.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, medium trust [192.94.94.41 listed in list.dnswl.org] 0.0 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain Cc: khilman@ti.com, tony@atomide.com, santosh.shilimkar@ti.com, Tarun Kanti DebBarma , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Fri, 15 Jul 2011 17:10:24 +0000 (UTC) Since the spinlock is not used in any interrupt context we can replace it with mutex instead. Signed-off-by: Tarun Kanti DebBarma Reviewed-by: Santosh Shilimkar --- arch/arm/plat-omap/dmtimer.c | 27 +++++++++++---------------- 1 files changed, 11 insertions(+), 16 deletions(-) diff --git a/arch/arm/plat-omap/dmtimer.c b/arch/arm/plat-omap/dmtimer.c index 0560248..be55e42 100644 --- a/arch/arm/plat-omap/dmtimer.c +++ b/arch/arm/plat-omap/dmtimer.c @@ -43,7 +43,7 @@ #include static LIST_HEAD(omap_timer_list); -static DEFINE_SPINLOCK(dm_timer_lock); +static DEFINE_MUTEX(dm_timer_mutex); /** * omap_dm_timer_read_reg - read timer registers in posted and non-posted mode @@ -136,9 +136,8 @@ void omap_dm_timer_prepare(struct omap_dm_timer *timer) struct omap_dm_timer *omap_dm_timer_request(void) { struct omap_dm_timer *timer = NULL, *t; - unsigned long flags; - spin_lock_irqsave(&dm_timer_lock, flags); + mutex_lock(&dm_timer_mutex); list_for_each_entry(t, &omap_timer_list, node) { if (t->reserved) continue; @@ -147,7 +146,7 @@ struct omap_dm_timer *omap_dm_timer_request(void) timer->reserved = 1; break; } - spin_unlock_irqrestore(&dm_timer_lock, flags); + mutex_unlock(&dm_timer_mutex); if (timer) omap_dm_timer_prepare(timer); @@ -161,9 +160,8 @@ EXPORT_SYMBOL_GPL(omap_dm_timer_request); struct omap_dm_timer *omap_dm_timer_request_specific(int id) { struct omap_dm_timer *timer = NULL, *t; - unsigned long flags; - spin_lock_irqsave(&dm_timer_lock, flags); + mutex_lock(&dm_timer_mutex); list_for_each_entry(t, &omap_timer_list, node) { if (t->pdev->id == id && !t->reserved) { timer = t; @@ -171,7 +169,7 @@ struct omap_dm_timer *omap_dm_timer_request_specific(int id) break; } } - spin_unlock_irqrestore(&dm_timer_lock, flags); + mutex_unlock(&dm_timer_mutex); if (timer) omap_dm_timer_prepare(timer); @@ -220,14 +218,13 @@ __u32 omap_dm_timer_modify_idlect_mask(__u32 inputmask) { int i = 0; struct omap_dm_timer *timer = NULL; - unsigned long flags; /* If ARMXOR cannot be idled this function call is unnecessary */ if (!(inputmask & (1 << 1))) return inputmask; /* If any active timer is using ARMXOR return modified mask */ - spin_lock_irqsave(&dm_timer_lock, flags); + mutex_lock(&dm_timer_mutex); list_for_each_entry(timer, &omap_timer_list, node) { u32 l; @@ -240,7 +237,7 @@ __u32 omap_dm_timer_modify_idlect_mask(__u32 inputmask) } i++; } - spin_unlock_irqrestore(&dm_timer_lock, flags); + mutex_unlock(&dm_timer_mutex); return inputmask; } @@ -464,7 +461,6 @@ EXPORT_SYMBOL_GPL(omap_dm_timers_active); static int __devinit omap_dm_timer_probe(struct platform_device *pdev) { int ret; - unsigned long flags; struct omap_dm_timer *timer; struct resource *mem, *irq, *ioarea; struct dmtimer_platform_data *pdata = pdev->dev.platform_data; @@ -522,9 +518,9 @@ static int __devinit omap_dm_timer_probe(struct platform_device *pdev) pm_runtime_enable(&pdev->dev); /* add the timer element to the list */ - spin_lock_irqsave(&dm_timer_lock, flags); + mutex_lock(&dm_timer_mutex); list_add_tail(&timer->node, &omap_timer_list); - spin_unlock_irqrestore(&dm_timer_lock, flags); + mutex_unlock(&dm_timer_mutex); dev_dbg(&pdev->dev, "Device Probed.\n"); @@ -550,10 +546,9 @@ err_free_ioregion: static int __devexit omap_dm_timer_remove(struct platform_device *pdev) { struct omap_dm_timer *timer; - unsigned long flags; int ret = -EINVAL; - spin_lock_irqsave(&dm_timer_lock, flags); + mutex_lock(&dm_timer_mutex); list_for_each_entry(timer, &omap_timer_list, node) if (timer->pdev->id == pdev->id) { list_del(&timer->node); @@ -561,7 +556,7 @@ static int __devexit omap_dm_timer_remove(struct platform_device *pdev) ret = 0; break; } - spin_unlock_irqrestore(&dm_timer_lock, flags); + mutex_unlock(&dm_timer_mutex); return ret; }