From patchwork Mon Aug 22 02:05:30 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabio Estevam X-Patchwork-Id: 9292791 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 42F4060574 for ; Mon, 22 Aug 2016 02:06:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 300A9288E7 for ; Mon, 22 Aug 2016 02:06:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 24BB4288E9; Mon, 22 Aug 2016 02:06:01 +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=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8DF8F288E7 for ; Mon, 22 Aug 2016 02:06:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753600AbcHVCGA (ORCPT ); Sun, 21 Aug 2016 22:06:00 -0400 Received: from mail-qk0-f196.google.com ([209.85.220.196]:33374 "EHLO mail-qk0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753494AbcHVCF7 (ORCPT ); Sun, 21 Aug 2016 22:05:59 -0400 Received: by mail-qk0-f196.google.com with SMTP id n66so4371073qkf.0 for ; Sun, 21 Aug 2016 19:05:59 -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=CJWmix99hOnQgTj4aSDRem3Hib4iVJJCzo/OoNyOB4Y=; b=ozGg0tFc/eyv9NEOPinJINLp6JppRgm6zcnVs44xgJmG9tANj36osLO5WSoQWPAUjz RjLxK3P56C5Udgod2Cx/fmucRle3C1rzSiwSBTMaQEFJhazt/y6jksqvOgkVX0rDccRB v52hRFXEYgIfaCXZR+W7Lr1oHelAGpi4rvNVNtTAHUnakDU1znnR0gmcAxNnIztHhLIS ANmgn6uUaOGmU6eABeIGxekyVu1PVwiGQNJcMtCruJs/ax3QmwSUydTwOzOTqc/pbEOH SGZf8eUp6B7auEn8MtzLrvPijK1Q6GiLPkkdGxOAEwQkE3oIoWU45U3hlaoUGvIR20Rw WaVA== 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=CJWmix99hOnQgTj4aSDRem3Hib4iVJJCzo/OoNyOB4Y=; b=QaruE8IdIH23eVs1kHNGMAyzBwzx6Tkln6sQBrbXbnLd5UqLE5RorGyTF/9WGtJaHQ Ya/CMX02fE9Q8wEGiwuBykCTehKkIFYiK5X+6XH7H1Zgau8f9tDZGlowkuw8mCyDicYs HsvvX3X89YhbInG4V/ZpoQVtlaHYRnAxxmkRF0qOgsiUHFCeT7u8fKb1g/1R8gUQxlX7 0CCAEtgFDSUc47ENJyqApzk0TmmYQdD0EhA82PmhB+UmcoGL2hFgKIpkep1MFKijFlQ1 84td1NgFLydC0VE+HzZ7Poz9Yu/BWZsOEPXa7GMZPyrLIF6z5umYIMmvO8gNragbq7Ib /rBA== X-Gm-Message-State: AEkoouvyzbEiZpSnSQGGN0qyZ/TbMBbwZmJZUTjj/X9wtDlAfkxeOcoJZN/QL36Af/Whxg== X-Received: by 10.55.95.71 with SMTP id t68mr18991151qkb.61.1471831558509; Sun, 21 Aug 2016 19:05:58 -0700 (PDT) Received: from localhost.localdomain ([187.180.185.30]) by smtp.gmail.com with ESMTPSA id v65sm8465836qte.41.2016.08.21.19.05.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 21 Aug 2016 19:05:58 -0700 (PDT) From: Fabio Estevam To: broonie@kernel.org Cc: linux-spi@vger.kernel.org, Fabio Estevam Subject: [PATCH] spi: spi-fsl-dspi: Check clk_prepare_enable() error Date: Sun, 21 Aug 2016 23:05:30 -0300 Message-Id: <1471831530-8527-1-git-send-email-festevam@gmail.com> X-Mailer: git-send-email 1.9.1 Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Fabio Estevam clk_prepare_enable() may fail, so we should better check its return value and propagate it in the case of failure. Signed-off-by: Fabio Estevam --- drivers/spi/spi-fsl-dspi.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/spi/spi-fsl-dspi.c b/drivers/spi/spi-fsl-dspi.c index d57baf6..95d8b92 100644 --- a/drivers/spi/spi-fsl-dspi.c +++ b/drivers/spi/spi-fsl-dspi.c @@ -624,10 +624,13 @@ static int dspi_resume(struct device *dev) { struct spi_master *master = dev_get_drvdata(dev); struct fsl_dspi *dspi = spi_master_get_devdata(master); + int ret; pinctrl_pm_select_default_state(dev); - clk_prepare_enable(dspi->clk); + ret = clk_prepare_enable(dspi->clk); + if (ret) + return ret; spi_master_resume(master); return 0; @@ -726,7 +729,9 @@ static int dspi_probe(struct platform_device *pdev) dev_err(&pdev->dev, "unable to get clock\n"); goto out_master_put; } - clk_prepare_enable(dspi->clk); + ret = clk_prepare_enable(dspi->clk); + if (ret) + goto out_master_put; master->max_speed_hz = clk_get_rate(dspi->clk) / dspi->devtype_data->max_clock_factor;