aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpio
diff options
context:
space:
mode:
authorAlexandre Courbot <acourbot@nvidia.com>2013-10-04 10:59:57 -0700
committerH. Nikolaus Schaller <hns@goldelico.com>2013-10-05 22:41:13 +0200
commit12dff5eb5cd2b44e46d8e13e6fba946afe75b1bf (patch)
tree507ea3e50343b7863afcdf1afe3e7da81d52a1e2 /drivers/gpio
parentcffb860a02cfc38311c9553748fa895aba5caa22 (diff)
downloadkernel_goldelico_gta04-12dff5eb5cd2b44e46d8e13e6fba946afe75b1bf.zip
kernel_goldelico_gta04-12dff5eb5cd2b44e46d8e13e6fba946afe75b1bf.tar.gz
kernel_goldelico_gta04-12dff5eb5cd2b44e46d8e13e6fba946afe75b1bf.tar.bz2
gpiolib: safer implementation of desc_to_gpio()
The current implementation of desc_to_gpio() relies on the chip pointer to be set to a valid value in order to compute the GPIO number. This was done in the hope that we can get rid of the gpio_desc global array, but this is not happening anytime soon. This patch reimplements desc_to_gpio() in a fashion similar to that of gpio_to_desc(). As a result, desc_to_gpio(gpio_to_desc(gpio)) == gpio is now always true. This allows to call desc_to_gpio() on non-initialized descriptors as some error-handling code currently does. Signed-off-by: Alexandre Courbot <acourbot@nvidia.com> Reported-by: Dr. H. Nikolaus Schaller <hns@goldelico.com>
Diffstat (limited to 'drivers/gpio')
-rw-r--r--drivers/gpio/gpiolib.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 86ef346..f330631 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -136,7 +136,7 @@ static struct gpio_desc *gpio_to_desc(unsigned gpio)
*/
static int desc_to_gpio(const struct gpio_desc *desc)
{
- return desc->chip->base + gpio_chip_hwgpio(desc);
+ return desc - &gpio_desc[0];
}