diff options
author | Axel Lin <axel.lin@gmail.com> | 2010-11-12 00:39:11 -0500 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2010-11-12 01:02:11 -0500 |
commit | 49cc69b6789b57d2d8ed78843c4219525b433b58 (patch) | |
tree | 1b831f622c242f64bb89621b2e7663c2ca2a184b /drivers/input/joystick | |
parent | 5fdbe44d033d059cc56c2803e6b4dbd8cb4e5e39 (diff) |
Input: xpad - return proper error in error path
In current implementation, xpad_probe return 0 when
usb_alloc_urb failed for xpad->bulk_out and kzalloc failed for xpad->bdata.
This patch removes the initialization for error variable,
assign the error code at the place the error happens instead.
Signed-off-by: Axel Lin <axel.lin@gmail.com>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'drivers/input/joystick')
-rw-r--r-- | drivers/input/joystick/xpad.c | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c index f9fb7fa10af..39c0265ca15 100644 --- a/drivers/input/joystick/xpad.c +++ b/drivers/input/joystick/xpad.c | |||
@@ -543,21 +543,25 @@ exit: | |||
543 | static int xpad_init_output(struct usb_interface *intf, struct usb_xpad *xpad) | 543 | static int xpad_init_output(struct usb_interface *intf, struct usb_xpad *xpad) |
544 | { | 544 | { |
545 | struct usb_endpoint_descriptor *ep_irq_out; | 545 | struct usb_endpoint_descriptor *ep_irq_out; |
546 | int error = -ENOMEM; | 546 | int error; |
547 | 547 | ||
548 | if (xpad->xtype != XTYPE_XBOX360 && xpad->xtype != XTYPE_XBOX) | 548 | if (xpad->xtype != XTYPE_XBOX360 && xpad->xtype != XTYPE_XBOX) |
549 | return 0; | 549 | return 0; |
550 | 550 | ||
551 | xpad->odata = usb_alloc_coherent(xpad->udev, XPAD_PKT_LEN, | 551 | xpad->odata = usb_alloc_coherent(xpad->udev, XPAD_PKT_LEN, |
552 | GFP_KERNEL, &xpad->odata_dma); | 552 | GFP_KERNEL, &xpad->odata_dma); |
553 | if (!xpad->odata) | 553 | if (!xpad->odata) { |
554 | error = -ENOMEM; | ||
554 | goto fail1; | 555 | goto fail1; |
556 | } | ||
555 | 557 | ||
556 | mutex_init(&xpad->odata_mutex); | 558 | mutex_init(&xpad->odata_mutex); |
557 | 559 | ||
558 | xpad->irq_out = usb_alloc_urb(0, GFP_KERNEL); | 560 | xpad->irq_out = usb_alloc_urb(0, GFP_KERNEL); |
559 | if (!xpad->irq_out) | 561 | if (!xpad->irq_out) { |
562 | error = -ENOMEM; | ||
560 | goto fail2; | 563 | goto fail2; |
564 | } | ||
561 | 565 | ||
562 | ep_irq_out = &intf->cur_altsetting->endpoint[1].desc; | 566 | ep_irq_out = &intf->cur_altsetting->endpoint[1].desc; |
563 | usb_fill_int_urb(xpad->irq_out, xpad->udev, | 567 | usb_fill_int_urb(xpad->irq_out, xpad->udev, |
@@ -789,8 +793,7 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id | |||
789 | struct usb_xpad *xpad; | 793 | struct usb_xpad *xpad; |
790 | struct input_dev *input_dev; | 794 | struct input_dev *input_dev; |
791 | struct usb_endpoint_descriptor *ep_irq_in; | 795 | struct usb_endpoint_descriptor *ep_irq_in; |
792 | int i; | 796 | int i, error; |
793 | int error = -ENOMEM; | ||
794 | 797 | ||
795 | for (i = 0; xpad_device[i].idVendor; i++) { | 798 | for (i = 0; xpad_device[i].idVendor; i++) { |
796 | if ((le16_to_cpu(udev->descriptor.idVendor) == xpad_device[i].idVendor) && | 799 | if ((le16_to_cpu(udev->descriptor.idVendor) == xpad_device[i].idVendor) && |
@@ -800,17 +803,23 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id | |||
800 | 803 | ||
801 | xpad = kzalloc(sizeof(struct usb_xpad), GFP_KERNEL); | 804 | xpad = kzalloc(sizeof(struct usb_xpad), GFP_KERNEL); |
802 | input_dev = input_allocate_device(); | 805 | input_dev = input_allocate_device(); |
803 | if (!xpad || !input_dev) | 806 | if (!xpad || !input_dev) { |
807 | error = -ENOMEM; | ||
804 | goto fail1; | 808 | goto fail1; |
809 | } | ||
805 | 810 | ||
806 | xpad->idata = usb_alloc_coherent(udev, XPAD_PKT_LEN, | 811 | xpad->idata = usb_alloc_coherent(udev, XPAD_PKT_LEN, |
807 | GFP_KERNEL, &xpad->idata_dma); | 812 | GFP_KERNEL, &xpad->idata_dma); |
808 | if (!xpad->idata) | 813 | if (!xpad->idata) { |
814 | error = -ENOMEM; | ||
809 | goto fail1; | 815 | goto fail1; |
816 | } | ||
810 | 817 | ||
811 | xpad->irq_in = usb_alloc_urb(0, GFP_KERNEL); | 818 | xpad->irq_in = usb_alloc_urb(0, GFP_KERNEL); |
812 | if (!xpad->irq_in) | 819 | if (!xpad->irq_in) { |
820 | error = -ENOMEM; | ||
813 | goto fail2; | 821 | goto fail2; |
822 | } | ||
814 | 823 | ||
815 | xpad->udev = udev; | 824 | xpad->udev = udev; |
816 | xpad->mapping = xpad_device[i].mapping; | 825 | xpad->mapping = xpad_device[i].mapping; |
@@ -929,12 +938,16 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id | |||
929 | * controller when it shows up | 938 | * controller when it shows up |
930 | */ | 939 | */ |
931 | xpad->bulk_out = usb_alloc_urb(0, GFP_KERNEL); | 940 | xpad->bulk_out = usb_alloc_urb(0, GFP_KERNEL); |
932 | if(!xpad->bulk_out) | 941 | if (!xpad->bulk_out) { |
942 | error = -ENOMEM; | ||
933 | goto fail5; | 943 | goto fail5; |
944 | } | ||
934 | 945 | ||
935 | xpad->bdata = kzalloc(XPAD_PKT_LEN, GFP_KERNEL); | 946 | xpad->bdata = kzalloc(XPAD_PKT_LEN, GFP_KERNEL); |
936 | if(!xpad->bdata) | 947 | if (!xpad->bdata) { |
948 | error = -ENOMEM; | ||
937 | goto fail6; | 949 | goto fail6; |
950 | } | ||
938 | 951 | ||
939 | xpad->bdata[2] = 0x08; | 952 | xpad->bdata[2] = 0x08; |
940 | switch (intf->cur_altsetting->desc.bInterfaceNumber) { | 953 | switch (intf->cur_altsetting->desc.bInterfaceNumber) { |