From patchwork Tue Aug 20 19:29:37 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabio Estevam X-Patchwork-Id: 19821 X-Patchwork-Delegate: kamil@wypas.org Received: from mail.tu-berlin.de ([130.149.7.33]) by www.linuxtv.org with esmtp (Exim 4.72) (envelope-from ) id 1VBrfw-0004fH-Cz; Tue, 20 Aug 2013 21:33:08 +0200 X-tubIT-Incoming-IP: 209.132.180.67 Received: from vger.kernel.org ([209.132.180.67]) by mail.tu-berlin.de (exim-4.72/mailfrontend-6) with esmtp id 1VBrfu-00075s-3U; Tue, 20 Aug 2013 21:33:08 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751773Ab3HTTdD (ORCPT + 1 other); Tue, 20 Aug 2013 15:33:03 -0400 Received: from [207.46.163.27] ([207.46.163.27]:41129 "EHLO co9outboundpool.messaging.microsoft.com" rhost-flags-FAIL-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1751753Ab3HTTdB (ORCPT ); Tue, 20 Aug 2013 15:33:01 -0400 Received: from mail122-co9-R.bigfish.com (10.236.132.252) by CO9EHSOBE034.bigfish.com (10.236.130.97) with Microsoft SMTP Server id 14.1.225.22; Tue, 20 Aug 2013 19:31:50 +0000 Received: from mail122-co9 (localhost [127.0.0.1]) by mail122-co9-R.bigfish.com (Postfix) with ESMTP id C06A4680090; Tue, 20 Aug 2013 19:31:50 +0000 (UTC) X-Forefront-Antispam-Report: CIP:70.37.183.190; KIP:(null); UIP:(null); IPV:NLI; H:mail.freescale.net; RD:none; EFVD:NLI X-SpamScore: 0 X-BigFish: VS0(zzzz1f42h208ch1ee6h1de0h1fdah2073h1202h1e76h1d1ah1d2ah1fc6hzz1de098h8275bh1de097hz2dh2a8h839hd24he5bhf0ah1288h12a5h12a9h12bdh12e5h137ah139eh13b6h1441h1504h1537h162dh1631h1758h1898h18e1h1946h19b5h1ad9h1b0ah1b2fh1fb3h1d0ch1d2eh1d3fh1dfeh1dffh1e23h1fe8h1ff5h1155h) Received: from mail122-co9 (localhost.localdomain [127.0.0.1]) by mail122-co9 (MessageSwitch) id 1377027109228975_27765; Tue, 20 Aug 2013 19:31:49 +0000 (UTC) Received: from CO9EHSMHS018.bigfish.com (unknown [10.236.132.239]) by mail122-co9.bigfish.com (Postfix) with ESMTP id 338AF8C0048; Tue, 20 Aug 2013 19:31:49 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by CO9EHSMHS018.bigfish.com (10.236.130.28) with Microsoft SMTP Server (TLS) id 14.16.227.3; Tue, 20 Aug 2013 19:31:47 +0000 Received: from tx30smr01.am.freescale.net (10.81.153.31) by 039-SN1MMR1-004.039d.mgd.msft.net (10.84.1.14) with Microsoft SMTP Server (TLS) id 14.3.146.2; Tue, 20 Aug 2013 19:31:46 +0000 Received: from fabio-OptiPlex-7010.am.freescale.net ([10.29.244.68]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id r7KJVg0F006884; Tue, 20 Aug 2013 12:31:45 -0700 From: Fabio Estevam To: CC: , , Fabio Estevam Subject: [PATCH v6 2/3] [media] coda: Check the return value from clk_prepare_enable() Date: Tue, 20 Aug 2013 16:29:37 -0300 Message-ID: <1377026978-23322-2-git-send-email-fabio.estevam@freescale.com> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <1377026978-23322-1-git-send-email-fabio.estevam@freescale.com> References: <1377026978-23322-1-git-send-email-fabio.estevam@freescale.com> MIME-Version: 1.0 X-OriginatorOrg: freescale.com X-FOPE-CONNECTOR: Id%0$Dn%*$RO%0$TLS%0$FQDN%$TlsDn% Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-PMX-Version: 6.0.0.2142326, Antispam-Engine: 2.7.2.2107409, Antispam-Data: 2013.8.20.192128 X-PMX-Spam: Gauge=IIIIIIIII, Probability=9%, Report=' MULTIPLE_RCPTS 0.1, HTML_00_01 0.05, HTML_00_10 0.05, MSGID_ADDED_BY_MTA 0.05, BODYTEXTP_SIZE_3000_LESS 0, BODY_SIZE_2000_2999 0, BODY_SIZE_5000_LESS 0, BODY_SIZE_7000_LESS 0, URI_ENDS_IN_HTML 0, __ANY_URI 0, __CP_URI_IN_BODY 0, __CT 0, __CT_TEXT_PLAIN 0, __HAS_FROM 0, __HAS_MSGID 0, __HAS_X_MAILER 0, __HAS_X_MAILING_LIST 0, __IN_REP_TO 0, __MIME_TEXT_ONLY 0, __MIME_VERSION 0, __MULTIPLE_RCPTS_CC_X2 0, __SANE_MSGID 0, __TO_MALFORMED_2 0, __TO_NO_NAME 0, __URI_NO_WWW 0, __URI_NS ' clk_prepare_enable() may fail, so let's check its return value and propagate it in the case of error. Signed-off-by: Fabio Estevam --- Changes since v5: - Rebased against latest Kamil's tree drivers/media/platform/coda.c | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/drivers/media/platform/coda.c b/drivers/media/platform/coda.c index b5d48b7..a68379c 100644 --- a/drivers/media/platform/coda.c +++ b/drivers/media/platform/coda.c @@ -2406,8 +2406,14 @@ static int coda_open(struct file *file) ctx->reg_idx = idx; } - clk_prepare_enable(dev->clk_per); - clk_prepare_enable(dev->clk_ahb); + ret = clk_prepare_enable(dev->clk_per); + if (ret) + goto err_clk_per; + + ret = clk_prepare_enable(dev->clk_ahb); + if (ret) + goto err_clk_ahb; + set_default_params(ctx); ctx->m2m_ctx = v4l2_m2m_ctx_init(dev->m2m_dev, ctx, &coda_queue_init); @@ -2465,7 +2471,9 @@ err_ctrls_setup: v4l2_m2m_ctx_release(ctx->m2m_ctx); err_ctx_init: clk_disable_unprepare(dev->clk_ahb); +err_clk_ahb: clk_disable_unprepare(dev->clk_per); +err_clk_per: v4l2_fh_del(&ctx->fh); v4l2_fh_exit(&ctx->fh); clear_bit(ctx->idx, &dev->instance_mask); @@ -2873,10 +2881,15 @@ static int coda_hw_init(struct coda_dev *dev) u16 product, major, minor, release; u32 data; u16 *p; - int i; + int i, ret; + + ret = clk_prepare_enable(dev->clk_per); + if (ret) + return ret; - clk_prepare_enable(dev->clk_per); - clk_prepare_enable(dev->clk_ahb); + ret = clk_prepare_enable(dev->clk_ahb); + if (ret) + goto err_clk_ahb; /* * Copy the first CODA_ISRAM_SIZE in the internal SRAM. @@ -2985,6 +2998,10 @@ static int coda_hw_init(struct coda_dev *dev) } return 0; + +err_clk_ahb: + clk_disable_unprepare(dev->clk_per); + return ret; } static void coda_fw_callback(const struct firmware *fw, void *context)