summaryrefslogtreecommitdiff
path: root/arch
diff options
context:
space:
mode:
authorChaitanya Bandi <bandik@nvidia.com>2011-11-03 16:13:18 +0530
committerVarun Colbert <vcolbert@nvidia.com>2011-11-08 14:10:31 -0800
commit091b3906b2dd64cd58221e7e61a24a57dabad16c (patch)
treea6fc7687ef5ce593d5c0005738520f7696b86bab /arch
parent9afabbf3d72135346b02c9a2cf48e4793fb90d43 (diff)
ARM: tegra: gpio: Add range check for gpio enable/disable
Added the range check into tegra_gpio_enable and tegra_gpio_disable Bug 897387 Reviewed-on: http://git-master/r/62104 (cherry picked from commit e2946c2cb77e3eacacb5169b3ce3f3f30caa87db) Change-Id: Ic9b745036959b64f1421b031d31f67b987dc2163 Reviewed-on: http://git-master/r/62641 Tested-by: Bandi Krishna Chaitanya <bandik@nvidia.com> Reviewed-by: Laxman Dewangan <ldewangan@nvidia.com>
Diffstat (limited to 'arch')
-rw-r--r--arch/arm/mach-tegra/gpio.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/arch/arm/mach-tegra/gpio.c b/arch/arm/mach-tegra/gpio.c
index 3ba21ca8e7e0..fecbb36f4b7b 100644
--- a/arch/arm/mach-tegra/gpio.c
+++ b/arch/arm/mach-tegra/gpio.c
@@ -124,16 +124,28 @@ static void tegra_gpio_mask_write(u32 reg, int gpio, int value)
void tegra_gpio_enable(int gpio)
{
+ if (gpio >= TEGRA_NR_GPIOS) {
+ pr_warn("%s : Invalid gpio ID - %d\n", __func__, gpio);
+ return;
+ }
tegra_gpio_mask_write(GPIO_MSK_CNF(gpio), gpio, 1);
}
void tegra_gpio_disable(int gpio)
{
+ if (gpio >= TEGRA_NR_GPIOS) {
+ pr_warn("%s : Invalid gpio ID - %d\n", __func__, gpio);
+ return;
+ }
tegra_gpio_mask_write(GPIO_MSK_CNF(gpio), gpio, 0);
}
void tegra_gpio_init_configure(unsigned gpio, bool is_input, int value)
{
+ if (gpio >= TEGRA_NR_GPIOS) {
+ pr_warn("%s : Invalid gpio ID - %d\n", __func__, gpio);
+ return;
+ }
if (is_input) {
tegra_gpio_mask_write(GPIO_MSK_OE(gpio), gpio, 0);
} else {