[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251029133323.24565-1-ansuelsmth@gmail.com>
Date: Wed, 29 Oct 2025 14:33:19 +0100
From: Christian Marangi <ansuelsmth@...il.com>
To: Ilia Lin <ilia.lin@...nel.org>,
	"Rafael J. Wysocki" <rafael@...nel.org>,
	Viresh Kumar <viresh.kumar@...aro.org>,
	Bjorn Andersson <andersson@...nel.org>,
	Konrad Dybcio <konradybcio@...nel.org>,
	Christian Marangi <ansuelsmth@...il.com>,
	Raag Jadav <raag.jadav@...el.com>,
	Arnd Bergmann <arnd@...db.de>,
	Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
	linux-arm-msm@...r.kernel.org,
	linux-pm@...r.kernel.org,
	linux-kernel@...r.kernel.org
Subject: [PATCH 1/3] err.h: add ERR_PTR_CONST macro
Add ERR_PTR_CONST macro to initialize global variables with error
pointers. This might be useful for specific case where there is a global
variables initialized to an error condition and then later set to the
real handle once probe finish/completes.
Signed-off-by: Christian Marangi <ansuelsmth@...il.com>
---
 include/linux/err.h | 8 ++++++++
 1 file changed, 8 insertions(+)
diff --git a/include/linux/err.h b/include/linux/err.h
index 1d60aa86db53..a38071881b20 100644
--- a/include/linux/err.h
+++ b/include/linux/err.h
@@ -41,6 +41,14 @@ static inline void * __must_check ERR_PTR(long error)
 	return (void *) error;
 }
 
+/**
+ * ERR_PTR_CONST - define a const error pointer.
+ * @error: A negative error code.
+ *
+ * Like ERR_PTR(), but usable to initialize global variables.
+ */
+#define ERR_PTR_CONST(error) ((void *)(error))
+
 /* Return the pointer in the percpu address space. */
 #define ERR_PTR_PCPU(error) ((void __percpu *)(unsigned long)ERR_PTR(error))
 
-- 
2.51.0
Powered by blists - more mailing lists
 
