I'm writing a Linux kernel module, which is builtin to kernel image. The module's init function, i.e. module_init(myinit)
, is thus called during boot. Inside myinit
, I need to do a SHA1 hash operation. However, the function crypto_alloc_hash("sha1", 0, CRYPTO_ALG_ASYNC);
returns -2. My guess is that myinit
is called before crypto library's init function, so the SHA1 algorithm has not been registered yet.
I then tried to use late_initcall
instead of module_init
. It worked. I think it's ugly. What if the crypto module is also using late_initcall
? How many modules are there and how many init levels are enough?
Is there a better way to do it? E.g. by specifying module dependency, or, wait for an event that signifies completion of crypto library loading.