* [PATCH] gpiolib: use the required minimum set of headers
@ 2025-02-21 12:30 Bartosz Golaszewski
2025-02-21 16:00 ` Andy Shevchenko
2025-02-24 11:45 ` Andy Shevchenko
0 siblings, 2 replies; 6+ messages in thread
From: Bartosz Golaszewski @ 2025-02-21 12:30 UTC (permalink / raw)
To: Linus Walleij
Cc: linux-gpio, linux-kernel, Bartosz Golaszewski, Andy Shevchenko
From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Andy suggested we should keep a fine-grained scheme for includes and
only pull in stuff required within individual ifdef sections. Let's
revert commit dea69f2d1cc8 ("gpiolib: move all includes to the top of
gpio/consumer.h") and make the headers situation even more fine-grained
by only including the first level headers containing requireded symbols
except for bug.h where checkpatch.pl warns against including asm/bug.h.
Fixes: dea69f2d1cc8 ("gpiolib: move all includes to the top of gpio/consumer.h")
Suggested-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Closes: https://lore.kernel.org/all/Z7XPcYtaA4COHDYj@smile.fi.intel.com/
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
include/linux/gpio/consumer.h | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/include/linux/gpio/consumer.h b/include/linux/gpio/consumer.h
index 0b2b56199c36..f53cd8a1eb1e 100644
--- a/include/linux/gpio/consumer.h
+++ b/include/linux/gpio/consumer.h
@@ -3,10 +3,7 @@
#define __LINUX_GPIO_CONSUMER_H
#include <linux/bits.h>
-#include <linux/bug.h>
#include <linux/err.h>
-#include <linux/errno.h>
-#include <linux/kernel.h>
#include <linux/types.h>
struct acpi_device;
@@ -185,6 +182,9 @@ struct gpio_desc *devm_fwnode_gpiod_get_index(struct device *dev,
#else /* CONFIG_GPIOLIB */
+#include <linux/bug.h>
+#include <linux/kernel.h>
+
static inline int gpiod_count(struct device *dev, const char *con_id)
{
return 0;
@@ -549,6 +549,10 @@ struct gpio_desc *devm_fwnode_gpiod_get_index(struct device *dev,
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
+
+#include <linux/bug.h>
+#include <asm/errno.h>
+
static inline int gpiod_enable_hw_timestamp_ns(struct gpio_desc *desc,
unsigned long flags)
{
@@ -615,6 +619,8 @@ int devm_acpi_dev_add_driver_gpios(struct device *dev,
#else /* CONFIG_GPIOLIB && CONFIG_ACPI */
+#include <asm/errno.h>
+
static inline int acpi_dev_add_driver_gpios(struct acpi_device *adev,
const struct acpi_gpio_mapping *gpios)
{
@@ -640,6 +646,8 @@ void gpiod_unexport(struct gpio_desc *desc);
#else /* CONFIG_GPIOLIB && CONFIG_GPIO_SYSFS */
+#include <asm/errno.h>
+
static inline int gpiod_export(struct gpio_desc *desc,
bool direction_may_change)
{
--
2.45.2
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH] gpiolib: use the required minimum set of headers
2025-02-21 12:30 [PATCH] gpiolib: use the required minimum set of headers Bartosz Golaszewski
@ 2025-02-21 16:00 ` Andy Shevchenko
2025-02-21 16:17 ` Bartosz Golaszewski
2025-02-24 11:45 ` Andy Shevchenko
1 sibling, 1 reply; 6+ messages in thread
From: Andy Shevchenko @ 2025-02-21 16:00 UTC (permalink / raw)
To: Bartosz Golaszewski
Cc: Linus Walleij, linux-gpio, linux-kernel, Bartosz Golaszewski
On Fri, Feb 21, 2025 at 01:30:01PM +0100, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Thanks for taking my suggestion into account!
> Andy suggested we should keep a fine-grained scheme for includes and
> only pull in stuff required within individual ifdef sections. Let's
> revert commit dea69f2d1cc8 ("gpiolib: move all includes to the top of
> gpio/consumer.h") and make the headers situation even more fine-grained
> by only including the first level headers containing requireded symbols
> except for bug.h where checkpatch.pl warns against including asm/bug.h.
I'm not sure we should consider the checkpatch.pl in this case.
...
This change is definitely an improvement from the current state in your
gpio/for-next branch, if you are really strong about linux/bug.h, let me more
time to check that header and see if there any potential issues.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH] gpiolib: use the required minimum set of headers
2025-02-21 16:00 ` Andy Shevchenko
@ 2025-02-21 16:17 ` Bartosz Golaszewski
2025-02-21 16:33 ` Andy Shevchenko
0 siblings, 1 reply; 6+ messages in thread
From: Bartosz Golaszewski @ 2025-02-21 16:17 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Linus Walleij, linux-gpio, linux-kernel, Bartosz Golaszewski
On Fri, Feb 21, 2025 at 5:00 PM Andy Shevchenko
<andriy.shevchenko@intel.com> wrote:
>
> On Fri, Feb 21, 2025 at 01:30:01PM +0100, Bartosz Golaszewski wrote:
> > From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
>
> Thanks for taking my suggestion into account!
>
> > Andy suggested we should keep a fine-grained scheme for includes and
> > only pull in stuff required within individual ifdef sections. Let's
> > revert commit dea69f2d1cc8 ("gpiolib: move all includes to the top of
> > gpio/consumer.h") and make the headers situation even more fine-grained
> > by only including the first level headers containing requireded symbols
> > except for bug.h where checkpatch.pl warns against including asm/bug.h.
>
> I'm not sure we should consider the checkpatch.pl in this case.
>
> ...
>
> This change is definitely an improvement from the current state in your
> gpio/for-next branch, if you are really strong about linux/bug.h, let me more
> time to check that header and see if there any potential issues.
>
Sure, take your time. For some reason checkpatch does recommend using
linux/foo.h over asm/foo.h if the former includes the latter but I
don't know the history of this.
Bart
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH] gpiolib: use the required minimum set of headers
2025-02-21 16:17 ` Bartosz Golaszewski
@ 2025-02-21 16:33 ` Andy Shevchenko
0 siblings, 0 replies; 6+ messages in thread
From: Andy Shevchenko @ 2025-02-21 16:33 UTC (permalink / raw)
To: Bartosz Golaszewski
Cc: Linus Walleij, linux-gpio, linux-kernel, Bartosz Golaszewski
On Fri, Feb 21, 2025 at 05:17:50PM +0100, Bartosz Golaszewski wrote:
> On Fri, Feb 21, 2025 at 5:00 PM Andy Shevchenko
> <andriy.shevchenko@intel.com> wrote:
> > On Fri, Feb 21, 2025 at 01:30:01PM +0100, Bartosz Golaszewski wrote:
> > > From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> >
> > Thanks for taking my suggestion into account!
> >
> > > Andy suggested we should keep a fine-grained scheme for includes and
> > > only pull in stuff required within individual ifdef sections. Let's
> > > revert commit dea69f2d1cc8 ("gpiolib: move all includes to the top of
> > > gpio/consumer.h") and make the headers situation even more fine-grained
> > > by only including the first level headers containing requireded symbols
> > > except for bug.h where checkpatch.pl warns against including asm/bug.h.
> >
> > I'm not sure we should consider the checkpatch.pl in this case.
...
> > This change is definitely an improvement from the current state in your
> > gpio/for-next branch, if you are really strong about linux/bug.h, let me more
> > time to check that header and see if there any potential issues.
>
> Sure, take your time. For some reason checkpatch does recommend using
> linux/foo.h over asm/foo.h if the former includes the latter but I
> don't know the history of this.
I know the history of this, lately (last year) it was again a discussion result
of which is linux/unaligned.h. But this recommendation is only for the leaf files
or custom (local) headers and code, it doesn't fully applicable to the globally
accessed headers, like gpio/consumer.h. I consider this as false positive by
checkpatch.
Yes, I will check more on the header nevertheless.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] gpiolib: use the required minimum set of headers
2025-02-21 12:30 [PATCH] gpiolib: use the required minimum set of headers Bartosz Golaszewski
2025-02-21 16:00 ` Andy Shevchenko
@ 2025-02-24 11:45 ` Andy Shevchenko
1 sibling, 0 replies; 6+ messages in thread
From: Andy Shevchenko @ 2025-02-24 11:45 UTC (permalink / raw)
To: Bartosz Golaszewski
Cc: Linus Walleij, linux-gpio, linux-kernel, Bartosz Golaszewski
On Fri, Feb 21, 2025 at 01:30:01PM +0100, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
>
> Andy suggested we should keep a fine-grained scheme for includes and
> only pull in stuff required within individual ifdef sections. Let's
> revert commit dea69f2d1cc8 ("gpiolib: move all includes to the top of
> gpio/consumer.h") and make the headers situation even more fine-grained
> by only including the first level headers containing requireded symbols
> except for bug.h where checkpatch.pl warns against including asm/bug.h.
> #include <linux/bits.h>
> -#include <linux/bug.h>
> #include <linux/err.h>
> -#include <linux/errno.h>
> -#include <linux/kernel.h>
> #include <linux/types.h>
...
> +#include <asm/errno.h>
> +#include <asm/errno.h>
> +#include <asm/errno.h>
These are redundant as err.h guarantees to include asm/errno.h
Dropping this will also satisfy the `make includecheck`.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] gpiolib: use the required minimum set of headers
@ 2025-02-22 15:57 kernel test robot
0 siblings, 0 replies; 6+ messages in thread
From: kernel test robot @ 2025-02-22 15:57 UTC (permalink / raw)
To: oe-kbuild; +Cc: lkp
::::::
:::::: Manual check reason: "low confidence bisect report"
::::::
BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
In-Reply-To: <20250221123001.95887-1-brgl@bgdev.pl>
References: <20250221123001.95887-1-brgl@bgdev.pl>
TO: Bartosz Golaszewski <brgl@bgdev.pl>
TO: Linus Walleij <linus.walleij@linaro.org>
CC: linux-gpio@vger.kernel.org
CC: linux-kernel@vger.kernel.org
CC: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
CC: Andy Shevchenko <andriy.shevchenko@intel.com>
Hi Bartosz,
kernel test robot noticed the following build warnings:
[auto build test WARNING on brgl/gpio/for-next]
[also build test WARNING on next-20250221]
[cannot apply to linus/master v6.14-rc3]
[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-use-the-required-minimum-set-of-headers/20250221-203135
base: https://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux.git gpio/for-next
patch link: https://lore.kernel.org/r/20250221123001.95887-1-brgl%40bgdev.pl
patch subject: [PATCH] gpiolib: use the required minimum set of headers
:::::: branch date: 27 hours ago
:::::: commit date: 27 hours ago
compiler: clang version 19.1.3 (https://github.com/llvm/llvm-project ab51eccf88f5321e7c60591c5546b254b6afab99)
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 <lkp@intel.com>
| Closes: https://lore.kernel.org/r/202502222310.eyZaU6RS-lkp@intel.com/
includecheck warnings: (new ones prefixed by >>)
>> include/linux/gpio/consumer.h: asm/errno.h is included more than once.
>> include/linux/gpio/consumer.h: linux/bug.h is included more than once.
vim +554 include/linux/gpio/consumer.h
552
553 #include <linux/bug.h>
> 554 #include <asm/errno.h>
555
556 static inline int gpiod_enable_hw_timestamp_ns(struct gpio_desc *desc,
557 unsigned long flags)
558 {
559 if (!IS_ENABLED(CONFIG_GPIOLIB))
560 WARN_ON(desc);
561
562 return -ENOSYS;
563 }
564 static inline int gpiod_disable_hw_timestamp_ns(struct gpio_desc *desc,
565 unsigned long flags)
566 {
567 if (!IS_ENABLED(CONFIG_GPIOLIB))
568 WARN_ON(desc);
569
570 return -ENOSYS;
571 }
572 #endif /* CONFIG_GPIOLIB && CONFIG_HTE */
573
574 static inline
575 struct gpio_desc *devm_fwnode_gpiod_get(struct device *dev,
576 struct fwnode_handle *fwnode,
577 const char *con_id,
578 enum gpiod_flags flags,
579 const char *label)
580 {
581 return devm_fwnode_gpiod_get_index(dev, fwnode, con_id, 0,
582 flags, label);
583 }
584
585 struct acpi_gpio_params {
586 unsigned int crs_entry_index;
587 unsigned int line_index;
588 bool active_low;
589 };
590
591 struct acpi_gpio_mapping {
592 const char *name;
593 const struct acpi_gpio_params *data;
594 unsigned int size;
595
596 /* Ignore IoRestriction field */
597 #define ACPI_GPIO_QUIRK_NO_IO_RESTRICTION BIT(0)
598 /*
599 * When ACPI GPIO mapping table is in use the index parameter inside it
600 * refers to the GPIO resource in _CRS method. That index has no
601 * distinction of actual type of the resource. When consumer wants to
602 * get GpioIo type explicitly, this quirk may be used.
603 */
604 #define ACPI_GPIO_QUIRK_ONLY_GPIOIO BIT(1)
605 /* Use given pin as an absolute GPIO number in the system */
606 #define ACPI_GPIO_QUIRK_ABSOLUTE_NUMBER BIT(2)
607
608 unsigned int quirks;
609 };
610
611 #if IS_ENABLED(CONFIG_GPIOLIB) && IS_ENABLED(CONFIG_ACPI)
612
613 int acpi_dev_add_driver_gpios(struct acpi_device *adev,
614 const struct acpi_gpio_mapping *gpios);
615 void acpi_dev_remove_driver_gpios(struct acpi_device *adev);
616
617 int devm_acpi_dev_add_driver_gpios(struct device *dev,
618 const struct acpi_gpio_mapping *gpios);
619
620 #else /* CONFIG_GPIOLIB && CONFIG_ACPI */
621
> 622 #include <asm/errno.h>
623
624 static inline int acpi_dev_add_driver_gpios(struct acpi_device *adev,
625 const struct acpi_gpio_mapping *gpios)
626 {
627 return -ENXIO;
628 }
629 static inline void acpi_dev_remove_driver_gpios(struct acpi_device *adev) {}
630
631 static inline int devm_acpi_dev_add_driver_gpios(struct device *dev,
632 const struct acpi_gpio_mapping *gpios)
633 {
634 return -ENXIO;
635 }
636
637 #endif /* CONFIG_GPIOLIB && CONFIG_ACPI */
638
639
640 #if IS_ENABLED(CONFIG_GPIOLIB) && IS_ENABLED(CONFIG_GPIO_SYSFS)
641
642 int gpiod_export(struct gpio_desc *desc, bool direction_may_change);
643 int gpiod_export_link(struct device *dev, const char *name,
644 struct gpio_desc *desc);
645 void gpiod_unexport(struct gpio_desc *desc);
646
647 #else /* CONFIG_GPIOLIB && CONFIG_GPIO_SYSFS */
648
> 649 #include <asm/errno.h>
650
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-02-24 11:45 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-21 12:30 [PATCH] gpiolib: use the required minimum set of headers Bartosz Golaszewski
2025-02-21 16:00 ` Andy Shevchenko
2025-02-21 16:17 ` Bartosz Golaszewski
2025-02-21 16:33 ` Andy Shevchenko
2025-02-24 11:45 ` Andy Shevchenko
-- strict thread matches above, loose matches on Subject: below --
2025-02-22 15:57 kernel test robot
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.