Skip to content

Commit

Permalink
Input: xpad - simplify error condition in init_output
Browse files Browse the repository at this point in the history
Replace first goto with simple returns as we really are just returning
one error code.

Signed-off-by: Pavel Rojtberg <rojtberg@gmail.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
  • Loading branch information
Pavel Rojtberg authored and Dmitry Torokhov committed Jan 6, 2017
1 parent 4f88476 commit a8c34e2
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions drivers/input/joystick/xpad.c
Original file line number Diff line number Diff line change
Expand Up @@ -849,17 +849,15 @@ static int xpad_init_output(struct usb_interface *intf, struct usb_xpad *xpad)

xpad->odata = usb_alloc_coherent(xpad->udev, XPAD_PKT_LEN,
GFP_KERNEL, &xpad->odata_dma);
if (!xpad->odata) {
error = -ENOMEM;
goto fail1;
}
if (!xpad->odata)
return -ENOMEM;

spin_lock_init(&xpad->odata_lock);

xpad->irq_out = usb_alloc_urb(0, GFP_KERNEL);
if (!xpad->irq_out) {
error = -ENOMEM;
goto fail2;
goto err_free_coherent;
}

/* Xbox One controller has in/out endpoints swapped. */
Expand All @@ -875,8 +873,9 @@ static int xpad_init_output(struct usb_interface *intf, struct usb_xpad *xpad)

return 0;

fail2: usb_free_coherent(xpad->udev, XPAD_PKT_LEN, xpad->odata, xpad->odata_dma);
fail1: return error;
err_free_coherent:
usb_free_coherent(xpad->udev, XPAD_PKT_LEN, xpad->odata, xpad->odata_dma);
return error;
}

static void xpad_stop_output(struct usb_xpad *xpad)
Expand Down

0 comments on commit a8c34e2

Please sign in to comment.