Skip to content

Commit c2e938e

Browse files
committed
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: Laurent Pinchart <[email protected]> Reviewed-by: Sui Jingfeng <[email protected]> Signed-off-by: Geert Uytterhoeven <[email protected]> Link: https://lore.kernel.org/r/8ef4be8bffe75efc7f4b66f3732ec357f7d43e0f.1694767209.git.geert+renesas@glider.be
1 parent 02e6c5b commit c2e938e

File tree

4 files changed

+19
-16
lines changed

4 files changed

+19
-16
lines changed

drivers/gpu/drm/renesas/shmobile/shmob_drm_crtc.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
static void shmob_drm_crtc_setup_geometry(struct shmob_drm_crtc *scrtc)
4141
{
4242
struct drm_crtc *crtc = &scrtc->crtc;
43-
struct shmob_drm_device *sdev = crtc->dev->dev_private;
43+
struct shmob_drm_device *sdev = to_shmob_device(crtc->dev);
4444
const struct shmob_drm_interface_data *idata = &sdev->pdata->iface;
4545
const struct drm_display_mode *mode = &crtc->mode;
4646
u32 value;
@@ -79,7 +79,7 @@ static void shmob_drm_crtc_setup_geometry(struct shmob_drm_crtc *scrtc)
7979

8080
static void shmob_drm_crtc_start_stop(struct shmob_drm_crtc *scrtc, bool start)
8181
{
82-
struct shmob_drm_device *sdev = scrtc->crtc.dev->dev_private;
82+
struct shmob_drm_device *sdev = to_shmob_device(scrtc->crtc.dev);
8383
u32 value;
8484

8585
value = lcdc_read(sdev, LDCNT2R);
@@ -113,7 +113,7 @@ static void shmob_drm_crtc_start_stop(struct shmob_drm_crtc *scrtc, bool start)
113113
static void shmob_drm_crtc_start(struct shmob_drm_crtc *scrtc)
114114
{
115115
struct drm_crtc *crtc = &scrtc->crtc;
116-
struct shmob_drm_device *sdev = crtc->dev->dev_private;
116+
struct shmob_drm_device *sdev = to_shmob_device(crtc->dev);
117117
const struct shmob_drm_interface_data *idata = &sdev->pdata->iface;
118118
const struct shmob_drm_format_info *format;
119119
struct drm_device *dev = &sdev->ddev;
@@ -193,7 +193,7 @@ static void shmob_drm_crtc_start(struct shmob_drm_crtc *scrtc)
193193
static void shmob_drm_crtc_stop(struct shmob_drm_crtc *scrtc)
194194
{
195195
struct drm_crtc *crtc = &scrtc->crtc;
196-
struct shmob_drm_device *sdev = crtc->dev->dev_private;
196+
struct shmob_drm_device *sdev = to_shmob_device(crtc->dev);
197197

198198
if (!scrtc->started)
199199
return;
@@ -247,7 +247,7 @@ static void shmob_drm_crtc_compute_base(struct shmob_drm_crtc *scrtc,
247247
static void shmob_drm_crtc_update_base(struct shmob_drm_crtc *scrtc)
248248
{
249249
struct drm_crtc *crtc = &scrtc->crtc;
250-
struct shmob_drm_device *sdev = crtc->dev->dev_private;
250+
struct shmob_drm_device *sdev = to_shmob_device(crtc->dev);
251251

252252
shmob_drm_crtc_compute_base(scrtc, crtc->x, crtc->y);
253253

@@ -289,8 +289,8 @@ static int shmob_drm_crtc_mode_set(struct drm_crtc *crtc,
289289
int x, int y,
290290
struct drm_framebuffer *old_fb)
291291
{
292+
struct shmob_drm_device *sdev = to_shmob_device(crtc->dev);
292293
struct shmob_drm_crtc *scrtc = to_shmob_crtc(crtc);
293-
struct shmob_drm_device *sdev = crtc->dev->dev_private;
294294
const struct shmob_drm_format_info *format;
295295

296296
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,
395395

396396
static int shmob_drm_enable_vblank(struct drm_crtc *crtc)
397397
{
398-
struct shmob_drm_device *sdev = crtc->dev->dev_private;
398+
struct shmob_drm_device *sdev = to_shmob_device(crtc->dev);
399399

400400
shmob_drm_crtc_enable_vblank(sdev, true);
401401

@@ -404,7 +404,7 @@ static int shmob_drm_enable_vblank(struct drm_crtc *crtc)
404404

405405
static void shmob_drm_disable_vblank(struct drm_crtc *crtc)
406406
{
407-
struct shmob_drm_device *sdev = crtc->dev->dev_private;
407+
struct shmob_drm_device *sdev = to_shmob_device(crtc->dev);
408408

409409
shmob_drm_crtc_enable_vblank(sdev, false);
410410
}
@@ -478,7 +478,7 @@ static bool shmob_drm_encoder_mode_fixup(struct drm_encoder *encoder,
478478
struct drm_display_mode *adjusted_mode)
479479
{
480480
struct drm_device *dev = encoder->dev;
481-
struct shmob_drm_device *sdev = dev->dev_private;
481+
struct shmob_drm_device *sdev = to_shmob_device(dev);
482482
struct drm_connector *connector = &sdev->connector.connector;
483483
const struct drm_display_mode *panel_mode;
484484

@@ -548,7 +548,7 @@ static inline struct shmob_drm_connector *to_shmob_connector(struct drm_connecto
548548

549549
static int shmob_drm_connector_get_modes(struct drm_connector *connector)
550550
{
551-
struct shmob_drm_device *sdev = connector->dev->dev_private;
551+
struct shmob_drm_device *sdev = to_shmob_device(connector->dev);
552552
struct drm_display_mode *mode;
553553

554554
mode = drm_mode_create(connector->dev);

drivers/gpu/drm/renesas/shmobile/shmob_drm_drv.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ static int shmob_drm_setup_clocks(struct shmob_drm_device *sdev,
9595
static irqreturn_t shmob_drm_irq(int irq, void *arg)
9696
{
9797
struct drm_device *dev = arg;
98-
struct shmob_drm_device *sdev = dev->dev_private;
98+
struct shmob_drm_device *sdev = to_shmob_device(dev);
9999
unsigned long flags;
100100
u32 status;
101101

@@ -243,8 +243,6 @@ static int shmob_drm_probe(struct platform_device *pdev)
243243
if (ret < 0)
244244
return ret;
245245

246-
ddev->dev_private = sdev;
247-
248246
ret = shmob_drm_modeset_init(sdev);
249247
if (ret < 0)
250248
return dev_err_probe(&pdev->dev, ret,

drivers/gpu/drm/renesas/shmobile/shmob_drm_drv.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,9 @@ struct shmob_drm_device {
3939
struct shmob_drm_connector connector;
4040
};
4141

42+
static inline struct shmob_drm_device *to_shmob_device(struct drm_device *dev)
43+
{
44+
return container_of(dev, struct shmob_drm_device, ddev);
45+
}
46+
4247
#endif /* __SHMOB_DRM_DRV_H__ */

drivers/gpu/drm/renesas/shmobile/shmob_drm_plane.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ static void shmob_drm_plane_compute_base(struct shmob_drm_plane *splane,
6363
static void __shmob_drm_plane_setup(struct shmob_drm_plane *splane,
6464
struct drm_framebuffer *fb)
6565
{
66-
struct shmob_drm_device *sdev = splane->plane.dev->dev_private;
66+
struct shmob_drm_device *sdev = to_shmob_device(splane->plane.dev);
6767
u32 format;
6868

6969
/* TODO: Support ROP3 mode */
@@ -135,8 +135,8 @@ shmob_drm_plane_update(struct drm_plane *plane, struct drm_crtc *crtc,
135135
uint32_t src_w, uint32_t src_h,
136136
struct drm_modeset_acquire_ctx *ctx)
137137
{
138+
struct shmob_drm_device *sdev = to_shmob_device(plane->dev);
138139
struct shmob_drm_plane *splane = to_shmob_plane(plane);
139-
struct shmob_drm_device *sdev = plane->dev->dev_private;
140140
const struct shmob_drm_format_info *format;
141141

142142
format = shmob_drm_format_info(fb->format->format);
@@ -167,8 +167,8 @@ shmob_drm_plane_update(struct drm_plane *plane, struct drm_crtc *crtc,
167167
static int shmob_drm_plane_disable(struct drm_plane *plane,
168168
struct drm_modeset_acquire_ctx *ctx)
169169
{
170+
struct shmob_drm_device *sdev = to_shmob_device(plane->dev);
170171
struct shmob_drm_plane *splane = to_shmob_plane(plane);
171-
struct shmob_drm_device *sdev = plane->dev->dev_private;
172172

173173
splane->format = NULL;
174174

0 commit comments

Comments
 (0)