crypto: inside-secure - use the error handler for invalidation requests
authorAntoine Tenart <antoine.tenart@bootlin.com>
Tue, 29 May 2018 12:13:43 +0000 (14:13 +0200)
committerHerbert Xu <herbert@gondor.apana.org.au>
Fri, 22 Jun 2018 15:03:00 +0000 (23:03 +0800)
This patch reworks the way invalidation request handlers handle the
result descriptor errors, to use the common error handling function.
This improves the drivers in terms of readability and maintainability.

Suggested-by: Ofer Heifetz <oferh@marvell.com>
Signed-off-by: Antoine Tenart <antoine.tenart@bootlin.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/inside-secure/safexcel_cipher.c
drivers/crypto/inside-secure/safexcel_hash.c

index 6bb60fda204397077bf06eb6b476c98167cb28c3..5bc0afc8e63a4b2fd50ada8e7b394f455796704c 100644 (file)
@@ -491,11 +491,8 @@ static int safexcel_handle_inv_result(struct safexcel_crypto_priv *priv,
                        break;
                }
 
-               if (rdesc->result_data.error_code) {
-                       dev_err(priv->dev, "cipher: invalidate: result descriptor error (%d)\n",
-                               rdesc->result_data.error_code);
-                       *ret = -EIO;
-               }
+               if (likely(!*ret))
+                       *ret = safexcel_rdesc_check_errors(priv, rdesc);
 
                ndesc++;
        } while (!rdesc->last_seg);
index c77b0e1655a8357f100bc820dde88afdb82570a4..9c1ba7f4f11e2ea6d7fcc79bbd9936a0418f234f 100644 (file)
@@ -369,11 +369,8 @@ static int safexcel_handle_inv_result(struct safexcel_crypto_priv *priv,
                dev_err(priv->dev,
                        "hash: invalidate: could not retrieve the result descriptor\n");
                *ret = PTR_ERR(rdesc);
-       } else if (rdesc->result_data.error_code) {
-               dev_err(priv->dev,
-                       "hash: invalidate: result descriptor error (%d)\n",
-                       rdesc->result_data.error_code);
-               *ret = -EINVAL;
+       } else {
+               *ret = safexcel_rdesc_check_errors(priv, rdesc);
        }
 
        safexcel_complete(priv, ring);