diff --git a/drivers/crypto/ccp/ccp-crypto-main.c b/drivers/crypto/ccp/ccp-crypto-main.c index 20dc848481e703b0867e6e460ff35184c705bdc5..4d4e016d755b0737368e9acef3052dd694ecf291 100644 --- a/drivers/crypto/ccp/ccp-crypto-main.c +++ b/drivers/crypto/ccp/ccp-crypto-main.c @@ -367,6 +367,10 @@ static int ccp_crypto_init(void) { int ret; + ret = ccp_present(); + if (ret) + return ret; + spin_lock_init(&req_queue_lock); INIT_LIST_HEAD(&req_queue.cmds); req_queue.backlog = &req_queue.cmds; diff --git a/drivers/crypto/ccp/ccp-dev.c b/drivers/crypto/ccp/ccp-dev.c index a7d110652a748e74ad6b562ad26fd4520426a34e..c6e6171eb6d31f764ab8e944174323f3a8ee5006 100644 --- a/drivers/crypto/ccp/ccp-dev.c +++ b/drivers/crypto/ccp/ccp-dev.c @@ -54,6 +54,20 @@ static inline void ccp_del_device(struct ccp_device *ccp) ccp_dev = NULL; } +/** + * ccp_present - check if a CCP device is present + * + * Returns zero if a CCP device is present, -ENODEV otherwise. + */ +int ccp_present(void) +{ + if (ccp_get_device()) + return 0; + + return -ENODEV; +} +EXPORT_SYMBOL_GPL(ccp_present); + /** * ccp_enqueue_cmd - queue an operation for processing by the CCP * diff --git a/include/linux/ccp.h b/include/linux/ccp.h index ebcc9d1462198d990a9a473f0fecd435045f7b53..7f437036baa4bec9efa4fd1f8b619f9849889218 100644 --- a/include/linux/ccp.h +++ b/include/linux/ccp.h @@ -26,6 +26,13 @@ struct ccp_cmd; #if defined(CONFIG_CRYPTO_DEV_CCP_DD) || \ defined(CONFIG_CRYPTO_DEV_CCP_DD_MODULE) +/** + * ccp_present - check if a CCP device is present + * + * Returns zero if a CCP device is present, -ENODEV otherwise. + */ +int ccp_present(void); + /** * ccp_enqueue_cmd - queue an operation for processing by the CCP * @@ -53,6 +60,11 @@ int ccp_enqueue_cmd(struct ccp_cmd *cmd); #else /* CONFIG_CRYPTO_DEV_CCP_DD is not enabled */ +static inline int ccp_present(void) +{ + return -ENODEV; +} + static inline int ccp_enqueue_cmd(struct ccp_cmd *cmd) { return -ENODEV;