drivers/gpu/drm/vc4/vc4_hvs.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)
There was a bug where we should have called rpi_firmware_put(firmware)
if devm_clk_get() failed. Really, it's better and more readable to
move all the firmware code together so that we can release it one
time.
Fixes: 2fa4ef5fb943 ("drm/vc4: hvs: Create hw_init function")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
v2: Use a cleaner solution
drivers/gpu/drm/vc4/vc4_hvs.c | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/drivers/gpu/drm/vc4/vc4_hvs.c b/drivers/gpu/drm/vc4/vc4_hvs.c
index 4811d794001f..06aedd906d74 100644
--- a/drivers/gpu/drm/vc4/vc4_hvs.c
+++ b/drivers/gpu/drm/vc4/vc4_hvs.c
@@ -1675,6 +1675,17 @@ static int vc4_hvs_bind(struct device *dev, struct device *master, void *data)
if (!firmware)
return -EPROBE_DEFER;
+ max_rate = rpi_firmware_clk_get_max_rate(firmware,
+ RPI_FIRMWARE_CORE_CLK_ID);
+ rpi_firmware_put(firmware);
+ if (max_rate >= 550000000)
+ hvs->vc5_hdmi_enable_hdmi_20 = true;
+
+ if (max_rate >= 600000000)
+ hvs->vc5_hdmi_enable_4096by2160 = true;
+
+ hvs->max_core_rate = max_rate;
+
hvs->core_clk = devm_clk_get(&pdev->dev,
(vc4->gen >= VC4_GEN_6_C) ? "core" : NULL);
if (IS_ERR(hvs->core_clk)) {
@@ -1689,17 +1700,6 @@ static int vc4_hvs_bind(struct device *dev, struct device *master, void *data)
return PTR_ERR(hvs->disp_clk);
}
- max_rate = rpi_firmware_clk_get_max_rate(firmware,
- RPI_FIRMWARE_CORE_CLK_ID);
- rpi_firmware_put(firmware);
- if (max_rate >= 550000000)
- hvs->vc5_hdmi_enable_hdmi_20 = true;
-
- if (max_rate >= 600000000)
- hvs->vc5_hdmi_enable_4096by2160 = true;
-
- hvs->max_core_rate = max_rate;
-
ret = clk_prepare_enable(hvs->core_clk);
if (ret) {
dev_err(&pdev->dev, "Couldn't enable the core clock\n");
--
2.47.2
On Thu, 3 Apr 2025 at 13:14, Dan Carpenter <dan.carpenter@linaro.org> wrote: > > There was a bug where we should have called rpi_firmware_put(firmware) > if devm_clk_get() failed. Really, it's better and more readable to > move all the firmware code together so that we can release it one > time. > > Fixes: 2fa4ef5fb943 ("drm/vc4: hvs: Create hw_init function") > Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org> Thanks for the respin Reviewed-by: Dave Stevenson <dave.stevenson@raspberrypi.com> > --- > v2: Use a cleaner solution > > drivers/gpu/drm/vc4/vc4_hvs.c | 22 +++++++++++----------- > 1 file changed, 11 insertions(+), 11 deletions(-) > > diff --git a/drivers/gpu/drm/vc4/vc4_hvs.c b/drivers/gpu/drm/vc4/vc4_hvs.c > index 4811d794001f..06aedd906d74 100644 > --- a/drivers/gpu/drm/vc4/vc4_hvs.c > +++ b/drivers/gpu/drm/vc4/vc4_hvs.c > @@ -1675,6 +1675,17 @@ static int vc4_hvs_bind(struct device *dev, struct device *master, void *data) > if (!firmware) > return -EPROBE_DEFER; > > + max_rate = rpi_firmware_clk_get_max_rate(firmware, > + RPI_FIRMWARE_CORE_CLK_ID); > + rpi_firmware_put(firmware); > + if (max_rate >= 550000000) > + hvs->vc5_hdmi_enable_hdmi_20 = true; > + > + if (max_rate >= 600000000) > + hvs->vc5_hdmi_enable_4096by2160 = true; > + > + hvs->max_core_rate = max_rate; > + > hvs->core_clk = devm_clk_get(&pdev->dev, > (vc4->gen >= VC4_GEN_6_C) ? "core" : NULL); > if (IS_ERR(hvs->core_clk)) { > @@ -1689,17 +1700,6 @@ static int vc4_hvs_bind(struct device *dev, struct device *master, void *data) > return PTR_ERR(hvs->disp_clk); > } > > - max_rate = rpi_firmware_clk_get_max_rate(firmware, > - RPI_FIRMWARE_CORE_CLK_ID); > - rpi_firmware_put(firmware); > - if (max_rate >= 550000000) > - hvs->vc5_hdmi_enable_hdmi_20 = true; > - > - if (max_rate >= 600000000) > - hvs->vc5_hdmi_enable_4096by2160 = true; > - > - hvs->max_core_rate = max_rate; > - > ret = clk_prepare_enable(hvs->core_clk); > if (ret) { > dev_err(&pdev->dev, "Couldn't enable the core clock\n"); > -- > 2.47.2 >
© 2016 - 2025 Red Hat, Inc.