Commit c2e938ee authored by Geert Uytterhoeven's avatar Geert Uytterhoeven

drm: renesas: shmobile: Replace .dev_private with container_of()

Now that drm_device is embedded in shmob_drm_device, we can use
a container_of()-based helper to get the shmob_drm_device pointer from
the drm_device, instead of using the deprecated drm_device.dev_private
field.

While at it, restore reverse Xmas tree ordering of local variable
declarations.
Reviewed-by: default avatarLaurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Reviewed-by: default avatarSui Jingfeng <suijingfeng@loongson.cn>
Signed-off-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
Link: https://lore.kernel.org/r/8ef4be8bffe75efc7f4b66f3732ec357f7d43e0f.1694767209.git.geert+renesas@glider.be
parent 02e6c5b7
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
static void shmob_drm_crtc_setup_geometry(struct shmob_drm_crtc *scrtc) static void shmob_drm_crtc_setup_geometry(struct shmob_drm_crtc *scrtc)
{ {
struct drm_crtc *crtc = &scrtc->crtc; struct drm_crtc *crtc = &scrtc->crtc;
struct shmob_drm_device *sdev = crtc->dev->dev_private; struct shmob_drm_device *sdev = to_shmob_device(crtc->dev);
const struct shmob_drm_interface_data *idata = &sdev->pdata->iface; const struct shmob_drm_interface_data *idata = &sdev->pdata->iface;
const struct drm_display_mode *mode = &crtc->mode; const struct drm_display_mode *mode = &crtc->mode;
u32 value; u32 value;
...@@ -79,7 +79,7 @@ static void shmob_drm_crtc_setup_geometry(struct shmob_drm_crtc *scrtc) ...@@ -79,7 +79,7 @@ static void shmob_drm_crtc_setup_geometry(struct shmob_drm_crtc *scrtc)
static void shmob_drm_crtc_start_stop(struct shmob_drm_crtc *scrtc, bool start) static void shmob_drm_crtc_start_stop(struct shmob_drm_crtc *scrtc, bool start)
{ {
struct shmob_drm_device *sdev = scrtc->crtc.dev->dev_private; struct shmob_drm_device *sdev = to_shmob_device(scrtc->crtc.dev);
u32 value; u32 value;
value = lcdc_read(sdev, LDCNT2R); value = lcdc_read(sdev, LDCNT2R);
...@@ -113,7 +113,7 @@ static void shmob_drm_crtc_start_stop(struct shmob_drm_crtc *scrtc, bool start) ...@@ -113,7 +113,7 @@ static void shmob_drm_crtc_start_stop(struct shmob_drm_crtc *scrtc, bool start)
static void shmob_drm_crtc_start(struct shmob_drm_crtc *scrtc) static void shmob_drm_crtc_start(struct shmob_drm_crtc *scrtc)
{ {
struct drm_crtc *crtc = &scrtc->crtc; struct drm_crtc *crtc = &scrtc->crtc;
struct shmob_drm_device *sdev = crtc->dev->dev_private; struct shmob_drm_device *sdev = to_shmob_device(crtc->dev);
const struct shmob_drm_interface_data *idata = &sdev->pdata->iface; const struct shmob_drm_interface_data *idata = &sdev->pdata->iface;
const struct shmob_drm_format_info *format; const struct shmob_drm_format_info *format;
struct drm_device *dev = &sdev->ddev; struct drm_device *dev = &sdev->ddev;
...@@ -193,7 +193,7 @@ static void shmob_drm_crtc_start(struct shmob_drm_crtc *scrtc) ...@@ -193,7 +193,7 @@ static void shmob_drm_crtc_start(struct shmob_drm_crtc *scrtc)
static void shmob_drm_crtc_stop(struct shmob_drm_crtc *scrtc) static void shmob_drm_crtc_stop(struct shmob_drm_crtc *scrtc)
{ {
struct drm_crtc *crtc = &scrtc->crtc; struct drm_crtc *crtc = &scrtc->crtc;
struct shmob_drm_device *sdev = crtc->dev->dev_private; struct shmob_drm_device *sdev = to_shmob_device(crtc->dev);
if (!scrtc->started) if (!scrtc->started)
return; return;
...@@ -247,7 +247,7 @@ static void shmob_drm_crtc_compute_base(struct shmob_drm_crtc *scrtc, ...@@ -247,7 +247,7 @@ static void shmob_drm_crtc_compute_base(struct shmob_drm_crtc *scrtc,
static void shmob_drm_crtc_update_base(struct shmob_drm_crtc *scrtc) static void shmob_drm_crtc_update_base(struct shmob_drm_crtc *scrtc)
{ {
struct drm_crtc *crtc = &scrtc->crtc; struct drm_crtc *crtc = &scrtc->crtc;
struct shmob_drm_device *sdev = crtc->dev->dev_private; struct shmob_drm_device *sdev = to_shmob_device(crtc->dev);
shmob_drm_crtc_compute_base(scrtc, crtc->x, crtc->y); shmob_drm_crtc_compute_base(scrtc, crtc->x, crtc->y);
...@@ -289,8 +289,8 @@ static int shmob_drm_crtc_mode_set(struct drm_crtc *crtc, ...@@ -289,8 +289,8 @@ static int shmob_drm_crtc_mode_set(struct drm_crtc *crtc,
int x, int y, int x, int y,
struct drm_framebuffer *old_fb) struct drm_framebuffer *old_fb)
{ {
struct shmob_drm_device *sdev = to_shmob_device(crtc->dev);
struct shmob_drm_crtc *scrtc = to_shmob_crtc(crtc); struct shmob_drm_crtc *scrtc = to_shmob_crtc(crtc);
struct shmob_drm_device *sdev = crtc->dev->dev_private;
const struct shmob_drm_format_info *format; const struct shmob_drm_format_info *format;
format = shmob_drm_format_info(crtc->primary->fb->format->format); format = shmob_drm_format_info(crtc->primary->fb->format->format);
...@@ -395,7 +395,7 @@ static void shmob_drm_crtc_enable_vblank(struct shmob_drm_device *sdev, ...@@ -395,7 +395,7 @@ static void shmob_drm_crtc_enable_vblank(struct shmob_drm_device *sdev,
static int shmob_drm_enable_vblank(struct drm_crtc *crtc) static int shmob_drm_enable_vblank(struct drm_crtc *crtc)
{ {
struct shmob_drm_device *sdev = crtc->dev->dev_private; struct shmob_drm_device *sdev = to_shmob_device(crtc->dev);
shmob_drm_crtc_enable_vblank(sdev, true); shmob_drm_crtc_enable_vblank(sdev, true);
...@@ -404,7 +404,7 @@ static int shmob_drm_enable_vblank(struct drm_crtc *crtc) ...@@ -404,7 +404,7 @@ static int shmob_drm_enable_vblank(struct drm_crtc *crtc)
static void shmob_drm_disable_vblank(struct drm_crtc *crtc) static void shmob_drm_disable_vblank(struct drm_crtc *crtc)
{ {
struct shmob_drm_device *sdev = crtc->dev->dev_private; struct shmob_drm_device *sdev = to_shmob_device(crtc->dev);
shmob_drm_crtc_enable_vblank(sdev, false); shmob_drm_crtc_enable_vblank(sdev, false);
} }
...@@ -478,7 +478,7 @@ static bool shmob_drm_encoder_mode_fixup(struct drm_encoder *encoder, ...@@ -478,7 +478,7 @@ static bool shmob_drm_encoder_mode_fixup(struct drm_encoder *encoder,
struct drm_display_mode *adjusted_mode) struct drm_display_mode *adjusted_mode)
{ {
struct drm_device *dev = encoder->dev; struct drm_device *dev = encoder->dev;
struct shmob_drm_device *sdev = dev->dev_private; struct shmob_drm_device *sdev = to_shmob_device(dev);
struct drm_connector *connector = &sdev->connector.connector; struct drm_connector *connector = &sdev->connector.connector;
const struct drm_display_mode *panel_mode; const struct drm_display_mode *panel_mode;
...@@ -548,7 +548,7 @@ static inline struct shmob_drm_connector *to_shmob_connector(struct drm_connecto ...@@ -548,7 +548,7 @@ static inline struct shmob_drm_connector *to_shmob_connector(struct drm_connecto
static int shmob_drm_connector_get_modes(struct drm_connector *connector) static int shmob_drm_connector_get_modes(struct drm_connector *connector)
{ {
struct shmob_drm_device *sdev = connector->dev->dev_private; struct shmob_drm_device *sdev = to_shmob_device(connector->dev);
struct drm_display_mode *mode; struct drm_display_mode *mode;
mode = drm_mode_create(connector->dev); mode = drm_mode_create(connector->dev);
......
...@@ -95,7 +95,7 @@ static int shmob_drm_setup_clocks(struct shmob_drm_device *sdev, ...@@ -95,7 +95,7 @@ static int shmob_drm_setup_clocks(struct shmob_drm_device *sdev,
static irqreturn_t shmob_drm_irq(int irq, void *arg) static irqreturn_t shmob_drm_irq(int irq, void *arg)
{ {
struct drm_device *dev = arg; struct drm_device *dev = arg;
struct shmob_drm_device *sdev = dev->dev_private; struct shmob_drm_device *sdev = to_shmob_device(dev);
unsigned long flags; unsigned long flags;
u32 status; u32 status;
...@@ -243,8 +243,6 @@ static int shmob_drm_probe(struct platform_device *pdev) ...@@ -243,8 +243,6 @@ static int shmob_drm_probe(struct platform_device *pdev)
if (ret < 0) if (ret < 0)
return ret; return ret;
ddev->dev_private = sdev;
ret = shmob_drm_modeset_init(sdev); ret = shmob_drm_modeset_init(sdev);
if (ret < 0) if (ret < 0)
return dev_err_probe(&pdev->dev, ret, return dev_err_probe(&pdev->dev, ret,
......
...@@ -39,4 +39,9 @@ struct shmob_drm_device { ...@@ -39,4 +39,9 @@ struct shmob_drm_device {
struct shmob_drm_connector connector; struct shmob_drm_connector connector;
}; };
static inline struct shmob_drm_device *to_shmob_device(struct drm_device *dev)
{
return container_of(dev, struct shmob_drm_device, ddev);
}
#endif /* __SHMOB_DRM_DRV_H__ */ #endif /* __SHMOB_DRM_DRV_H__ */
...@@ -63,7 +63,7 @@ static void shmob_drm_plane_compute_base(struct shmob_drm_plane *splane, ...@@ -63,7 +63,7 @@ static void shmob_drm_plane_compute_base(struct shmob_drm_plane *splane,
static void __shmob_drm_plane_setup(struct shmob_drm_plane *splane, static void __shmob_drm_plane_setup(struct shmob_drm_plane *splane,
struct drm_framebuffer *fb) struct drm_framebuffer *fb)
{ {
struct shmob_drm_device *sdev = splane->plane.dev->dev_private; struct shmob_drm_device *sdev = to_shmob_device(splane->plane.dev);
u32 format; u32 format;
/* TODO: Support ROP3 mode */ /* TODO: Support ROP3 mode */
...@@ -135,8 +135,8 @@ shmob_drm_plane_update(struct drm_plane *plane, struct drm_crtc *crtc, ...@@ -135,8 +135,8 @@ shmob_drm_plane_update(struct drm_plane *plane, struct drm_crtc *crtc,
uint32_t src_w, uint32_t src_h, uint32_t src_w, uint32_t src_h,
struct drm_modeset_acquire_ctx *ctx) struct drm_modeset_acquire_ctx *ctx)
{ {
struct shmob_drm_device *sdev = to_shmob_device(plane->dev);
struct shmob_drm_plane *splane = to_shmob_plane(plane); struct shmob_drm_plane *splane = to_shmob_plane(plane);
struct shmob_drm_device *sdev = plane->dev->dev_private;
const struct shmob_drm_format_info *format; const struct shmob_drm_format_info *format;
format = shmob_drm_format_info(fb->format->format); format = shmob_drm_format_info(fb->format->format);
...@@ -167,8 +167,8 @@ shmob_drm_plane_update(struct drm_plane *plane, struct drm_crtc *crtc, ...@@ -167,8 +167,8 @@ shmob_drm_plane_update(struct drm_plane *plane, struct drm_crtc *crtc,
static int shmob_drm_plane_disable(struct drm_plane *plane, static int shmob_drm_plane_disable(struct drm_plane *plane,
struct drm_modeset_acquire_ctx *ctx) struct drm_modeset_acquire_ctx *ctx)
{ {
struct shmob_drm_device *sdev = to_shmob_device(plane->dev);
struct shmob_drm_plane *splane = to_shmob_plane(plane); struct shmob_drm_plane *splane = to_shmob_plane(plane);
struct shmob_drm_device *sdev = plane->dev->dev_private;
splane->format = NULL; splane->format = NULL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment