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

gpiolib: remove unused gpio_cansleep()

There is not a single user in the entire kernel of this deprecated API,
kill it for good.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Yanteng Si <siyanteng@loongson.cn>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

authored by

Andy Shevchenko and committed by
Bartosz Golaszewski
7d0b8064 57e30e00

+7 -63
+1 -11
Documentation/driver-api/gpio/legacy.rst
··· 165 165 Those don't need to sleep, and can safely be done from inside hard 166 166 (nonthreaded) IRQ handlers and similar contexts. 167 167 168 - Use the following calls to access such GPIOs, 169 - for which gpio_cansleep() will always return false (see below):: 168 + Use the following calls to access such GPIOs:: 170 169 171 170 /* GPIO INPUT: return zero or nonzero */ 172 171 int gpio_get_value(unsigned gpio); ··· 199 200 or SPI. Commands to read or write those GPIO values require waiting to 200 201 get to the head of a queue to transmit a command and get its response. 201 202 This requires sleeping, which can't be done from inside IRQ handlers. 202 - 203 - Platforms that support this type of GPIO distinguish them from other GPIOs 204 - by returning nonzero from this call (which requires a valid GPIO number, 205 - which should have been previously allocated with gpio_request):: 206 - 207 - int gpio_cansleep(unsigned gpio); 208 - 209 203 To access such GPIOs, a different set of accessors is defined:: 210 204 211 205 /* GPIO INPUT: return zero or nonzero, might sleep */ ··· 206 214 207 215 /* GPIO OUTPUT, might sleep */ 208 216 void gpio_set_value_cansleep(unsigned gpio, int value); 209 - 210 217 211 218 Accessing such GPIOs requires a context which may sleep, for example 212 219 a threaded IRQ handler, and those accessors must be used instead of ··· 528 537 529 538 #define gpio_get_value __gpio_get_value 530 539 #define gpio_set_value __gpio_set_value 531 - #define gpio_cansleep __gpio_cansleep 532 540 533 541 Fancier implementations could instead define those as inline functions with 534 542 logic optimizing access to specific SOC-based GPIOs. For example, if the
+3 -11
Documentation/translations/zh_CN/driver-api/gpio/legacy.rst
··· 153 153 大多数 GPIO 控制器可以通过内存读/写指令来访问。这些指令不会休眠,可以 154 154 安全地在硬(非线程)中断例程和类似的上下文中完成。 155 155 156 - 对于那些用 gpio_cansleep()测试总是返回失败的 GPIO(见下文),使用 157 - 以下的函数访问:: 156 + 对于那些 GPIO,使用以下的函数访问:: 158 157 159 158 /* GPIO 输入:返回零或非零 */ 160 159 int gpio_get_value(unsigned gpio); ··· 185 186 GPIO 值的命令需要等待其信息排到队首才发送命令,再获得其反馈。期间需要 186 187 休眠,这不能在 IRQ 例程(中断上下文)中执行。 187 188 188 - 支持此类 GPIO 的平台通过以下函数返回非零值来区分出这种 GPIO。(此函数需要 189 - 一个之前通过 gpio_request 分配到的有效 GPIO 编号):: 190 - 191 - int gpio_cansleep(unsigned gpio); 192 - 193 189 为了访问这种 GPIO,内核定义了一套不同的函数:: 194 190 195 191 /* GPIO 输入:返回零或非零 ,可能会休眠 */ ··· 192 198 193 199 /* GPIO 输出,可能会休眠 */ 194 200 void gpio_set_value_cansleep(unsigned gpio, int value); 195 - 196 201 197 202 访问这样的 GPIO 需要一个允许休眠的上下文,例如线程 IRQ 处理例程,并用以上的 198 203 访问函数替换那些没有 cansleep()后缀的自旋锁安全访问函数。 ··· 476 483 477 484 为了支持这个框架,一个平台的 Kconfig 文件将会 "select"(选择) 478 485 ARCH_REQUIRE_GPIOLIB 或 ARCH_WANT_OPTIONAL_GPIOLIB,并让它的 479 - <asm/gpio.h> 包含 <asm-generic/gpio.h>,同时定义三个方法: 480 - gpio_get_value()、gpio_set_value()和 gpio_cansleep()。 486 + <asm/gpio.h> 包含 <asm-generic/gpio.h>,同时定义两个方法: 487 + gpio_get_value()、gpio_set_value()。 481 488 482 489 它也应提供一个 ARCH_NR_GPIOS 的定义值,这样可以更好地反映该平台 GPIO 483 490 的实际数量,节省静态表的空间。(这个定义值应该包含片上系统内建 GPIO 和 ··· 495 502 496 503 #define gpio_get_value __gpio_get_value 497 504 #define gpio_set_value __gpio_set_value 498 - #define gpio_cansleep __gpio_cansleep 499 505 500 506 这些定义可以用更理想的实现方法替代,那就是使用经过逻辑优化的内联函数来访问 501 507 基于特定片上系统的 GPIO。例如,若引用的 GPIO (寄存器位偏移)是常量“12”,
+3 -11
Documentation/translations/zh_TW/gpio.txt
··· 161 161 大多數 GPIO 控制器可以通過內存讀/寫指令來訪問。這些指令不會休眠,可以 162 162 安全地在硬(非線程)中斷例程和類似的上下文中完成。 163 163 164 - 對於那些用 gpio_cansleep()測試總是返回失敗的 GPIO(見下文),使用 165 - 以下的函數訪問: 164 + 對於那些 GPIO,使用以下的函數訪問: 166 165 167 166 /* GPIO 輸入:返回零或非零 */ 168 167 int gpio_get_value(unsigned gpio); ··· 192 193 GPIO 值的命令需要等待其信息排到隊首才發送命令,再獲得其反饋。期間需要 193 194 休眠,這不能在 IRQ 例程(中斷上下文)中執行。 194 195 195 - 支持此類 GPIO 的平台通過以下函數返回非零值來區分出這種 GPIO。(此函數需要 196 - 一個之前通過 gpio_request 分配到的有效 GPIO 編號): 197 - 198 - int gpio_cansleep(unsigned gpio); 199 - 200 196 爲了訪問這種 GPIO,內核定義了一套不同的函數: 201 197 202 198 /* GPIO 輸入:返回零或非零 ,可能會休眠 */ ··· 199 205 200 206 /* GPIO 輸出,可能會休眠 */ 201 207 void gpio_set_value_cansleep(unsigned gpio, int value); 202 - 203 208 204 209 訪問這樣的 GPIO 需要一個允許休眠的上下文,例如線程 IRQ 處理例程,並用以上的 205 210 訪問函數替換那些沒有 cansleep()後綴的自旋鎖安全訪問函數。 ··· 442 449 ------- 443 450 爲了支持這個框架,一個平台的 Kconfig 文件將會 "select"(選擇) 444 451 ARCH_REQUIRE_GPIOLIB 或 ARCH_WANT_OPTIONAL_GPIOLIB,並讓它的 445 - <asm/gpio.h> 包含 <asm-generic/gpio.h>,同時定義三個方法: 446 - gpio_get_value()、gpio_set_value()和 gpio_cansleep()。 452 + <asm/gpio.h> 包含 <asm-generic/gpio.h>,同時定義二個方法: 453 + gpio_get_value()、gpio_set_value()。 447 454 448 455 它也應提供一個 ARCH_NR_GPIOS 的定義值,這樣可以更好地反映該平台 GPIO 449 456 的實際數量,節省靜態表的空間。(這個定義值應該包含片上系統內建 GPIO 和 ··· 461 468 462 469 #define gpio_get_value __gpio_get_value 463 470 #define gpio_set_value __gpio_set_value 464 - #define gpio_cansleep __gpio_cansleep 465 471 466 472 這些定義可以用更理想的實現方法替代,那就是使用經過邏輯優化的內聯函數來訪問 467 473 基於特定片上系統的 GPIO。例如,若引用的 GPIO (寄存器位偏移)是常量「12」,
-8
arch/m68k/include/asm/mcfgpio.h
··· 34 34 __mcfgpio_set_value(gpio, value); 35 35 } 36 36 37 - static inline int __gpio_cansleep(unsigned gpio) 38 - { 39 - if (gpio < MCFGPIO_PIN_MAX) 40 - return 0; 41 - else 42 - return -EINVAL; 43 - } 44 - 45 37 static inline int __gpio_to_irq(unsigned gpio) 46 38 { 47 39 return -EINVAL;
-5
arch/mips/include/asm/mach-au1x00/gpio-au1000.h
··· 500 500 alchemy_gpio1_is_valid(gpio); 501 501 } 502 502 503 - static inline int alchemy_gpio_cansleep(int gpio) 504 - { 505 - return 0; /* Alchemy never gets tired */ 506 - } 507 - 508 503 static inline int alchemy_gpio_to_irq(int gpio) 509 504 { 510 505 return (gpio >= ALCHEMY_GPIO2_BASE) ?
-5
arch/mips/include/asm/mach-au1x00/gpio-au1300.h
··· 98 98 return ret; 99 99 } 100 100 101 - static inline int au1300_gpio_cansleep(unsigned int gpio) 102 - { 103 - return 0; 104 - } 105 - 106 101 /* hardware remembers gpio 0-63 levels on powerup */ 107 102 static inline int au1300_gpio_getinitlvl(unsigned int gpio) 108 103 {
-12
include/linux/gpio.h
··· 108 108 return gpiod_set_raw_value(gpio_to_desc(gpio), value); 109 109 } 110 110 111 - static inline int gpio_cansleep(unsigned gpio) 112 - { 113 - return gpiod_cansleep(gpio_to_desc(gpio)); 114 - } 115 - 116 111 static inline int gpio_to_irq(unsigned gpio) 117 112 { 118 113 return gpiod_to_irq(gpio_to_desc(gpio)); ··· 188 193 { 189 194 /* GPIO can never have been requested or set as output */ 190 195 WARN_ON(1); 191 - } 192 - 193 - static inline int gpio_cansleep(unsigned gpio) 194 - { 195 - /* GPIO can never have been requested or set as {in,out}put */ 196 - WARN_ON(1); 197 - return 0; 198 196 } 199 197 200 198 static inline int gpio_get_value_cansleep(unsigned gpio)