OpenSBI Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Jones <ajones@ventanamicro.com>
To: opensbi@lists.infradead.org
Subject: [PATCH v6 6/7] lib: sbi: Remove 0/1 probe implementations
Date: Mon, 15 May 2023 13:12:39 +0200	[thread overview]
Message-ID: <20230515111240.95059-7-ajones@ventanamicro.com> (raw)
In-Reply-To: <20230515111240.95059-1-ajones@ventanamicro.com>

When a probe implementation just returns zero for not available and
one for available then we don't need it, as the extension won't be
registered at all if it would return zero and the Base extension
probe function will already set out_val to 1 if not probe function
is implemented. Currently all probe functions only return zero or
one, so remove them all.

Signed-off-by: Andrew Jones <ajones@ventanamicro.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
---
 lib/sbi/sbi_ecall_cppc.c |  7 -------
 lib/sbi/sbi_ecall_dbcn.c |  7 -------
 lib/sbi/sbi_ecall_srst.c | 18 +++++-------------
 lib/sbi/sbi_ecall_susp.c | 17 +++++------------
 4 files changed, 10 insertions(+), 39 deletions(-)

diff --git a/lib/sbi/sbi_ecall_cppc.c b/lib/sbi/sbi_ecall_cppc.c
index a6398ac78226..b54d54ec684c 100644
--- a/lib/sbi/sbi_ecall_cppc.c
+++ b/lib/sbi/sbi_ecall_cppc.c
@@ -49,12 +49,6 @@ static int sbi_ecall_cppc_handler(unsigned long extid, unsigned long funcid,
 	return ret;
 }
 
-static int sbi_ecall_cppc_probe(unsigned long extid, unsigned long *out_val)
-{
-	*out_val = sbi_cppc_get_device() ? 1 : 0;
-	return 0;
-}
-
 struct sbi_ecall_extension ecall_cppc;
 
 static int sbi_ecall_cppc_register_extensions(void)
@@ -69,6 +63,5 @@ struct sbi_ecall_extension ecall_cppc = {
 	.extid_start		= SBI_EXT_CPPC,
 	.extid_end		= SBI_EXT_CPPC,
 	.register_extensions	= sbi_ecall_cppc_register_extensions,
-	.probe			= sbi_ecall_cppc_probe,
 	.handle			= sbi_ecall_cppc_handler,
 };
diff --git a/lib/sbi/sbi_ecall_dbcn.c b/lib/sbi/sbi_ecall_dbcn.c
index cbb2e802e615..e0b892c2ed6b 100644
--- a/lib/sbi/sbi_ecall_dbcn.c
+++ b/lib/sbi/sbi_ecall_dbcn.c
@@ -58,12 +58,6 @@ static int sbi_ecall_dbcn_handler(unsigned long extid, unsigned long funcid,
 	return SBI_ENOTSUPP;
 }
 
-static int sbi_ecall_dbcn_probe(unsigned long extid, unsigned long *out_val)
-{
-	*out_val = sbi_console_get_device() ? 1 : 0;
-	return 0;
-}
-
 struct sbi_ecall_extension ecall_dbcn;
 
 static int sbi_ecall_dbcn_register_extensions(void)
@@ -78,6 +72,5 @@ struct sbi_ecall_extension ecall_dbcn = {
 	.extid_start		= SBI_EXT_DBCN,
 	.extid_end		= SBI_EXT_DBCN,
 	.register_extensions	= sbi_ecall_dbcn_register_extensions,
-	.probe			= sbi_ecall_dbcn_probe,
 	.handle			= sbi_ecall_dbcn_handler,
 };
diff --git a/lib/sbi/sbi_ecall_srst.c b/lib/sbi/sbi_ecall_srst.c
index fd2dc0d251f3..dcd560d22f9d 100644
--- a/lib/sbi/sbi_ecall_srst.c
+++ b/lib/sbi/sbi_ecall_srst.c
@@ -48,7 +48,7 @@ static int sbi_ecall_srst_handler(unsigned long extid, unsigned long funcid,
 	return SBI_ENOTSUPP;
 }
 
-static int sbi_ecall_srst_probe(unsigned long extid, unsigned long *out_val)
+static bool srst_available(void)
 {
 	u32 type;
 
@@ -56,27 +56,20 @@ static int sbi_ecall_srst_probe(unsigned long extid, unsigned long *out_val)
 	 * At least one standard reset types should be supported by
 	 * the platform for SBI SRST extension to be usable.
 	 */
-
 	for (type = 0; type <= SBI_SRST_RESET_TYPE_LAST; type++) {
 		if (sbi_system_reset_supported(type,
-					SBI_SRST_RESET_REASON_NONE)) {
-			*out_val = 1;
-			return 0;
-		}
+					SBI_SRST_RESET_REASON_NONE))
+			return true;
 	}
 
-	*out_val = 0;
-	return 0;
+	return false;
 }
 
 struct sbi_ecall_extension ecall_srst;
 
 static int sbi_ecall_srst_register_extensions(void)
 {
-	unsigned long out_val;
-
-	sbi_ecall_srst_probe(SBI_EXT_SRST, &out_val);
-	if (!out_val)
+	if (!srst_available())
 		return 0;
 
 	return sbi_ecall_register_extension(&ecall_srst);
@@ -86,6 +79,5 @@ struct sbi_ecall_extension ecall_srst = {
 	.extid_start		= SBI_EXT_SRST,
 	.extid_end		= SBI_EXT_SRST,
 	.register_extensions	= sbi_ecall_srst_register_extensions,
-	.probe			= sbi_ecall_srst_probe,
 	.handle			= sbi_ecall_srst_handler,
 };
diff --git a/lib/sbi/sbi_ecall_susp.c b/lib/sbi/sbi_ecall_susp.c
index 716a6d585af7..2bfd99ae8720 100644
--- a/lib/sbi/sbi_ecall_susp.c
+++ b/lib/sbi/sbi_ecall_susp.c
@@ -23,7 +23,7 @@ static int sbi_ecall_susp_handler(unsigned long extid, unsigned long funcid,
 	return ret;
 }
 
-static int sbi_ecall_susp_probe(unsigned long extid, unsigned long *out_val)
+static bool susp_available(void)
 {
 	u32 type;
 
@@ -32,24 +32,18 @@ static int sbi_ecall_susp_probe(unsigned long extid, unsigned long *out_val)
 	 * platform for the SBI SUSP extension to be usable.
 	 */
 	for (type = 0; type <= SBI_SUSP_SLEEP_TYPE_LAST; type++) {
-		if (sbi_system_suspend_supported(type)) {
-			*out_val = 1;
-			return 0;
-		}
+		if (sbi_system_suspend_supported(type))
+			return true;
 	}
 
-	*out_val = 0;
-	return 0;
+	return false;
 }
 
 struct sbi_ecall_extension ecall_susp;
 
 static int sbi_ecall_susp_register_extensions(void)
 {
-	unsigned long out_val;
-
-	sbi_ecall_susp_probe(SBI_EXT_SUSP, &out_val);
-	if (!out_val)
+	if (!susp_available())
 		return 0;
 
 	return sbi_ecall_register_extension(&ecall_susp);
@@ -59,6 +53,5 @@ struct sbi_ecall_extension ecall_susp = {
 	.extid_start		= SBI_EXT_SUSP,
 	.extid_end		= SBI_EXT_SUSP,
 	.register_extensions	= sbi_ecall_susp_register_extensions,
-	.probe			= sbi_ecall_susp_probe,
 	.handle			= sbi_ecall_susp_handler,
 };
-- 
2.40.0



  parent reply	other threads:[~2023-05-15 11:12 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-15 11:12 [PATCH v6 0/7] lib: sbi: Ensure SBI extension is available Andrew Jones
2023-05-15 11:12 ` [PATCH v6 1/7] lib: sbi: Introduce register_extensions extension callback Andrew Jones
2023-05-21 15:26   ` Anup Patel
2023-05-15 11:12 ` [PATCH v6 2/7] lib: sbi: Narrow vendor extension range Andrew Jones
2023-05-15 13:43   ` Anup Patel
2023-05-21 15:26   ` Anup Patel
2023-05-15 11:12 ` [PATCH v6 3/7] lib: sbi: pmu: Remove unnecessary probe function Andrew Jones
2023-05-21 15:26   ` Anup Patel
2023-05-15 11:12 ` [PATCH v6 4/7] lib: sbi: Only register available extensions Andrew Jones
2023-05-21 15:31   ` Anup Patel
2023-05-15 11:12 ` [PATCH v6 5/7] lib: sbi: Optimize probe of srst/susp Andrew Jones
2023-05-21 15:31   ` Anup Patel
2023-05-15 11:12 ` Andrew Jones [this message]
2023-05-21 15:31   ` [PATCH v6 6/7] lib: sbi: Remove 0/1 probe implementations Anup Patel
2023-05-15 11:12 ` [PATCH v6 7/7] lib: sbi: Document sbi_ecall_extension members Andrew Jones
2023-05-21 15:32   ` Anup Patel

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=20230515111240.95059-7-ajones@ventanamicro.com \
    --to=ajones@ventanamicro.com \
    --cc=opensbi@lists.infradead.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