Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[POWERPC] of/gpio: Use dynamic base allocation

Since the "gpiolib: dynamic gpio number allocation" patch was recently
merged into Linus' tree (commit 8d0aab2f16c4fa170f32e7a74a52cd0122bbafef),
we can use dynamic GPIO base allocation now.

This, in turn, removes number of gpios per chip constraint.

Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>

authored by

Anton Vorontsov and committed by
Paul Mackerras
21451155 09e67ca2

+1 -37
+1 -37
drivers/of/gpio.c
··· 137 137 } 138 138 EXPORT_SYMBOL(of_gpio_simple_xlate); 139 139 140 - /* Should be sufficient for now, later we'll use dynamic bases. */ 141 - #if defined(CONFIG_PPC32) || defined(CONFIG_SPARC32) 142 - #define GPIOS_PER_CHIP 32 143 - #else 144 - #define GPIOS_PER_CHIP 64 145 - #endif 146 - 147 - static int of_get_gpiochip_base(struct device_node *np) 148 - { 149 - struct device_node *gc = NULL; 150 - int gpiochip_base = 0; 151 - 152 - while ((gc = of_find_all_nodes(gc))) { 153 - if (!of_get_property(gc, "gpio-controller", NULL)) 154 - continue; 155 - 156 - if (gc != np) { 157 - gpiochip_base += GPIOS_PER_CHIP; 158 - continue; 159 - } 160 - 161 - of_node_put(gc); 162 - 163 - if (gpiochip_base >= ARCH_NR_GPIOS) 164 - return -ENOSPC; 165 - 166 - return gpiochip_base; 167 - } 168 - 169 - return -ENOENT; 170 - } 171 - 172 140 /** 173 141 * of_mm_gpiochip_add - Add memory mapped GPIO chip (bank) 174 142 * @np: device node of the GPIO chip ··· 173 205 if (!mm_gc->regs) 174 206 goto err1; 175 207 176 - gc->base = of_get_gpiochip_base(np); 177 - if (gc->base < 0) { 178 - ret = gc->base; 179 - goto err1; 180 - } 208 + gc->base = -1; 181 209 182 210 if (!of_gc->xlate) 183 211 of_gc->xlate = of_gpio_simple_xlate;