diff mbox series

[19/39] drm: renesas: shmobile: Convert container helpers to static inline functions

Message ID 63f1bef1f316175615a54490f752d64b7ddd29ab.1687423204.git.geert+renesas@glider.be (mailing list archive)
State Superseded
Delegated to: Kieran Bingham
Headers show
Series drm: renesas: shmobile: Atomic conversion + DT support | expand

Commit Message

Geert Uytterhoeven June 22, 2023, 9:21 a.m. UTC
Replace to conversion helper macros using container_of() by static
inline functions, to improve type-safety.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
 drivers/gpu/drm/renesas/shmobile/shmob_drm_crtc.c  | 11 ++++++++---
 drivers/gpu/drm/renesas/shmobile/shmob_drm_plane.c |  5 ++++-
 2 files changed, 12 insertions(+), 4 deletions(-)

Comments

Laurent Pinchart June 23, 2023, 3:49 p.m. UTC | #1
Hi Geert,

Thank you for the patch.

On Thu, Jun 22, 2023 at 11:21:31AM +0200, Geert Uytterhoeven wrote:
> Replace to conversion helper macros using container_of() by static
> inline functions, to improve type-safety.
> 
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>

Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>

> ---
>  drivers/gpu/drm/renesas/shmobile/shmob_drm_crtc.c  | 11 ++++++++---
>  drivers/gpu/drm/renesas/shmobile/shmob_drm_plane.c |  5 ++++-
>  2 files changed, 12 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/renesas/shmobile/shmob_drm_crtc.c b/drivers/gpu/drm/renesas/shmobile/shmob_drm_crtc.c
> index 26611440f7a12715..40948b56017ff2df 100644
> --- a/drivers/gpu/drm/renesas/shmobile/shmob_drm_crtc.c
> +++ b/drivers/gpu/drm/renesas/shmobile/shmob_drm_crtc.c
> @@ -291,7 +291,10 @@ static void shmob_drm_crtc_update_base(struct shmob_drm_crtc *scrtc)
>  	lcdc_write(sdev, LDRCNTR, lcdc_read(sdev, LDRCNTR) ^ LDRCNTR_MRS);
>  }
>  
> -#define to_shmob_crtc(c)	container_of(c, struct shmob_drm_crtc, crtc)
> +static inline struct shmob_drm_crtc *to_shmob_crtc(struct drm_crtc *crtc)
> +{
> +	return container_of(crtc, struct shmob_drm_crtc, crtc);
> +}
>  
>  static void shmob_drm_crtc_dpms(struct drm_crtc *crtc, int mode)
>  {
> @@ -571,8 +574,10 @@ int shmob_drm_encoder_create(struct shmob_drm_device *sdev)
>   * Connector
>   */
>  
> -#define to_shmob_connector(c) \
> -	container_of(c, struct shmob_drm_connector, connector)
> +static inline struct shmob_drm_connector *to_shmob_connector(struct drm_connector *connector)
> +{
> +	return container_of(connector, struct shmob_drm_connector, connector);
> +}
>  
>  static int shmob_drm_connector_get_modes(struct drm_connector *connector)
>  {
> diff --git a/drivers/gpu/drm/renesas/shmobile/shmob_drm_plane.c b/drivers/gpu/drm/renesas/shmobile/shmob_drm_plane.c
> index 17e66a018689f648..258288c80756bf16 100644
> --- a/drivers/gpu/drm/renesas/shmobile/shmob_drm_plane.c
> +++ b/drivers/gpu/drm/renesas/shmobile/shmob_drm_plane.c
> @@ -34,7 +34,10 @@ struct shmob_drm_plane {
>  	unsigned int crtc_h;
>  };
>  
> -#define to_shmob_plane(p)	container_of(p, struct shmob_drm_plane, plane)
> +static inline struct shmob_drm_plane *to_shmob_plane(struct drm_plane *plane)
> +{
> +	return container_of(plane, struct shmob_drm_plane, plane);
> +}
>  
>  static void shmob_drm_plane_compute_base(struct shmob_drm_plane *splane,
>  					 struct drm_framebuffer *fb,
diff mbox series

Patch

diff --git a/drivers/gpu/drm/renesas/shmobile/shmob_drm_crtc.c b/drivers/gpu/drm/renesas/shmobile/shmob_drm_crtc.c
index 26611440f7a12715..40948b56017ff2df 100644
--- a/drivers/gpu/drm/renesas/shmobile/shmob_drm_crtc.c
+++ b/drivers/gpu/drm/renesas/shmobile/shmob_drm_crtc.c
@@ -291,7 +291,10 @@  static void shmob_drm_crtc_update_base(struct shmob_drm_crtc *scrtc)
 	lcdc_write(sdev, LDRCNTR, lcdc_read(sdev, LDRCNTR) ^ LDRCNTR_MRS);
 }
 
-#define to_shmob_crtc(c)	container_of(c, struct shmob_drm_crtc, crtc)
+static inline struct shmob_drm_crtc *to_shmob_crtc(struct drm_crtc *crtc)
+{
+	return container_of(crtc, struct shmob_drm_crtc, crtc);
+}
 
 static void shmob_drm_crtc_dpms(struct drm_crtc *crtc, int mode)
 {
@@ -571,8 +574,10 @@  int shmob_drm_encoder_create(struct shmob_drm_device *sdev)
  * Connector
  */
 
-#define to_shmob_connector(c) \
-	container_of(c, struct shmob_drm_connector, connector)
+static inline struct shmob_drm_connector *to_shmob_connector(struct drm_connector *connector)
+{
+	return container_of(connector, struct shmob_drm_connector, connector);
+}
 
 static int shmob_drm_connector_get_modes(struct drm_connector *connector)
 {
diff --git a/drivers/gpu/drm/renesas/shmobile/shmob_drm_plane.c b/drivers/gpu/drm/renesas/shmobile/shmob_drm_plane.c
index 17e66a018689f648..258288c80756bf16 100644
--- a/drivers/gpu/drm/renesas/shmobile/shmob_drm_plane.c
+++ b/drivers/gpu/drm/renesas/shmobile/shmob_drm_plane.c
@@ -34,7 +34,10 @@  struct shmob_drm_plane {
 	unsigned int crtc_h;
 };
 
-#define to_shmob_plane(p)	container_of(p, struct shmob_drm_plane, plane)
+static inline struct shmob_drm_plane *to_shmob_plane(struct drm_plane *plane)
+{
+	return container_of(plane, struct shmob_drm_plane, plane);
+}
 
 static void shmob_drm_plane_compute_base(struct shmob_drm_plane *splane,
 					 struct drm_framebuffer *fb,