2021-04-15 06:04:16

by Tian Tao

[permalink] [raw]
Subject: [PATCH] crypto: ccp - Make ccp_dev_suspend and ccp_dev_resume void functions

Since ccp_dev_suspend() and ccp_dev_resume() only return 0 which causes
ret to equal 0 in sp_suspend and sp_resume, making the if condition
impossible to use. it might be a more appropriate fix to have these be
void functions and eliminate the if condition in sp_suspend() and
sp_resume().

Signed-off-by: Tian Tao <[email protected]>
---
drivers/crypto/ccp/ccp-dev.c | 12 ++++--------
drivers/crypto/ccp/sp-dev.c | 12 ++----------
drivers/crypto/ccp/sp-dev.h | 4 ++--
3 files changed, 8 insertions(+), 20 deletions(-)

diff --git a/drivers/crypto/ccp/ccp-dev.c b/drivers/crypto/ccp/ccp-dev.c
index 0971ee6..6777582 100644
--- a/drivers/crypto/ccp/ccp-dev.c
+++ b/drivers/crypto/ccp/ccp-dev.c
@@ -548,7 +548,7 @@ bool ccp_queues_suspended(struct ccp_device *ccp)
return ccp->cmd_q_count == suspended;
}

-int ccp_dev_suspend(struct sp_device *sp)
+void ccp_dev_suspend(struct sp_device *sp)
{
struct ccp_device *ccp = sp->ccp_data;
unsigned long flags;
@@ -556,7 +556,7 @@ int ccp_dev_suspend(struct sp_device *sp)

/* If there's no device there's nothing to do */
if (!ccp)
- return 0;
+ return;

spin_lock_irqsave(&ccp->cmd_lock, flags);

@@ -572,11 +572,9 @@ int ccp_dev_suspend(struct sp_device *sp)
while (!ccp_queues_suspended(ccp))
wait_event_interruptible(ccp->suspend_queue,
ccp_queues_suspended(ccp));
-
- return 0;
}

-int ccp_dev_resume(struct sp_device *sp)
+void ccp_dev_resume(struct sp_device *sp)
{
struct ccp_device *ccp = sp->ccp_data;
unsigned long flags;
@@ -584,7 +582,7 @@ int ccp_dev_resume(struct sp_device *sp)

/* If there's no device there's nothing to do */
if (!ccp)
- return 0;
+ return;

spin_lock_irqsave(&ccp->cmd_lock, flags);

@@ -597,8 +595,6 @@ int ccp_dev_resume(struct sp_device *sp)
}

spin_unlock_irqrestore(&ccp->cmd_lock, flags);
-
- return 0;
}

int ccp_dev_init(struct sp_device *sp)
diff --git a/drivers/crypto/ccp/sp-dev.c b/drivers/crypto/ccp/sp-dev.c
index 6284a15..7eb3e46 100644
--- a/drivers/crypto/ccp/sp-dev.c
+++ b/drivers/crypto/ccp/sp-dev.c
@@ -213,12 +213,8 @@ void sp_destroy(struct sp_device *sp)

int sp_suspend(struct sp_device *sp)
{
- int ret;
-
if (sp->dev_vdata->ccp_vdata) {
- ret = ccp_dev_suspend(sp);
- if (ret)
- return ret;
+ ccp_dev_suspend(sp);
}

return 0;
@@ -226,12 +222,8 @@ int sp_suspend(struct sp_device *sp)

int sp_resume(struct sp_device *sp)
{
- int ret;
-
if (sp->dev_vdata->ccp_vdata) {
- ret = ccp_dev_resume(sp);
- if (ret)
- return ret;
+ ccp_dev_resume(sp);
}

return 0;
diff --git a/drivers/crypto/ccp/sp-dev.h b/drivers/crypto/ccp/sp-dev.h
index 0218d06..e6e9f9d 100644
--- a/drivers/crypto/ccp/sp-dev.h
+++ b/drivers/crypto/ccp/sp-dev.h
@@ -134,8 +134,8 @@ struct sp_device *sp_get_psp_master_device(void);
int ccp_dev_init(struct sp_device *sp);
void ccp_dev_destroy(struct sp_device *sp);

-int ccp_dev_suspend(struct sp_device *sp);
-int ccp_dev_resume(struct sp_device *sp);
+void ccp_dev_suspend(struct sp_device *sp);
+void ccp_dev_resume(struct sp_device *sp);

#else /* !CONFIG_CRYPTO_DEV_SP_CCP */

--
2.7.4


2021-04-15 13:48:27

by Tom Lendacky

[permalink] [raw]
Subject: Re: [PATCH] crypto: ccp - Make ccp_dev_suspend and ccp_dev_resume void functions

On 4/15/21 1:03 AM, Tian Tao wrote:
> Since ccp_dev_suspend() and ccp_dev_resume() only return 0 which causes
> ret to equal 0 in sp_suspend and sp_resume, making the if condition
> impossible to use. it might be a more appropriate fix to have these be
> void functions and eliminate the if condition in sp_suspend() and
> sp_resume().
>
> Signed-off-by: Tian Tao <[email protected]>

Your patch subject should have had a v2 in it, e.g. [PATCH v2]

And please Cc: the other maintainer, who I've added via cc.

> ---
> drivers/crypto/ccp/ccp-dev.c | 12 ++++--------
> drivers/crypto/ccp/sp-dev.c | 12 ++----------
> drivers/crypto/ccp/sp-dev.h | 4 ++--
> 3 files changed, 8 insertions(+), 20 deletions(-)
>
> diff --git a/drivers/crypto/ccp/ccp-dev.c b/drivers/crypto/ccp/ccp-dev.c
> index 0971ee6..6777582 100644
> --- a/drivers/crypto/ccp/ccp-dev.c
> +++ b/drivers/crypto/ccp/ccp-dev.c
> @@ -548,7 +548,7 @@ bool ccp_queues_suspended(struct ccp_device *ccp)
> return ccp->cmd_q_count == suspended;
> }
>
> -int ccp_dev_suspend(struct sp_device *sp)
> +void ccp_dev_suspend(struct sp_device *sp)
> {
> struct ccp_device *ccp = sp->ccp_data;
> unsigned long flags;
> @@ -556,7 +556,7 @@ int ccp_dev_suspend(struct sp_device *sp)
>
> /* If there's no device there's nothing to do */
> if (!ccp)
> - return 0;
> + return;
>
> spin_lock_irqsave(&ccp->cmd_lock, flags);
>
> @@ -572,11 +572,9 @@ int ccp_dev_suspend(struct sp_device *sp)
> while (!ccp_queues_suspended(ccp))
> wait_event_interruptible(ccp->suspend_queue,
> ccp_queues_suspended(ccp));
> -
> - return 0;
> }
>
> -int ccp_dev_resume(struct sp_device *sp)
> +void ccp_dev_resume(struct sp_device *sp)
> {
> struct ccp_device *ccp = sp->ccp_data;
> unsigned long flags;
> @@ -584,7 +582,7 @@ int ccp_dev_resume(struct sp_device *sp)
>
> /* If there's no device there's nothing to do */
> if (!ccp)
> - return 0;
> + return;
>
> spin_lock_irqsave(&ccp->cmd_lock, flags);
>
> @@ -597,8 +595,6 @@ int ccp_dev_resume(struct sp_device *sp)
> }
>
> spin_unlock_irqrestore(&ccp->cmd_lock, flags);
> -
> - return 0;
> }
>
> int ccp_dev_init(struct sp_device *sp)
> diff --git a/drivers/crypto/ccp/sp-dev.c b/drivers/crypto/ccp/sp-dev.c
> index 6284a15..7eb3e46 100644
> --- a/drivers/crypto/ccp/sp-dev.c
> +++ b/drivers/crypto/ccp/sp-dev.c
> @@ -213,12 +213,8 @@ void sp_destroy(struct sp_device *sp)
>
> int sp_suspend(struct sp_device *sp)
> {
> - int ret;
> -
> if (sp->dev_vdata->ccp_vdata) {
> - ret = ccp_dev_suspend(sp);
> - if (ret)
> - return ret;
> + ccp_dev_suspend(sp);
> }
>
> return 0;
> @@ -226,12 +222,8 @@ int sp_suspend(struct sp_device *sp)
>
> int sp_resume(struct sp_device *sp)
> {
> - int ret;
> -
> if (sp->dev_vdata->ccp_vdata) {
> - ret = ccp_dev_resume(sp);
> - if (ret)
> - return ret;
> + ccp_dev_resume(sp);
> }
>
> return 0;
> diff --git a/drivers/crypto/ccp/sp-dev.h b/drivers/crypto/ccp/sp-dev.h
> index 0218d06..e6e9f9d 100644
> --- a/drivers/crypto/ccp/sp-dev.h
> +++ b/drivers/crypto/ccp/sp-dev.h
> @@ -134,8 +134,8 @@ struct sp_device *sp_get_psp_master_device(void);
> int ccp_dev_init(struct sp_device *sp);
> void ccp_dev_destroy(struct sp_device *sp);
>
> -int ccp_dev_suspend(struct sp_device *sp);
> -int ccp_dev_resume(struct sp_device *sp);
> +void ccp_dev_suspend(struct sp_device *sp);
> +void ccp_dev_resume(struct sp_device *sp);

You should also change the static inline versions of these functions below
in the #else path.

Thanks,
Tom

>
> #else /* !CONFIG_CRYPTO_DEV_SP_CCP */
>
>