]> Pileus Git - ~andy/linux/commitdiff
staging: usbip: replaced pointer arithmetic, and strongly type function return.
authorBart Westgeest <bart@elbrys.com>
Wed, 10 Oct 2012 17:34:25 +0000 (13:34 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 22 Oct 2012 20:36:28 +0000 (13:36 -0700)
Replaced pointer arithmetic by using array indexing, and changed
function return type for usbip_alloc_iso_desc_pdu from 'void*' to
'struct usbip_iso_packet_descriptor'.

Signed-off-by: Bart Westgeest <bart@elbrys.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/usbip/stub_tx.c
drivers/staging/usbip/usbip_common.c
drivers/staging/usbip/usbip_common.h
drivers/staging/usbip/vhci_tx.c

index 023fda305be292a89be270b146da9321d43eeba8..1c37b5d888bc8845feb64220aa95b5bb2811b450 100644 (file)
@@ -166,7 +166,7 @@ static int stub_send_ret_submit(struct stub_device *sdev)
                int ret;
                struct urb *urb = priv->urb;
                struct usbip_header pdu_header;
-               void *iso_buffer = NULL;
+               struct usbip_iso_packet_descriptor *iso_buffer = NULL;
                struct kvec *iov = NULL;
                int iovnum = 0;
 
index 57f11f9cd8a583517cf4b16b2ddc722b6e84d967..ec7a8853d07353256e22543c26f0bf0197c2af7a 100644 (file)
@@ -639,28 +639,26 @@ static void usbip_pack_iso(struct usbip_iso_packet_descriptor *iso,
 }
 
 /* must free buffer */
-void *usbip_alloc_iso_desc_pdu(struct urb *urb, ssize_t *bufflen)
+struct usbip_iso_packet_descriptor*
+usbip_alloc_iso_desc_pdu(struct urb *urb, ssize_t *bufflen)
 {
-       void *buff;
        struct usbip_iso_packet_descriptor *iso;
        int np = urb->number_of_packets;
        ssize_t size = np * sizeof(*iso);
        int i;
 
-       buff = kzalloc(size, GFP_KERNEL);
-       if (!buff)
+       iso = kzalloc(size, GFP_KERNEL);
+       if (!iso)
                return NULL;
 
        for (i = 0; i < np; i++) {
-               iso = buff + (i * sizeof(*iso));
-
-               usbip_pack_iso(iso, &urb->iso_frame_desc[i], 1);
-               usbip_iso_packet_correct_endian(iso, 1);
+               usbip_pack_iso(&iso[i], &urb->iso_frame_desc[i], 1);
+               usbip_iso_packet_correct_endian(&iso[i], 1);
        }
 
        *bufflen = size;
 
-       return buff;
+       return iso;
 }
 EXPORT_SYMBOL_GPL(usbip_alloc_iso_desc_pdu);
 
@@ -703,11 +701,10 @@ int usbip_recv_iso(struct usbip_device *ud, struct urb *urb)
                return -EPIPE;
        }
 
+       iso = (struct usbip_iso_packet_descriptor *) buff;
        for (i = 0; i < np; i++) {
-               iso = buff + (i * sizeof(*iso));
-
-               usbip_iso_packet_correct_endian(iso, 0);
-               usbip_pack_iso(iso, &urb->iso_frame_desc[i], 0);
+               usbip_iso_packet_correct_endian(&iso[i], 0);
+               usbip_pack_iso(&iso[i], &urb->iso_frame_desc[i], 0);
                total_length += urb->iso_frame_desc[i].actual_length;
        }
 
index 5d89c0fd6f7bb2f79a4b068bc94f10b814ca50ca..7e6c5436d972f6201a19cbc691e3a4cbfac6f528 100644 (file)
@@ -320,7 +320,9 @@ void usbip_pack_pdu(struct usbip_header *pdu, struct urb *urb, int cmd,
                    int pack);
 void usbip_header_correct_endian(struct usbip_header *pdu, int send);
 
-void *usbip_alloc_iso_desc_pdu(struct urb *urb, ssize_t *bufflen);
+struct usbip_iso_packet_descriptor*
+usbip_alloc_iso_desc_pdu(struct urb *urb, ssize_t *bufflen);
+
 /* some members of urb must be substituted before. */
 int usbip_recv_iso(struct usbip_device *ud, struct urb *urb);
 void usbip_pad_iso(struct usbip_device *ud, struct urb *urb);
index 9b437e7ef1a764032a6c63e23852a1e62440d8ae..b1f0dcd68f5592c28dd57997d7604c37ebf409c3 100644 (file)
@@ -76,7 +76,7 @@ static int vhci_send_cmd_submit(struct vhci_device *vdev)
                int ret;
                struct urb *urb = priv->urb;
                struct usbip_header pdu_header;
-               void *iso_buffer = NULL;
+               struct usbip_iso_packet_descriptor *iso_buffer = NULL;
 
                txsize = 0;
                memset(&pdu_header, 0, sizeof(pdu_header));