Skip to contentSkip to conversation

headers: don't depend on errno.h being available

PATCH In review [email protected] 3 participants 4 messages Jan 18, 2024 – Jan 25, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 headers: don't depend on errno.h being available

From: Max Krummenacher <[email protected]>

These headers follow the pattern:

| #if CONFIG_IS_ENABLED(FANCY_FEATURE)
|   void foo(void);
| #else
|   static inline void foo(void) { return -ENOSYS; }
| #endif

In the #else path ENOSYS is used, however linux/errno.h is not included. If errno.h has not been included already the compiler errors out even if the inline function is not referenced.

Make those headers self contained.

---

 include/dfu.h             | 1 +
 include/dm/pinctrl.h      | 2 ++
 include/hwspinlock.h      | 2 ++
 include/i2c_eeprom.h      | 2 ++
 include/nvmem.h           | 2 ++
 include/power-domain.h    | 2 ++
 include/power/regulator.h | 2 ++
 include/remoteproc.h      | 1 +
 include/soc.h             | 2 ++
 include/spi-mem.h         | 2 ++
 include/sysinfo.h         | 2 ++
 include/tlv_eeprom.h      | 2 ++
 12 files changed, 22 insertions(+)
include/dfu.h +1 -0
index 2f42781888a..fa1918cd663 100644
@@ -10,6 +10,7 @@
 #ifndef __DFU_ENTITY_H_
 #define __DFU_ENTITY_H_
 
+#include <linux/errno.h>
 #include <linux/list.h>
 #include <mmc.h>
 #include <spi_flash.h>
include/dm/pinctrl.h +2 -0
index 70d8cc5ecac..e41baea6200 100644
@@ -6,6 +6,8 @@
 #ifndef __PINCTRL_H
 #define __PINCTRL_H
 
+#include <linux/errno.h>
+
 #define PINNAME_SIZE	10
 #define PINMUX_SIZE	90
 
include/hwspinlock.h +2 -0
index d8556c0b4b4..dd5135442ec 100644
@@ -6,6 +6,8 @@
 #ifndef _HWSPINLOCK_H_
 #define _HWSPINLOCK_H_
 
+#include <linux/errno.h>
+
 /**
  * Implement a hwspinlock uclass.
  * Hardware spinlocks are used to perform hardware protection of
include/i2c_eeprom.h +2 -0
index 32dcb034973..cba991e3574 100644
@@ -6,6 +6,8 @@
 #ifndef __I2C_EEPROM
 #define __I2C_EEPROM
 
+#include <linux/errno.h>
+
 struct udevice;
 
 struct i2c_eeprom_ops {
include/nvmem.h +2 -0
index 822e698bdd4..e6a8a98828b 100644
@@ -6,6 +6,8 @@
 #ifndef NVMEM_H
 #define NVMEM_H
 
+#include <linux/errno.h>
+
 /**
  * DOC: Design
  *
include/power-domain.h +2 -0
index 2ff6c77cd76..18525073e5e 100644
@@ -6,6 +6,8 @@
 #ifndef _POWER_DOMAIN_H
 #define _POWER_DOMAIN_H
 
+#include <linux/errno.h>
+
 /**
  * A power domain is a portion of an SoC or chip that is powered by a
  * switchable source of power. In many cases, software has control over the
include/power/regulator.h +2 -0
index 200652cb3d7..bb07a814c79 100644
@@ -7,6 +7,8 @@
 #ifndef _INCLUDE_REGULATOR_H_
 #define _INCLUDE_REGULATOR_H_
 
+#include <linux/errno.h>
+
 struct udevice;
 
 /**
include/remoteproc.h +1 -0
index a11dc8a9b6c..91a88791a47 100644
@@ -14,6 +14,7 @@
  * platforms have moved to dm/fdt.
  */
 #include <dm/platdata.h>	/* For platform data support - non dt world */
+#include <linux/errno.h>
 
 /**
  * struct fw_rsc_hdr - firmware resource entry header
include/soc.h +2 -0
index 850db28b76a..b8cfc507706 100644
@@ -7,6 +7,8 @@
 #ifndef __SOC_H
 #define __SOC_H
 
+#include <linux/errno.h>
+
 #define SOC_MAX_STR_SIZE	128
 
 struct udevice;
include/spi-mem.h +2 -0
index b07cf2ed83d..3c8e95b6f53 100644
@@ -11,6 +11,8 @@
 #ifndef __UBOOT_SPI_MEM_H
 #define __UBOOT_SPI_MEM_H
 
+#include <linux/errno.h>
+
 struct udevice;
 
 #define SPI_MEM_OP_CMD(__opcode, __buswidth)			\
include/sysinfo.h +2 -0
index f2c1aa29d18..524c7d6b223 100644
@@ -7,6 +7,8 @@
 #ifndef __SYSINFO_H__
 #define __SYSINFO_H__
 
+#include <linux/errno.h>
+
 struct udevice;
 
 /*
include/tlv_eeprom.h +2 -0
index fd45e5f6ebb..2b1e19b2bdd 100644
@@ -7,6 +7,8 @@
 #ifndef __TLV_EEPROM_H_
 #define __TLV_EEPROM_H_
 
+#include <linux/errno.h>
+
 /*
  *  The Definition of the TlvInfo EEPROM format can be found at onie.org or
  *  github.com/onie
Signature · 1 line
2.42.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · On Thu, Jan 18, 2024 at 07:10:47PM +0100, [email protected] wrote:

From: Max Krummenacher <[email protected]>

These headers follow the pattern:

| #if CONFIG_IS_ENABLED(FANCY_FEATURE)
|   void foo(void);
| #else
|   static inline void foo(void) { return -ENOSYS; }
| #endif
Quoted 7 lines

In the #else path ENOSYS is used, however linux/errno.h is not included. If errno.h has not been included already the compiler errors out even if the inline function is not referenced.

Make those headers self contained.

Reviewed-by on v1 1/1
#2 lore raw
In reply to [email protected]
Quoted 10 lines · On Thu, Jan 18, 2024 at 07:10:47PM +0100, [email protected] wrote:

From: Max Krummenacher <[email protected]>

These headers follow the pattern:

| #if CONFIG_IS_ENABLED(FANCY_FEATURE)
|   void foo(void);
| #else
|   static inline void foo(void) { return -ENOSYS; }
| #endif
Quoted 7 lines

In the #else path ENOSYS is used, however linux/errno.h is not included. If errno.h has not been included already the compiler errors out even if the inline function is not referenced.

Make those headers self contained.

Signature · 1 line
Tom
#3 lore raw
In reply to [email protected]
Quoted 14 lines · On Thu, Jan 18, 2024 at 07:10:47PM +0100, [email protected] wrote:

From: Max Krummenacher <[email protected]>

These headers follow the pattern:

| #if CONFIG_IS_ENABLED(FANCY_FEATURE)
|   void foo(void);
| #else
|   static inline void foo(void) { return -ENOSYS; }
| #endif

In the #else path ENOSYS is used, however linux/errno.h is not included. If errno.h has not been included already the compiler errors out even if the inline function is not referenced.

Quoted 5 lines

Make those headers self contained.

Applied to u-boot/master, thanks!

Signature · 1 line
Tom