Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/meson: osd_afbcd: Add an exit callback to struct meson_afbcd_ops

Use this to simplify the driver shutdown. It will also come handy when
fixing the error handling in meson_drv_bind_master().

Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Fixes: d1b5e41e13a7e9 ("drm/meson: Add AFBCD module driver")
Acked-by: Neil Armstrong <narmstrong@baylibre.com>
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20211230235515.1627522-2-martin.blumenstingl@googlemail.com

authored by

Martin Blumenstingl and committed by
Neil Armstrong
04b8a5d9 6edf6156

+30 -18
+2 -4
drivers/gpu/drm/meson/meson_drv.c
··· 385 385 free_irq(priv->vsync_irq, drm); 386 386 drm_dev_put(drm); 387 387 388 - if (priv->afbcd.ops) { 389 - priv->afbcd.ops->reset(priv); 390 - meson_rdma_free(priv); 391 - } 388 + if (priv->afbcd.ops) 389 + priv->afbcd.ops->exit(priv); 392 390 } 393 391 394 392 static const struct component_master_ops meson_drv_master_ops = {
+27 -14
drivers/gpu/drm/meson/meson_osd_afbcd.c
··· 79 79 return meson_gxm_afbcd_pixel_fmt(modifier, format) >= 0; 80 80 } 81 81 82 - static int meson_gxm_afbcd_init(struct meson_drm *priv) 83 - { 84 - return 0; 85 - } 86 - 87 82 static int meson_gxm_afbcd_reset(struct meson_drm *priv) 88 83 { 89 84 writel_relaxed(VIU_SW_RESET_OSD1_AFBCD, ··· 86 91 writel_relaxed(0, priv->io_base + _REG(VIU_SW_RESET)); 87 92 88 93 return 0; 94 + } 95 + 96 + static int meson_gxm_afbcd_init(struct meson_drm *priv) 97 + { 98 + return 0; 99 + } 100 + 101 + static void meson_gxm_afbcd_exit(struct meson_drm *priv) 102 + { 103 + meson_gxm_afbcd_reset(priv); 89 104 } 90 105 91 106 static int meson_gxm_afbcd_enable(struct meson_drm *priv) ··· 177 172 178 173 struct meson_afbcd_ops meson_afbcd_gxm_ops = { 179 174 .init = meson_gxm_afbcd_init, 175 + .exit = meson_gxm_afbcd_exit, 180 176 .reset = meson_gxm_afbcd_reset, 181 177 .enable = meson_gxm_afbcd_enable, 182 178 .disable = meson_gxm_afbcd_disable, ··· 275 269 return meson_g12a_afbcd_pixel_fmt(modifier, format) >= 0; 276 270 } 277 271 272 + static int meson_g12a_afbcd_reset(struct meson_drm *priv) 273 + { 274 + meson_rdma_reset(priv); 275 + 276 + meson_rdma_writel_sync(priv, VIU_SW_RESET_G12A_AFBC_ARB | 277 + VIU_SW_RESET_G12A_OSD1_AFBCD, 278 + VIU_SW_RESET); 279 + meson_rdma_writel_sync(priv, 0, VIU_SW_RESET); 280 + 281 + return 0; 282 + } 283 + 278 284 static int meson_g12a_afbcd_init(struct meson_drm *priv) 279 285 { 280 286 int ret; ··· 304 286 return 0; 305 287 } 306 288 307 - static int meson_g12a_afbcd_reset(struct meson_drm *priv) 289 + static void meson_g12a_afbcd_exit(struct meson_drm *priv) 308 290 { 309 - meson_rdma_reset(priv); 310 - 311 - meson_rdma_writel_sync(priv, VIU_SW_RESET_G12A_AFBC_ARB | 312 - VIU_SW_RESET_G12A_OSD1_AFBCD, 313 - VIU_SW_RESET); 314 - meson_rdma_writel_sync(priv, 0, VIU_SW_RESET); 315 - 316 - return 0; 291 + meson_g12a_afbcd_reset(priv); 292 + meson_rdma_free(priv); 317 293 } 318 294 319 295 static int meson_g12a_afbcd_enable(struct meson_drm *priv) ··· 392 380 393 381 struct meson_afbcd_ops meson_afbcd_g12a_ops = { 394 382 .init = meson_g12a_afbcd_init, 383 + .exit = meson_g12a_afbcd_exit, 395 384 .reset = meson_g12a_afbcd_reset, 396 385 .enable = meson_g12a_afbcd_enable, 397 386 .disable = meson_g12a_afbcd_disable,
+1
drivers/gpu/drm/meson/meson_osd_afbcd.h
··· 14 14 15 15 struct meson_afbcd_ops { 16 16 int (*init)(struct meson_drm *priv); 17 + void (*exit)(struct meson_drm *priv); 17 18 int (*reset)(struct meson_drm *priv); 18 19 int (*enable)(struct meson_drm *priv); 19 20 int (*disable)(struct meson_drm *priv);