Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751640AbdFFJof (ORCPT ); Tue, 6 Jun 2017 05:44:35 -0400 Received: from mail-pg0-f67.google.com ([74.125.83.67]:33710 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751329AbdFFJoe (ORCPT ); Tue, 6 Jun 2017 05:44:34 -0400 From: Arvind Yadav To: daniel@zonque.org, haojian.zhuang@gmail.com, robert.jarzmik@free.fr, broonie@kernel.org, geert@linux-m68k.org Cc: linux-arm-kernel@lists.infradead.org, linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] spi: pxa2xx: Handle return value of clk_prepare_enable Date: Tue, 6 Jun 2017 15:14:15 +0530 Message-Id: <4e16c0aba047b068aaa41c1d180d98ccb441afd0.1496668108.git.arvind.yadav.cs@gmail.com> X-Mailer: git-send-email 1.9.1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1426 Lines: 52 clk_prepare_enable() can fail here and we must check its return value. Signed-off-by: Arvind Yadav --- drivers/spi/spi-pxa2xx.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/drivers/spi/spi-pxa2xx.c b/drivers/spi/spi-pxa2xx.c index 47b65d7..e9c0fe5 100644 --- a/drivers/spi/spi-pxa2xx.c +++ b/drivers/spi/spi-pxa2xx.c @@ -1676,7 +1676,11 @@ static int pxa2xx_spi_probe(struct platform_device *pdev) } /* Enable SOC clock */ - clk_prepare_enable(ssp->clk); + status = clk_prepare_enable(ssp->clk); + if (status) { + dev_err(&pdev->dev, "Failed to prepare clock\n"); + goto out_error_master_alloc; + } master->max_speed_hz = clk_get_rate(ssp->clk); @@ -1855,8 +1859,13 @@ static int pxa2xx_spi_resume(struct device *dev) int status; /* Enable the SSP clock */ - if (!pm_runtime_suspended(dev)) - clk_prepare_enable(ssp->clk); + if (!pm_runtime_suspended(dev)) { + status = clk_prepare_enable(ssp->clk); + if (status) { + dev_err(dev, "Failed to prepare clock\n"); + return status; + } + } /* Restore LPSS private register bits */ if (is_lpss_ssp(drv_data)) @@ -1886,8 +1895,7 @@ static int pxa2xx_spi_runtime_resume(struct device *dev) { struct driver_data *drv_data = dev_get_drvdata(dev); - clk_prepare_enable(drv_data->ssp->clk); - return 0; + return clk_prepare_enable(drv_data->ssp->clk); } #endif -- 1.9.1