diff options
author | Maxime Ripard <maxime@cerno.tech> | 2022-07-11 20:39:13 +0300 |
---|---|---|
committer | Maxime Ripard <maxime@cerno.tech> | 2022-07-13 11:46:10 +0300 |
commit | d3a84242f897506509d1bb29b8e64166958fb991 (patch) | |
tree | 07767ef565a29bff89f5e45ead9ebf643474ea6b | |
parent | 015653f7af7cb7fa56e9a88af2a15c814a39b6b4 (diff) | |
download | linux-d3a84242f897506509d1bb29b8e64166958fb991.tar.xz |
drm/vc4: hdmi: Use a device-managed action for DDC
The reference to the DDC controller device needs to be put back when we're
done with it. Let's use a device-managed action to simplify the driver.
Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Link: https://lore.kernel.org/r/20220711173939.1132294-44-maxime@cerno.tech
-rw-r--r-- | drivers/gpu/drm/vc4/vc4_hdmi.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.c b/drivers/gpu/drm/vc4/vc4_hdmi.c index 83ca1c02dde2..274f17880455 100644 --- a/drivers/gpu/drm/vc4/vc4_hdmi.c +++ b/drivers/gpu/drm/vc4/vc4_hdmi.c @@ -2932,6 +2932,13 @@ static int vc4_hdmi_runtime_resume(struct device *dev) return 0; } +static void vc4_hdmi_put_ddc_device(void *ptr) +{ + struct vc4_hdmi *vc4_hdmi = ptr; + + put_device(&vc4_hdmi->ddc->dev); +} + static int vc4_hdmi_bind(struct device *dev, struct device *master, void *data) { const struct vc4_hdmi_variant *variant = of_device_get_match_data(dev); @@ -2987,13 +2994,16 @@ static int vc4_hdmi_bind(struct device *dev, struct device *master, void *data) return -EPROBE_DEFER; } + ret = devm_add_action_or_reset(dev, vc4_hdmi_put_ddc_device, vc4_hdmi); + if (ret) + return ret; + /* Only use the GPIO HPD pin if present in the DT, otherwise * we'll use the HDMI core's register. */ vc4_hdmi->hpd_gpio = devm_gpiod_get_optional(dev, "hpd", GPIOD_IN); if (IS_ERR(vc4_hdmi->hpd_gpio)) { - ret = PTR_ERR(vc4_hdmi->hpd_gpio); - goto err_put_ddc; + return PTR_ERR(vc4_hdmi->hpd_gpio); } vc4_hdmi->disable_wifi_frequencies = @@ -3064,8 +3074,6 @@ err_put_runtime_pm: pm_runtime_put_sync(dev); err_disable_runtime_pm: pm_runtime_disable(dev); -err_put_ddc: - put_device(&vc4_hdmi->ddc->dev); return ret; } @@ -3102,8 +3110,6 @@ static void vc4_hdmi_unbind(struct device *dev, struct device *master, vc4_hdmi_hotplug_exit(vc4_hdmi); pm_runtime_disable(dev); - - put_device(&vc4_hdmi->ddc->dev); } static const struct component_ops vc4_hdmi_ops = { |