From patchwork Thu Sep 1 22:04:30 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Warren X-Patchwork-Id: 1120732 Received: from lists.sourceforge.net (lists.sourceforge.net [216.34.181.88]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p81MKFjN010569 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 1 Sep 2011 22:20:36 GMT 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 1QzFcG-0001d2-Kg; Thu, 01 Sep 2011 22:20:08 +0000 Received: from sog-mx-3.v43.ch3.sourceforge.com ([172.29.43.193] helo=mx.sourceforge.net) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1QzFcF-0001cs-Hq for spi-devel-general@lists.sourceforge.net; Thu, 01 Sep 2011 22:20:07 +0000 Received-SPF: fail (sog-mx-3.v43.ch3.sourceforge.com: domain of nvidia.com does not designate 70.85.31.133 as permitted sender) client-ip=70.85.31.133; envelope-from=swarren@nvidia.com; helo=avon.wwwdotorg.org; Received: from avon.wwwdotorg.org ([70.85.31.133]) by sog-mx-3.v43.ch3.sourceforge.com with esmtps (TLSv1:AES256-SHA:256) (Exim 4.76) id 1QzFcE-0007pk-T4 for spi-devel-general@lists.sourceforge.net; Thu, 01 Sep 2011 22:20:07 +0000 Received: from severn.wwwdotorg.org (unknown [192.168.65.5]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by avon.wwwdotorg.org (Postfix) with ESMTPS id 1CA7B640F; Thu, 1 Sep 2011 16:06:58 -0600 (MDT) Received: from localhost.localdomain (searspoint.nvidia.com [216.228.112.21]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by severn.wwwdotorg.org (Postfix) with ESMTPSA id 488DCE4782; Thu, 1 Sep 2011 16:04:50 -0600 (MDT) From: Stephen Warren To: Greg Kroah-Hartman , Jean Delvare , Ben Dooks , Jonathan Cameron , Grant Likely , Arnd Bergmann Subject: [PATCH V3 4/5] staging:iio:magnetometer:ak8975: Don't assume 0 is an invalid GPIO Date: Thu, 1 Sep 2011 16:04:30 -0600 Message-Id: <1314914676-28397-4-git-send-email-swarren@nvidia.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1314914676-28397-1-git-send-email-swarren@nvidia.com> References: <1314914676-28397-1-git-send-email-swarren@nvidia.com> X-Virus-Scanned: clamav-milter 0.96.5 at avon.wwwdotorg.org X-Virus-Status: Clean X-Spam-Score: 3.4 (+++) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. 4.0 SPF_CHECK_FAIL SPF reports sender host as NOT permitted to send mails from 0.9 SPF_FAIL SPF: sender does not match SPF record (fail) -1.5 AWL AWL: From: address is in the auto white-list X-Headers-End: 1QzFcE-0007pk-T4 Cc: devel@driverdev.osuosl.org, Andrew Chew , Stephen Warren , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Jonathan Cameron , spi-devel-general@lists.sourceforge.net, linux-tegra@vger.kernel.org, Russell King , linux-i2c@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: , MIME-Version: 1.0 Errors-To: spi-devel-general-bounces@lists.sourceforge.net X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Thu, 01 Sep 2011 22:20:36 +0000 (UTC) gpio_is_valid() is the defined mechanism to determine whether a GPIO is valid. Use this instead of assuming that 0 is an invalid GPIO. Signed-off-by: Stephen Warren --- drivers/staging/iio/magnetometer/ak8975.c | 11 +++++------ 1 files changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/staging/iio/magnetometer/ak8975.c b/drivers/staging/iio/magnetometer/ak8975.c index 14076da..0dfdf50 100644 --- a/drivers/staging/iio/magnetometer/ak8975.c +++ b/drivers/staging/iio/magnetometer/ak8975.c @@ -373,7 +373,7 @@ static int ak8975_read_axis(struct iio_dev *indio_dev, int index, int *val) } /* Wait for the conversion to complete. */ - if (data->eoc_gpio) + if (gpio_is_valid(data->eoc_gpio)) ret = wait_conversion_complete_gpio(data); else ret = wait_conversion_complete_polled(data); @@ -481,7 +481,7 @@ static int ak8975_probe(struct i2c_client *client, /* We may not have a GPIO based IRQ to scan, that is fine, we will poll if so */ - if (eoc_gpio > 0) { + if (gpio_is_valid(eoc_gpio)) { err = gpio_request(eoc_gpio, "ak_8975"); if (err < 0) { dev_err(&client->dev, @@ -497,8 +497,7 @@ static int ak8975_probe(struct i2c_client *client, eoc_gpio, err); goto exit_gpio; } - } else - eoc_gpio = 0; /* No GPIO available */ + } /* Register with IIO */ indio_dev = iio_allocate_device(sizeof(*data)); @@ -534,7 +533,7 @@ static int ak8975_probe(struct i2c_client *client, exit_free_iio: iio_free_device(indio_dev); exit_gpio: - if (eoc_gpio) + if (gpio_is_valid(eoc_gpio)) gpio_free(eoc_gpio); exit: return err; @@ -549,7 +548,7 @@ static int ak8975_remove(struct i2c_client *client) iio_device_unregister(indio_dev); iio_free_device(indio_dev); - if (eoc_gpio) + if (gpio_is_valid(eoc_gpio)) gpio_free(eoc_gpio); return 0;