From patchwork Sun Aug 21 22:32:13 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabio Estevam X-Patchwork-Id: 9292749 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 15533607FF for ; Sun, 21 Aug 2016 22:32:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0F81A288F1 for ; Sun, 21 Aug 2016 22:32:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 02BBF288F4; Sun, 21 Aug 2016 22:32:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id EBA0D288F1 for ; Sun, 21 Aug 2016 22:32:42 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1D7DE6E26F; Sun, 21 Aug 2016 22:32:40 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qk0-x242.google.com (mail-qk0-x242.google.com [IPv6:2607:f8b0:400d:c09::242]) by gabe.freedesktop.org (Postfix) with ESMTPS id 938426E26F for ; Sun, 21 Aug 2016 22:32:39 +0000 (UTC) Received: by mail-qk0-x242.google.com with SMTP id o1so7595723qkd.2 for ; Sun, 21 Aug 2016 15:32:39 -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; bh=4Dm2u5YeLKGyQF+lsUV35LPnDqfjK0P6VFs41J+Htcw=; b=pMFFedmOvtwPk15t4xIi08hWUn5xc63kFL2+8xvCBjyfmWoExREQYE6B4HhNLPKDes 5ryIvbr/oqzrQS2FBm5OjOfLMbCUAa+m9G7SMTmYL4oCIr1fwhch3BKrSbpCcf6sDxye wNjZlYIhKEGISFMK5wKPwbpNL9S/6WGBnyQopTEuNW2+VwF5dYiXxi5mlCtfVCEzcqvO is0SjmaevOh4/9PhftAN+aWSfRIT3C6nVItAlLhydMvcKu9sQyhVhbLfWS2vVbemXaVl ZKVttJe95idRxTywTWMacynZgAcW+tYj8hvSvhdYLqsNc+qvtc0i8+vJQZ5S7AjZ8iV4 195g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=4Dm2u5YeLKGyQF+lsUV35LPnDqfjK0P6VFs41J+Htcw=; b=DpEAhDTS3IkJq4Z1WCvBx+SE5ET6keM2mAU6IIUGIQFtBX/viE05BHmmc9Bxynq4LZ J6K0jQVG7FzfSLY6GxkaO9zb21Q4NMcpEDeuwF16Y3IdbAV64Xp6qvzIhbFwB6hlqsoP e2zkf1hHnbeTSZwqfLeR+Q4t6YASqJ481E5WMj5XQTUlLKG/P57lIwcLWTK9hAHoejZp FNLPsutEuefKN+Ee4+OJsyoBg6hAX+Vi1o/m6KY7i2qjiyoikhR/eugy5Fp1rDD4cRjX KJRTSiTyHZcJBgQsIs806U5O608d55sH0zLTFpA0zADZbi9fG9wssOO3Vxvv5hIifcei NpSQ== X-Gm-Message-State: AEkoouvFgMDUTxDB1fVhzO+UJ4Cdy9Vd1jeHKNCbN0UlCzvrVUuLPi6LXP1RUs5Ur9qRRA== X-Received: by 10.55.5.5 with SMTP id 5mr20088131qkf.275.1471818758804; Sun, 21 Aug 2016 15:32:38 -0700 (PDT) Received: from localhost.localdomain ([187.180.185.30]) by smtp.gmail.com with ESMTPSA id 95sm9633135qkx.15.2016.08.21.15.32.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 21 Aug 2016 15:32:38 -0700 (PDT) From: Fabio Estevam To: l.stach@pengutronix.de Subject: [PATCH 1/3] drm/etnaviv: check for errors when enabling clocks Date: Sun, 21 Aug 2016 19:32:13 -0300 Message-Id: <1471818735-5553-1-git-send-email-festevam@gmail.com> X-Mailer: git-send-email 1.9.1 Cc: dri-devel@lists.freedesktop.org, linux+etnaviv@armlinux.org.uk X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP clk_prepare_enable() may fail, so we should better check for its return value and propagate it in the case of failure. Signed-off-by: Fabio Estevam --- drivers/gpu/drm/etnaviv/etnaviv_gpu.c | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c index 87ef341..efee7d47 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c +++ b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c @@ -872,12 +872,25 @@ int etnaviv_gpu_debugfs(struct etnaviv_gpu *gpu, struct seq_file *m) */ static int enable_clk(struct etnaviv_gpu *gpu) { - if (gpu->clk_core) - clk_prepare_enable(gpu->clk_core); - if (gpu->clk_shader) - clk_prepare_enable(gpu->clk_shader); + int ret; + + if (gpu->clk_core) { + ret = clk_prepare_enable(gpu->clk_core); + if (ret) + return ret; + } + + if (gpu->clk_shader) { + ret = clk_prepare_enable(gpu->clk_shader); + if (ret) + goto disable_clk_core; + } return 0; + +disable_clk_core: + clk_disable_unprepare(gpu->clk_core); + return ret; } static int disable_clk(struct etnaviv_gpu *gpu) @@ -892,8 +905,13 @@ static int disable_clk(struct etnaviv_gpu *gpu) static int enable_axi(struct etnaviv_gpu *gpu) { - if (gpu->clk_bus) - clk_prepare_enable(gpu->clk_bus); + int ret; + + if (gpu->clk_bus) { + ret = clk_prepare_enable(gpu->clk_bus); + if (ret) + return ret; + } return 0; }