Skip to content

Commit 7d0b806

Browse files
andy-shevBartosz Golaszewski
authored andcommitted
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>
1 parent 57e30e0 commit 7d0b806

7 files changed

Lines changed: 7 additions & 63 deletions

File tree

Documentation/driver-api/gpio/legacy.rst

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,7 @@ Most GPIO controllers can be accessed with memory read/write instructions.
165165
Those don't need to sleep, and can safely be done from inside hard
166166
(nonthreaded) IRQ handlers and similar contexts.
167167

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::
170169

171170
/* GPIO INPUT: return zero or nonzero */
172171
int gpio_get_value(unsigned gpio);
@@ -200,13 +199,6 @@ Some GPIO controllers must be accessed using message based busses like I2C
200199
or SPI. Commands to read or write those GPIO values require waiting to
201200
get to the head of a queue to transmit a command and get its response.
202201
This requires sleeping, which can't be done from inside IRQ handlers.
203-
204-
Platforms that support this type of GPIO distinguish them from other GPIOs
205-
by returning nonzero from this call (which requires a valid GPIO number,
206-
which should have been previously allocated with gpio_request)::
207-
208-
int gpio_cansleep(unsigned gpio);
209-
210202
To access such GPIOs, a different set of accessors is defined::
211203

212204
/* GPIO INPUT: return zero or nonzero, might sleep */
@@ -215,7 +207,6 @@ To access such GPIOs, a different set of accessors is defined::
215207
/* GPIO OUTPUT, might sleep */
216208
void gpio_set_value_cansleep(unsigned gpio, int value);
217209

218-
219210
Accessing such GPIOs requires a context which may sleep, for example
220211
a threaded IRQ handler, and those accessors must be used instead of
221212
spinlock-safe accessors without the cansleep() name suffix.
@@ -537,7 +528,6 @@ code, which always dispatches through the gpio_chip::
537528

538529
#define gpio_get_value __gpio_get_value
539530
#define gpio_set_value __gpio_set_value
540-
#define gpio_cansleep __gpio_cansleep
541531

542532
Fancier implementations could instead define those as inline functions with
543533
logic optimizing access to specific SOC-based GPIOs. For example, if the

Documentation/translations/zh_CN/driver-api/gpio/legacy.rst

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,7 @@ get/set(获取/设置)函数调用没法返回错误,且有可能是配置错误
153153
大多数 GPIO 控制器可以通过内存读/写指令来访问。这些指令不会休眠,可以
154154
安全地在硬(非线程)中断例程和类似的上下文中完成。
155155

156-
对于那些用 gpio_cansleep()测试总是返回失败的 GPIO(见下文),使用
157-
以下的函数访问::
156+
对于那些 GPIO,使用以下的函数访问::
158157

159158
/* GPIO 输入:返回零或非零 */
160159
int gpio_get_value(unsigned gpio);
@@ -186,11 +185,6 @@ GPIO值是布尔值,零表示低电平,非零表示高电平。当读取一
186185
GPIO 值的命令需要等待其信息排到队首才发送命令,再获得其反馈。期间需要
187186
休眠,这不能在 IRQ 例程(中断上下文)中执行。
188187

189-
支持此类 GPIO 的平台通过以下函数返回非零值来区分出这种 GPIO。(此函数需要
190-
一个之前通过 gpio_request 分配到的有效 GPIO 编号)::
191-
192-
int gpio_cansleep(unsigned gpio);
193-
194188
为了访问这种 GPIO,内核定义了一套不同的函数::
195189

196190
/* GPIO 输入:返回零或非零 ,可能会休眠 */
@@ -199,7 +193,6 @@ GPIO 值的命令需要等待其信息排到队首才发送命令,再获得其
199193
/* GPIO 输出,可能会休眠 */
200194
void gpio_set_value_cansleep(unsigned gpio, int value);
201195

202-
203196
访问这样的 GPIO 需要一个允许休眠的上下文,例如线程 IRQ 处理例程,并用以上的
204197
访问函数替换那些没有 cansleep()后缀的自旋锁安全访问函数。
205198

@@ -483,8 +476,8 @@ GPIO 实现者的框架(可选)
483476

484477
为了支持这个框架,一个平台的 Kconfig 文件将会 "select"(选择)
485478
ARCH_REQUIRE_GPIOLIB 或 ARCH_WANT_OPTIONAL_GPIOLIB,并让它的
486-
<asm/gpio.h> 包含 <asm-generic/gpio.h>,同时定义三个方法:
487-
gpio_get_value()、gpio_set_value()和 gpio_cansleep()
479+
<asm/gpio.h> 包含 <asm-generic/gpio.h>,同时定义两个方法:
480+
gpio_get_value()、gpio_set_value()。
488481

489482
它也应提供一个 ARCH_NR_GPIOS 的定义值,这样可以更好地反映该平台 GPIO
490483
的实际数量,节省静态表的空间。(这个定义值应该包含片上系统内建 GPIO 和
@@ -502,7 +495,6 @@ ARCH_WANT_OPTIONAL_GPIOLIB 意味着 gpiolib 核心默认关闭,且用户可以
502495

503496
#define gpio_get_value __gpio_get_value
504497
#define gpio_set_value __gpio_set_value
505-
#define gpio_cansleep __gpio_cansleep
506498

507499
这些定义可以用更理想的实现方法替代,那就是使用经过逻辑优化的内联函数来访问
508500
基于特定片上系统的 GPIO。例如,若引用的 GPIO (寄存器位偏移)是常量“12”,

Documentation/translations/zh_TW/gpio.txt

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,7 @@ get/set(獲取/設置)函數調用沒法返回錯誤,且有可能是配置錯誤
161161
大多數 GPIO 控制器可以通過內存讀/寫指令來訪問。這些指令不會休眠,可以
162162
安全地在硬(非線程)中斷例程和類似的上下文中完成。
163163

164-
對於那些用 gpio_cansleep()測試總是返回失敗的 GPIO(見下文),使用
165-
以下的函數訪問:
164+
對於那些 GPIO,使用以下的函數訪問:
166165

167166
/* GPIO 輸入:返回零或非零 */
168167
int gpio_get_value(unsigned gpio);
@@ -193,11 +192,6 @@ GPIO值是布爾值,零表示低電平,非零表示高電平。當讀取一
193192
GPIO 值的命令需要等待其信息排到隊首才發送命令,再獲得其反饋。期間需要
194193
休眠,這不能在 IRQ 例程(中斷上下文)中執行。
195194

196-
支持此類 GPIO 的平台通過以下函數返回非零值來區分出這種 GPIO。(此函數需要
197-
一個之前通過 gpio_request 分配到的有效 GPIO 編號):
198-
199-
int gpio_cansleep(unsigned gpio);
200-
201195
爲了訪問這種 GPIO,內核定義了一套不同的函數:
202196

203197
/* GPIO 輸入:返回零或非零 ,可能會休眠 */
@@ -206,7 +200,6 @@ GPIO 值的命令需要等待其信息排到隊首才發送命令,再獲得其
206200
/* GPIO 輸出,可能會休眠 */
207201
void gpio_set_value_cansleep(unsigned gpio, int value);
208202

209-
210203
訪問這樣的 GPIO 需要一個允許休眠的上下文,例如線程 IRQ 處理例程,並用以上的
211204
訪問函數替換那些沒有 cansleep()後綴的自旋鎖安全訪問函數。
212205

@@ -449,8 +442,8 @@ GPIO 實現者的框架 (可選)
449442
-------
450443
爲了支持這個框架,一個平台的 Kconfig 文件將會 "select"(選擇)
451444
ARCH_REQUIRE_GPIOLIB 或 ARCH_WANT_OPTIONAL_GPIOLIB,並讓它的
452-
<asm/gpio.h> 包含 <asm-generic/gpio.h>,同時定義三個方法:
453-
gpio_get_value()、gpio_set_value()和 gpio_cansleep()
445+
<asm/gpio.h> 包含 <asm-generic/gpio.h>,同時定義二個方法:
446+
gpio_get_value()、gpio_set_value()。
454447

455448
它也應提供一個 ARCH_NR_GPIOS 的定義值,這樣可以更好地反映該平台 GPIO
456449
的實際數量,節省靜態表的空間。(這個定義值應該包含片上系統內建 GPIO 和
@@ -468,7 +461,6 @@ ARCH_WANT_OPTIONAL_GPIOLIB 意味著 gpiolib 核心默認關閉,且用戶可以
468461

469462
#define gpio_get_value __gpio_get_value
470463
#define gpio_set_value __gpio_set_value
471-
#define gpio_cansleep __gpio_cansleep
472464

473465
這些定義可以用更理想的實現方法替代,那就是使用經過邏輯優化的內聯函數來訪問
474466
基於特定片上系統的 GPIO。例如,若引用的 GPIO (寄存器位偏移)是常量「12」,

arch/m68k/include/asm/mcfgpio.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,6 @@ static inline void __gpio_set_value(unsigned gpio, int value)
3434
__mcfgpio_set_value(gpio, value);
3535
}
3636

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-
4537
static inline int __gpio_to_irq(unsigned gpio)
4638
{
4739
return -EINVAL;

arch/mips/include/asm/mach-au1x00/gpio-au1000.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -500,11 +500,6 @@ static inline int alchemy_gpio_is_valid(int gpio)
500500
alchemy_gpio1_is_valid(gpio);
501501
}
502502

503-
static inline int alchemy_gpio_cansleep(int gpio)
504-
{
505-
return 0; /* Alchemy never gets tired */
506-
}
507-
508503
static inline int alchemy_gpio_to_irq(int gpio)
509504
{
510505
return (gpio >= ALCHEMY_GPIO2_BASE) ?

arch/mips/include/asm/mach-au1x00/gpio-au1300.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,6 @@ static inline int au1300_gpio_is_valid(unsigned int gpio)
9898
return ret;
9999
}
100100

101-
static inline int au1300_gpio_cansleep(unsigned int gpio)
102-
{
103-
return 0;
104-
}
105-
106101
/* hardware remembers gpio 0-63 levels on powerup */
107102
static inline int au1300_gpio_getinitlvl(unsigned int gpio)
108103
{

include/linux/gpio.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,6 @@ static inline void gpio_set_value(unsigned gpio, int value)
108108
return gpiod_set_raw_value(gpio_to_desc(gpio), value);
109109
}
110110

111-
static inline int gpio_cansleep(unsigned gpio)
112-
{
113-
return gpiod_cansleep(gpio_to_desc(gpio));
114-
}
115-
116111
static inline int gpio_to_irq(unsigned gpio)
117112
{
118113
return gpiod_to_irq(gpio_to_desc(gpio));
@@ -195,13 +190,6 @@ static inline void gpio_set_value(unsigned gpio, int value)
195190
WARN_ON(1);
196191
}
197192

198-
static inline int gpio_cansleep(unsigned gpio)
199-
{
200-
/* GPIO can never have been requested or set as {in,out}put */
201-
WARN_ON(1);
202-
return 0;
203-
}
204-
205193
static inline int gpio_get_value_cansleep(unsigned gpio)
206194
{
207195
/* GPIO can never have been requested or set as {in,out}put */

0 commit comments

Comments
 (0)