Browse Source

drm/sti: hdmi use of_get_i2c_adapter_by_node interface

This change is needed to properly lock I2C bus device and driver,
which serve DDC lines. Without this change I2C bus driver module
may gone in runtime and this won't be noticed by the driver.

Signed-off-by: Vladimir Zapolskiy <vladimir_zapolskiy@mentor.com>
Reviewed-by: Vincent Abriou <vincent.abriou@st.com>
Vladimir Zapolskiy 10 năm trước cách đây
mục cha
commit
4d5821a71c
1 tập tin đã thay đổi với 6 bổ sung11 xóa
  1. 6 11
      drivers/gpu/drm/sti/sti_hdmi.c

+ 6 - 11
drivers/gpu/drm/sti/sti_hdmi.c

@@ -793,13 +793,10 @@ static int sti_hdmi_probe(struct platform_device *pdev)
 
 
 	ddc = of_parse_phandle(pdev->dev.of_node, "ddc", 0);
 	ddc = of_parse_phandle(pdev->dev.of_node, "ddc", 0);
 	if (ddc) {
 	if (ddc) {
-		hdmi->ddc_adapt = of_find_i2c_adapter_by_node(ddc);
-		if (!hdmi->ddc_adapt) {
-			of_node_put(ddc);
-			return -EPROBE_DEFER;
-		}
-
+		hdmi->ddc_adapt = of_get_i2c_adapter_by_node(ddc);
 		of_node_put(ddc);
 		of_node_put(ddc);
+		if (!hdmi->ddc_adapt)
+			return -EPROBE_DEFER;
 	}
 	}
 
 
 	hdmi->dev = pdev->dev;
 	hdmi->dev = pdev->dev;
@@ -888,8 +885,7 @@ static int sti_hdmi_probe(struct platform_device *pdev)
 	return component_add(&pdev->dev, &sti_hdmi_ops);
 	return component_add(&pdev->dev, &sti_hdmi_ops);
 
 
  release_adapter:
  release_adapter:
-	if (hdmi->ddc_adapt)
-		put_device(&hdmi->ddc_adapt->dev);
+	i2c_put_adapter(hdmi->ddc_adapt);
 
 
 	return ret;
 	return ret;
 }
 }
@@ -898,10 +894,9 @@ static int sti_hdmi_remove(struct platform_device *pdev)
 {
 {
 	struct sti_hdmi *hdmi = dev_get_drvdata(&pdev->dev);
 	struct sti_hdmi *hdmi = dev_get_drvdata(&pdev->dev);
 
 
-	if (hdmi->ddc_adapt)
-		put_device(&hdmi->ddc_adapt->dev);
-
+	i2c_put_adapter(hdmi->ddc_adapt);
 	component_del(&pdev->dev, &sti_hdmi_ops);
 	component_del(&pdev->dev, &sti_hdmi_ops);
+
 	return 0;
 	return 0;
 }
 }