Re: [PATCH] [v2] nvme: keyring: fix conditional compilation

From: Arnd Bergmann
Date: Wed Oct 25 2023 - 03:46:21 EST


On Wed, Oct 25, 2023, at 09:02, Hannes Reinecke wrote:
> On 10/20/23 22:54, Arnd Bergmann wrote:
oid)
>> +
>> +static inline key_serial_t nvme_target_keyring_id(void)
>> {
>> + if (IS_ENABLED(CONFIG_NVME_TARGET_TCP_TLS))
>> + return nvme_keyring_id();
>> +
>> return 0;
>> }
>> -static inline int nvme_keyring_init(void)
>> +
>> +static inline int nvme_target_keyring_init(void)
>> {
>> + if (IS_ENABLED(CONFIG_NVME_TCP_TLS))
>> + return nvme_keyring_init();
>> +
>> return 0;
>> }
>> -static inline void nvme_keyring_exit(void) {}
>>
>> -#endif /* !CONFIG_NVME_KEYRING */
>> +static inline void nvme_target_keyring_exit(void)
>> +{
>> + if (IS_ENABLED(CONFIG_NVME_TARGET_TCP_TLS))
>> + nvme_keyring_exit();
>> +}
>> +
>> #endif /* _NVME_KEYRING_H */
>
> I guess the right way is to make 'keyring' a 'real' module, and move
> 'nvme_keyring_init()' and 'nvme_keyring_exit()' as the modules init/exit
> functions. I'll prepare a patch.

That's probably a good idea, but you still need to address
the link failure for nvme_keyring_id() and nvme_tls_psk_default()
when the caller is built-in and the definition is in a loadable
module.

Arnd