]> git.karo-electronics.de Git - mv-sheeva.git/commitdiff
[media] ttusb-budget: use goto for exception handling
authorJonathan Nieder <jrnieder@gmail.com>
Sat, 31 Dec 2011 11:01:56 +0000 (08:01 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Fri, 6 Jan 2012 14:44:22 +0000 (12:44 -0200)
Avoid some repetition by adopting the usual "goto err" idiom for error
handling.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c

index 5f6ac48198f0c5f97a81fa2f40ce404dabb2883f..8aa01149351a166e6c2bd8d2848d61068e7194db 100644 (file)
@@ -1704,10 +1704,8 @@ static int ttusb_probe(struct usb_interface *intf, const struct usb_device_id *i
        ttusb->i2c_adap.dev.parent        = &udev->dev;
 
        result = i2c_add_adapter(&ttusb->i2c_adap);
-       if (result) {
-               dvb_unregister_adapter (&ttusb->adapter);
-               return result;
-       }
+       if (result)
+               goto err_unregister_adapter;
 
        memset(&ttusb->dvb_demux, 0, sizeof(ttusb->dvb_demux));
 
@@ -1724,33 +1722,29 @@ static int ttusb_probe(struct usb_interface *intf, const struct usb_device_id *i
        ttusb->dvb_demux.stop_feed = ttusb_stop_feed;
        ttusb->dvb_demux.write_to_decoder = NULL;
 
-       if ((result = dvb_dmx_init(&ttusb->dvb_demux)) < 0) {
+       result = dvb_dmx_init(&ttusb->dvb_demux);
+       if (result < 0) {
                printk("ttusb_dvb: dvb_dmx_init failed (errno = %d)\n", result);
-               i2c_del_adapter(&ttusb->i2c_adap);
-               dvb_unregister_adapter (&ttusb->adapter);
-               return -ENODEV;
+               result = -ENODEV;
+               goto err_i2c_del_adapter;
        }
 //FIXME dmxdev (nur WAS?)
        ttusb->dmxdev.filternum = ttusb->dvb_demux.filternum;
        ttusb->dmxdev.demux = &ttusb->dvb_demux.dmx;
        ttusb->dmxdev.capabilities = 0;
 
-       if ((result = dvb_dmxdev_init(&ttusb->dmxdev, &ttusb->adapter)) < 0) {
+       result = dvb_dmxdev_init(&ttusb->dmxdev, &ttusb->adapter);
+       if (result < 0) {
                printk("ttusb_dvb: dvb_dmxdev_init failed (errno = %d)\n",
                       result);
-               dvb_dmx_release(&ttusb->dvb_demux);
-               i2c_del_adapter(&ttusb->i2c_adap);
-               dvb_unregister_adapter (&ttusb->adapter);
-               return -ENODEV;
+               result = -ENODEV;
+               goto err_release_dmx;
        }
 
        if (dvb_net_init(&ttusb->adapter, &ttusb->dvbnet, &ttusb->dvb_demux.dmx)) {
                printk("ttusb_dvb: dvb_net_init failed!\n");
-               dvb_dmxdev_release(&ttusb->dmxdev);
-               dvb_dmx_release(&ttusb->dvb_demux);
-               i2c_del_adapter(&ttusb->i2c_adap);
-               dvb_unregister_adapter (&ttusb->adapter);
-               return -ENODEV;
+               result = -ENODEV;
+               goto err_release_dmxdev;
        }
 
        usb_set_intfdata(intf, (void *) ttusb);
@@ -1758,6 +1752,16 @@ static int ttusb_probe(struct usb_interface *intf, const struct usb_device_id *i
        frontend_init(ttusb);
 
        return 0;
+
+err_release_dmxdev:
+       dvb_dmxdev_release(&ttusb->dmxdev);
+err_release_dmx:
+       dvb_dmx_release(&ttusb->dvb_demux);
+err_i2c_del_adapter:
+       i2c_del_adapter(&ttusb->i2c_adap);
+err_unregister_adapter:
+       dvb_unregister_adapter (&ttusb->adapter);
+       return result;
 }
 
 static void ttusb_disconnect(struct usb_interface *intf)