summaryrefslogtreecommitdiff
path: root/drivers/staging
diff options
context:
space:
mode:
authorStephen Warren <swarren@nvidia.com>2011-09-21 11:16:00 +0100
committerSimone Willett <swillett@nvidia.com>2012-02-18 10:58:16 -0800
commit0a57a174957a81bf870fe43f91ded27b0401ccc7 (patch)
tree954366d8e5749e48cd31e82ece2c1a0e22de1496 /drivers/staging
parentab7b32a5b1614e12877a0328d2bb250320d9d617 (diff)
staging:iio:magnetometer:ak8975: Don't assume 0 is an invalid GPIO
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. Upstream v3.2 commit 7c6c936832a46e86b0fac654923ce5015bdc80ee Change-Id: Ica81b9fa8379db07ca7d23a6c43c6ab742ef09b6 Signed-off-by: Stephen Warren <swarren@nvidia.com> Acked-by: Andrew Chew <achew@nvidia.com> Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> Signed-off-by: Dan Willemsen <dwillemsen@nvidia.com> Reviewed-on: http://git-master/r/83531 Reviewed-by: Andrew Chew <achew@nvidia.com> Reviewed-by: Allen Martin <amartin@nvidia.com>
Diffstat (limited to 'drivers/staging')
-rw-r--r--drivers/staging/iio/magnetometer/ak8975.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/drivers/staging/iio/magnetometer/ak8975.c b/drivers/staging/iio/magnetometer/ak8975.c
index d8c65c08a564..6d87503f5621 100644
--- a/drivers/staging/iio/magnetometer/ak8975.c
+++ b/drivers/staging/iio/magnetometer/ak8975.c
@@ -403,7 +403,7 @@ static ssize_t show_raw(struct device *dev, struct device_attribute *devattr,
}
/* 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);
@@ -494,7 +494,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,
@@ -510,8 +510,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));
@@ -546,7 +545,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;
@@ -561,7 +560,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;