From patchwork Thu Apr 24 21:43:53 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Fernandes X-Patchwork-Id: 4054311 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id B95DDBFF02 for ; Thu, 24 Apr 2014 21:48:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C73F220374 for ; Thu, 24 Apr 2014 21:48:51 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7B21520379 for ; Thu, 24 Apr 2014 21:48:50 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WdRTh-0004St-TW; Thu, 24 Apr 2014 21:46:45 +0000 Received: from devils.ext.ti.com ([198.47.26.153]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WdRRo-0001qX-6f for linux-arm-kernel@lists.infradead.org; Thu, 24 Apr 2014 21:44:50 +0000 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by devils.ext.ti.com (8.13.7/8.13.7) with ESMTP id s3OLiQhe025609; Thu, 24 Apr 2014 16:44:26 -0500 Received: from DLEE70.ent.ti.com (dlee70.ent.ti.com [157.170.170.113]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id s3OLiQ6F009665; Thu, 24 Apr 2014 16:44:26 -0500 Received: from dflp33.itg.ti.com (10.64.6.16) by DLEE70.ent.ti.com (157.170.170.113) with Microsoft SMTP Server id 14.3.174.1; Thu, 24 Apr 2014 16:44:26 -0500 Received: from legion.dal.design.ti.com (legion.dal.design.ti.com [128.247.22.53]) by dflp33.itg.ti.com (8.14.3/8.13.8) with ESMTP id s3OLiPYa012879; Thu, 24 Apr 2014 16:44:26 -0500 Received: from joel-laptop.am.dhcp.ti.com (joel-laptop.am.dhcp.ti.com [10.247.29.57]) by legion.dal.design.ti.com (8.11.7p1+Sun/8.11.7) with ESMTP id s3OLiPt29785; Thu, 24 Apr 2014 16:44:25 -0500 (CDT) From: Joel Fernandes To: Linux OMAP List , Linux ARM Kernel List , Linux Kernel Mailing List Subject: [PATCH 10/26] ARM: OMAP: dmtimer: Check return of pm_runtime_get_sync Date: Thu, 24 Apr 2014 16:43:53 -0500 Message-ID: <1398375849-6017-11-git-send-email-joelf@ti.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1398375849-6017-1-git-send-email-joelf@ti.com> References: <1398375849-6017-1-git-send-email-joelf@ti.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140424_144448_352513_2E0DD73E X-CRM114-Status: GOOD ( 14.01 ) X-Spam-Score: -5.7 (-----) Cc: Tony Lindgren , Joel Fernandes X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP omap_timer_enable doesn't check return value, this can lead to nasty bus errors. Add a check and report issues. Tested-by: Joachim Eastwood Signed-off-by: Joel Fernandes --- arch/arm/plat-omap/dmtimer.c | 62 +++++++++++++++++++++++------ arch/arm/plat-omap/include/plat/dmtimer.h | 2 +- 2 files changed, 51 insertions(+), 13 deletions(-) diff --git a/arch/arm/plat-omap/dmtimer.c b/arch/arm/plat-omap/dmtimer.c index 1fd30fa..b52d34d 100644 --- a/arch/arm/plat-omap/dmtimer.c +++ b/arch/arm/plat-omap/dmtimer.c @@ -164,7 +164,9 @@ static int omap_dm_timer_prepare(struct omap_dm_timer *timer) } } - omap_dm_timer_enable(timer); + rc = omap_dm_timer_enable(timer); + if (rc) + return rc; if (timer->capability & OMAP_TIMER_NEEDS_RESET) { rc = omap_dm_timer_reset(timer); @@ -375,11 +377,16 @@ int omap_dm_timer_free(struct omap_dm_timer *timer) } EXPORT_SYMBOL_GPL(omap_dm_timer_free); -void omap_dm_timer_enable(struct omap_dm_timer *timer) +int omap_dm_timer_enable(struct omap_dm_timer *timer) { - int c; + int c, err; - pm_runtime_get_sync(&timer->pdev->dev); + err = pm_runtime_get_sync(&timer->pdev->dev); + if (err < 0) { + dev_err(&timer->pdev->dev, "%s: pm_runtime_get_sync failed (err=%d).", + __func__, err); + return err; + } if (!(timer->capability & OMAP_TIMER_ALWON)) { if (timer->get_context_loss_count) { @@ -392,6 +399,7 @@ void omap_dm_timer_enable(struct omap_dm_timer *timer) omap_timer_restore_context(timer); } } + return 0; } EXPORT_SYMBOL_GPL(omap_dm_timer_enable); @@ -432,11 +440,14 @@ EXPORT_SYMBOL_GPL(omap_dm_timer_trigger); int omap_dm_timer_start(struct omap_dm_timer *timer) { u32 l; + int rc; if (unlikely(!timer)) return -EINVAL; - omap_dm_timer_enable(timer); + rc = omap_dm_timer_enable(timer); + if (rc) + return rc; l = omap_dm_timer_read_reg(timer, OMAP_TIMER_CTRL_REG); if (!(l & OMAP_TIMER_CTRL_ST)) { @@ -534,11 +545,15 @@ int omap_dm_timer_set_load(struct omap_dm_timer *timer, int autoreload, unsigned int load) { u32 mask = ~0, val = 0; + int rc; if (unlikely(!timer)) return -EINVAL; - omap_dm_timer_enable(timer); + rc = omap_dm_timer_enable(timer); + if (rc) + return rc; + if (autoreload) val |= OMAP_TIMER_CTRL_AR; else @@ -560,11 +575,14 @@ int omap_dm_timer_set_load_start(struct omap_dm_timer *timer, int autoreload, unsigned int load) { u32 l; + int rc; if (unlikely(!timer)) return -EINVAL; - omap_dm_timer_enable(timer); + rc = omap_dm_timer_enable(timer); + if (rc) + return rc; l = omap_dm_timer_read_reg(timer, OMAP_TIMER_CTRL_REG); if (autoreload) { @@ -588,11 +606,15 @@ int omap_dm_timer_set_match(struct omap_dm_timer *timer, int enable, unsigned int match) { u32 mask = ~0, val = 0; + int rc; if (unlikely(!timer)) return -EINVAL; - omap_dm_timer_enable(timer); + rc = omap_dm_timer_enable(timer); + if (rc) + return rc; + if (enable) val |= OMAP_TIMER_CTRL_CE; else @@ -613,11 +635,15 @@ int omap_dm_timer_set_pwm(struct omap_dm_timer *timer, int def_on, int toggle, int trigger) { u32 mask = ~0, val = 0; + int rc; if (unlikely(!timer)) return -EINVAL; - omap_dm_timer_enable(timer); + rc = omap_dm_timer_enable(timer); + if (rc) + return rc; + mask &= ~(OMAP_TIMER_CTRL_GPOCFG | OMAP_TIMER_CTRL_SCPWM | OMAP_TIMER_CTRL_PT | (0x03 << 10)); if (def_on) @@ -637,11 +663,15 @@ EXPORT_SYMBOL_GPL(omap_dm_timer_set_pwm); int omap_dm_timer_set_prescaler(struct omap_dm_timer *timer, int prescaler) { u32 mask = ~0, val = 0; + int rc; if (unlikely(!timer)) return -EINVAL; - omap_dm_timer_enable(timer); + rc = omap_dm_timer_enable(timer); + if (rc) + return rc; + mask &= ~(OMAP_TIMER_CTRL_PRE | (0x07 << 2)); if (prescaler >= 0x00 && prescaler <= 0x07) { val |= OMAP_TIMER_CTRL_PRE; @@ -659,10 +689,15 @@ EXPORT_SYMBOL_GPL(omap_dm_timer_set_prescaler); int omap_dm_timer_set_int_enable(struct omap_dm_timer *timer, unsigned int value) { + int rc; + if (unlikely(!timer)) return -EINVAL; - omap_dm_timer_enable(timer); + rc = omap_dm_timer_enable(timer); + if (rc) + return rc; + __omap_dm_timer_int_enable(timer, value); /* Save the context */ @@ -683,11 +718,14 @@ EXPORT_SYMBOL_GPL(omap_dm_timer_set_int_enable); int omap_dm_timer_set_int_disable(struct omap_dm_timer *timer, u32 mask) { u32 l = mask; + int rc; if (unlikely(!timer)) return -EINVAL; - omap_dm_timer_enable(timer); + rc = omap_dm_timer_enable(timer); + if (rc) + return rc; if (timer->revision == 1) l = __raw_readl(timer->irq_ena) & ~mask; diff --git a/arch/arm/plat-omap/include/plat/dmtimer.h b/arch/arm/plat-omap/include/plat/dmtimer.h index fe3780a..6b6fbd2 100644 --- a/arch/arm/plat-omap/include/plat/dmtimer.h +++ b/arch/arm/plat-omap/include/plat/dmtimer.h @@ -130,7 +130,7 @@ struct omap_dm_timer *omap_dm_timer_request_specific(int timer_id); struct omap_dm_timer *omap_dm_timer_request_by_cap(u32 cap); struct omap_dm_timer *omap_dm_timer_request_by_node(struct device_node *np); int omap_dm_timer_free(struct omap_dm_timer *timer); -void omap_dm_timer_enable(struct omap_dm_timer *timer); +int omap_dm_timer_enable(struct omap_dm_timer *timer); void omap_dm_timer_disable(struct omap_dm_timer *timer); int omap_dm_timer_get_irq(struct omap_dm_timer *timer);