[RESEND PATCH v2 3/3] drm: tegra: use of_get_i2c_adapter_by_node interface

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This change is needed to properly lock I2C bus driver, which serves
DDC, otherwise there is an error in I2C bus driver user counting.

Note, that prior to the change put_device() coupled with
of_find_i2c_adapter_by_node() was missing on error path of
tegra_output_probe().

Signed-off-by: Vladimir Zapolskiy <vladimir_zapolskiy@xxxxxxxxxx>
Cc: Thierry Reding <thierry.reding@xxxxxxxxx>
---
 drivers/gpu/drm/tegra/output.c | 25 ++++++++++++++-----------
 1 file changed, 14 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/tegra/output.c b/drivers/gpu/drm/tegra/output.c
index 595d1ec3e02e..1edfde77bb6d 100644
--- a/drivers/gpu/drm/tegra/output.c
+++ b/drivers/gpu/drm/tegra/output.c
@@ -113,14 +113,12 @@ int tegra_output_probe(struct tegra_output *output)
 
 	ddc = of_parse_phandle(output->of_node, "nvidia,ddc-i2c-bus", 0);
 	if (ddc) {
-		output->ddc = of_find_i2c_adapter_by_node(ddc);
+		output->ddc = of_get_i2c_adapter_by_node(ddc);
+		of_node_put(ddc);
 		if (!output->ddc) {
 			err = -EPROBE_DEFER;
-			of_node_put(ddc);
 			return err;
 		}
-
-		of_node_put(ddc);
 	}
 
 	output->hpd_gpio = of_get_named_gpio_flags(output->of_node,
@@ -133,14 +131,13 @@ int tegra_output_probe(struct tegra_output *output)
 				       "HDMI hotplug detect");
 		if (err < 0) {
 			dev_err(output->dev, "gpio_request_one(): %d\n", err);
-			return err;
+			goto i2c_release;
 		}
 
 		err = gpio_to_irq(output->hpd_gpio);
 		if (err < 0) {
 			dev_err(output->dev, "gpio_to_irq(): %d\n", err);
-			gpio_free(output->hpd_gpio);
-			return err;
+			goto gpio_release;
 		}
 
 		output->hpd_irq = err;
@@ -153,8 +150,7 @@ int tegra_output_probe(struct tegra_output *output)
 		if (err < 0) {
 			dev_err(output->dev, "failed to request IRQ#%u: %d\n",
 				output->hpd_irq, err);
-			gpio_free(output->hpd_gpio);
-			return err;
+			goto gpio_release;
 		}
 
 		output->connector.polled = DRM_CONNECTOR_POLL_HPD;
@@ -168,6 +164,14 @@ int tegra_output_probe(struct tegra_output *output)
 	}
 
 	return 0;
+
+gpio_release:
+	gpio_free(output->hpd_gpio);
+
+i2c_release:
+	i2c_put_adapter(output->ddc);
+
+	return err;
 }
 
 void tegra_output_remove(struct tegra_output *output)
@@ -177,8 +181,7 @@ void tegra_output_remove(struct tegra_output *output)
 		gpio_free(output->hpd_gpio);
 	}
 
-	if (output->ddc)
-		put_device(&output->ddc->dev);
+	i2c_put_adapter(output->ddc);
 }
 
 int tegra_output_init(struct drm_device *drm, struct tegra_output *output)
-- 
2.8.1

_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/dri-devel




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux