From patchwork Tue Jul 10 09:44:23 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Wang X-Patchwork-Id: 1177041 Return-Path: X-Original-To: patchwork-spi-devel-general@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from lists.sourceforge.net (lists.sourceforge.net [216.34.181.88]) by patchwork1.kernel.org (Postfix) with ESMTP id 9B4B6402D2 for ; Tue, 10 Jul 2012 11:16:27 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=sfs-ml-3.v29.ch3.sourceforge.com) by sfs-ml-3.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1SoYQd-0002Sz-Br; Tue, 10 Jul 2012 11:16:27 +0000 Received: from sog-mx-3.v43.ch3.sourceforge.com ([172.29.43.193] helo=mx.sourceforge.net) by sfs-ml-3.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1SoYQc-0002Sm-GZ for spi-devel-general@lists.sourceforge.net; Tue, 10 Jul 2012 11:16:26 +0000 Received-SPF: neutral (sog-mx-3.v43.ch3.sourceforge.com: 147.11.146.13 is neither permitted nor denied by domain of gmail.com) client-ip=147.11.146.13; envelope-from=jason77.wang@gmail.com; helo=mail1.windriver.com; Received: from mail1.windriver.com ([147.11.146.13]) by sog-mx-3.v43.ch3.sourceforge.com with esmtps (TLSv1:AES256-SHA:256) (Exim 4.76) id 1SoYQW-0006kb-WF for spi-devel-general@lists.sourceforge.net; Tue, 10 Jul 2012 11:16:26 +0000 Received: from ALA-HCA.corp.ad.wrs.com (ala-hca [147.11.189.40]) by mail1.windriver.com (8.14.5/8.14.3) with ESMTP id q6A9iN9q008869 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=FAIL); Tue, 10 Jul 2012 02:44:23 -0700 (PDT) Received: from localhost.localdomain (128.224.163.220) by ALA-HCA.corp.ad.wrs.com (147.11.189.50) with Microsoft SMTP Server id 14.1.255.0; Tue, 10 Jul 2012 02:44:23 -0700 From: Hui Wang To: , Subject: [PATCH 2/2] spi/imx: use gpio_is_valid to determine if a gpio is Date: Tue, 10 Jul 2012 17:44:23 +0800 Message-ID: <1341913463-10128-3-git-send-email-jason77.wang@gmail.com> X-Mailer: git-send-email 1.5.6.5 In-Reply-To: <1341913463-10128-2-git-send-email-jason77.wang@gmail.com> References: <1341913463-10128-1-git-send-email-jason77.wang@gmail.com> <1341913463-10128-2-git-send-email-jason77.wang@gmail.com> MIME-Version: 1.0 X-Spam-Score: 1.4 (+) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (jason77.wang[at]gmail.com) 0.0 DKIM_ADSP_CUSTOM_MED No valid author signature, adsp_override is CUSTOM_MED 0.7 SPF_NEUTRAL SPF: sender does not match SPF record (neutral) 1.2 NML_ADSP_CUSTOM_MED ADSP custom_med hit, and not from a mailing list -0.5 AWL AWL: From: address is in the auto white-list X-Headers-End: 1SoYQW-0006kb-WF Cc: spi-devel-general@lists.sourceforge.net 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 Use gpio_is_valid() to replace "gpio >= 0" or "gpio < 0". Cc: Sascha Hauer Cc: Grant Likely Signed-off-by: Hui Wang --- drivers/spi/spi-imx.c | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c index c12052f..e834ff8 100644 --- a/drivers/spi/spi-imx.c +++ b/drivers/spi/spi-imx.c @@ -626,7 +626,7 @@ static void spi_imx_chipselect(struct spi_device *spi, int is_active) int active = is_active != BITBANG_CS_INACTIVE; int dev_is_lowactive = !(spi->mode & SPI_CS_HIGH); - if (gpio < 0) + if (!gpio_is_valid(gpio)) return; gpio_set_value(gpio, dev_is_lowactive ^ active); @@ -736,7 +736,7 @@ static int spi_imx_setup(struct spi_device *spi) dev_dbg(&spi->dev, "%s: mode %d, %u bpw, %d hz\n", __func__, spi->mode, spi->bits_per_word, spi->max_speed_hz); - if (gpio >= 0) + if (gpio_is_valid(gpio)) gpio_direction_output(gpio, spi->mode & SPI_CS_HIGH ? 0 : 1); spi_imx_chipselect(spi, BITBANG_CS_INACTIVE); @@ -789,11 +789,11 @@ static int __devinit spi_imx_probe(struct platform_device *pdev) for (i = 0; i < master->num_chipselect; i++) { int cs_gpio = of_get_named_gpio(np, "cs-gpios", i); - if (cs_gpio < 0 && mxc_platform_info) + if (!gpio_is_valid(cs_gpio) && mxc_platform_info) cs_gpio = mxc_platform_info->chipselect[i]; spi_imx->chipselect[i] = cs_gpio; - if (cs_gpio < 0) + if (!gpio_is_valid(cs_gpio)) continue; ret = gpio_request(spi_imx->chipselect[i], DRIVER_NAME); @@ -895,7 +895,7 @@ out_release_mem: release_mem_region(res->start, resource_size(res)); out_gpio_free: while (--i >= 0) { - if (spi_imx->chipselect[i] >= 0) + if (gpio_is_valid(spi_imx->chipselect[i])) gpio_free(spi_imx->chipselect[i]); } spi_master_put(master); @@ -920,7 +920,7 @@ static int __devexit spi_imx_remove(struct platform_device *pdev) iounmap(spi_imx->base); for (i = 0; i < master->num_chipselect; i++) - if (spi_imx->chipselect[i] >= 0) + if (gpio_is_valid(spi_imx->chipselect[i])) gpio_free(spi_imx->chipselect[i]); spi_master_put(master);