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

blackfin: GPIO: Implement more GPIO APIs

Implement more GPIO APIs in case GPIOLIB is disabled.

Signed-off-by: Sonic Zhang <sonic.zhang@analog.com>
Signed-off-by: Bob Liu <lliubbo@gmail.com>

authored by

Sonic Zhang and committed by
Bob Liu
45abc49d 494b7948

+44
+44
arch/blackfin/include/asm/gpio.h
··· 26 26 #ifndef __ASSEMBLY__ 27 27 28 28 #include <linux/compiler.h> 29 + #include <linux/gpio.h> 29 30 30 31 /*********************************************************** 31 32 * ··· 243 242 static inline int gpio_set_debounce(unsigned gpio, unsigned debounce) 244 243 { 245 244 return -EINVAL; 245 + } 246 + 247 + static inline int gpio_request_one(unsigned gpio, unsigned long flags, const char *label) 248 + { 249 + int err; 250 + 251 + err = bfin_gpio_request(gpio, label); 252 + if (err) 253 + return err; 254 + 255 + if (flags & GPIOF_DIR_IN) 256 + err = bfin_gpio_direction_input(gpio); 257 + else 258 + err = bfin_gpio_direction_output(gpio, 259 + (flags & GPIOF_INIT_HIGH) ? 1 : 0); 260 + 261 + if (err) 262 + bfin_gpio_free(gpio); 263 + 264 + return err; 265 + } 266 + 267 + static inline int gpio_request_array(const struct gpio *array, size_t num) 268 + { 269 + int i, err; 270 + 271 + for (i = 0; i < num; i++, array++) { 272 + err = gpio_request_one(array->gpio, array->flags, array->label); 273 + if (err) 274 + goto err_free; 275 + } 276 + return 0; 277 + 278 + err_free: 279 + while (i--) 280 + bfin_gpio_free((--array)->gpio); 281 + return err; 282 + } 283 + 284 + static inline void gpio_free_array(const struct gpio *array, size_t num) 285 + { 286 + while (num--) 287 + bfin_gpio_free((array++)->gpio); 246 288 } 247 289 248 290 static inline int __gpio_get_value(unsigned gpio)