gpiolib: Get rid of gpio_free_array()/gpio_request_array()
Subsystems (7)
cover gpiolib: Get rid of gpio_free_array()/gpio_request_array()
There are only two users left of the gpio_free_array()/gpio_request_array(). Convert them to very basic legacy APIs (it requires much less work for now) and drop no more used gpio_free_array()/gpio_request_array().
(Not tested)
Andy Shevchenko (3):
ARM: pxa: spitz: Open code gpio_request_array()
ARM: sa1100: Open code gpio_request_array()
gpiolib: legacy: Remove unused gpio_request_array() and
gpio_free_array()
Documentation/driver-api/gpio/legacy.rst | 16 ------- .../zh_CN/driver-api/gpio/legacy.rst | 16 ------- Documentation/translations/zh_TW/gpio.txt | 17 ------- arch/arm/mach-pxa/spitz_pm.c | 22 +++++---- arch/arm/mach-sa1100/h3600.c | 47 ++++++++++++++----- drivers/gpio/gpiolib-legacy.c | 39 --------------- include/linux/gpio.h | 15 ------ 7 files changed, 48 insertions(+), 124 deletions(-)
Signature · 1 line
2.43.0.rc1.1.gbec44491f096
PATCH 1/3 ARM: pxa: spitz: Open code gpio_request_array()
In order to prerare for removal of gpio_request_array(), open code the latter. Note, we are not using gpio_request_one() as it's also deprecated, hence reducing legacy API usage to the very basic ones.
--- arch/arm/mach-pxa/spitz_pm.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-)
arch/arm/mach-pxa/spitz_pm.c +12 -10
@@ -35,18 +35,20 @@static int spitz_last_ac_status; -static struct gpio spitz_charger_gpios[] = { - {SPITZ_GPIO_KEY_INT ,GPIOF_IN ,"Keyboard Interrupt" }, - {SPITZ_GPIO_SYNC ,GPIOF_IN ,"Sync" }, - {SPITZ_GPIO_AC_IN ,GPIOF_IN ,"Charger Detection" }, - {SPITZ_GPIO_ADC_TEMP_ON ,GPIOF_OUT_INIT_LOW ,"ADC Temp On" }, - {SPITZ_GPIO_JK_B ,GPIOF_OUT_INIT_LOW ,"JK B" }, - {SPITZ_GPIO_CHRG_ON ,GPIOF_OUT_INIT_LOW ,"Charger On" }, -}; -static void spitz_charger_init (void ) { -gpio_request_array (ARRAY_AND_SIZE (spitz_charger_gpios)); +gpio_request (SPITZ_GPIO_KEY_INT ,"Keyboard Interrupt" ); +gpio_direction_input (SPITZ_GPIO_KEY_INT ); +gpio_request (SPITZ_GPIO_SYNC ,"Sync" ); +gpio_direction_input (SPITZ_GPIO_SYNC ); +gpio_request (SPITZ_GPIO_AC_IN ,"Charger Detection" ); +gpio_direction_input (SPITZ_GPIO_AC_IN ); +gpio_request (SPITZ_GPIO_ADC_TEMP_ON ,"ADC Temp On" ); +gpio_direction_output (SPITZ_GPIO_ADC_TEMP_ON ,0 ); +gpio_request (SPITZ_GPIO_JK_B ,"JK B" ); +gpio_direction_output (SPITZ_GPIO_JK_B ,0 ); +gpio_request (SPITZ_GPIO_CHRG_ON ,"Charger On" ); +gpio_direction_output (SPITZ_GPIO_CHRG_ON ,0 ); }static void spitz_measure_temp (int on)
Signature · 1 line
2.43.0.rc1.1.gbec44491f096
PATCH 2/3 ARM: sa1100: Open code gpio_request_array()
In reply to Andy ShevchenkoIn order to prerare for removal of gpio_request_array(), open code the latter. Note, we are not using gpio_request_one() as it's also deprecated, hence reducing legacy API usage to the very basic ones.
--- arch/arm/mach-sa1100/h3600.c | 47 +++++++++++++++++++++++++++--------- 1 file changed, 36 insertions(+), 11 deletions(-)
arch/arm/mach-sa1100/h3600.c +36 -11
@@ -20,16 +20,6 @@#include "generic.h" -/* -* helper for sa1100fb -*/ -static struct gpio h3600_lcd_gpio[] = { - {H3XXX_EGPIO_LCD_ON ,GPIOF_OUT_INIT_LOW ,"LCD power" }, - {H3600_EGPIO_LCD_PCI ,GPIOF_OUT_INIT_LOW ,"LCD control" }, - {H3600_EGPIO_LCD_5V_ON ,GPIOF_OUT_INIT_LOW ,"LCD 5v" }, - {H3600_EGPIO_LVDD_ON ,GPIOF_OUT_INIT_LOW ,"LCD 9v/-6.5v" }, -}; -static bool h3600_lcd_request (void ) {static bool h3600_lcd_ok;
@@ -38,7 +28,42 @@ static bool h3600_lcd_request(void)if (h3600_lcd_ok)return true; - rc =gpio_request_array (h3600_lcd_gpio,ARRAY_SIZE (h3600_lcd_gpio)); + rc =gpio_request (H3XXX_EGPIO_LCD_ON ,"LCD power" ); +if (rc) + goto out; + rc =gpio_direction_output (H3XXX_EGPIO_LCD_ON ,0 ); +if (rc) + goto out_free_on; + rc =gpio_request (H3600_EGPIO_LCD_PCI ,"LCD control" ); +if (rc) + goto out_free_on; + rc =gpio_direction_output (H3600_EGPIO_LCD_PCI ,0 ); +if (rc) + goto out_free_pci; + rc =gpio_request (H3600_EGPIO_LCD_5V_ON ,"LCD 5v" ); +if (rc) + goto out_free_pci; + rc =gpio_direction_output (H3600_EGPIO_LCD_5V_ON ,0 ); +if (rc) + goto out_free_5v_on; + rc =gpio_request (H3600_EGPIO_LVDD_ON ,"LCD 9v/-6.5v" ); +if (rc) + goto out_free_5v_on; + rc =gpio_direction_output (H3600_EGPIO_LVDD_ON ,0 ); +if (rc) + goto out_free_lvdd_on; + + goto out; + +out_free_lvdd_on: +gpio_free (H3600_EGPIO_LVDD_ON ); +out_free_5v_on: +gpio_free (H3600_EGPIO_LCD_5V_ON ); +out_free_pci: +gpio_free (H3600_EGPIO_LCD_PCI ); +out_free_on: +gpio_free (H3XXX_EGPIO_LCD_ON ); +out:if (rc)pr_err ("%s: can't request GPIOs\n" , __func__);else
Signature · 1 line
2.43.0.rc1.1.gbec44491f096
PATCH 3/3 gpiolib: legacy: Remove unused gpio_request_array() and gpio_free_array()
In reply to Andy ShevchenkoNo more users.
--- Documentation/driver-api/gpio/legacy.rst | 16 -------- .../zh_CN/driver-api/gpio/legacy.rst | 16 -------- Documentation/translations/zh_TW/gpio.txt | 17 -------- drivers/gpio/gpiolib-legacy.c | 39 ------------------- include/linux/gpio.h | 15 ------- 5 files changed, 103 deletions(-)
Documentation/driver-api/gpio/legacy.rst +0 -16
@@ -225,8 +225,6 @@ setup or driver probe/teardown code, so this is an easy constraint.):: gpio_request() ## gpio_request_one() - ## gpio_request_array() - ## gpio_free_array() gpio_free()
@@ -295,14 +293,6 @@ are claimed, three additional calls are defined:: */ int gpio_request_one(unsigned gpio, unsigned long flags, const char *label); - /* request multiple GPIOs in a single call - */ - int gpio_request_array(struct gpio *array, size_t num); - - /* release multiple GPIOs in a single call - */ - void gpio_free_array(struct gpio *array, size_t num); - where 'flags' is currently defined to specify the following properties: * GPIOF_DIR_IN - to configure direction as input
@@ -341,12 +331,6 @@ A typical example of usage:: if (err) ... - err = gpio_request_array(leds_gpios, ARRAY_SIZE(leds_gpios)); - if (err) - ... - - gpio_free_array(leds_gpios, ARRAY_SIZE(leds_gpios)); - GPIOs mapped to IRQs --------------------
Documentation/translations/zh_CN/driver-api/gpio/legacy.rst +0 -16
@@ -208,8 +208,6 @@ GPIO 值的命令需要等待其信息排到队首才发送命令,再获得其 gpio_request() ## gpio_request_one() - ## gpio_request_array() - ## gpio_free_array() gpio_free()
@@ -272,14 +270,6 @@ gpio_request()前将这类细节配置好,例如使用引脚控制子系统的 */ int gpio_request_one(unsigned gpio, unsigned long flags, const char *label); - /* 在单个函数中申请多个 GPIO - */ - int gpio_request_array(struct gpio *array, size_t num); - - /* 在单个函数中释放多个 GPIO - */ - void gpio_free_array(struct gpio *array, size_t num); - 这里 'flags' 当前定义可指定以下属性: * GPIOF_DIR_IN - 配置方向为输入
@@ -317,12 +307,6 @@ gpio_request()前将这类细节配置好,例如使用引脚控制子系统的 if (err) ... - err = gpio_request_array(leds_gpios, ARRAY_SIZE(leds_gpios)); - if (err) - ... - - gpio_free_array(leds_gpios, ARRAY_SIZE(leds_gpios)); - GPIO 映射到 IRQ ----------------
Documentation/translations/zh_TW/gpio.txt +0 -17
@@ -215,13 +215,10 @@ GPIO 值的命令需要等待其信息排到隊首才發送命令,再獲得其 gpio_request() ## gpio_request_one() -## gpio_request_array() -## gpio_free_array() gpio_free() - 聲明和釋放 GPIO ---------------------------- 爲了有助於捕獲系統配置錯誤,定義了兩個函數。
@@ -278,14 +275,6 @@ gpio_request()前將這類細節配置好,例如使用 pinctrl 子系統的映 */ int gpio_request_one(unsigned gpio, unsigned long flags, const char *label); - /* 在單個函數中申請多個 GPIO - */ - int gpio_request_array(struct gpio *array, size_t num); - - /* 在單個函數中釋放多個 GPIO - */ - void gpio_free_array(struct gpio *array, size_t num); - 這裡 'flags' 當前定義可指定以下屬性: * GPIOF_DIR_IN - 配置方向爲輸入
@@ -323,12 +312,6 @@ gpio_request()前將這類細節配置好,例如使用 pinctrl 子系統的映 if (err) ... - err = gpio_request_array(leds_gpios, ARRAY_SIZE(leds_gpios)); - if (err) - ... - - gpio_free_array(leds_gpios, ARRAY_SIZE(leds_gpios)); - GPIO 映射到 IRQ --------------------
drivers/gpio/gpiolib-legacy.c +0 -39
@@ -72,42 +72,3 @@ int gpio_request(unsigned gpio, const char *label)return gpiod_request (desc, label); }EXPORT_SYMBOL_GPL (gpio_request); - -/** -* gpio_request_array - request multiple GPIOs in a single call -* @array: array of the 'struct gpio' -* @num: how many GPIOs in the array -* -* **DEPRECATED** This function is deprecated and must not be used in new code. -*/ -int gpio_request_array (const struct gpio *array,size_t num) -{ -int i, err; - -for (i =0 ; i < num; i++, array++) { - err =gpio_request_one (array->gpio, array->flags, array->label); -if (err) - goto err_free; - } -return 0 ; - -err_free: -while (i--) -gpio_free ((--array)->gpio); -return err; -} -EXPORT_SYMBOL_GPL (gpio_request_array); - -/** -* gpio_free_array - release multiple GPIOs in a single call -* @array: array of the 'struct gpio' -* @num: how many GPIOs in the array -* -* **DEPRECATED** This function is deprecated and must not be used in new code. -*/ -void gpio_free_array (const struct gpio *array,size_t num) -{ -while (num--) -gpio_free ((array++)->gpio); -} -EXPORT_SYMBOL_GPL (gpio_free_array);
include/linux/gpio.h +0 -15
@@ -120,8 +120,6 @@ static inline int gpio_to_irq(unsigned gpio) }int gpio_request_one (unsigned gpio,unsigned long flags,const char *label); -int gpio_request_array (const struct gpio *array,size_t num); -void gpio_free_array (const struct gpio *array,size_t num);/* CONFIG_GPIOLIB: bindings for managed devices that want to request gpios */
@@ -152,11 +150,6 @@ static inline int gpio_request_one(unsigned gpio,return -ENOSYS ; } -static inline int gpio_request_array (const struct gpio *array,size_t num) -{ -return -ENOSYS ; -} -static inline void gpio_free (unsigned gpio) {might_sleep ();
@@ -165,14 +158,6 @@ static inline void gpio_free(unsigned gpio)WARN_ON (1 ); } -static inline void gpio_free_array (const struct gpio *array,size_t num) -{ -might_sleep (); - -/* GPIO can never have been requested */ -WARN_ON (1 ); -} -static inline int gpio_direction_input (unsigned gpio) {return -ENOSYS ;
Signature · 1 line
2.43.0.rc1.1.gbec44491f096
Re: [PATCH v1 3/3] gpiolib: legacy: Remove unused gpio_request_array() and gpio_free_array()
Quoted 6 lines · Andy Shevchenko
No more users.
Signed-off-by Andy Shevchenko <[email protected]>--- Documentation/driver-api/gpio/legacy.rst | 16 -------- .../zh_CN/driver-api/gpio/legacy.rst | 16 --------
For Chinese:
Thanks,
Yanteng
Quoted 220 lines
Documentation/translations/zh_TW/gpio.txt | 17 -------- drivers/gpio/gpiolib-legacy.c | 39 ------------------- include/linux/gpio.h | 15 ------- 5 files changed, 103 deletions(-)Documentation/driver-api/gpio/legacy.rst +0
-16@@ -225,8 +225,6 @@ setup or driver probe/teardown code, so this is an easy constraint.):: gpio_request() ## gpio_request_one() - ## gpio_request_array() - ## gpio_free_array() gpio_free()@@ -295,14 +293,6 @@ are claimed, three additional calls are defined:: */ int gpio_request_one(unsigned gpio, unsigned long flags, const char *label); - /* request multiple GPIOs in a single call - */ - int gpio_request_array(struct gpio *array, size_t num); - - /* release multiple GPIOs in a single call - */ - void gpio_free_array(struct gpio *array, size_t num); - where 'flags' is currently defined to specify the following properties: * GPIOF_DIR_IN - to configure direction as input@@ -341,12 +331,6 @@ A typical example of usage:: if (err) - err = gpio_request_array(leds_gpios, ARRAY_SIZE(leds_gpios)); - if (err) - ... - - gpio_free_array(leds_gpios, ARRAY_SIZE(leds_gpios)); - GPIOs mapped to IRQs --------------------Documentation/translations/zh_CN/driver-api/gpio/legacy.rst +0
-16@@ -208,8 +208,6 @@ GPIO 值的命令需要等待其信息排到队首才发送命令,再获得其 gpio_request() ## gpio_request_one() - ## gpio_request_array() - ## gpio_free_array() gpio_free()@@ -272,14 +270,6 @@ gpio_request()前将这类细节配置好,例如使用引脚控制子系统的 */ int gpio_request_one(unsigned gpio, unsigned long flags, const char *label); - /* 在单个函数中申请多个 GPIO - */ - int gpio_request_array(struct gpio *array, size_t num); - - /* 在单个函数中释放多个 GPIO - */ - void gpio_free_array(struct gpio *array, size_t num); - 这里 'flags' 当前定义可指定以下属性: * GPIOF_DIR_IN - 配置方向为输入@@ -317,12 +307,6 @@ gpio_request()前将这类细节配置好,例如使用引脚控制子系统的 if (err) - err = gpio_request_array(leds_gpios, ARRAY_SIZE(leds_gpios)); - if (err) - ... - - gpio_free_array(leds_gpios, ARRAY_SIZE(leds_gpios)); - GPIO 映射到 IRQ ----------------Documentation/translations/zh_TW/gpio.txt +0
-17@@ -215,13 +215,10 @@ GPIO 值的命令需要等待其信息排到隊首才發送命令,再獲得其 gpio_request() ## gpio_request_one() -## gpio_request_array() -## gpio_free_array() gpio_free() - 聲明和釋放 GPIO ---------------------------- 爲了有助於捕獲系統配置錯誤,定義了兩個函數。@@ -278,14 +275,6 @@ gpio_request()前將這類細節配置好,例如使用 pinctrl 子系統的映 */ int gpio_request_one(unsigned gpio, unsigned long flags, const char *label); - /* 在單個函數中申請多個 GPIO - */ - int gpio_request_array(struct gpio *array, size_t num); - - /* 在單個函數中釋放多個 GPIO - */ - void gpio_free_array(struct gpio *array, size_t num); - 這裡 'flags' 當前定義可指定以下屬性: * GPIOF_DIR_IN - 配置方向爲輸入@@ -323,12 +312,6 @@ gpio_request()前將這類細節配置好,例如使用 pinctrl 子系統的映 if (err) - err = gpio_request_array(leds_gpios, ARRAY_SIZE(leds_gpios)); - if (err) - ... - - gpio_free_array(leds_gpios, ARRAY_SIZE(leds_gpios)); - GPIO 映射到 IRQ --------------------drivers/gpio/gpiolib-legacy.c +0
-39@@ -72,42 +72,3 @@ int gpio_request(unsigned gpio, const char *label)return gpiod_request (desc, label); }EXPORT_SYMBOL_GPL (gpio_request); - -/** -* gpio_request_array - request multiple GPIOs in a single call -* @array: array of the 'struct gpio' -* @num: how many GPIOs in the array -* -* **DEPRECATED** This function is deprecated and must not be used in new code. -*/ -int gpio_request_array (const struct gpio *array,size_t num) -{ -int i, err; - -for (i =0 ; i < num; i++, array++) { - err =gpio_request_one (array->gpio, array->flags, array->label); -if (err) - goto err_free; - } -return 0 ; - -err_free: -while (i--) -gpio_free ((--array)->gpio); -return err; -} -EXPORT_SYMBOL_GPL (gpio_request_array); - -/** -* gpio_free_array - release multiple GPIOs in a single call -* @array: array of the 'struct gpio' -* @num: how many GPIOs in the array -* -* **DEPRECATED** This function is deprecated and must not be used in new code. -*/ -void gpio_free_array (const struct gpio *array,size_t num) -{ -while (num--) -gpio_free ((array++)->gpio); -} -EXPORT_SYMBOL_GPL (gpio_free_array);include/linux/gpio.h +0
-15@@ -120,8 +120,6 @@ static inline int gpio_to_irq(unsigned gpio) }int gpio_request_one (unsigned gpio,unsigned long flags,const char *label); -int gpio_request_array (const struct gpio *array,size_t num); -void gpio_free_array (const struct gpio *array,size_t num);/* CONFIG_GPIOLIB: bindings for managed devices that want to request gpios */ @@ -152,11 +150,6 @@ static inline int gpio_request_one(unsigned gpio,return -ENOSYS ; } -static inline int gpio_request_array (const struct gpio *array,size_t num) -{ -return -ENOSYS ; -} -static inline void gpio_free (unsigned gpio) {might_sleep ();@@ -165,14 +158,6 @@ static inline void gpio_free(unsigned gpio)WARN_ON (1 ); } -static inline void gpio_free_array (const struct gpio *array,size_t num) -{ -might_sleep (); - -/* GPIO can never have been requested */ -WARN_ON (1 ); -} -static inline int gpio_direction_input (unsigned gpio) {return -ENOSYS ;
Quoted 3 lines · Andy Shevchenko
There are only two users left of the gpio_free_array()/gpio_request_array(). Convert them to very basic legacy APIs (it requires much less work for now) and drop no more used gpio_free_array()/gpio_request_array().
That's reasonable and makes the kernel a better place.
Yours,
Linus Walleij
Quoted 9 lines · Linus Walleij
Quoted 3 lines · Andy Shevchenko
There are only two users left of the gpio_free_array()/gpio_request_array(). Convert them to very basic legacy APIs (it requires much less work for now) and drop no more used gpio_free_array()/gpio_request_array().
That's reasonable and makes the kernel a better place.
Reviewed-by Linus Walleij <[email protected]>
Thank you!
Bart, do you want me to take it via my tree or you want to take directly?
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 9 lines · Andy Shevchenko
Quoted 7 lines · Linus Walleij
Quoted 3 lines · Andy Shevchenko
There are only two users left of the gpio_free_array()/gpio_request_array(). Convert them to very basic legacy APIs (it requires much less work for now) and drop no more used gpio_free_array()/gpio_request_array().
Quoted 7 lines
Quoted 2 lines
That's reasonable and makes the kernel a better place.
Reviewed-by Linus Walleij <[email protected]>Thank you!
Bart, do you want me to take it via my tree or you want to take directly?
We don't have Acks from the relevant arch maintainers yet. I can pick it up but I won't do it before the end of the merge window anyway.
Bart
Quoted 10 lines · Bartosz Golaszewski
Quoted 8 lines · Andy Shevchenko
Quoted 7 lines · Linus Walleij
Quoted 3 lines · Andy Shevchenko
There are only two users left of the gpio_free_array()/gpio_request_array(). Convert them to very basic legacy APIs (it requires much less work for now) and drop no more used gpio_free_array()/gpio_request_array().
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
That's reasonable and makes the kernel a better place.
Reviewed-by Linus Walleij <[email protected]>Thank you!
Bart, do you want me to take it via my tree or you want to take directly?
We don't have Acks from the relevant arch maintainers yet.
True. But I haven't noticed much maintainer's activity WRT PXA code. I dunno who can be the best to Ack these. Arnd?
Quoted 1 line
I can pick it up but I won't do it before the end of the merge window anyway.
Sure.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 3 lines · Andy Shevchenko
There are only two users left of the gpio_free_array()/gpio_request_array(). Convert them to very basic legacy APIs (it requires much less work for now) and drop no more used gpio_free_array()/gpio_request_array().
Any comments on this? We really want to get rid of the legacy APIs.
While at here, would be also good to have a comment/tag for
https://lore.kernel.org/r/[email protected]
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 8 lines · Andy Shevchenko
Quoted 3 lines · Andy Shevchenko
There are only two users left of the gpio_free_array()/gpio_request_array(). Convert them to very basic legacy APIs (it requires much less work for now) and drop no more used gpio_free_array()/gpio_request_array().
Any comments on this? We really want to get rid of the legacy APIs.
I applied the patches, they only touch the GPIO part in legacy platform code. It's not very controversial IMO.
Bart
Quoted 4 lines · Bartosz Golaszewski
Quoted 2 lines · Andy Shevchenko
On Thu, Mar 07, 2024 at 03:49:02PM +0200, Andy Shevchenko wrote:
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
There are only two users left of the gpio_free_array()/gpio_request_array(). Convert them to very basic legacy APIs (it requires much less work for now) and drop no more used gpio_free_array()/gpio_request_array().
Any comments on this? We really want to get rid of the legacy APIs.
I applied the patches, they only touch the GPIO part in legacy platform code. It's not very controversial IMO.
Thank you!
FWIW, In case of issue(s) I would like to help to fix, but I don't think it will be even one.
Signature · 2 lines
With Best Regards, Andy Shevchenko