From: Laurent Pinchart Date: Mon, 23 Mar 2026 16:45:24 +0000 (+0200) Subject: drm: rcar-du: Store CMM device pointer instead of platform_device X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=0f6f28c8d88e33ccab524b3c8a86e629e12e3276;p=thirdparty%2Flinux.git drm: rcar-du: Store CMM device pointer instead of platform_device The DU driver stores the CMM devices as pointers to struct platform_device, and passes them to the API exposed by the CMM driver. This is similar to how the VSP is handled, except that the VSP uses struct device pointers. Replace the CMM platform_device pointers with device pointers for consistency. Signed-off-by: Laurent Pinchart Link: https://patch.msgid.link/20260323164526.2292491-3-laurent.pinchart+renesas@ideasonboard.com Signed-off-by: Tomi Valkeinen --- diff --git a/drivers/gpu/drm/renesas/rcar-du/rcar_cmm.c b/drivers/gpu/drm/renesas/rcar-du/rcar_cmm.c index 93ba115d654f9..5bced9d778e8d 100644 --- a/drivers/gpu/drm/renesas/rcar-du/rcar_cmm.c +++ b/drivers/gpu/drm/renesas/rcar-du/rcar_cmm.c @@ -59,7 +59,7 @@ static void rcar_cmm_lut_write(struct rcar_cmm *rcmm, /* * rcar_cmm_setup() - Configure the CMM unit - * @pdev: The platform device associated with the CMM instance + * @dev: The device associated with the CMM instance * @config: The CMM unit configuration * * Configure the CMM unit with the given configuration. Currently enabling, @@ -73,10 +73,10 @@ static void rcar_cmm_lut_write(struct rcar_cmm *rcmm, * TODO: Add support for LUT double buffer operations to avoid updating the * LUT table entries while a frame is being displayed. */ -int rcar_cmm_setup(struct platform_device *pdev, +int rcar_cmm_setup(struct device *dev, const struct rcar_cmm_config *config) { - struct rcar_cmm *rcmm = platform_get_drvdata(pdev); + struct rcar_cmm *rcmm = dev_get_drvdata(dev); /* Disable LUT if no table is provided. */ if (!config->lut.table) { @@ -102,7 +102,7 @@ EXPORT_SYMBOL_GPL(rcar_cmm_setup); /* * rcar_cmm_enable() - Enable the CMM unit - * @pdev: The platform device associated with the CMM instance + * @dev: The device associated with the CMM instance * * When the output of the corresponding DU channel is routed to the CMM unit, * the unit shall be enabled before the DU channel is started, and remain @@ -113,11 +113,11 @@ EXPORT_SYMBOL_GPL(rcar_cmm_setup); * It is an error to attempt to enable an already enabled CMM unit, or to * attempt to disable a disabled unit. */ -int rcar_cmm_enable(struct platform_device *pdev) +int rcar_cmm_enable(struct device *dev) { int ret; - ret = pm_runtime_resume_and_get(&pdev->dev); + ret = pm_runtime_resume_and_get(dev); if (ret < 0) return ret; @@ -127,7 +127,7 @@ EXPORT_SYMBOL_GPL(rcar_cmm_enable); /* * rcar_cmm_disable() - Disable the CMM unit - * @pdev: The platform device associated with the CMM instance + * @dev: The device associated with the CMM instance * * See rcar_cmm_enable() for usage information. * @@ -135,27 +135,27 @@ EXPORT_SYMBOL_GPL(rcar_cmm_enable); * state shall thus be restored with rcar_cmm_setup() when re-enabling the CMM * unit after the next rcar_cmm_enable() call. */ -void rcar_cmm_disable(struct platform_device *pdev) +void rcar_cmm_disable(struct device *dev) { - struct rcar_cmm *rcmm = platform_get_drvdata(pdev); + struct rcar_cmm *rcmm = dev_get_drvdata(dev); rcar_cmm_write(rcmm, CM2_LUT_CTRL, 0); rcmm->lut.enabled = false; - pm_runtime_put(&pdev->dev); + pm_runtime_put(dev); } EXPORT_SYMBOL_GPL(rcar_cmm_disable); /* * rcar_cmm_init() - Initialize the CMM unit - * @pdev: The platform device associated with the CMM instance + * @dev: The device associated with the CMM instance * * Return: 0 on success, -EPROBE_DEFER if the CMM is not available yet, * -ENODEV if the DRM_RCAR_CMM config option is disabled */ -int rcar_cmm_init(struct platform_device *pdev) +int rcar_cmm_init(struct device *dev) { - struct rcar_cmm *rcmm = platform_get_drvdata(pdev); + struct rcar_cmm *rcmm = dev_get_drvdata(dev); if (!rcmm) return -EPROBE_DEFER; diff --git a/drivers/gpu/drm/renesas/rcar-du/rcar_cmm.h b/drivers/gpu/drm/renesas/rcar-du/rcar_cmm.h index 628072acc98b9..c420113430b90 100644 --- a/drivers/gpu/drm/renesas/rcar-du/rcar_cmm.h +++ b/drivers/gpu/drm/renesas/rcar-du/rcar_cmm.h @@ -10,8 +10,8 @@ #define CM2_LUT_SIZE 256 +struct device; struct drm_color_lut; -struct platform_device; /** * struct rcar_cmm_config - CMM configuration @@ -26,29 +26,29 @@ struct rcar_cmm_config { }; #if IS_ENABLED(CONFIG_DRM_RCAR_CMM) -int rcar_cmm_init(struct platform_device *pdev); +int rcar_cmm_init(struct device *dev); -int rcar_cmm_enable(struct platform_device *pdev); -void rcar_cmm_disable(struct platform_device *pdev); +int rcar_cmm_enable(struct device *dev); +void rcar_cmm_disable(struct device *dev); -int rcar_cmm_setup(struct platform_device *pdev, +int rcar_cmm_setup(struct device *dev, const struct rcar_cmm_config *config); #else -static inline int rcar_cmm_init(struct platform_device *pdev) +static inline int rcar_cmm_init(struct device *dev) { return -ENODEV; } -static inline int rcar_cmm_enable(struct platform_device *pdev) +static inline int rcar_cmm_enable(struct device *dev) { return 0; } -static inline void rcar_cmm_disable(struct platform_device *pdev) +static inline void rcar_cmm_disable(struct device *dev) { } -static inline int rcar_cmm_setup(struct platform_device *pdev, +static inline int rcar_cmm_setup(struct device *dev, const struct rcar_cmm_config *config) { return 0; diff --git a/drivers/gpu/drm/renesas/rcar-du/rcar_du_crtc.h b/drivers/gpu/drm/renesas/rcar-du/rcar_du_crtc.h index d0f38a8b35618..07a40b305be82 100644 --- a/drivers/gpu/drm/renesas/rcar-du/rcar_du_crtc.h +++ b/drivers/gpu/drm/renesas/rcar-du/rcar_du_crtc.h @@ -65,7 +65,7 @@ struct rcar_du_crtc { unsigned int vblank_count; struct rcar_du_group *group; - struct platform_device *cmm; + struct device *cmm; struct rcar_du_vsp *vsp; unsigned int vsp_pipe; diff --git a/drivers/gpu/drm/renesas/rcar-du/rcar_du_drv.h b/drivers/gpu/drm/renesas/rcar-du/rcar_du_drv.h index 5cfa2bb7ad93d..9e160dede4e62 100644 --- a/drivers/gpu/drm/renesas/rcar-du/rcar_du_drv.h +++ b/drivers/gpu/drm/renesas/rcar-du/rcar_du_drv.h @@ -106,7 +106,7 @@ struct rcar_du_device { unsigned int num_crtcs; struct rcar_du_group groups[RCAR_DU_MAX_GROUPS]; - struct platform_device *cmms[RCAR_DU_MAX_CRTCS]; + struct device *cmms[RCAR_DU_MAX_CRTCS]; struct rcar_du_vsp vsps[RCAR_DU_MAX_VSPS]; struct drm_bridge *lvds[RCAR_DU_MAX_LVDS]; struct drm_bridge *dsi[RCAR_DU_MAX_DSI]; diff --git a/drivers/gpu/drm/renesas/rcar-du/rcar_du_kms.c b/drivers/gpu/drm/renesas/rcar-du/rcar_du_kms.c index 60e6f43b8ab2f..f38e45d38ad23 100644 --- a/drivers/gpu/drm/renesas/rcar-du/rcar_du_kms.c +++ b/drivers/gpu/drm/renesas/rcar-du/rcar_du_kms.c @@ -806,13 +806,13 @@ static int rcar_du_cmm_init(struct rcar_du_device *rcdu) * -ENODEV is used to report that the CMM config option is * disabled: return 0 and let the DU continue probing. */ - ret = rcar_cmm_init(pdev); + ret = rcar_cmm_init(&pdev->dev); if (ret) { platform_device_put(pdev); return ret == -ENODEV ? 0 : ret; } - rcdu->cmms[i] = pdev; + rcdu->cmms[i] = &pdev->dev; /* * Enforce suspend/resume ordering by making the CMM a provider @@ -835,7 +835,7 @@ static void rcar_du_modeset_cleanup(struct drm_device *dev, void *res) unsigned int i; for (i = 0; i < ARRAY_SIZE(rcdu->cmms); ++i) - platform_device_put(rcdu->cmms[i]); + put_device(rcdu->cmms[i]); } int rcar_du_modeset_init(struct rcar_du_device *rcdu)