From nobody Wed Dec 17 23:26:18 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EE055EE644C for ; Fri, 15 Sep 2023 08:56:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233607AbjIOI4E (ORCPT ); Fri, 15 Sep 2023 04:56:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60206 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233425AbjIOIyq (ORCPT ); Fri, 15 Sep 2023 04:54:46 -0400 Received: from riemann.telenet-ops.be (riemann.telenet-ops.be [IPv6:2a02:1800:110:4::f00:10]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 42C1610C3 for ; Fri, 15 Sep 2023 01:54:20 -0700 (PDT) Received: from michel.telenet-ops.be (michel.telenet-ops.be [IPv6:2a02:1800:110:4::f00:18]) by riemann.telenet-ops.be (Postfix) with ESMTPS id 4Rn7KP64Gzz4xr35 for ; Fri, 15 Sep 2023 10:54:17 +0200 (CEST) Received: from ramsan.of.borg ([IPv6:2a02:1810:ac12:ed40:7135:da8b:ba1d:1a7c]) by michel.telenet-ops.be with bizsmtp id m8uE2A00e3q21w7068uEDX; Fri, 15 Sep 2023 10:54:17 +0200 Received: from rox.of.borg ([192.168.97.57]) by ramsan.of.borg with esmtp (Exim 4.95) (envelope-from ) id 1qh4aJ-003lHI-NY; Fri, 15 Sep 2023 10:54:14 +0200 Received: from geert by rox.of.borg with local (Exim 4.95) (envelope-from ) id 1qh4ac-00GdcO-OA; Fri, 15 Sep 2023 10:54:14 +0200 From: Geert Uytterhoeven To: Laurent Pinchart , Kieran Bingham , David Airlie , Daniel Vetter , Thomas Zimmermann , Magnus Damm Cc: dri-devel@lists.freedesktop.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Geert Uytterhoeven , Laurent Pinchart , Sui Jingfeng Subject: [PATCH v4 22/41] drm: renesas: shmobile: Replace .dev_private with container_of() Date: Fri, 15 Sep 2023 10:53:37 +0200 Message-Id: <8ef4be8bffe75efc7f4b66f3732ec357f7d43e0f.1694767209.git.geert+renesas@glider.be> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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. Signed-off-by: Geert Uytterhoeven Reviewed-by: Laurent Pinchart Reviewed-by: Sui Jingfeng --- v4: - No changes, v3: - No changes, v2: - Add Reviewed-by. --- .../gpu/drm/renesas/shmobile/shmob_drm_crtc.c | 20 +++++++++---------- .../gpu/drm/renesas/shmobile/shmob_drm_drv.c | 4 +--- .../gpu/drm/renesas/shmobile/shmob_drm_drv.h | 5 +++++ .../drm/renesas/shmobile/shmob_drm_plane.c | 6 +++--- 4 files changed, 19 insertions(+), 16 deletions(-) diff --git a/drivers/gpu/drm/renesas/shmobile/shmob_drm_crtc.c b/drivers/gp= u/drm/renesas/shmobile/shmob_drm_crtc.c index 207fa98fe76d6f88..f62ae047a48f615b 100644 --- a/drivers/gpu/drm/renesas/shmobile/shmob_drm_crtc.c +++ b/drivers/gpu/drm/renesas/shmobile/shmob_drm_crtc.c @@ -40,7 +40,7 @@ static void shmob_drm_crtc_setup_geometry(struct shmob_drm_crtc *scrtc) { struct drm_crtc *crtc =3D &scrtc->crtc; - struct shmob_drm_device *sdev =3D crtc->dev->dev_private; + struct shmob_drm_device *sdev =3D to_shmob_device(crtc->dev); const struct shmob_drm_interface_data *idata =3D &sdev->pdata->iface; const struct drm_display_mode *mode =3D &crtc->mode; u32 value; @@ -79,7 +79,7 @@ static void shmob_drm_crtc_setup_geometry(struct shmob_dr= m_crtc *scrtc) =20 static void shmob_drm_crtc_start_stop(struct shmob_drm_crtc *scrtc, bool s= tart) { - struct shmob_drm_device *sdev =3D scrtc->crtc.dev->dev_private; + struct shmob_drm_device *sdev =3D to_shmob_device(scrtc->crtc.dev); u32 value; =20 value =3D lcdc_read(sdev, LDCNT2R); @@ -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) { struct drm_crtc *crtc =3D &scrtc->crtc; - struct shmob_drm_device *sdev =3D crtc->dev->dev_private; + struct shmob_drm_device *sdev =3D to_shmob_device(crtc->dev); const struct shmob_drm_interface_data *idata =3D &sdev->pdata->iface; const struct shmob_drm_format_info *format; struct drm_device *dev =3D &sdev->ddev; @@ -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) { struct drm_crtc *crtc =3D &scrtc->crtc; - struct shmob_drm_device *sdev =3D crtc->dev->dev_private; + struct shmob_drm_device *sdev =3D to_shmob_device(crtc->dev); =20 if (!scrtc->started) return; @@ -247,7 +247,7 @@ static void shmob_drm_crtc_compute_base(struct shmob_dr= m_crtc *scrtc, static void shmob_drm_crtc_update_base(struct shmob_drm_crtc *scrtc) { struct drm_crtc *crtc =3D &scrtc->crtc; - struct shmob_drm_device *sdev =3D crtc->dev->dev_private; + struct shmob_drm_device *sdev =3D to_shmob_device(crtc->dev); =20 shmob_drm_crtc_compute_base(scrtc, crtc->x, crtc->y); =20 @@ -289,8 +289,8 @@ static int shmob_drm_crtc_mode_set(struct drm_crtc *crt= c, int x, int y, struct drm_framebuffer *old_fb) { + struct shmob_drm_device *sdev =3D to_shmob_device(crtc->dev); struct shmob_drm_crtc *scrtc =3D to_shmob_crtc(crtc); - struct shmob_drm_device *sdev =3D crtc->dev->dev_private; const struct shmob_drm_format_info *format; =20 format =3D shmob_drm_format_info(crtc->primary->fb->format->format); @@ -395,7 +395,7 @@ static void shmob_drm_crtc_enable_vblank(struct shmob_d= rm_device *sdev, =20 static int shmob_drm_enable_vblank(struct drm_crtc *crtc) { - struct shmob_drm_device *sdev =3D crtc->dev->dev_private; + struct shmob_drm_device *sdev =3D to_shmob_device(crtc->dev); =20 shmob_drm_crtc_enable_vblank(sdev, true); =20 @@ -404,7 +404,7 @@ static int shmob_drm_enable_vblank(struct drm_crtc *crt= c) =20 static void shmob_drm_disable_vblank(struct drm_crtc *crtc) { - struct shmob_drm_device *sdev =3D crtc->dev->dev_private; + struct shmob_drm_device *sdev =3D to_shmob_device(crtc->dev); =20 shmob_drm_crtc_enable_vblank(sdev, false); } @@ -478,7 +478,7 @@ static bool shmob_drm_encoder_mode_fixup(struct drm_enc= oder *encoder, struct drm_display_mode *adjusted_mode) { struct drm_device *dev =3D encoder->dev; - struct shmob_drm_device *sdev =3D dev->dev_private; + struct shmob_drm_device *sdev =3D to_shmob_device(dev); struct drm_connector *connector =3D &sdev->connector.connector; const struct drm_display_mode *panel_mode; =20 @@ -548,7 +548,7 @@ static inline struct shmob_drm_connector *to_shmob_conn= ector(struct drm_connecto =20 static int shmob_drm_connector_get_modes(struct drm_connector *connector) { - struct shmob_drm_device *sdev =3D connector->dev->dev_private; + struct shmob_drm_device *sdev =3D to_shmob_device(connector->dev); struct drm_display_mode *mode; =20 mode =3D drm_mode_create(connector->dev); diff --git a/drivers/gpu/drm/renesas/shmobile/shmob_drm_drv.c b/drivers/gpu= /drm/renesas/shmobile/shmob_drm_drv.c index 56e2f407ab53a476..7e5977d3e256dab2 100644 --- a/drivers/gpu/drm/renesas/shmobile/shmob_drm_drv.c +++ b/drivers/gpu/drm/renesas/shmobile/shmob_drm_drv.c @@ -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) { struct drm_device *dev =3D arg; - struct shmob_drm_device *sdev =3D dev->dev_private; + struct shmob_drm_device *sdev =3D to_shmob_device(dev); unsigned long flags; u32 status; =20 @@ -243,8 +243,6 @@ static int shmob_drm_probe(struct platform_device *pdev) if (ret < 0) return ret; =20 - ddev->dev_private =3D sdev; - ret =3D shmob_drm_modeset_init(sdev); if (ret < 0) return dev_err_probe(&pdev->dev, ret, diff --git a/drivers/gpu/drm/renesas/shmobile/shmob_drm_drv.h b/drivers/gpu= /drm/renesas/shmobile/shmob_drm_drv.h index 77bb0da48f37ace8..5e55ba7a207865bd 100644 --- a/drivers/gpu/drm/renesas/shmobile/shmob_drm_drv.h +++ b/drivers/gpu/drm/renesas/shmobile/shmob_drm_drv.h @@ -39,4 +39,9 @@ struct shmob_drm_device { struct shmob_drm_connector connector; }; =20 +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__ */ diff --git a/drivers/gpu/drm/renesas/shmobile/shmob_drm_plane.c b/drivers/g= pu/drm/renesas/shmobile/shmob_drm_plane.c index 258288c80756bf16..c58b9dca34736342 100644 --- a/drivers/gpu/drm/renesas/shmobile/shmob_drm_plane.c +++ b/drivers/gpu/drm/renesas/shmobile/shmob_drm_plane.c @@ -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, struct drm_framebuffer *fb) { - struct shmob_drm_device *sdev =3D splane->plane.dev->dev_private; + struct shmob_drm_device *sdev =3D to_shmob_device(splane->plane.dev); u32 format; =20 /* TODO: Support ROP3 mode */ @@ -135,8 +135,8 @@ shmob_drm_plane_update(struct drm_plane *plane, struct = drm_crtc *crtc, uint32_t src_w, uint32_t src_h, struct drm_modeset_acquire_ctx *ctx) { + struct shmob_drm_device *sdev =3D to_shmob_device(plane->dev); struct shmob_drm_plane *splane =3D to_shmob_plane(plane); - struct shmob_drm_device *sdev =3D plane->dev->dev_private; const struct shmob_drm_format_info *format; =20 format =3D shmob_drm_format_info(fb->format->format); @@ -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, struct drm_modeset_acquire_ctx *ctx) { + struct shmob_drm_device *sdev =3D to_shmob_device(plane->dev); struct shmob_drm_plane *splane =3D to_shmob_plane(plane); - struct shmob_drm_device *sdev =3D plane->dev->dev_private; =20 splane->format =3D NULL; =20 --=20 2.34.1