Skip to contentSkip to conversation

gpiolib: don't build HTE code with CONFIG_HTE disabled

PATCH Superseded Bartosz Golaszewski 2 participants 4 messages Feb 7, 2025 – Feb 13, 2025

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 gpiolib: don't build HTE code with CONFIG_HTE disabled

From: Bartosz Golaszewski <[email protected]>

Hardware timestamping is only used on tegra186 platforms but we include the code and export the symbols everywhere. Shrink the binary a bit by compiling the relevant functions conditionally.

---
Changes in v2:
- reduce preprocessor ifdiffery

 drivers/gpio/gpiolib.c        |  2 ++
 include/linux/gpio/consumer.h | 36 +++++++++++++++++++++--------------
 2 files changed, 24 insertions(+), 14 deletions(-)
drivers/gpio/gpiolib.c +2 -0
index be3351583508..0f4b31f4a995 100644
@@ -2908,6 +2908,7 @@ int gpiod_direction_output_nonotify(struct gpio_desc *desc, int value)
 	return ret;
 }
 
+#if IS_ENABLED(CONFIG_HTE)
 /**
  * gpiod_enable_hw_timestamp_ns - Enable hardware timestamp in nanoseconds.
  *
@@ -2973,6 +2974,7 @@ int gpiod_disable_hw_timestamp_ns(struct gpio_desc *desc, unsigned long flags)
 	return ret;
 }
 EXPORT_SYMBOL_GPL(gpiod_disable_hw_timestamp_ns);
+#endif /* CONFIG_HTE */
 
 /**
  * gpiod_set_config - sets @config for a GPIO
include/linux/gpio/consumer.h +22 -14
index 0b1acd014186..bc670f98faa6 100644
@@ -111,8 +111,6 @@ int gpiod_get_direction(struct gpio_desc *desc);
 int gpiod_direction_input(struct gpio_desc *desc);
 int gpiod_direction_output(struct gpio_desc *desc, int value);
 int gpiod_direction_output_raw(struct gpio_desc *desc, int value);
-int gpiod_enable_hw_timestamp_ns(struct gpio_desc *desc, unsigned long flags);
-int gpiod_disable_hw_timestamp_ns(struct gpio_desc *desc, unsigned long flags);
 
 /* Value get/set from non-sleeping context */
 int gpiod_get_value(const struct gpio_desc *desc);
@@ -349,18 +347,6 @@ static inline int gpiod_direction_output_raw(struct gpio_desc *desc, int value)
 	WARN_ON(desc);
 	return -ENOSYS;
 }
-static inline int gpiod_enable_hw_timestamp_ns(struct gpio_desc *desc,
-					       unsigned long flags)
-{
-	WARN_ON(desc);
-	return -ENOSYS;
-}
-static inline int gpiod_disable_hw_timestamp_ns(struct gpio_desc *desc,
-						unsigned long flags)
-{
-	WARN_ON(desc);
-	return -ENOSYS;
-}
 static inline int gpiod_get_value(const struct gpio_desc *desc)
 {
 	/* GPIO can never have been requested */
@@ -561,6 +547,28 @@ struct gpio_desc *devm_fwnode_gpiod_get_index(struct device *dev,
 
 #endif /* CONFIG_GPIOLIB */
 
+#if IS_ENABLED(CONFIG_GPIOLIB) && IS_ENABLED(CONFIG_HTE)
+int gpiod_enable_hw_timestamp_ns(struct gpio_desc *desc, unsigned long flags);
+int gpiod_disable_hw_timestamp_ns(struct gpio_desc *desc, unsigned long flags);
+#else
+static inline int gpiod_enable_hw_timestamp_ns(struct gpio_desc *desc,
+					       unsigned long flags)
+{
+	if (!IS_ENABLED(CONFIG_GPIOLIB))
+		WARN_ON(desc);
+
+	return -ENOSYS;
+}
+static inline int gpiod_disable_hw_timestamp_ns(struct gpio_desc *desc,
+						unsigned long flags)
+{
+	if (!IS_ENABLED(CONFIG_GPIOLIB))
+		WARN_ON(desc);
+
+	return -ENOSYS;
+}
+#endif /* CONFIG_GPIOLIB && CONFIG_HTE */
+
 static inline
 struct gpio_desc *devm_fwnode_gpiod_get(struct device *dev,
 					struct fwnode_handle *fwnode,
Signature · 1 line
2.45.2
#2 lore raw
In reply to Bartosz Golaszewski
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.14-rc1 next-20250207] [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/gpiolib-don-t-build-HTE-code-with-CONFIG_HTE-disabled/20250207-163408
base:   https://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux.git gpio/for-next
patch link:    https://lore.kernel.org/r/20250207083146.17872-1-brgl%40bgdev.pl
patch subject: [PATCH v2] gpiolib: don't build HTE code with CONFIG_HTE disabled
config: i386-buildonly-randconfig-002-20250208 (https://download.01.org/0day-ci/archive/20250208/[email protected]/config)
compiler: clang version 19.1.3 (https://github.com/llvm/llvm-project ab51eccf88f5321e7c60591c5546b254b6afab99)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250208/[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 >>):

In file included from drivers/power/supply/max8903_charger.c:9:
include/linux/gpio/consumer.h:557:3: error: call to undeclared function 'WARN_ON'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]

     557 |                 WARN_ON(desc);
         |                 ^
>> include/linux/gpio/consumer.h:559:10: error: use of undeclared identifier 'ENOSYS'
     559 |         return -ENOSYS;
         |                 ^
   include/linux/gpio/consumer.h:565:3: error: call to undeclared function 'WARN_ON'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
     565 |                 WARN_ON(desc);
         |                 ^
   include/linux/gpio/consumer.h:567:10: error: use of undeclared identifier 'ENOSYS'
     567 |         return -ENOSYS;
         |                 ^

4 errors generated.

vim +/ENOSYS +559 include/linux/gpio/consumer.h

548
549 #if IS_ENABLED(CONFIG_GPIOLIB) && IS_ENABLED(CONFIG_HTE)
550 int gpiod_enable_hw_timestamp_ns(struct gpio_desc *desc, unsigned long flags);
551 int gpiod_disable_hw_timestamp_ns(struct gpio_desc *desc, unsigned long flags);
552 #else
553 static inline int gpiod_enable_hw_timestamp_ns(struct gpio_desc *desc,
554 unsigned long flags)
555 {
556 if (!IS_ENABLED(CONFIG_GPIOLIB))
557 WARN_ON(desc);
558

 > 559		return -ENOSYS;

560 }
561 static inline int gpiod_disable_hw_timestamp_ns(struct gpio_desc *desc,
562 unsigned long flags)
563 {
564 if (!IS_ENABLED(CONFIG_GPIOLIB))
565 WARN_ON(desc);
566
567 return -ENOSYS;
568 }
569 #endif /* CONFIG_GPIOLIB && CONFIG_HTE */
570

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#3 lore raw
In reply to Bartosz Golaszewski
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.14-rc2 next-20250212] [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/gpiolib-don-t-build-HTE-code-with-CONFIG_HTE-disabled/20250207-163408
base:   https://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux.git gpio/for-next
patch link:    https://lore.kernel.org/r/20250207083146.17872-1-brgl%40bgdev.pl
patch subject: [PATCH v2] gpiolib: don't build HTE code with CONFIG_HTE disabled
config: i386-buildonly-randconfig-001-20250213 (https://download.01.org/0day-ci/archive/20250213/[email protected]/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250213/[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 >>):

In file included from drivers/reset/reset-gpio.c:3:
include/linux/gpio/consumer.h: In function 'gpiod_enable_hw_timestamp_ns':

>> include/linux/gpio/consumer.h:557:17: error: implicit declaration of function 'WARN_ON' [-Werror=implicit-function-declaration]
     557 |                 WARN_ON(desc);
         |                 ^~~~~~~
   include/linux/gpio/consumer.h:559:17: error: 'ENOSYS' undeclared (first use in this function)
     559 |         return -ENOSYS;
         |                 ^~~~~~
   include/linux/gpio/consumer.h:559:17: note: each undeclared identifier is reported only once for each function it appears in
   include/linux/gpio/consumer.h: In function 'gpiod_disable_hw_timestamp_ns':
   include/linux/gpio/consumer.h:567:17: error: 'ENOSYS' undeclared (first use in this function)
     567 |         return -ENOSYS;
         |                 ^~~~~~

cc1: some warnings being treated as errors

vim +/WARN_ON +557 include/linux/gpio/consumer.h

548
549 #if IS_ENABLED(CONFIG_GPIOLIB) && IS_ENABLED(CONFIG_HTE)
550 int gpiod_enable_hw_timestamp_ns(struct gpio_desc *desc, unsigned long flags);
551 int gpiod_disable_hw_timestamp_ns(struct gpio_desc *desc, unsigned long flags);
552 #else
553 static inline int gpiod_enable_hw_timestamp_ns(struct gpio_desc *desc,
554 unsigned long flags)
555 {
556 if (!IS_ENABLED(CONFIG_GPIOLIB))

 > 557			WARN_ON(desc);

558
559 return -ENOSYS;
560 }
561 static inline int gpiod_disable_hw_timestamp_ns(struct gpio_desc *desc,
562 unsigned long flags)
563 {
564 if (!IS_ENABLED(CONFIG_GPIOLIB))
565 WARN_ON(desc);
566
567 return -ENOSYS;
568 }
569 #endif /* CONFIG_GPIOLIB && CONFIG_HTE */
570

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki