Merge branch 'devel-stable' into for-linus
[pandora-kernel.git] / drivers / crypto / mv_cesa.c
index a2d9e39..3cf303e 100644 (file)
@@ -133,7 +133,6 @@ struct mv_req_hash_ctx {
        int extra_bytes;        /* unprocessed bytes in buffer */
        enum hash_op op;
        int count_add;
-       struct scatterlist dummysg;
 };
 
 static void compute_aes_dec_key(struct mv_ctx *ctx)
@@ -482,7 +481,7 @@ static int count_sgs(struct scatterlist *sl, unsigned int total_bytes)
        int i = 0;
        size_t cur_len;
 
-       while (1) {
+       while (sl) {
                cur_len = sl[i].length;
                ++i;
                if (total_bytes > cur_len)
@@ -525,12 +524,6 @@ static void mv_start_new_hash_req(struct ahash_request *req)
        hw_bytes = req->nbytes + ctx->extra_bytes;
        old_extra_bytes = ctx->extra_bytes;
 
-       if (unlikely(ctx->extra_bytes)) {
-               memcpy(cpg->sram + SRAM_DATA_IN_START, ctx->buffer,
-                      ctx->extra_bytes);
-               p->crypt_len = ctx->extra_bytes;
-       }
-
        ctx->extra_bytes = hw_bytes % SHA1_BLOCK_SIZE;
        if (ctx->extra_bytes != 0
            && (!ctx->last_chunk || ctx->count > MAX_HW_HASH_SIZE))
@@ -546,6 +539,12 @@ static void mv_start_new_hash_req(struct ahash_request *req)
                p->complete = mv_hash_algo_completion;
                p->process = mv_process_hash_current;
 
+               if (unlikely(old_extra_bytes)) {
+                       memcpy(cpg->sram + SRAM_DATA_IN_START, ctx->buffer,
+                              old_extra_bytes);
+                       p->crypt_len = old_extra_bytes;
+               }
+
                mv_process_hash_current(1);
        } else {
                copy_src_to_buf(p, ctx->buffer + old_extra_bytes,
@@ -711,10 +710,7 @@ static int mv_hash_update(struct ahash_request *req)
 static int mv_hash_final(struct ahash_request *req)
 {
        struct mv_req_hash_ctx *ctx = ahash_request_ctx(req);
-       /* dummy buffer of 4 bytes */
-       sg_init_one(&ctx->dummysg, ctx->buffer, 4);
-       /* I think I'm allowed to do that... */
-       ahash_request_set_crypt(req, &ctx->dummysg, req->result, 0);
+
        mv_update_hash_req_ctx(ctx, 1, 0);
        return mv_handle_req(&req->base);
 }