diff options
author | Thomas Pugliese <thomas.pugliese@gmail.com> | 2013-08-15 15:37:43 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-08-15 20:36:27 -0400 |
commit | 66591015d88d0b7fc88da79e2054830094ace4c9 (patch) | |
tree | 8970af4cfc9e4d4d3c44655ac8f50803a2bd3f80 /drivers/usb/wusbcore | |
parent | 79731cbd783d3693d4b84731e3cfc79b9f828170 (diff) |
USB: WUSBCORE: Use usb_init_urb instead of creating the URB manually
In wa_seg_init, use usb_init_urb to init the URB object contained in the
transfer segment instead of initializing it manually. Use kmalloc to
allocate the memory for segment instead of kzalloc and then use memset
to set the non-URB portion of the transfer segment struct to 0 since
that was already done by usb_init_urb.
Signed-off-by: Thomas Pugliese <thomas.pugliese@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/wusbcore')
-rw-r--r-- | drivers/usb/wusbcore/wa-xfer.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/drivers/usb/wusbcore/wa-xfer.c b/drivers/usb/wusbcore/wa-xfer.c index 956aab51cbda..86dd3b65692f 100644 --- a/drivers/usb/wusbcore/wa-xfer.c +++ b/drivers/usb/wusbcore/wa-xfer.c | |||
@@ -125,10 +125,13 @@ struct wa_seg { | |||
125 | u8 xfer_extra[]; /* xtra space for xfer_hdr_ctl */ | 125 | u8 xfer_extra[]; /* xtra space for xfer_hdr_ctl */ |
126 | }; | 126 | }; |
127 | 127 | ||
128 | static void wa_seg_init(struct wa_seg *seg) | 128 | static inline void wa_seg_init(struct wa_seg *seg) |
129 | { | 129 | { |
130 | /* usb_init_urb() repeats a lot of work, so we do it here */ | 130 | usb_init_urb(&seg->urb); |
131 | kref_init(&seg->urb.kref); | 131 | |
132 | /* set the remaining memory to 0. */ | ||
133 | memset(((void *)seg) + sizeof(seg->urb), 0, | ||
134 | sizeof(*seg) - sizeof(seg->urb)); | ||
132 | } | 135 | } |
133 | 136 | ||
134 | /* | 137 | /* |
@@ -731,9 +734,9 @@ static int __wa_xfer_setup_segs(struct wa_xfer *xfer, size_t xfer_hdr_size) | |||
731 | buf_itr = 0; | 734 | buf_itr = 0; |
732 | buf_size = xfer->urb->transfer_buffer_length; | 735 | buf_size = xfer->urb->transfer_buffer_length; |
733 | for (cnt = 0; cnt < xfer->segs; cnt++) { | 736 | for (cnt = 0; cnt < xfer->segs; cnt++) { |
734 | seg = xfer->seg[cnt] = kzalloc(alloc_size, GFP_ATOMIC); | 737 | seg = xfer->seg[cnt] = kmalloc(alloc_size, GFP_ATOMIC); |
735 | if (seg == NULL) | 738 | if (seg == NULL) |
736 | goto error_seg_kzalloc; | 739 | goto error_seg_kmalloc; |
737 | wa_seg_init(seg); | 740 | wa_seg_init(seg); |
738 | seg->xfer = xfer; | 741 | seg->xfer = xfer; |
739 | seg->index = cnt; | 742 | seg->index = cnt; |
@@ -807,7 +810,7 @@ error_sg_alloc: | |||
807 | error_dto_alloc: | 810 | error_dto_alloc: |
808 | kfree(xfer->seg[cnt]); | 811 | kfree(xfer->seg[cnt]); |
809 | cnt--; | 812 | cnt--; |
810 | error_seg_kzalloc: | 813 | error_seg_kmalloc: |
811 | /* use the fact that cnt is left at were it failed */ | 814 | /* use the fact that cnt is left at were it failed */ |
812 | for (; cnt >= 0; cnt--) { | 815 | for (; cnt >= 0; cnt--) { |
813 | if (xfer->seg[cnt] && xfer->is_inbound == 0) { | 816 | if (xfer->seg[cnt] && xfer->is_inbound == 0) { |