diff options
author | Tomi Valkeinen <tomi.valkeinen@ti.com> | 2012-01-25 06:31:04 -0500 |
---|---|---|
committer | Tomi Valkeinen <tomi.valkeinen@ti.com> | 2012-02-21 02:39:12 -0500 |
commit | cd3b34493f9b5de1d617e0be39f6cb5c59c9889c (patch) | |
tree | f26a0b7c01a43eeeb9ec4c355e424b17c9e18153 /drivers/video/omap2 | |
parent | 3f60db4bde17088feed5f143582d7661cdbb9a01 (diff) |
OMAPDSS: cleanup probe functions
Now that dss is using devm_ functions for allocation in probe functions,
small reordering of the allocations allows us to clean up the probe
functions more.
This patch moves "unmanaged" allocations after the managed ones, and
uses plain returns instead of gotos where possible. This lets us remove
a bunch of goto labels, simplifying the probe's error handling.
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Diffstat (limited to 'drivers/video/omap2')
-rw-r--r-- | drivers/video/omap2/dss/dispc.c | 33 | ||||
-rw-r--r-- | drivers/video/omap2/dss/dsi.c | 37 | ||||
-rw-r--r-- | drivers/video/omap2/dss/dss.c | 10 | ||||
-rw-r--r-- | drivers/video/omap2/dss/rfbi.c | 31 | ||||
-rw-r--r-- | drivers/video/omap2/dss/venc.c | 21 |
5 files changed, 61 insertions, 71 deletions
diff --git a/drivers/video/omap2/dss/dispc.c b/drivers/video/omap2/dss/dispc.c index f235798a7ba1..d8e044df3d40 100644 --- a/drivers/video/omap2/dss/dispc.c +++ b/drivers/video/omap2/dss/dispc.c | |||
@@ -3341,15 +3341,6 @@ static int omap_dispchw_probe(struct platform_device *pdev) | |||
3341 | 3341 | ||
3342 | dispc.pdev = pdev; | 3342 | dispc.pdev = pdev; |
3343 | 3343 | ||
3344 | clk = clk_get(&pdev->dev, "fck"); | ||
3345 | if (IS_ERR(clk)) { | ||
3346 | DSSERR("can't get fck\n"); | ||
3347 | r = PTR_ERR(clk); | ||
3348 | goto err_get_clk; | ||
3349 | } | ||
3350 | |||
3351 | dispc.dss_clk = clk; | ||
3352 | |||
3353 | spin_lock_init(&dispc.irq_lock); | 3344 | spin_lock_init(&dispc.irq_lock); |
3354 | 3345 | ||
3355 | #ifdef CONFIG_OMAP2_DSS_COLLECT_IRQ_STATS | 3346 | #ifdef CONFIG_OMAP2_DSS_COLLECT_IRQ_STATS |
@@ -3362,30 +3353,38 @@ static int omap_dispchw_probe(struct platform_device *pdev) | |||
3362 | dispc_mem = platform_get_resource(dispc.pdev, IORESOURCE_MEM, 0); | 3353 | dispc_mem = platform_get_resource(dispc.pdev, IORESOURCE_MEM, 0); |
3363 | if (!dispc_mem) { | 3354 | if (!dispc_mem) { |
3364 | DSSERR("can't get IORESOURCE_MEM DISPC\n"); | 3355 | DSSERR("can't get IORESOURCE_MEM DISPC\n"); |
3365 | r = -EINVAL; | 3356 | return -EINVAL; |
3366 | goto err_ioremap; | ||
3367 | } | 3357 | } |
3358 | |||
3368 | dispc.base = devm_ioremap(&pdev->dev, dispc_mem->start, | 3359 | dispc.base = devm_ioremap(&pdev->dev, dispc_mem->start, |
3369 | resource_size(dispc_mem)); | 3360 | resource_size(dispc_mem)); |
3370 | if (!dispc.base) { | 3361 | if (!dispc.base) { |
3371 | DSSERR("can't ioremap DISPC\n"); | 3362 | DSSERR("can't ioremap DISPC\n"); |
3372 | r = -ENOMEM; | 3363 | return -ENOMEM; |
3373 | goto err_ioremap; | ||
3374 | } | 3364 | } |
3365 | |||
3375 | dispc.irq = platform_get_irq(dispc.pdev, 0); | 3366 | dispc.irq = platform_get_irq(dispc.pdev, 0); |
3376 | if (dispc.irq < 0) { | 3367 | if (dispc.irq < 0) { |
3377 | DSSERR("platform_get_irq failed\n"); | 3368 | DSSERR("platform_get_irq failed\n"); |
3378 | r = -ENODEV; | 3369 | return -ENODEV; |
3379 | goto err_ioremap; | ||
3380 | } | 3370 | } |
3381 | 3371 | ||
3382 | r = devm_request_irq(&pdev->dev, dispc.irq, omap_dispc_irq_handler, | 3372 | r = devm_request_irq(&pdev->dev, dispc.irq, omap_dispc_irq_handler, |
3383 | IRQF_SHARED, "OMAP DISPC", dispc.pdev); | 3373 | IRQF_SHARED, "OMAP DISPC", dispc.pdev); |
3384 | if (r < 0) { | 3374 | if (r < 0) { |
3385 | DSSERR("request_irq failed\n"); | 3375 | DSSERR("request_irq failed\n"); |
3386 | goto err_ioremap; | 3376 | return r; |
3377 | } | ||
3378 | |||
3379 | clk = clk_get(&pdev->dev, "fck"); | ||
3380 | if (IS_ERR(clk)) { | ||
3381 | DSSERR("can't get fck\n"); | ||
3382 | r = PTR_ERR(clk); | ||
3383 | return r; | ||
3387 | } | 3384 | } |
3388 | 3385 | ||
3386 | dispc.dss_clk = clk; | ||
3387 | |||
3389 | pm_runtime_enable(&pdev->dev); | 3388 | pm_runtime_enable(&pdev->dev); |
3390 | 3389 | ||
3391 | r = dispc_runtime_get(); | 3390 | r = dispc_runtime_get(); |
@@ -3406,9 +3405,7 @@ static int omap_dispchw_probe(struct platform_device *pdev) | |||
3406 | 3405 | ||
3407 | err_runtime_get: | 3406 | err_runtime_get: |
3408 | pm_runtime_disable(&pdev->dev); | 3407 | pm_runtime_disable(&pdev->dev); |
3409 | err_ioremap: | ||
3410 | clk_put(dispc.dss_clk); | 3408 | clk_put(dispc.dss_clk); |
3411 | err_get_clk: | ||
3412 | return r; | 3409 | return r; |
3413 | } | 3410 | } |
3414 | 3411 | ||
diff --git a/drivers/video/omap2/dss/dsi.c b/drivers/video/omap2/dss/dsi.c index 0330216bd4ec..662d14f8c2c3 100644 --- a/drivers/video/omap2/dss/dsi.c +++ b/drivers/video/omap2/dss/dsi.c | |||
@@ -4688,10 +4688,8 @@ static int omap_dsihw_probe(struct platform_device *dsidev) | |||
4688 | struct dsi_data *dsi; | 4688 | struct dsi_data *dsi; |
4689 | 4689 | ||
4690 | dsi = devm_kzalloc(&dsidev->dev, sizeof(*dsi), GFP_KERNEL); | 4690 | dsi = devm_kzalloc(&dsidev->dev, sizeof(*dsi), GFP_KERNEL); |
4691 | if (!dsi) { | 4691 | if (!dsi) |
4692 | r = -ENOMEM; | 4692 | return -ENOMEM; |
4693 | goto err_alloc; | ||
4694 | } | ||
4695 | 4693 | ||
4696 | dsi->pdev = dsidev; | 4694 | dsi->pdev = dsidev; |
4697 | dsi_pdev_map[dsi_module] = dsidev; | 4695 | dsi_pdev_map[dsi_module] = dsidev; |
@@ -4714,12 +4712,6 @@ static int omap_dsihw_probe(struct platform_device *dsidev) | |||
4714 | mutex_init(&dsi->lock); | 4712 | mutex_init(&dsi->lock); |
4715 | sema_init(&dsi->bus_lock, 1); | 4713 | sema_init(&dsi->bus_lock, 1); |
4716 | 4714 | ||
4717 | r = dsi_get_clocks(dsidev); | ||
4718 | if (r) | ||
4719 | goto err_alloc; | ||
4720 | |||
4721 | pm_runtime_enable(&dsidev->dev); | ||
4722 | |||
4723 | INIT_DELAYED_WORK_DEFERRABLE(&dsi->framedone_timeout_work, | 4715 | INIT_DELAYED_WORK_DEFERRABLE(&dsi->framedone_timeout_work, |
4724 | dsi_framedone_timeout_work_callback); | 4716 | dsi_framedone_timeout_work_callback); |
4725 | 4717 | ||
@@ -4731,28 +4723,27 @@ static int omap_dsihw_probe(struct platform_device *dsidev) | |||
4731 | dsi_mem = platform_get_resource(dsi->pdev, IORESOURCE_MEM, 0); | 4723 | dsi_mem = platform_get_resource(dsi->pdev, IORESOURCE_MEM, 0); |
4732 | if (!dsi_mem) { | 4724 | if (!dsi_mem) { |
4733 | DSSERR("can't get IORESOURCE_MEM DSI\n"); | 4725 | DSSERR("can't get IORESOURCE_MEM DSI\n"); |
4734 | r = -EINVAL; | 4726 | return -EINVAL; |
4735 | goto err_ioremap; | ||
4736 | } | 4727 | } |
4728 | |||
4737 | dsi->base = devm_ioremap(&dsidev->dev, dsi_mem->start, | 4729 | dsi->base = devm_ioremap(&dsidev->dev, dsi_mem->start, |
4738 | resource_size(dsi_mem)); | 4730 | resource_size(dsi_mem)); |
4739 | if (!dsi->base) { | 4731 | if (!dsi->base) { |
4740 | DSSERR("can't ioremap DSI\n"); | 4732 | DSSERR("can't ioremap DSI\n"); |
4741 | r = -ENOMEM; | 4733 | return -ENOMEM; |
4742 | goto err_ioremap; | ||
4743 | } | 4734 | } |
4735 | |||
4744 | dsi->irq = platform_get_irq(dsi->pdev, 0); | 4736 | dsi->irq = platform_get_irq(dsi->pdev, 0); |
4745 | if (dsi->irq < 0) { | 4737 | if (dsi->irq < 0) { |
4746 | DSSERR("platform_get_irq failed\n"); | 4738 | DSSERR("platform_get_irq failed\n"); |
4747 | r = -ENODEV; | 4739 | return -ENODEV; |
4748 | goto err_ioremap; | ||
4749 | } | 4740 | } |
4750 | 4741 | ||
4751 | r = devm_request_irq(&dsidev->dev, dsi->irq, omap_dsi_irq_handler, | 4742 | r = devm_request_irq(&dsidev->dev, dsi->irq, omap_dsi_irq_handler, |
4752 | IRQF_SHARED, dev_name(&dsidev->dev), dsi->pdev); | 4743 | IRQF_SHARED, dev_name(&dsidev->dev), dsi->pdev); |
4753 | if (r < 0) { | 4744 | if (r < 0) { |
4754 | DSSERR("request_irq failed\n"); | 4745 | DSSERR("request_irq failed\n"); |
4755 | goto err_ioremap; | 4746 | return r; |
4756 | } | 4747 | } |
4757 | 4748 | ||
4758 | /* DSI VCs initialization */ | 4749 | /* DSI VCs initialization */ |
@@ -4764,9 +4755,15 @@ static int omap_dsihw_probe(struct platform_device *dsidev) | |||
4764 | 4755 | ||
4765 | dsi_calc_clock_param_ranges(dsidev); | 4756 | dsi_calc_clock_param_ranges(dsidev); |
4766 | 4757 | ||
4758 | r = dsi_get_clocks(dsidev); | ||
4759 | if (r) | ||
4760 | return r; | ||
4761 | |||
4762 | pm_runtime_enable(&dsidev->dev); | ||
4763 | |||
4767 | r = dsi_runtime_get(dsidev); | 4764 | r = dsi_runtime_get(dsidev); |
4768 | if (r) | 4765 | if (r) |
4769 | goto err_ioremap; | 4766 | goto err_runtime_get; |
4770 | 4767 | ||
4771 | rev = dsi_read_reg(dsidev, DSI_REVISION); | 4768 | rev = dsi_read_reg(dsidev, DSI_REVISION); |
4772 | dev_dbg(&dsidev->dev, "OMAP DSI rev %d.%d\n", | 4769 | dev_dbg(&dsidev->dev, "OMAP DSI rev %d.%d\n", |
@@ -4784,9 +4781,9 @@ static int omap_dsihw_probe(struct platform_device *dsidev) | |||
4784 | 4781 | ||
4785 | return 0; | 4782 | return 0; |
4786 | 4783 | ||
4787 | err_ioremap: | 4784 | err_runtime_get: |
4788 | pm_runtime_disable(&dsidev->dev); | 4785 | pm_runtime_disable(&dsidev->dev); |
4789 | err_alloc: | 4786 | dsi_put_clocks(dsidev); |
4790 | return r; | 4787 | return r; |
4791 | } | 4788 | } |
4792 | 4789 | ||
diff --git a/drivers/video/omap2/dss/dss.c b/drivers/video/omap2/dss/dss.c index aa2e08968649..4a6b5eeef6a7 100644 --- a/drivers/video/omap2/dss/dss.c +++ b/drivers/video/omap2/dss/dss.c | |||
@@ -748,20 +748,19 @@ static int omap_dsshw_probe(struct platform_device *pdev) | |||
748 | dss_mem = platform_get_resource(dss.pdev, IORESOURCE_MEM, 0); | 748 | dss_mem = platform_get_resource(dss.pdev, IORESOURCE_MEM, 0); |
749 | if (!dss_mem) { | 749 | if (!dss_mem) { |
750 | DSSERR("can't get IORESOURCE_MEM DSS\n"); | 750 | DSSERR("can't get IORESOURCE_MEM DSS\n"); |
751 | r = -EINVAL; | 751 | return -EINVAL; |
752 | goto err_ioremap; | ||
753 | } | 752 | } |
753 | |||
754 | dss.base = devm_ioremap(&pdev->dev, dss_mem->start, | 754 | dss.base = devm_ioremap(&pdev->dev, dss_mem->start, |
755 | resource_size(dss_mem)); | 755 | resource_size(dss_mem)); |
756 | if (!dss.base) { | 756 | if (!dss.base) { |
757 | DSSERR("can't ioremap DSS\n"); | 757 | DSSERR("can't ioremap DSS\n"); |
758 | r = -ENOMEM; | 758 | return -ENOMEM; |
759 | goto err_ioremap; | ||
760 | } | 759 | } |
761 | 760 | ||
762 | r = dss_get_clocks(); | 761 | r = dss_get_clocks(); |
763 | if (r) | 762 | if (r) |
764 | goto err_ioremap; | 763 | return r; |
765 | 764 | ||
766 | pm_runtime_enable(&pdev->dev); | 765 | pm_runtime_enable(&pdev->dev); |
767 | 766 | ||
@@ -809,7 +808,6 @@ err_dpi: | |||
809 | err_runtime_get: | 808 | err_runtime_get: |
810 | pm_runtime_disable(&pdev->dev); | 809 | pm_runtime_disable(&pdev->dev); |
811 | dss_put_clocks(); | 810 | dss_put_clocks(); |
812 | err_ioremap: | ||
813 | return r; | 811 | return r; |
814 | } | 812 | } |
815 | 813 | ||
diff --git a/drivers/video/omap2/dss/rfbi.c b/drivers/video/omap2/dss/rfbi.c index 7370482b726f..788a0ef6323a 100644 --- a/drivers/video/omap2/dss/rfbi.c +++ b/drivers/video/omap2/dss/rfbi.c | |||
@@ -922,36 +922,34 @@ static int omap_rfbihw_probe(struct platform_device *pdev) | |||
922 | rfbi_mem = platform_get_resource(rfbi.pdev, IORESOURCE_MEM, 0); | 922 | rfbi_mem = platform_get_resource(rfbi.pdev, IORESOURCE_MEM, 0); |
923 | if (!rfbi_mem) { | 923 | if (!rfbi_mem) { |
924 | DSSERR("can't get IORESOURCE_MEM RFBI\n"); | 924 | DSSERR("can't get IORESOURCE_MEM RFBI\n"); |
925 | r = -EINVAL; | 925 | return -EINVAL; |
926 | goto err_ioremap; | ||
927 | } | 926 | } |
927 | |||
928 | rfbi.base = devm_ioremap(&pdev->dev, rfbi_mem->start, | 928 | rfbi.base = devm_ioremap(&pdev->dev, rfbi_mem->start, |
929 | resource_size(rfbi_mem)); | 929 | resource_size(rfbi_mem)); |
930 | if (!rfbi.base) { | 930 | if (!rfbi.base) { |
931 | DSSERR("can't ioremap RFBI\n"); | 931 | DSSERR("can't ioremap RFBI\n"); |
932 | r = -ENOMEM; | 932 | return -ENOMEM; |
933 | goto err_ioremap; | ||
934 | } | 933 | } |
935 | 934 | ||
936 | pm_runtime_enable(&pdev->dev); | ||
937 | |||
938 | r = rfbi_runtime_get(); | ||
939 | if (r) | ||
940 | goto err_get_rfbi; | ||
941 | |||
942 | msleep(10); | ||
943 | |||
944 | clk = clk_get(&pdev->dev, "ick"); | 935 | clk = clk_get(&pdev->dev, "ick"); |
945 | if (IS_ERR(clk)) { | 936 | if (IS_ERR(clk)) { |
946 | DSSERR("can't get ick\n"); | 937 | DSSERR("can't get ick\n"); |
947 | r = PTR_ERR(clk); | 938 | return PTR_ERR(clk); |
948 | goto err_get_ick; | ||
949 | } | 939 | } |
950 | 940 | ||
951 | rfbi.l4_khz = clk_get_rate(clk) / 1000; | 941 | rfbi.l4_khz = clk_get_rate(clk) / 1000; |
952 | 942 | ||
953 | clk_put(clk); | 943 | clk_put(clk); |
954 | 944 | ||
945 | pm_runtime_enable(&pdev->dev); | ||
946 | |||
947 | r = rfbi_runtime_get(); | ||
948 | if (r) | ||
949 | goto err_runtime_get; | ||
950 | |||
951 | msleep(10); | ||
952 | |||
955 | rev = rfbi_read_reg(RFBI_REVISION); | 953 | rev = rfbi_read_reg(RFBI_REVISION); |
956 | dev_dbg(&pdev->dev, "OMAP RFBI rev %d.%d\n", | 954 | dev_dbg(&pdev->dev, "OMAP RFBI rev %d.%d\n", |
957 | FLD_GET(rev, 7, 4), FLD_GET(rev, 3, 0)); | 955 | FLD_GET(rev, 7, 4), FLD_GET(rev, 3, 0)); |
@@ -960,11 +958,8 @@ static int omap_rfbihw_probe(struct platform_device *pdev) | |||
960 | 958 | ||
961 | return 0; | 959 | return 0; |
962 | 960 | ||
963 | err_get_ick: | 961 | err_runtime_get: |
964 | rfbi_runtime_put(); | ||
965 | err_get_rfbi: | ||
966 | pm_runtime_disable(&pdev->dev); | 962 | pm_runtime_disable(&pdev->dev); |
967 | err_ioremap: | ||
968 | return r; | 963 | return r; |
969 | } | 964 | } |
970 | 965 | ||
diff --git a/drivers/video/omap2/dss/venc.c b/drivers/video/omap2/dss/venc.c index 967d4432c67b..9c3daf71750c 100644 --- a/drivers/video/omap2/dss/venc.c +++ b/drivers/video/omap2/dss/venc.c | |||
@@ -795,38 +795,41 @@ static int omap_venchw_probe(struct platform_device *pdev) | |||
795 | venc_mem = platform_get_resource(venc.pdev, IORESOURCE_MEM, 0); | 795 | venc_mem = platform_get_resource(venc.pdev, IORESOURCE_MEM, 0); |
796 | if (!venc_mem) { | 796 | if (!venc_mem) { |
797 | DSSERR("can't get IORESOURCE_MEM VENC\n"); | 797 | DSSERR("can't get IORESOURCE_MEM VENC\n"); |
798 | r = -EINVAL; | 798 | return -EINVAL; |
799 | goto err_ioremap; | ||
800 | } | 799 | } |
800 | |||
801 | venc.base = devm_ioremap(&pdev->dev, venc_mem->start, | 801 | venc.base = devm_ioremap(&pdev->dev, venc_mem->start, |
802 | resource_size(venc_mem)); | 802 | resource_size(venc_mem)); |
803 | if (!venc.base) { | 803 | if (!venc.base) { |
804 | DSSERR("can't ioremap VENC\n"); | 804 | DSSERR("can't ioremap VENC\n"); |
805 | r = -ENOMEM; | 805 | return -ENOMEM; |
806 | goto err_ioremap; | ||
807 | } | 806 | } |
808 | 807 | ||
809 | r = venc_get_clocks(pdev); | 808 | r = venc_get_clocks(pdev); |
810 | if (r) | 809 | if (r) |
811 | goto err_ioremap; | 810 | return r; |
812 | 811 | ||
813 | pm_runtime_enable(&pdev->dev); | 812 | pm_runtime_enable(&pdev->dev); |
814 | 813 | ||
815 | r = venc_runtime_get(); | 814 | r = venc_runtime_get(); |
816 | if (r) | 815 | if (r) |
817 | goto err_get_venc; | 816 | goto err_runtime_get; |
818 | 817 | ||
819 | rev_id = (u8)(venc_read_reg(VENC_REV_ID) & 0xff); | 818 | rev_id = (u8)(venc_read_reg(VENC_REV_ID) & 0xff); |
820 | dev_dbg(&pdev->dev, "OMAP VENC rev %d\n", rev_id); | 819 | dev_dbg(&pdev->dev, "OMAP VENC rev %d\n", rev_id); |
821 | 820 | ||
822 | venc_runtime_put(); | 821 | venc_runtime_put(); |
823 | 822 | ||
824 | return omap_dss_register_driver(&venc_driver); | 823 | r = omap_dss_register_driver(&venc_driver); |
824 | if (r) | ||
825 | goto err_reg_panel_driver; | ||
826 | |||
827 | return 0; | ||
825 | 828 | ||
826 | err_get_venc: | 829 | err_reg_panel_driver: |
830 | err_runtime_get: | ||
827 | pm_runtime_disable(&pdev->dev); | 831 | pm_runtime_disable(&pdev->dev); |
828 | venc_put_clocks(); | 832 | venc_put_clocks(); |
829 | err_ioremap: | ||
830 | return r; | 833 | return r; |
831 | } | 834 | } |
832 | 835 | ||