mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Christian Melki <christian.melki@t2data.com>
To: barebox@lists.infradead.org
Subject: [PATCH] machine_id: Add getter of machine id hashables.
Date: Tue, 17 Oct 2023 21:18:33 +0200	[thread overview]
Message-ID: <20231017191833.1092768-1-christian.melki@t2data.com> (raw)

Add the possibility for reusing the registered
hashables for other functions beside machine id
and the truncated sha1 it offers.

Signed-off-by: Christian Melki <christian.melki@t2data.com>
---
 common/machine_id.c  | 5 +++++
 include/machine_id.h | 7 +++++++
 2 files changed, 12 insertions(+)

diff --git a/common/machine_id.c b/common/machine_id.c
index 8c273b9349..f0b148fb9b 100644
--- a/common/machine_id.c
+++ b/common/machine_id.c
@@ -16,6 +16,11 @@
 static void *__machine_id_hashable;
 static size_t __machine_id_hashable_length;
 
+const void *machine_id_get_hashable(size_t *len)
+{
+	*len = __machine_id_hashable_length;
+	return __machine_id_hashable;
+}
 
 void machine_id_set_hashable(const void *hashable, size_t len)
 {
diff --git a/include/machine_id.h b/include/machine_id.h
index e30bbada1a..9699e7f207 100644
--- a/include/machine_id.h
+++ b/include/machine_id.h
@@ -5,10 +5,17 @@
 
 #if IS_ENABLED(CONFIG_MACHINE_ID)
 
+const void *machine_id_get_hashable(size_t *len);
+
 void machine_id_set_hashable(const void *hashable, size_t len);
 
 #else
 
+static inline const void *machine_id_get_hashable(size_t *len)
+{
+	return NULL;
+}
+
 static inline void machine_id_set_hashable(const void *hashable, size_t len)
 {
 }
-- 
2.34.1




             reply	other threads:[~2023-10-17 19:20 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-17 19:18 Christian Melki [this message]
2023-10-18  8:20 ` Sascha Hauer

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=20231017191833.1092768-1-christian.melki@t2data.com \
    --to=christian.melki@t2data.com \
    --cc=barebox@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