]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - drivers/crypto/sahara.c
Merge remote-tracking branch 'input-current/for-linus'
[karo-tx-linux.git] / drivers / crypto / sahara.c
index cea241125938fe1ff521f2375872da91417656ff..f68c24a98277a0263c2fa88b79b17c408591a81c 100644 (file)
@@ -173,7 +173,6 @@ struct sahara_aes_reqctx {
  * @sg_in_idx: number of hw links
  * @in_sg: scatterlist for input data
  * @in_sg_chain: scatterlists for chained input data
- * @in_sg_chained: specifies if chained scatterlists are used or not
  * @total: total number of bytes for transfer
  * @last: is this the last block
  * @first: is this the first block
@@ -191,7 +190,6 @@ struct sahara_sha_reqctx {
        unsigned int            sg_in_idx;
        struct scatterlist      *in_sg;
        struct scatterlist      in_sg_chain[2];
-       bool                    in_sg_chained;
        size_t                  total;
        unsigned int            last;
        unsigned int            first;
@@ -274,7 +272,7 @@ static u32 sahara_aes_data_link_hdr(struct sahara_dev *dev)
                        SAHARA_HDR_CHA_SKHA | SAHARA_HDR_PARITY_BIT;
 }
 
-static char *sahara_err_src[16] = {
+static const char *sahara_err_src[16] = {
        "No error",
        "Header error",
        "Descriptor length error",
@@ -293,14 +291,14 @@ static char *sahara_err_src[16] = {
        "DMA error"
 };
 
-static char *sahara_err_dmasize[4] = {
+static const char *sahara_err_dmasize[4] = {
        "Byte transfer",
        "Half-word transfer",
        "Word transfer",
        "Reserved"
 };
 
-static char *sahara_err_dmasrc[8] = {
+static const char *sahara_err_dmasrc[8] = {
        "No error",
        "AHB bus error",
        "Internal IP bus error",
@@ -311,7 +309,7 @@ static char *sahara_err_dmasrc[8] = {
        "DMA HW error"
 };
 
-static char *sahara_cha_errsrc[12] = {
+static const char *sahara_cha_errsrc[12] = {
        "Input buffer non-empty",
        "Illegal address",
        "Illegal mode",
@@ -326,7 +324,7 @@ static char *sahara_cha_errsrc[12] = {
        "Reserved"
 };
 
-static char *sahara_cha_err[4] = { "No error", "SKHA", "MDHA", "RNG" };
+static const char *sahara_cha_err[4] = { "No error", "SKHA", "MDHA", "RNG" };
 
 static void sahara_decode_error(struct sahara_dev *dev, unsigned int error)
 {
@@ -356,7 +354,7 @@ static void sahara_decode_error(struct sahara_dev *dev, unsigned int error)
        dev_err(dev->device, "\n");
 }
 
-static char *sahara_state[4] = { "Idle", "Busy", "Error", "HW Fault" };
+static const char *sahara_state[4] = { "Idle", "Busy", "Error", "HW Fault" };
 
 static void sahara_decode_status(struct sahara_dev *dev, unsigned int status)
 {
@@ -801,38 +799,19 @@ static int sahara_sha_hw_links_create(struct sahara_dev *dev,
                return -EINVAL;
        }
 
-       if (rctx->in_sg_chained) {
-               i = start;
-               sg = dev->in_sg;
-               while (sg) {
-                       ret = dma_map_sg(dev->device, sg, 1,
-                                        DMA_TO_DEVICE);
-                       if (!ret)
-                               return -EFAULT;
-
-                       dev->hw_link[i]->len = sg->length;
-                       dev->hw_link[i]->p = sg->dma_address;
+       sg = dev->in_sg;
+       ret = dma_map_sg(dev->device, dev->in_sg, dev->nb_in_sg, DMA_TO_DEVICE);
+       if (!ret)
+               return -EFAULT;
+
+       for (i = start; i < dev->nb_in_sg + start; i++) {
+               dev->hw_link[i]->len = sg->length;
+               dev->hw_link[i]->p = sg->dma_address;
+               if (i == (dev->nb_in_sg + start - 1)) {
+                       dev->hw_link[i]->next = 0;
+               } else {
                        dev->hw_link[i]->next = dev->hw_phys_link[i + 1];
                        sg = sg_next(sg);
-                       i += 1;
-               }
-               dev->hw_link[i-1]->next = 0;
-       } else {
-               sg = dev->in_sg;
-               ret = dma_map_sg(dev->device, dev->in_sg, dev->nb_in_sg,
-                                DMA_TO_DEVICE);
-               if (!ret)
-                       return -EFAULT;
-
-               for (i = start; i < dev->nb_in_sg + start; i++) {
-                       dev->hw_link[i]->len = sg->length;
-                       dev->hw_link[i]->p = sg->dma_address;
-                       if (i == (dev->nb_in_sg + start - 1)) {
-                               dev->hw_link[i]->next = 0;
-                       } else {
-                               dev->hw_link[i]->next = dev->hw_phys_link[i + 1];
-                               sg = sg_next(sg);
-                       }
                }
        }
 
@@ -980,7 +959,6 @@ static int sahara_sha_prepare_request(struct ahash_request *req)
                rctx->total = req->nbytes + rctx->buf_cnt;
                rctx->in_sg = rctx->in_sg_chain;
 
-               rctx->in_sg_chained = true;
                req->src = rctx->in_sg_chain;
        /* only data from previous operation */
        } else if (rctx->buf_cnt) {
@@ -991,13 +969,11 @@ static int sahara_sha_prepare_request(struct ahash_request *req)
                /* buf was copied into rembuf above */
                sg_init_one(rctx->in_sg, rctx->rembuf, rctx->buf_cnt);
                rctx->total = rctx->buf_cnt;
-               rctx->in_sg_chained = false;
        /* no data from previous operation */
        } else {
                rctx->in_sg = req->src;
                rctx->total = req->nbytes;
                req->src = rctx->in_sg;
-               rctx->in_sg_chained = false;
        }
 
        /* on next call, we only have the remaining data in the buffer */
@@ -1006,23 +982,6 @@ static int sahara_sha_prepare_request(struct ahash_request *req)
        return -EINPROGRESS;
 }
 
-static void sahara_sha_unmap_sg(struct sahara_dev *dev,
-                               struct sahara_sha_reqctx *rctx)
-{
-       struct scatterlist *sg;
-
-       if (rctx->in_sg_chained) {
-               sg = dev->in_sg;
-               while (sg) {
-                       dma_unmap_sg(dev->device, sg, 1, DMA_TO_DEVICE);
-                       sg = sg_next(sg);
-               }
-       } else {
-               dma_unmap_sg(dev->device, dev->in_sg, dev->nb_in_sg,
-                       DMA_TO_DEVICE);
-       }
-}
-
 static int sahara_sha_process(struct ahash_request *req)
 {
        struct sahara_dev *dev = dev_ptr;
@@ -1062,7 +1021,8 @@ static int sahara_sha_process(struct ahash_request *req)
        }
 
        if (rctx->sg_in_idx)
-               sahara_sha_unmap_sg(dev, rctx);
+               dma_unmap_sg(dev->device, dev->in_sg, dev->nb_in_sg,
+                            DMA_TO_DEVICE);
 
        memcpy(rctx->context, dev->context_base, rctx->context_size);