]> git.ipfire.org Git - people/ms/linux.git/blobdiff - drivers/infiniband/hw/qib/qib_verbs.c
IB/{hfi1,qib}: Cleanup open coded sge sizing
[people/ms/linux.git] / drivers / infiniband / hw / qib / qib_verbs.c
index ff8dab8e234429c74224bd55553dcdddac3fc980..5ff32d32c61c86f9058a2a74c16f069eb3305809 100644 (file)
@@ -144,12 +144,8 @@ static u32 qib_count_sge(struct rvt_sge_state *ss, u32 length)
        u32 ndesc = 1;  /* count the header */
 
        while (length) {
-               u32 len = sge.length;
+               u32 len = rvt_get_sge_length(&sge, length);
 
-               if (len > length)
-                       len = length;
-               if (len > sge.sge_length)
-                       len = sge.sge_length;
                if (((long) sge.vaddr & (sizeof(u32) - 1)) ||
                    (len != length && (len & (sizeof(u32) - 1)))) {
                        ndesc = 0;
@@ -186,12 +182,8 @@ static void qib_copy_from_sge(void *data, struct rvt_sge_state *ss, u32 length)
        struct rvt_sge *sge = &ss->sge;
 
        while (length) {
-               u32 len = sge->length;
+               u32 len = rvt_get_sge_length(sge, length);
 
-               if (len > length)
-                       len = length;
-               if (len > sge->sge_length)
-                       len = sge->sge_length;
                memcpy(data, sge->vaddr, len);
                sge->vaddr += len;
                sge->length -= len;
@@ -440,13 +432,9 @@ static void copy_io(u32 __iomem *piobuf, struct rvt_sge_state *ss,
        u32 last;
 
        while (1) {
-               u32 len = ss->sge.length;
+               u32 len = rvt_get_sge_length(&ss->sge, length);
                u32 off;
 
-               if (len > length)
-                       len = length;
-               if (len > ss->sge.sge_length)
-                       len = ss->sge.sge_length;
                /* If the source address is not aligned, try to align it. */
                off = (unsigned long)ss->sge.vaddr & (sizeof(u32) - 1);
                if (off) {