aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/gpu/drm/sti/sti_hdmi.c49
1 files changed, 31 insertions, 18 deletions
diff --git a/drivers/gpu/drm/sti/sti_hdmi.c b/drivers/gpu/drm/sti/sti_hdmi.c
index 1241763a33b6..0ebae95d59e5 100644
--- a/drivers/gpu/drm/sti/sti_hdmi.c
+++ b/drivers/gpu/drm/sti/sti_hdmi.c
@@ -701,18 +701,17 @@ static int sti_hdmi_bind(struct device *dev, struct device *master, void *data)
701 701
702 encoder = sti_hdmi_find_encoder(drm_dev); 702 encoder = sti_hdmi_find_encoder(drm_dev);
703 if (!encoder) 703 if (!encoder)
704 goto err_adapt; 704 return -EINVAL;
705 705
706 connector = devm_kzalloc(dev, sizeof(*connector), GFP_KERNEL); 706 connector = devm_kzalloc(dev, sizeof(*connector), GFP_KERNEL);
707 if (!connector) 707 if (!connector)
708 goto err_adapt; 708 return -EINVAL;
709
710 709
711 connector->hdmi = hdmi; 710 connector->hdmi = hdmi;
712 711
713 bridge = devm_kzalloc(dev, sizeof(*bridge), GFP_KERNEL); 712 bridge = devm_kzalloc(dev, sizeof(*bridge), GFP_KERNEL);
714 if (!bridge) 713 if (!bridge)
715 goto err_adapt; 714 return -EINVAL;
716 715
717 bridge->driver_private = hdmi; 716 bridge->driver_private = hdmi;
718 bridge->funcs = &sti_hdmi_bridge_funcs; 717 bridge->funcs = &sti_hdmi_bridge_funcs;
@@ -749,8 +748,7 @@ err_sysfs:
749 drm_connector_unregister(drm_connector); 748 drm_connector_unregister(drm_connector);
750err_connector: 749err_connector:
751 drm_connector_cleanup(drm_connector); 750 drm_connector_cleanup(drm_connector);
752err_adapt: 751
753 put_device(&hdmi->ddc_adapt->dev);
754 return -EINVAL; 752 return -EINVAL;
755} 753}
756 754
@@ -810,24 +808,29 @@ static int sti_hdmi_probe(struct platform_device *pdev)
810 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "hdmi-reg"); 808 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "hdmi-reg");
811 if (!res) { 809 if (!res) {
812 DRM_ERROR("Invalid hdmi resource\n"); 810 DRM_ERROR("Invalid hdmi resource\n");
813 return -ENOMEM; 811 ret = -ENOMEM;
812 goto release_adapter;
814 } 813 }
815 hdmi->regs = devm_ioremap_nocache(dev, res->start, resource_size(res)); 814 hdmi->regs = devm_ioremap_nocache(dev, res->start, resource_size(res));
816 if (!hdmi->regs) 815 if (!hdmi->regs) {
817 return -ENOMEM; 816 ret = -ENOMEM;
817 goto release_adapter;
818 }
818 819
819 if (of_device_is_compatible(np, "st,stih416-hdmi")) { 820 if (of_device_is_compatible(np, "st,stih416-hdmi")) {
820 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, 821 res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
821 "syscfg"); 822 "syscfg");
822 if (!res) { 823 if (!res) {
823 DRM_ERROR("Invalid syscfg resource\n"); 824 DRM_ERROR("Invalid syscfg resource\n");
824 return -ENOMEM; 825 ret = -ENOMEM;
826 goto release_adapter;
825 } 827 }
826 hdmi->syscfg = devm_ioremap_nocache(dev, res->start, 828 hdmi->syscfg = devm_ioremap_nocache(dev, res->start,
827 resource_size(res)); 829 resource_size(res));
828 if (!hdmi->syscfg) 830 if (!hdmi->syscfg) {
829 return -ENOMEM; 831 ret = -ENOMEM;
830 832 goto release_adapter;
833 }
831 } 834 }
832 835
833 hdmi->phy_ops = (struct hdmi_phy_ops *) 836 hdmi->phy_ops = (struct hdmi_phy_ops *)
@@ -837,25 +840,29 @@ static int sti_hdmi_probe(struct platform_device *pdev)
837 hdmi->clk_pix = devm_clk_get(dev, "pix"); 840 hdmi->clk_pix = devm_clk_get(dev, "pix");
838 if (IS_ERR(hdmi->clk_pix)) { 841 if (IS_ERR(hdmi->clk_pix)) {
839 DRM_ERROR("Cannot get hdmi_pix clock\n"); 842 DRM_ERROR("Cannot get hdmi_pix clock\n");
840 return PTR_ERR(hdmi->clk_pix); 843 ret = PTR_ERR(hdmi->clk_pix);
844 goto release_adapter;
841 } 845 }
842 846
843 hdmi->clk_tmds = devm_clk_get(dev, "tmds"); 847 hdmi->clk_tmds = devm_clk_get(dev, "tmds");
844 if (IS_ERR(hdmi->clk_tmds)) { 848 if (IS_ERR(hdmi->clk_tmds)) {
845 DRM_ERROR("Cannot get hdmi_tmds clock\n"); 849 DRM_ERROR("Cannot get hdmi_tmds clock\n");
846 return PTR_ERR(hdmi->clk_tmds); 850 ret = PTR_ERR(hdmi->clk_tmds);
851 goto release_adapter;
847 } 852 }
848 853
849 hdmi->clk_phy = devm_clk_get(dev, "phy"); 854 hdmi->clk_phy = devm_clk_get(dev, "phy");
850 if (IS_ERR(hdmi->clk_phy)) { 855 if (IS_ERR(hdmi->clk_phy)) {
851 DRM_ERROR("Cannot get hdmi_phy clock\n"); 856 DRM_ERROR("Cannot get hdmi_phy clock\n");
852 return PTR_ERR(hdmi->clk_phy); 857 ret = PTR_ERR(hdmi->clk_phy);
858 goto release_adapter;
853 } 859 }
854 860
855 hdmi->clk_audio = devm_clk_get(dev, "audio"); 861 hdmi->clk_audio = devm_clk_get(dev, "audio");
856 if (IS_ERR(hdmi->clk_audio)) { 862 if (IS_ERR(hdmi->clk_audio)) {
857 DRM_ERROR("Cannot get hdmi_audio clock\n"); 863 DRM_ERROR("Cannot get hdmi_audio clock\n");
858 return PTR_ERR(hdmi->clk_audio); 864 ret = PTR_ERR(hdmi->clk_audio);
865 goto release_adapter;
859 } 866 }
860 867
861 hdmi->hpd = readl(hdmi->regs + HDMI_STA) & HDMI_STA_HOT_PLUG; 868 hdmi->hpd = readl(hdmi->regs + HDMI_STA) & HDMI_STA_HOT_PLUG;
@@ -868,7 +875,7 @@ static int sti_hdmi_probe(struct platform_device *pdev)
868 hdmi_irq_thread, IRQF_ONESHOT, dev_name(dev), hdmi); 875 hdmi_irq_thread, IRQF_ONESHOT, dev_name(dev), hdmi);
869 if (ret) { 876 if (ret) {
870 DRM_ERROR("Failed to register HDMI interrupt\n"); 877 DRM_ERROR("Failed to register HDMI interrupt\n");
871 return ret; 878 goto release_adapter;
872 } 879 }
873 880
874 hdmi->reset = devm_reset_control_get(dev, "hdmi"); 881 hdmi->reset = devm_reset_control_get(dev, "hdmi");
@@ -879,6 +886,12 @@ static int sti_hdmi_probe(struct platform_device *pdev)
879 platform_set_drvdata(pdev, hdmi); 886 platform_set_drvdata(pdev, hdmi);
880 887
881 return component_add(&pdev->dev, &sti_hdmi_ops); 888 return component_add(&pdev->dev, &sti_hdmi_ops);
889
890 release_adapter:
891 if (hdmi->ddc_adapt)
892 put_device(&hdmi->ddc_adapt->dev);
893
894 return ret;
882} 895}
883 896
884static int sti_hdmi_remove(struct platform_device *pdev) 897static int sti_hdmi_remove(struct platform_device *pdev)