Linux ARM-MSM sub-architecture
 help / color / mirror / Atom feed
From: Christian Marangi <ansuelsmth@gmail.com>
To: Ilia Lin <ilia.lin@kernel.org>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	Viresh Kumar <viresh.kumar@linaro.org>,
	Bjorn Andersson <andersson@kernel.org>,
	Konrad Dybcio <konradybcio@kernel.org>,
	Arnd Bergmann <arnd@arndb.de>,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	Christian Marangi <ansuelsmth@gmail.com>,
	Raag Jadav <raag.jadav@intel.com>,
	linux-arm-msm@vger.kernel.org, linux-pm@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH v2 1/3] err.h: add INIT_ERR_PTR macro
Date: Fri, 31 Oct 2025 14:08:32 +0100	[thread overview]
Message-ID: <20251031130835.7953-2-ansuelsmth@gmail.com> (raw)
In-Reply-To: <20251031130835.7953-1-ansuelsmth@gmail.com>

Add INIT_ERR_PTR macro to initialize static variables with error
pointers. This might be useful for specific case where there is a static
variable initialized to an error condition and then later set to the
real handle once probe finish/completes.

This is to handle compilation problems like:

error: initializer element is not constant

where ERR_PTR can't be used.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.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..8c37be0620ab 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;
 }
 
+/**
+ * INIT_ERR_PTR - Init a const error pointer.
+ * @error: A negative error code.
+ *
+ * Like ERR_PTR(), but usable to initialize static variables.
+ */
+#define INIT_ERR_PTR(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


  reply	other threads:[~2025-10-31 13:08 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-31 13:08 [PATCH v2 0/3] cpufreq: qcom: handle ipq806x with no SMEM Christian Marangi
2025-10-31 13:08 ` Christian Marangi [this message]
2025-10-31 13:23   ` [PATCH v2 1/3] err.h: add INIT_ERR_PTR macro Andy Shevchenko
2025-10-31 13:08 ` [PATCH v2 2/3] soc: qcom: smem: better track SMEM uninitialized state Christian Marangi
2025-10-31 13:08 ` [PATCH v2 3/3] cpufreq: qcom-nvmem: add compatible fallback for ipq806x for no SMEM Christian Marangi
2025-10-31 13:26   ` Andy Shevchenko
2025-10-31 14:19     ` Christian Marangi
2025-10-31 14:34       ` Andy Shevchenko
2025-11-01 11:50         ` Christian Marangi
2025-11-02 20:23           ` Dmitry Baryshkov
2025-10-31 13:27   ` Andy Shevchenko
2025-11-01 17:42   ` Bjorn Andersson
2025-11-04 11:59     ` Christian Marangi
2025-11-04 12:13       ` Konrad Dybcio
2025-11-02 18:09 ` (subset) [PATCH v2 0/3] cpufreq: qcom: handle ipq806x with " Bjorn Andersson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251031130835.7953-2-ansuelsmth@gmail.com \
    --to=ansuelsmth@gmail.com \
    --cc=andersson@kernel.org \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=arnd@arndb.de \
    --cc=ilia.lin@kernel.org \
    --cc=konradybcio@kernel.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=raag.jadav@intel.com \
    --cc=rafael@kernel.org \
    --cc=viresh.kumar@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox