Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 66591015 authored by Thomas Pugliese's avatar Thomas Pugliese Committed by Greg Kroah-Hartman
Browse files

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: default avatarThomas Pugliese <thomas.pugliese@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 79731cbd
Loading
Loading
Loading
Loading
+9 −6
Original line number Original line Diff line number Diff line
@@ -125,10 +125,13 @@ struct wa_seg {
	u8 xfer_extra[];		/* xtra space for xfer_hdr_ctl */
	u8 xfer_extra[];		/* xtra space for xfer_hdr_ctl */
};
};


static void wa_seg_init(struct wa_seg *seg)
static inline void wa_seg_init(struct wa_seg *seg)
{
{
	/* usb_init_urb() repeats a lot of work, so we do it here */
	usb_init_urb(&seg->urb);
	kref_init(&seg->urb.kref);

	/* set the remaining memory to 0. */
	memset(((void *)seg) + sizeof(seg->urb), 0,
		sizeof(*seg) - sizeof(seg->urb));
}
}


/*
/*
@@ -731,9 +734,9 @@ static int __wa_xfer_setup_segs(struct wa_xfer *xfer, size_t xfer_hdr_size)
	buf_itr = 0;
	buf_itr = 0;
	buf_size = xfer->urb->transfer_buffer_length;
	buf_size = xfer->urb->transfer_buffer_length;
	for (cnt = 0; cnt < xfer->segs; cnt++) {
	for (cnt = 0; cnt < xfer->segs; cnt++) {
		seg = xfer->seg[cnt] = kzalloc(alloc_size, GFP_ATOMIC);
		seg = xfer->seg[cnt] = kmalloc(alloc_size, GFP_ATOMIC);
		if (seg == NULL)
		if (seg == NULL)
			goto error_seg_kzalloc;
			goto error_seg_kmalloc;
		wa_seg_init(seg);
		wa_seg_init(seg);
		seg->xfer = xfer;
		seg->xfer = xfer;
		seg->index = cnt;
		seg->index = cnt;
@@ -807,7 +810,7 @@ error_sg_alloc:
error_dto_alloc:
error_dto_alloc:
	kfree(xfer->seg[cnt]);
	kfree(xfer->seg[cnt]);
	cnt--;
	cnt--;
error_seg_kzalloc:
error_seg_kmalloc:
	/* use the fact that cnt is left at were it failed */
	/* use the fact that cnt is left at were it failed */
	for (; cnt >= 0; cnt--) {
	for (; cnt >= 0; cnt--) {
		if (xfer->seg[cnt] && xfer->is_inbound == 0) {
		if (xfer->seg[cnt] && xfer->is_inbound == 0) {