[RFC v3 26/27] rust: add bindings for hash_info

alistair23@gmail.com posted 27 patches 1 month, 2 weeks ago
[RFC v3 26/27] rust: add bindings for hash_info
Posted by alistair23@gmail.com 1 month, 2 weeks ago
From: Alistair Francis <alistair.francis@wdc.com>

C code can get the hash_digest_size by indexing into the global
hash_digest_size array. We can't do that in the Rust code, so let's add
a Rust helper function to allow us to get the hash_digest_size.

Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
---
 rust/helpers/hash_info.c | 8 ++++++++
 rust/helpers/helpers.c   | 1 +
 2 files changed, 9 insertions(+)
 create mode 100644 rust/helpers/hash_info.c

diff --git a/rust/helpers/hash_info.c b/rust/helpers/hash_info.c
new file mode 100644
index 000000000000..d2cbc08b57d1
--- /dev/null
+++ b/rust/helpers/hash_info.c
@@ -0,0 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
+
+#include <crypto/hash_info.h>
+
+int rust_helper_get_hash_digest_size(uint32_t offset)
+{
+	return hash_digest_size[offset];
+}
diff --git a/rust/helpers/helpers.c b/rust/helpers/helpers.c
index 4b08b4f1d3a3..34db9eb5e43e 100644
--- a/rust/helpers/helpers.c
+++ b/rust/helpers/helpers.c
@@ -31,6 +31,7 @@
 #include "drm.c"
 #include "err.c"
 #include "hash.c"
+#include "hash_info.c"
 #include "irq.c"
 #include "fs.c"
 #include "io.c"
-- 
2.52.0