[PATCH v2 3/3] drm: tegra: use of_get_i2c_adapter_by_node interface
Vladimir Zapolskiy
vladimir_zapolskiy at mentor.com
Tue Sep 22 14:48:12 PDT 2015
This change is needed to properly lock I2C bus driver, which serves DDC.
On release of_get_i2c_adapter_by_node() requires i2c_put_adapter() call.
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 at mentor.com>
Cc: Thierry Reding <thierry.reding at gmail.com>
Cc: Terje Bergström <tbergstrom at nvidia.com>
---
Changes from v1 to v2:
- converted two of_node_put(ddc) calls into one
drivers/gpu/drm/tegra/output.c | 23 ++++++++++++-----------
1 file changed, 12 insertions(+), 11 deletions(-)
diff --git a/drivers/gpu/drm/tegra/output.c b/drivers/gpu/drm/tegra/output.c
index 46664b6..9f3cec5 100644
--- a/drivers/gpu/drm/tegra/output.c
+++ b/drivers/gpu/drm/tegra/output.c
@@ -120,14 +120,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,
@@ -140,14 +138,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;
@@ -160,8 +157,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;
@@ -175,6 +171,12 @@ 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)
@@ -184,8 +186,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.5.0
More information about the dri-devel
mailing list