From patchwork Fri Jul 13 02:51:29 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Wang X-Patchwork-Id: 1193621 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 09A2E3FC5A for ; Fri, 13 Jul 2012 02:51:48 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=sfs-ml-4.v29.ch3.sourceforge.com) by sfs-ml-4.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1SpVyt-0008C9-Ou; Fri, 13 Jul 2012 02:51:47 +0000 Received: from sog-mx-4.v43.ch3.sourceforge.com ([172.29.43.194] helo=mx.sourceforge.net) by sfs-ml-4.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1SpVys-0008Bk-DQ for spi-devel-general@lists.sourceforge.net; Fri, 13 Jul 2012 02:51:46 +0000 Received-SPF: neutral (sog-mx-4.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-4.v43.ch3.sourceforge.com with esmtps (TLSv1:AES256-SHA:256) (Exim 4.76) id 1SpVyr-0003dV-Gl for spi-devel-general@lists.sourceforge.net; Fri, 13 Jul 2012 02:51:46 +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 q6D2peGO009710 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=FAIL); Thu, 12 Jul 2012 19:51:40 -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; Thu, 12 Jul 2012 19:51:39 -0700 From: Hui Wang To: , Subject: [PATCH 2/2] spi/imx: use gpio_is_valid to determine if a gpio is valid Date: Fri, 13 Jul 2012 10:51:29 +0800 Message-ID: <1342147889-25043-3-git-send-email-jason77.wang@gmail.com> X-Mailer: git-send-email 1.5.6.5 In-Reply-To: <1342147889-25043-2-git-send-email-jason77.wang@gmail.com> References: <1342147889-25043-1-git-send-email-jason77.wang@gmail.com> <1342147889-25043-2-git-send-email-jason77.wang@gmail.com> MIME-Version: 1.0 X-Spam-Score: 1.5 (+) 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.3 AWL AWL: From: address is in the auto white-list X-Headers-End: 1SpVyr-0003dV-Gl 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: Mark Brown Acked-by: Sascha Hauer 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);