USB: use DIV_ROUND_UP
[firefly-linux-kernel-4.4.55.git] / drivers / usb / misc / usbtest.c
index da922dfc0dccfefa3c308d35301580fe1e39d82f..17100471e461fcf1637a6eaeda531f19eb011974 100644 (file)
@@ -378,6 +378,7 @@ alloc_sglist (int nents, int max, int vary)
        sg = kmalloc (nents * sizeof *sg, GFP_KERNEL);
        if (!sg)
                return NULL;
+       sg_init_table(sg, nents);
 
        for (i = 0; i < nents; i++) {
                char            *buf;
@@ -390,7 +391,7 @@ alloc_sglist (int nents, int max, int vary)
                }
 
                /* kmalloc pages are always physically contiguous! */
-               sg_init_one(&sg[i], buf, size);
+               sg_set_buf(&sg[i], buf, size);
 
                switch (pattern) {
                case 0:
@@ -1403,7 +1404,7 @@ static struct urb *iso_alloc_urb (
                return NULL;
        maxp = 0x7ff & le16_to_cpu(desc->wMaxPacketSize);
        maxp *= 1 + (0x3 & (le16_to_cpu(desc->wMaxPacketSize) >> 11));
-       packets = (bytes + maxp - 1) / maxp;
+       packets = DIV_ROUND_UP(bytes, maxp);
 
        urb = usb_alloc_urb (packets, GFP_KERNEL);
        if (!urb)