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

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'gpio-v3.17-3' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio

Pull GPIO fixes from Linus Walleij:
- some documentation sync
- resource leak in the bt8xx driver
- again fix the way varargs are used to handle the optional flags on
the gpiod_* accessors. Now hopefully nailed the entire problem.

* tag 'gpio-v3.17-3' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio:
gpio: move varargs hack outside #ifdef GPIOLIB
gpio: bt8xx: fix release of managed resources
Documentation: gpio: documentation for optional getters functions

+83 -49
+23 -1
Documentation/gpio/consumer.txt
··· 53 53 if and only if no GPIO has been assigned to the device/function/index triplet, 54 54 other error codes are used for cases where a GPIO has been assigned but an error 55 55 occurred while trying to acquire it. This is useful to discriminate between mere 56 - errors and an absence of GPIO for optional GPIO parameters. 56 + errors and an absence of GPIO for optional GPIO parameters. For the common 57 + pattern where a GPIO is optional, the gpiod_get_optional() and 58 + gpiod_get_index_optional() functions can be used. These functions return NULL 59 + instead of -ENOENT if no GPIO has been assigned to the requested function: 60 + 61 + 62 + struct gpio_desc *gpiod_get_optional(struct device *dev, 63 + const char *con_id, 64 + enum gpiod_flags flags) 65 + 66 + struct gpio_desc *gpiod_get_index_optional(struct device *dev, 67 + const char *con_id, 68 + unsigned int index, 69 + enum gpiod_flags flags) 57 70 58 71 Device-managed variants of these functions are also defined: 59 72 ··· 77 64 const char *con_id, 78 65 unsigned int idx, 79 66 enum gpiod_flags flags) 67 + 68 + struct gpio_desc *devm_gpiod_get_optional(struct device *dev, 69 + const char *con_id, 70 + enum gpiod_flags flags) 71 + 72 + struct gpio_desc * devm_gpiod_get_index_optional(struct device *dev, 73 + const char *con_id, 74 + unsigned int index, 75 + enum gpiod_flags flags) 80 76 81 77 A GPIO descriptor can be disposed of using the gpiod_put() function: 82 78
-3
drivers/gpio/gpio-bt8xx.c
··· 241 241 bgwrite(~0x0, BT848_INT_STAT); 242 242 bgwrite(0x0, BT848_GPIO_OUT_EN); 243 243 244 - iounmap(bg->mmio); 245 - release_mem_region(pci_resource_start(pdev, 0), 246 - pci_resource_len(pdev, 0)); 247 244 pci_disable_device(pdev); 248 245 } 249 246
+60 -45
include/linux/gpio/consumer.h
··· 38 38 struct gpio_desc *__must_check __gpiod_get(struct device *dev, 39 39 const char *con_id, 40 40 enum gpiod_flags flags); 41 - #define __gpiod_get(dev, con_id, flags, ...) __gpiod_get(dev, con_id, flags) 42 - #define gpiod_get(varargs...) __gpiod_get(varargs, 0) 43 41 struct gpio_desc *__must_check __gpiod_get_index(struct device *dev, 44 42 const char *con_id, 45 43 unsigned int idx, 46 44 enum gpiod_flags flags); 47 - #define __gpiod_get_index(dev, con_id, index, flags, ...) \ 48 - __gpiod_get_index(dev, con_id, index, flags) 49 - #define gpiod_get_index(varargs...) __gpiod_get_index(varargs, 0) 50 45 struct gpio_desc *__must_check __gpiod_get_optional(struct device *dev, 51 46 const char *con_id, 52 47 enum gpiod_flags flags); 53 - #define __gpiod_get_optional(dev, con_id, flags, ...) \ 54 - __gpiod_get_optional(dev, con_id, flags) 55 - #define gpiod_get_optional(varargs...) __gpiod_get_optional(varargs, 0) 56 48 struct gpio_desc *__must_check __gpiod_get_index_optional(struct device *dev, 57 49 const char *con_id, 58 50 unsigned int index, 59 51 enum gpiod_flags flags); 60 - #define __gpiod_get_index_optional(dev, con_id, index, flags, ...) \ 61 - __gpiod_get_index_optional(dev, con_id, index, flags) 62 - #define gpiod_get_index_optional(varargs...) \ 63 - __gpiod_get_index_optional(varargs, 0) 64 - 65 52 void gpiod_put(struct gpio_desc *desc); 66 53 67 54 struct gpio_desc *__must_check __devm_gpiod_get(struct device *dev, 68 55 const char *con_id, 69 56 enum gpiod_flags flags); 70 - #define __devm_gpiod_get(dev, con_id, flags, ...) \ 71 - __devm_gpiod_get(dev, con_id, flags) 72 - #define devm_gpiod_get(varargs...) __devm_gpiod_get(varargs, 0) 73 57 struct gpio_desc *__must_check __devm_gpiod_get_index(struct device *dev, 74 58 const char *con_id, 75 59 unsigned int idx, 76 60 enum gpiod_flags flags); 77 - #define __devm_gpiod_get_index(dev, con_id, index, flags, ...) \ 78 - __devm_gpiod_get_index(dev, con_id, index, flags) 79 - #define devm_gpiod_get_index(varargs...) __devm_gpiod_get_index(varargs, 0) 80 61 struct gpio_desc *__must_check __devm_gpiod_get_optional(struct device *dev, 81 62 const char *con_id, 82 63 enum gpiod_flags flags); 83 - #define __devm_gpiod_get_optional(dev, con_id, flags, ...) \ 84 - __devm_gpiod_get_optional(dev, con_id, flags) 85 - #define devm_gpiod_get_optional(varargs...) \ 86 - __devm_gpiod_get_optional(varargs, 0) 87 64 struct gpio_desc *__must_check 88 65 __devm_gpiod_get_index_optional(struct device *dev, const char *con_id, 89 66 unsigned int index, enum gpiod_flags flags); 90 - #define __devm_gpiod_get_index_optional(dev, con_id, index, flags, ...) \ 91 - __devm_gpiod_get_index_optional(dev, con_id, index, flags) 92 - #define devm_gpiod_get_index_optional(varargs...) \ 93 - __devm_gpiod_get_index_optional(varargs, 0) 94 - 95 67 void devm_gpiod_put(struct device *dev, struct gpio_desc *desc); 96 68 97 69 int gpiod_get_direction(const struct gpio_desc *desc); ··· 96 124 97 125 #else /* CONFIG_GPIOLIB */ 98 126 99 - static inline struct gpio_desc *__must_check gpiod_get(struct device *dev, 100 - const char *con_id) 127 + static inline struct gpio_desc *__must_check __gpiod_get(struct device *dev, 128 + const char *con_id, 129 + enum gpiod_flags flags) 101 130 { 102 131 return ERR_PTR(-ENOSYS); 103 132 } 104 - static inline struct gpio_desc *__must_check gpiod_get_index(struct device *dev, 105 - const char *con_id, 106 - unsigned int idx) 133 + static inline struct gpio_desc *__must_check 134 + __gpiod_get_index(struct device *dev, 135 + const char *con_id, 136 + unsigned int idx, 137 + enum gpiod_flags flags) 107 138 { 108 139 return ERR_PTR(-ENOSYS); 109 140 } 110 141 111 142 static inline struct gpio_desc *__must_check 112 - gpiod_get_optional(struct device *dev, const char *con_id) 143 + __gpiod_get_optional(struct device *dev, const char *con_id, 144 + enum gpiod_flags flags) 113 145 { 114 146 return ERR_PTR(-ENOSYS); 115 147 } 116 148 117 149 static inline struct gpio_desc *__must_check 118 - gpiod_get_index_optional(struct device *dev, const char *con_id, 119 - unsigned int index) 150 + __gpiod_get_index_optional(struct device *dev, const char *con_id, 151 + unsigned int index, enum gpiod_flags flags) 120 152 { 121 153 return ERR_PTR(-ENOSYS); 122 154 } ··· 133 157 WARN_ON(1); 134 158 } 135 159 136 - static inline struct gpio_desc *__must_check devm_gpiod_get(struct device *dev, 137 - const char *con_id) 160 + static inline struct gpio_desc *__must_check 161 + __devm_gpiod_get(struct device *dev, 162 + const char *con_id, 163 + enum gpiod_flags flags) 138 164 { 139 165 return ERR_PTR(-ENOSYS); 140 166 } 141 167 static inline 142 - struct gpio_desc *__must_check devm_gpiod_get_index(struct device *dev, 143 - const char *con_id, 144 - unsigned int idx) 168 + struct gpio_desc *__must_check 169 + __devm_gpiod_get_index(struct device *dev, 170 + const char *con_id, 171 + unsigned int idx, 172 + enum gpiod_flags flags) 145 173 { 146 174 return ERR_PTR(-ENOSYS); 147 175 } 148 176 149 177 static inline struct gpio_desc *__must_check 150 - devm_gpiod_get_optional(struct device *dev, const char *con_id) 178 + __devm_gpiod_get_optional(struct device *dev, const char *con_id, 179 + enum gpiod_flags flags) 151 180 { 152 181 return ERR_PTR(-ENOSYS); 153 182 } 154 183 155 184 static inline struct gpio_desc *__must_check 156 - devm_gpiod_get_index_optional(struct device *dev, const char *con_id, 157 - unsigned int index) 185 + __devm_gpiod_get_index_optional(struct device *dev, const char *con_id, 186 + unsigned int index, enum gpiod_flags flags) 158 187 { 159 188 return ERR_PTR(-ENOSYS); 160 189 } ··· 284 303 return -EINVAL; 285 304 } 286 305 287 - 288 306 #endif /* CONFIG_GPIOLIB */ 307 + 308 + /* 309 + * Vararg-hacks! This is done to transition the kernel to always pass 310 + * the options flags argument to the below functions. During a transition 311 + * phase these vararg macros make both old-and-newstyle code compile, 312 + * but when all calls to the elder API are removed, these should go away 313 + * and the __gpiod_get() etc functions above be renamed just gpiod_get() 314 + * etc. 315 + */ 316 + #define __gpiod_get(dev, con_id, flags, ...) __gpiod_get(dev, con_id, flags) 317 + #define gpiod_get(varargs...) __gpiod_get(varargs, 0) 318 + #define __gpiod_get_index(dev, con_id, index, flags, ...) \ 319 + __gpiod_get_index(dev, con_id, index, flags) 320 + #define gpiod_get_index(varargs...) __gpiod_get_index(varargs, 0) 321 + #define __gpiod_get_optional(dev, con_id, flags, ...) \ 322 + __gpiod_get_optional(dev, con_id, flags) 323 + #define gpiod_get_optional(varargs...) __gpiod_get_optional(varargs, 0) 324 + #define __gpiod_get_index_optional(dev, con_id, index, flags, ...) \ 325 + __gpiod_get_index_optional(dev, con_id, index, flags) 326 + #define gpiod_get_index_optional(varargs...) \ 327 + __gpiod_get_index_optional(varargs, 0) 328 + #define __devm_gpiod_get(dev, con_id, flags, ...) \ 329 + __devm_gpiod_get(dev, con_id, flags) 330 + #define devm_gpiod_get(varargs...) __devm_gpiod_get(varargs, 0) 331 + #define __devm_gpiod_get_index(dev, con_id, index, flags, ...) \ 332 + __devm_gpiod_get_index(dev, con_id, index, flags) 333 + #define devm_gpiod_get_index(varargs...) __devm_gpiod_get_index(varargs, 0) 334 + #define __devm_gpiod_get_optional(dev, con_id, flags, ...) \ 335 + __devm_gpiod_get_optional(dev, con_id, flags) 336 + #define devm_gpiod_get_optional(varargs...) \ 337 + __devm_gpiod_get_optional(varargs, 0) 338 + #define __devm_gpiod_get_index_optional(dev, con_id, index, flags, ...) \ 339 + __devm_gpiod_get_index_optional(dev, con_id, index, flags) 340 + #define devm_gpiod_get_index_optional(varargs...) \ 341 + __devm_gpiod_get_index_optional(varargs, 0) 289 342 290 343 #if IS_ENABLED(CONFIG_GPIOLIB) && IS_ENABLED(CONFIG_GPIO_SYSFS) 291 344