crypto: tegra-se: Use sg_next to get next sg
Mallikarjun Kasoju [Wed, 9 May 2012 12:54:17 +0000 (17:54 +0530)]
Use sg_next to get next sg

Bug 958431

Signed-off-by: Mallikarjun Kasoju <mkasoju@nvidia.com>

Change-Id: I14aa7c9c551d0230b9c5b681a2699dd5355d0a6d
Reviewed-on: http://git-master/r/98449
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Mallikarjun Kasoju <mkasoju@nvidia.com>
Tested-by: Mallikarjun Kasoju <mkasoju@nvidia.com>
Reviewed-by: Venkat Moganty <vmoganty@nvidia.com>

drivers/crypto/tegra-se.c

index 3d2e918..8332416 100644 (file)
@@ -622,9 +622,12 @@ static int tegra_se_count_sgs(struct scatterlist *sl, u32 total_bytes)
                return 0;
 
        do {
-               total_bytes -= min(sl[i].length, total_bytes);
+               if (!sl->length)
+                       return 0;
+               total_bytes -= min(sl->length, total_bytes);
                i++;
-       } while (total_bytes);
+               sl = sg_next(sl);
+       } while (total_bytes && sl);
 
        return i;
 }
@@ -846,7 +849,7 @@ static int tegra_se_aes_queue_req(struct ablkcipher_request *req)
        bool idle = true;
        int err = 0;
 
-       if (!req->nbytes)
+       if (!tegra_se_count_sgs(req->src, req->nbytes))
                return -EINVAL;
 
        spin_lock_irqsave(&se_dev->lock, flags);