OSDN Git Service

drm/bridge: adv7533: Switch to devm MIPI-DSI helpers
authorMaxime Ripard <maxime@cerno.tech>
Mon, 25 Oct 2021 15:15:16 +0000 (17:15 +0200)
committerMaxime Ripard <maxime@cerno.tech>
Wed, 27 Oct 2021 20:07:56 +0000 (22:07 +0200)
Let's switch to the new devm MIPI-DSI function to register and attach
our secondary device. This also avoids leaking the device when we detach
the bridge.

Acked-by: Sam Ravnborg <sam@ravnborg.org>
Tested-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Link: https://patchwork.freedesktop.org/patch/msgid/20211025151536.1048186-2-maxime@cerno.tech
drivers/gpu/drm/bridge/adv7511/adv7511.h
drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
drivers/gpu/drm/bridge/adv7511/adv7533.c

index 05e3abb..592ecfc 100644 (file)
@@ -401,7 +401,6 @@ void adv7533_mode_set(struct adv7511 *adv, const struct drm_display_mode *mode);
 int adv7533_patch_registers(struct adv7511 *adv);
 int adv7533_patch_cec_registers(struct adv7511 *adv);
 int adv7533_attach_dsi(struct adv7511 *adv);
-void adv7533_detach_dsi(struct adv7511 *adv);
 int adv7533_parse_dt(struct device_node *np, struct adv7511 *adv);
 
 #ifdef CONFIG_DRM_I2C_ADV7511_AUDIO
index 76555ae..9e3585f 100644 (file)
@@ -1307,8 +1307,6 @@ static int adv7511_remove(struct i2c_client *i2c)
 {
        struct adv7511 *adv7511 = i2c_get_clientdata(i2c);
 
-       if (adv7511->type == ADV7533 || adv7511->type == ADV7535)
-               adv7533_detach_dsi(adv7511);
        i2c_unregister_device(adv7511->i2c_cec);
        clk_disable_unprepare(adv7511->cec_clk);
 
index 59d718b..eb7579d 100644 (file)
@@ -153,11 +153,10 @@ int adv7533_attach_dsi(struct adv7511 *adv)
                return -EPROBE_DEFER;
        }
 
-       dsi = mipi_dsi_device_register_full(host, &info);
+       dsi = devm_mipi_dsi_device_register_full(dev, host, &info);
        if (IS_ERR(dsi)) {
                dev_err(dev, "failed to create dsi device\n");
-               ret = PTR_ERR(dsi);
-               goto err_dsi_device;
+               return PTR_ERR(dsi);
        }
 
        adv->dsi = dsi;
@@ -167,24 +166,13 @@ int adv7533_attach_dsi(struct adv7511 *adv)
        dsi->mode_flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_SYNC_PULSE |
                          MIPI_DSI_MODE_NO_EOT_PACKET | MIPI_DSI_MODE_VIDEO_HSE;
 
-       ret = mipi_dsi_attach(dsi);
+       ret = devm_mipi_dsi_attach(dev, dsi);
        if (ret < 0) {
                dev_err(dev, "failed to attach dsi to host\n");
-               goto err_dsi_attach;
+               return ret;
        }
 
        return 0;
-
-err_dsi_attach:
-       mipi_dsi_device_unregister(dsi);
-err_dsi_device:
-       return ret;
-}
-
-void adv7533_detach_dsi(struct adv7511 *adv)
-{
-       mipi_dsi_detach(adv->dsi);
-       mipi_dsi_device_unregister(adv->dsi);
 }
 
 int adv7533_parse_dt(struct device_node *np, struct adv7511 *adv)