From patchwork Wed Aug 21 15:14:17 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabio Estevam X-Patchwork-Id: 2847826 Return-Path: X-Original-To: patchwork-linux-media@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 52A76BF546 for ; Wed, 21 Aug 2013 15:14:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9EC2520520 for ; Wed, 21 Aug 2013 15:14:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7216D20459 for ; Wed, 21 Aug 2013 15:14:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751813Ab3HUPO3 (ORCPT ); Wed, 21 Aug 2013 11:14:29 -0400 Received: from mail-yh0-f43.google.com ([209.85.213.43]:37137 "EHLO mail-yh0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751779Ab3HUPO2 (ORCPT ); Wed, 21 Aug 2013 11:14:28 -0400 Received: by mail-yh0-f43.google.com with SMTP id z20so128303yhz.16 for ; Wed, 21 Aug 2013 08:14:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ZHfZBKbTrSAu0v/L1NQ1DCTDbNKOKRkCz45FRWED/4A=; b=do3yEN5YEx1yh59PpwpsmfhpLpfpjZsZEEyan1DihZj50wKjx2MVsmJWZSnZozc2/Z 0S3fLSOoIPTFB6mU0HXRFRTdCsRIAx60QyHTTfhU5MEuWuHU8EEQ+jprrQrVWZXa2hDs hQ088//96iyVXsAYfQce5SmeToC6BcN87FrC9fOeS0IFIjNSDBDxtnPbSX12bniJzwtv MG2onLH1yZa5XR7a461DX/HILKn714vnc5FclmPmfxW+obdPFuFeJcba4RaZmVfPutWG jJevwcRk8XPfuPKytUfRqPdYkiCqoeWzifzF309587xSKJu2CCU6VrW3RpadfXto314W kcxQ== X-Received: by 10.236.172.162 with SMTP id t22mr6384870yhl.20.1377098067608; Wed, 21 Aug 2013 08:14:27 -0700 (PDT) Received: from localhost.localdomain ([177.194.45.238]) by mx.google.com with ESMTPSA id v22sm8284836yhn.12.1969.12.31.16.00.00 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 21 Aug 2013 08:14:27 -0700 (PDT) From: Fabio Estevam To: k.debski@samsung.com Cc: p.zabel@pengutronix.de, linux-media@vger.kernel.org, Fabio Estevam Subject: [PATCH v7 2/3] [media] coda: Check the return value from clk_prepare_enable() Date: Wed, 21 Aug 2013 12:14:17 -0300 Message-Id: <1377098058-12566-2-git-send-email-festevam@gmail.com> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <1377098058-12566-1-git-send-email-festevam@gmail.com> References: <1377098058-12566-1-git-send-email-festevam@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham 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 From: Fabio Estevam 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 v6: - Rebased against correct branch 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 0894d80..04ced56 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)