diff options
author | Jonathan Nieder <jrnieder@gmail.com> | 2011-12-31 05:58:34 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2012-01-06 09:43:34 -0500 |
commit | e4b8537c974cf0f95282286e2f9e3e2476258f52 (patch) | |
tree | 0bc9c094d1382ed0f760f407c77f6cb552741f5c /drivers/media | |
parent | 5c96ebb7cea790c6ca1b8b70fdea531fb194dabb (diff) |
[media] dvb-bt8xx: use goto based exception handling
Repeating the same cleanup code in each error handling path makes life
unnecessarily difficult for reviewers, who much check each instance of
the same copy+pasted code separately. A "goto" to the end of the
function is more maintainable and conveys the intent more clearly.
While we're touching this code, also lift some assignments from "if"
conditionals for simplicity.
No functional change intended.
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media')
-rw-r--r-- | drivers/media/dvb/bt8xx/dvb-bt8xx.c | 57 |
1 files changed, 27 insertions, 30 deletions
diff --git a/drivers/media/dvb/bt8xx/dvb-bt8xx.c b/drivers/media/dvb/bt8xx/dvb-bt8xx.c index b79629f1e520..1952f6bfc90e 100644 --- a/drivers/media/dvb/bt8xx/dvb-bt8xx.c +++ b/drivers/media/dvb/bt8xx/dvb-bt8xx.c | |||
@@ -744,57 +744,42 @@ static int __devinit dvb_bt8xx_load_card(struct dvb_bt8xx_card *card, u32 type) | |||
744 | card->demux.stop_feed = dvb_bt8xx_stop_feed; | 744 | card->demux.stop_feed = dvb_bt8xx_stop_feed; |
745 | card->demux.write_to_decoder = NULL; | 745 | card->demux.write_to_decoder = NULL; |
746 | 746 | ||
747 | if ((result = dvb_dmx_init(&card->demux)) < 0) { | 747 | result = dvb_dmx_init(&card->demux); |
748 | if (result < 0) { | ||
748 | printk("dvb_bt8xx: dvb_dmx_init failed (errno = %d)\n", result); | 749 | printk("dvb_bt8xx: dvb_dmx_init failed (errno = %d)\n", result); |
749 | 750 | goto err_unregister_adaptor; | |
750 | dvb_unregister_adapter(&card->dvb_adapter); | ||
751 | return result; | ||
752 | } | 751 | } |
753 | 752 | ||
754 | card->dmxdev.filternum = 256; | 753 | card->dmxdev.filternum = 256; |
755 | card->dmxdev.demux = &card->demux.dmx; | 754 | card->dmxdev.demux = &card->demux.dmx; |
756 | card->dmxdev.capabilities = 0; | 755 | card->dmxdev.capabilities = 0; |
757 | 756 | ||
758 | if ((result = dvb_dmxdev_init(&card->dmxdev, &card->dvb_adapter)) < 0) { | 757 | result = dvb_dmxdev_init(&card->dmxdev, &card->dvb_adapter); |
758 | if (result < 0) { | ||
759 | printk("dvb_bt8xx: dvb_dmxdev_init failed (errno = %d)\n", result); | 759 | printk("dvb_bt8xx: dvb_dmxdev_init failed (errno = %d)\n", result); |
760 | 760 | goto err_dmx_release; | |
761 | dvb_dmx_release(&card->demux); | ||
762 | dvb_unregister_adapter(&card->dvb_adapter); | ||
763 | return result; | ||
764 | } | 761 | } |
765 | 762 | ||
766 | card->fe_hw.source = DMX_FRONTEND_0; | 763 | card->fe_hw.source = DMX_FRONTEND_0; |
767 | 764 | ||
768 | if ((result = card->demux.dmx.add_frontend(&card->demux.dmx, &card->fe_hw)) < 0) { | 765 | result = card->demux.dmx.add_frontend(&card->demux.dmx, &card->fe_hw); |
766 | if (result < 0) { | ||
769 | printk("dvb_bt8xx: dvb_dmx_init failed (errno = %d)\n", result); | 767 | printk("dvb_bt8xx: dvb_dmx_init failed (errno = %d)\n", result); |
770 | 768 | goto err_dmxdev_release; | |
771 | dvb_dmxdev_release(&card->dmxdev); | ||
772 | dvb_dmx_release(&card->demux); | ||
773 | dvb_unregister_adapter(&card->dvb_adapter); | ||
774 | return result; | ||
775 | } | 769 | } |
776 | 770 | ||
777 | card->fe_mem.source = DMX_MEMORY_FE; | 771 | card->fe_mem.source = DMX_MEMORY_FE; |
778 | 772 | ||
779 | if ((result = card->demux.dmx.add_frontend(&card->demux.dmx, &card->fe_mem)) < 0) { | 773 | result = card->demux.dmx.add_frontend(&card->demux.dmx, &card->fe_mem); |
774 | if (result < 0) { | ||
780 | printk("dvb_bt8xx: dvb_dmx_init failed (errno = %d)\n", result); | 775 | printk("dvb_bt8xx: dvb_dmx_init failed (errno = %d)\n", result); |
781 | 776 | goto err_remove_hw_frontend; | |
782 | card->demux.dmx.remove_frontend(&card->demux.dmx, &card->fe_hw); | ||
783 | dvb_dmxdev_release(&card->dmxdev); | ||
784 | dvb_dmx_release(&card->demux); | ||
785 | dvb_unregister_adapter(&card->dvb_adapter); | ||
786 | return result; | ||
787 | } | 777 | } |
788 | 778 | ||
789 | if ((result = card->demux.dmx.connect_frontend(&card->demux.dmx, &card->fe_hw)) < 0) { | 779 | result = card->demux.dmx.connect_frontend(&card->demux.dmx, &card->fe_hw); |
780 | if (result < 0) { | ||
790 | printk("dvb_bt8xx: dvb_dmx_init failed (errno = %d)\n", result); | 781 | printk("dvb_bt8xx: dvb_dmx_init failed (errno = %d)\n", result); |
791 | 782 | goto err_remove_mem_frontend; | |
792 | card->demux.dmx.remove_frontend(&card->demux.dmx, &card->fe_mem); | ||
793 | card->demux.dmx.remove_frontend(&card->demux.dmx, &card->fe_hw); | ||
794 | dvb_dmxdev_release(&card->dmxdev); | ||
795 | dvb_dmx_release(&card->demux); | ||
796 | dvb_unregister_adapter(&card->dvb_adapter); | ||
797 | return result; | ||
798 | } | 783 | } |
799 | 784 | ||
800 | dvb_net_init(&card->dvb_adapter, &card->dvbnet, &card->demux.dmx); | 785 | dvb_net_init(&card->dvb_adapter, &card->dvbnet, &card->demux.dmx); |
@@ -804,6 +789,18 @@ static int __devinit dvb_bt8xx_load_card(struct dvb_bt8xx_card *card, u32 type) | |||
804 | frontend_init(card, type); | 789 | frontend_init(card, type); |
805 | 790 | ||
806 | return 0; | 791 | return 0; |
792 | |||
793 | err_remove_mem_frontend: | ||
794 | card->demux.dmx.remove_frontend(&card->demux.dmx, &card->fe_mem); | ||
795 | err_remove_hw_frontend: | ||
796 | card->demux.dmx.remove_frontend(&card->demux.dmx, &card->fe_hw); | ||
797 | err_dmxdev_release: | ||
798 | dvb_dmxdev_release(&card->dmxdev); | ||
799 | err_dmx_release: | ||
800 | dvb_dmx_release(&card->demux); | ||
801 | err_unregister_adaptor: | ||
802 | dvb_unregister_adapter(&card->dvb_adapter); | ||
803 | return result; | ||
807 | } | 804 | } |
808 | 805 | ||
809 | static int __devinit dvb_bt8xx_probe(struct bttv_sub_device *sub) | 806 | static int __devinit dvb_bt8xx_probe(struct bttv_sub_device *sub) |