diff options
| author | Edgardo Handal <ehandal@nvidia.com> | 2016-09-19 12:48:18 -0400 |
|---|---|---|
| committer | mobile promotions <svcmobile_promotions@nvidia.com> | 2016-09-21 14:07:26 -0400 |
| commit | b64cf2cf576d109e77b77d893be7cd9c8a163f8f (patch) | |
| tree | ac29cc1871e2435d7c3f7311d3e93aece30fafa0 | |
| parent | c682c0a2b13a2760547a7b55d244d84c8dc23982 (diff) | |
gpio: tegra: don't access nonexistent pins
Store how many pins exist per port in a table and limit accesses based
on that table. This will prevent reading nonexistent registers
Change-Id: I94c8393565970849fd4d731721824245e50258d5
Signed-off-by: Edgardo Handal <ehandal@nvidia.com>
Reviewed-on: http://git-master/r/1223135
GVS: Gerrit_Virtual_Submit
Reviewed-by: Laxman Dewangan <ldewangan@nvidia.com>
| -rw-r--r-- | drivers/gpio/gpio-tegra186.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/drivers/gpio/gpio-tegra186.c b/drivers/gpio/gpio-tegra186.c index 3ed3e00ac..4c5d718b6 100644 --- a/drivers/gpio/gpio-tegra186.c +++ b/drivers/gpio/gpio-tegra186.c | |||
| @@ -123,6 +123,11 @@ static int tegra186_gpio_map[MAX_GPIO_CONTROLLERS][MAX_GPIO_PORTS] = { | |||
| 123 | {31, 18, 20, 30, 21, 22, 26, 25},/* AON gpio cntrlr */ | 123 | {31, 18, 20, 30, 21, 22, 26, 25},/* AON gpio cntrlr */ |
| 124 | }; | 124 | }; |
| 125 | 125 | ||
| 126 | static u32 tegra186_gpio_port_pin_count[MAX_PORTS] = { | ||
| 127 | 7, 7, 7, 6, 8, 6, 6, 7, 8, 8, 1, 8, 6, 7, 4, 7, | ||
| 128 | 6, 6, 5, 4, 6, 8, 8, 8, 7, 4, 8, 2, 4, 0, 3, 5, | ||
| 129 | }; | ||
| 130 | |||
| 126 | static u32 address_map[32][2]; | 131 | static u32 address_map[32][2]; |
| 127 | static u32 tegra_gpio_bank_count; | 132 | static u32 tegra_gpio_bank_count; |
| 128 | static struct tegra_gpio_controller | 133 | static struct tegra_gpio_controller |
| @@ -199,6 +204,9 @@ static inline bool is_gpio_accessible(u32 offset) | |||
| 199 | if (controller == -1) | 204 | if (controller == -1) |
| 200 | return false; | 205 | return false; |
| 201 | 206 | ||
| 207 | if (pin >= tegra186_gpio_port_pin_count[port]) | ||
| 208 | return false; | ||
| 209 | |||
| 202 | for (i = 0; i < MAX_GPIO_CONTROLLERS; i++) { | 210 | for (i = 0; i < MAX_GPIO_CONTROLLERS; i++) { |
| 203 | for (j = 0; j < MAX_GPIO_PORTS; j++) { | 211 | for (j = 0; j < MAX_GPIO_PORTS; j++) { |
| 204 | if (tegra186_gpio_map[i][j] == port) { | 212 | if (tegra186_gpio_map[i][j] == port) { |
