From patchwork Thu May 16 05:11:32 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yongjun X-Patchwork-Id: 2575261 Return-Path: X-Original-To: patchwork-spi-devel-general@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from lists.sourceforge.net (lists.sourceforge.net [216.34.181.88]) by patchwork2.kernel.org (Postfix) with ESMTP id 9A456DFB7B for ; Thu, 16 May 2013 05:11:47 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=sfs-ml-2.v29.ch3.sourceforge.com) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1UcqTi-00025v-H3; Thu, 16 May 2013 05:11:46 +0000 Received: from sog-mx-1.v43.ch3.sourceforge.com ([172.29.43.191] helo=mx.sourceforge.net) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1UcqTg-00025m-9p for spi-devel-general@lists.sourceforge.net; Thu, 16 May 2013 05:11:44 +0000 Received-SPF: pass (sog-mx-1.v43.ch3.sourceforge.com: domain of gmail.com designates 209.85.214.49 as permitted sender) client-ip=209.85.214.49; envelope-from=weiyj.lk@gmail.com; helo=mail-bk0-f49.google.com; Received: from mail-bk0-f49.google.com ([209.85.214.49]) by sog-mx-1.v43.ch3.sourceforge.com with esmtps (TLSv1:RC4-SHA:128) (Exim 4.76) id 1UcqTb-0003We-DV for spi-devel-general@lists.sourceforge.net; Thu, 16 May 2013 05:11:44 +0000 Received: by mail-bk0-f49.google.com with SMTP id na10so1411083bkb.8 for ; Wed, 15 May 2013 22:11:33 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.204.62.137 with SMTP id x9mr11467295bkh.90.1368681092982; Wed, 15 May 2013 22:11:32 -0700 (PDT) Received: by 10.204.232.195 with HTTP; Wed, 15 May 2013 22:11:32 -0700 (PDT) Date: Thu, 16 May 2013 13:11:32 +0800 Message-ID: Subject: [PATCH] spi: coldfire-qspi: fix error return code in mcfqspi_probe() From: Wei Yongjun To: broonie@kernel.org, grant.likely@linaro.org X-Spam-Score: -1.6 (-) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -1.5 SPF_CHECK_PASS SPF reports sender host as permitted sender for sender-domain 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (weiyj.lk[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-Headers-End: 1UcqTb-0003We-DV Cc: spi-devel-general@lists.sourceforge.net, yongjun_wei@trendmicro.com.cn, linux-kernel@vger.kernel.org X-BeenThere: spi-devel-general@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list List-Id: Linux SPI core/device drivers discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: spi-devel-general-bounces@lists.sourceforge.net From: Wei Yongjun If pdev->dev.platform_data is not set, mcfqspi_probe() will return 0 and release all the resources, in this case, we should return a error code instead of 0. This patch fix to return -ENOENT in this case and move the check for pdev->dev.platform_data to the begin of this function. Signed-off-by: Wei Yongjun --- drivers/spi/spi-coldfire-qspi.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) ------------------------------------------------------------------------------ AlienVault Unified Security Management (USM) platform delivers complete security visibility with the essential security capabilities. Easily and efficiently configure, manage, and operate all of your security controls from a single console and one unified framework. Download a free trial. http://p.sf.net/sfu/alienvault_d2d diff --git a/drivers/spi/spi-coldfire-qspi.c b/drivers/spi/spi-coldfire-qspi.c index 3f17660..f2acb90 100644 --- a/drivers/spi/spi-coldfire-qspi.c +++ b/drivers/spi/spi-coldfire-qspi.c @@ -408,6 +408,12 @@ static int mcfqspi_probe(struct platform_device *pdev) struct mcfqspi_platform_data *pdata; int status; + pdata = pdev->dev.platform_data; + if (!pdata) { + dev_dbg(&pdev->dev, "platform data is missing\n"); + return -ENOENT; + } + master = spi_alloc_master(&pdev->dev, sizeof(*mcfqspi)); if (master == NULL) { dev_dbg(&pdev->dev, "spi_alloc_master failed\n"); @@ -458,11 +464,6 @@ static int mcfqspi_probe(struct platform_device *pdev) } clk_enable(mcfqspi->clk); - pdata = pdev->dev.platform_data; - if (!pdata) { - dev_dbg(&pdev->dev, "platform data is missing\n"); - goto fail4; - } master->bus_num = pdata->bus_num; master->num_chipselect = pdata->num_chipselect;