Skip to contentSkip to conversation

gpio: remove legacy GPIO line value setter callbacks

PATCH Applied Bartosz Golaszewski 2 participants 3 messages Jul 25, 2025 – Aug 7, 2025 GPIO

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gpio: remove legacy GPIO line value setter callbacks

From: Bartosz Golaszewski <[email protected]>

With no more users of the legacy GPIO line value setters - .set() and .set_multiple() - we can now remove them from the kernel.

---
Note that this patch may trigger build bot error reports as it's not valid until all GPIO drivers are converted upstream treewide.I intend to wait until all relevant trees are upstream and then send this patch on top during the upcoming merge window.

I have a second patch[1] that I will probably send directly to Torvalds as it's almost 4000 lines of diff. It renames the callbacks back to their original names.

[1] https://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux.git/commit/?h=gpio/devel&id=e27a47cfa1fdbfa754664ae3dbac450008831fa0

 drivers/gpio/gpiolib.c      | 27 ++++++---------------------
 include/linux/gpio/driver.h |  7 -------
 2 files changed, 6 insertions(+), 28 deletions(-)
drivers/gpio/gpiolib.c +6 -21
index a93d2a9355e2..9ac4c23d656a 100644
@@ -1037,11 +1037,6 @@ int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data,
 	int base = 0;
 	int ret;
 
-	/* Only allow one set() and one set_multiple(). */
-	if ((gc->set && gc->set_rv) ||
-	    (gc->set_multiple && gc->set_multiple_rv))
-		return -EINVAL;
-
 	/*
 	 * First: allocate and populate the internal stat container, and
 	 * set up the struct device.
@@ -2891,19 +2886,14 @@ static int gpiochip_set(struct gpio_chip *gc, unsigned int offset, int value)
 
 	lockdep_assert_held(&gc->gpiodev->srcu);
 
-	if (WARN_ON(unlikely(!gc->set && !gc->set_rv)))
+	if (WARN_ON(unlikely(!gc->set_rv)))
 		return -EOPNOTSUPP;
 
-	if (gc->set_rv) {
-		ret = gc->set_rv(gc, offset, value);
-		if (ret > 0)
-			ret = -EBADE;
+	ret = gc->set_rv(gc, offset, value);
+	if (ret > 0)
+		ret = -EBADE;
 
-		return ret;
-	}
-
-	gc->set(gc, offset, value);
-	return 0;
+	return ret;
 }
 
 static int gpiod_direction_output_raw_commit(struct gpio_desc *desc, int value)
@@ -2919,7 +2909,7 @@ static int gpiod_direction_output_raw_commit(struct gpio_desc *desc, int value)
 	 * output-only, but if there is then not even a .set() operation it
 	 * is pretty tricky to drive the output line.
 	 */
-	if (!guard.gc->set && !guard.gc->set_rv && !guard.gc->direction_output) {
+	if (!guard.gc->set_rv && !guard.gc->direction_output) {
 		gpiod_warn(desc,
 			   "%s: missing set() and direction_output() operations\n",
 			   __func__);
@@ -3673,11 +3663,6 @@ static int gpiochip_set_multiple(struct gpio_chip *gc,
 		return ret;
 	}
 
-	if (gc->set_multiple) {
-		gc->set_multiple(gc, mask, bits);
-		return 0;
-	}
-
 	/* set outputs if the corresponding mask bit is set */
 	for_each_set_bit(i, mask, gc->ngpio) {
 		ret = gpiochip_set(gc, i, test_bit(i, bits));
include/linux/gpio/driver.h +0 -7
index 4b984e8f8fcd..90567dde7d8e 100644
@@ -347,8 +347,6 @@ struct gpio_irq_chip {
  * @get: returns value for signal "offset", 0=low, 1=high, or negative error
  * @get_multiple: reads values for multiple signals defined by "mask" and
  *	stores them in "bits", returns 0 on success or negative error
- * @set: **DEPRECATED** - please use set_rv() instead
- * @set_multiple: **DEPRECATED** - please use set_multiple_rv() instead
  * @set_rv: assigns output value for signal "offset", returns 0 on success or
  *          negative error value
  * @set_multiple_rv: assigns output values for multiple signals defined by
@@ -445,11 +443,6 @@ struct gpio_chip {
 	int			(*get_multiple)(struct gpio_chip *gc,
 						unsigned long *mask,
 						unsigned long *bits);
-	void			(*set)(struct gpio_chip *gc,
-						unsigned int offset, int value);
-	void			(*set_multiple)(struct gpio_chip *gc,
-						unsigned long *mask,
-						unsigned long *bits);
 	int			(*set_rv)(struct gpio_chip *gc,
 					  unsigned int offset,
 					  int value);
Signature · 1 line
2.48.1
#1 lore raw
kernel test robot noticed the following build errors:

Hi Bartosz,

kernel test robot noticed the following build errors:

[auto build test ERROR on brgl/gpio/for-next]
[also build test ERROR on linus/master v6.16 next-20250729] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Bartosz-Golaszewski/gpio-remove-legacy-GPIO-line-value-setter-callbacks/20250725-154843
base:   https://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux.git gpio/for-next
patch link:    https://lore.kernel.org/r/20250725074651.14002-1-brgl%40bgdev.pl
patch subject: [PATCH] gpio: remove legacy GPIO line value setter callbacks
config: arm-allmodconfig (https://download.01.org/0day-ci/archive/20250730/[email protected]/config)
compiler: arm-linux-gnueabi-gcc (GCC) 15.1.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250730/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

arch/arm/mach-s3c/gpio-samsung.c: In function 'samsung_gpiolib_add':

>> arch/arm/mach-s3c/gpio-samsung.c:519:18: error: 'struct gpio_chip' has no member named 'set'; did you mean 'get'?
     519 |         if (!gc->set)
         |                  ^~~
         |                  get

vim +519 arch/arm/mach-s3c/gpio-samsung.c

1b39d5f2cc5c28 drivers/gpio/gpio-samsung.c      Kukjin Kim          2011-08-30  493  
1b39d5f2cc5c28 drivers/gpio/gpio-samsung.c      Kukjin Kim          2011-08-30  494  /*
1b39d5f2cc5c28 drivers/gpio/gpio-samsung.c      Kukjin Kim          2011-08-30  495   * samsung_gpiolib_add() - add the Samsung gpio_chip.
1b39d5f2cc5c28 drivers/gpio/gpio-samsung.c      Kukjin Kim          2011-08-30  496   * @chip: The chip to register
1b39d5f2cc5c28 drivers/gpio/gpio-samsung.c      Kukjin Kim          2011-08-30  497   *
1b39d5f2cc5c28 drivers/gpio/gpio-samsung.c      Kukjin Kim          2011-08-30  498   * This is a wrapper to gpiochip_add() that takes our specific gpio chip
1b39d5f2cc5c28 drivers/gpio/gpio-samsung.c      Kukjin Kim          2011-08-30  499   * information and makes the necessary alterations for the platform and
1b39d5f2cc5c28 drivers/gpio/gpio-samsung.c      Kukjin Kim          2011-08-30  500   * notes the information for use with the configuration systems and any
1b39d5f2cc5c28 drivers/gpio/gpio-samsung.c      Kukjin Kim          2011-08-30  501   * other parts of the system.
1b39d5f2cc5c28 drivers/gpio/gpio-samsung.c      Kukjin Kim          2011-08-30  502   */
1b39d5f2cc5c28 drivers/gpio/gpio-samsung.c      Kukjin Kim          2011-08-30  503  
1b39d5f2cc5c28 drivers/gpio/gpio-samsung.c      Kukjin Kim          2011-08-30  504  static void __init samsung_gpiolib_add(struct samsung_gpio_chip *chip)
1b39d5f2cc5c28 drivers/gpio/gpio-samsung.c      Kukjin Kim          2011-08-30  505  {
1b39d5f2cc5c28 drivers/gpio/gpio-samsung.c      Kukjin Kim          2011-08-30  506  	struct gpio_chip *gc = &chip->chip;
1b39d5f2cc5c28 drivers/gpio/gpio-samsung.c      Kukjin Kim          2011-08-30  507  	int ret;
1b39d5f2cc5c28 drivers/gpio/gpio-samsung.c      Kukjin Kim          2011-08-30  508  
1b39d5f2cc5c28 drivers/gpio/gpio-samsung.c      Kukjin Kim          2011-08-30  509  	BUG_ON(!chip->base);
1b39d5f2cc5c28 drivers/gpio/gpio-samsung.c      Kukjin Kim          2011-08-30  510  	BUG_ON(!gc->label);
1b39d5f2cc5c28 drivers/gpio/gpio-samsung.c      Kukjin Kim          2011-08-30  511  	BUG_ON(!gc->ngpio);
1b39d5f2cc5c28 drivers/gpio/gpio-samsung.c      Kukjin Kim          2011-08-30  512  
1b39d5f2cc5c28 drivers/gpio/gpio-samsung.c      Kukjin Kim          2011-08-30  513  	spin_lock_init(&chip->lock);
1b39d5f2cc5c28 drivers/gpio/gpio-samsung.c      Kukjin Kim          2011-08-30  514  
1b39d5f2cc5c28 drivers/gpio/gpio-samsung.c      Kukjin Kim          2011-08-30  515  	if (!gc->direction_input)
1b39d5f2cc5c28 drivers/gpio/gpio-samsung.c      Kukjin Kim          2011-08-30  516  		gc->direction_input = samsung_gpiolib_2bit_input;
1b39d5f2cc5c28 drivers/gpio/gpio-samsung.c      Kukjin Kim          2011-08-30  517  	if (!gc->direction_output)
1b39d5f2cc5c28 drivers/gpio/gpio-samsung.c      Kukjin Kim          2011-08-30  518  		gc->direction_output = samsung_gpiolib_2bit_output;
1b39d5f2cc5c28 drivers/gpio/gpio-samsung.c      Kukjin Kim          2011-08-30 @519  	if (!gc->set)
fb52f3226cab41 arch/arm/mach-s3c/gpio-samsung.c Bartosz Golaszewski 2025-04-07  520  		gc->set_rv = samsung_gpiolib_set;
1b39d5f2cc5c28 drivers/gpio/gpio-samsung.c      Kukjin Kim          2011-08-30  521  	if (!gc->get)
1b39d5f2cc5c28 drivers/gpio/gpio-samsung.c      Kukjin Kim          2011-08-30  522  		gc->get = samsung_gpiolib_get;
1b39d5f2cc5c28 drivers/gpio/gpio-samsung.c      Kukjin Kim          2011-08-30  523  
Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
author Applied
#2 lore raw
In reply to Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

Quoted 4 lines · Bartosz Golaszewski

With no more users of the legacy GPIO line value setters - .set() and .set_multiple() - we can now remove them from the kernel.

Applied, thanks!

[1/1] gpio: remove legacy GPIO line value setter callbacks

      https://git.kernel.org/brgl/linux/c/397a46c9aa3343e8efe6847bdaa124945bab1de4

Best regards,

Signature · 1 line
Bartosz Golaszewski <[email protected]>