diff mbox series

[2/3] drm/panel: use mipi_dsi_dcs_write_buffer where possible

Message ID 20200505160329.2976059-2-emil.l.velikov@gmail.com (mailing list archive)
State New, archived
Headers show
Series [1/3] drm/dsi: use stack buffer in mipi_dsi_dcs_write() | expand

Commit Message

Emil Velikov May 5, 2020, 4:03 p.m. UTC
From: Emil Velikov <emil.velikov@collabora.com>

A few of the new panels create a local macro wrapping around
mipi_dsi_dcs_write. At the same time, they don't really care about the
command/payload split.

mipi_dsi_dcs_write does a kmalloc/memcpy/kfree for payload > 7 bytes.
kmalloc - avoid that all together by using the _buffer function.

Aside:
panel-xinpeng-xpp055c272.c calls its wrapper "generic" although it
should be "dcs". But that for another day/patch.

Cc: Heiko Stuebner <heiko@sntech.de>
Cc: Heiko Stuebner <heiko.stuebner@theobroma-systems.com>
Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
---
 drivers/gpu/drm/panel/panel-elida-kd35t133.c       | 4 ++--
 drivers/gpu/drm/panel/panel-leadtek-ltk050h3146w.c | 4 ++--
 drivers/gpu/drm/panel/panel-xinpeng-xpp055c272.c   | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)

Comments

Emil Velikov May 11, 2020, 11:28 a.m. UTC | #1
On Tue, 5 May 2020 at 17:05, Emil Velikov <emil.l.velikov@gmail.com> wrote:
>
> From: Emil Velikov <emil.velikov@collabora.com>
>
> A few of the new panels create a local macro wrapping around
> mipi_dsi_dcs_write. At the same time, they don't really care about the
> command/payload split.
>
> mipi_dsi_dcs_write does a kmalloc/memcpy/kfree for payload > 7 bytes.
> kmalloc - avoid that all together by using the _buffer function.
>
Seems like I've left an extra word here - will fix in v2, alongside
any review feedback.
s/kmalloc - avoid/Avoid/

> Aside:
> panel-xinpeng-xpp055c272.c calls its wrapper "generic" although it
> should be "dcs". But that for another day/patch.
>
> Cc: Heiko Stuebner <heiko@sntech.de>
> Cc: Heiko Stuebner <heiko.stuebner@theobroma-systems.com>
> Cc: Thierry Reding <thierry.reding@gmail.com>
> Cc: Sam Ravnborg <sam@ravnborg.org>
> Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
> ---
>  drivers/gpu/drm/panel/panel-elida-kd35t133.c       | 4 ++--
>  drivers/gpu/drm/panel/panel-leadtek-ltk050h3146w.c | 4 ++--
>  drivers/gpu/drm/panel/panel-xinpeng-xpp055c272.c   | 4 ++--
>  3 files changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/gpu/drm/panel/panel-elida-kd35t133.c b/drivers/gpu/drm/panel/panel-elida-kd35t133.c
> index 711ded453c44..00e3d67af812 100644
> --- a/drivers/gpu/drm/panel/panel-elida-kd35t133.c
> +++ b/drivers/gpu/drm/panel/panel-elida-kd35t133.c
> @@ -52,9 +52,9 @@ static inline struct kd35t133 *panel_to_kd35t133(struct drm_panel *panel)
>  }
>
>  #define dsi_dcs_write_seq(dsi, cmd, seq...) do {                       \
> -               static const u8 d[] = { seq };                          \
> +               static const u8 b[] = { cmd, seq };                     \
>                 int ret;                                                \
> -               ret = mipi_dsi_dcs_write(dsi, cmd, d, ARRAY_SIZE(d));   \
> +               ret = mipi_dsi_dcs_write_buffer(dsi, b, ARRAY_SIZE(b)); \
>                 if (ret < 0)                                            \
>                         return ret;                                     \
>         } while (0)
> diff --git a/drivers/gpu/drm/panel/panel-leadtek-ltk050h3146w.c b/drivers/gpu/drm/panel/panel-leadtek-ltk050h3146w.c
> index 5a7a31c8513e..eaa9da3ebbea 100644
> --- a/drivers/gpu/drm/panel/panel-leadtek-ltk050h3146w.c
> +++ b/drivers/gpu/drm/panel/panel-leadtek-ltk050h3146w.c
> @@ -246,9 +246,9 @@ struct ltk050h3146w *panel_to_ltk050h3146w(struct drm_panel *panel)
>  }
>
>  #define dsi_dcs_write_seq(dsi, cmd, seq...) do {                       \
> -               static const u8 d[] = { seq };                          \
> +               static const u8 b[] = { cmd, seq };                     \
>                 int ret;                                                \
> -               ret = mipi_dsi_dcs_write(dsi, cmd, d, ARRAY_SIZE(d));   \
> +               ret = mipi_dsi_dcs_write_buffer(dsi, b, ARRAY_SIZE(b)); \
>                 if (ret < 0)                                            \
>                         return ret;                                     \
>         } while (0)
> diff --git a/drivers/gpu/drm/panel/panel-xinpeng-xpp055c272.c b/drivers/gpu/drm/panel/panel-xinpeng-xpp055c272.c
> index 1645aceab597..9e07d7e86807 100644
> --- a/drivers/gpu/drm/panel/panel-xinpeng-xpp055c272.c
> +++ b/drivers/gpu/drm/panel/panel-xinpeng-xpp055c272.c
> @@ -62,9 +62,9 @@ static inline struct xpp055c272 *panel_to_xpp055c272(struct drm_panel *panel)
>  }
>
>  #define dsi_generic_write_seq(dsi, cmd, seq...) do {                   \
> -               static const u8 d[] = { seq };                          \
> +               static const u8 b[] = { cmd, seq };                     \
>                 int ret;                                                \
> -               ret = mipi_dsi_dcs_write(dsi, cmd, d, ARRAY_SIZE(d));   \
> +               ret = mipi_dsi_dcs_write_buffer(dsi, b, ARRAY_SIZE(b)); \
>                 if (ret < 0)                                            \
>                         return ret;                                     \
>         } while (0)
> --
> 2.25.1
>

Humble poke?

-Emil
Sam Ravnborg June 29, 2020, 7:46 a.m. UTC | #2
On Mon, May 11, 2020 at 12:28:40PM +0100, Emil Velikov wrote:
> On Tue, 5 May 2020 at 17:05, Emil Velikov <emil.l.velikov@gmail.com> wrote:
> >
> > From: Emil Velikov <emil.velikov@collabora.com>
> >
> > A few of the new panels create a local macro wrapping around
> > mipi_dsi_dcs_write. At the same time, they don't really care about the
> > command/payload split.
> >
> > mipi_dsi_dcs_write does a kmalloc/memcpy/kfree for payload > 7 bytes.
> > kmalloc - avoid that all together by using the _buffer function.
> >
> Seems like I've left an extra word here - will fix in v2, alongside
> any review feedback.
> s/kmalloc - avoid/Avoid/
> 
> > Aside:
> > panel-xinpeng-xpp055c272.c calls its wrapper "generic" although it
> > should be "dcs". But that for another day/patch.
> >
> > Cc: Heiko Stuebner <heiko@sntech.de>
> > Cc: Heiko Stuebner <heiko.stuebner@theobroma-systems.com>
> > Cc: Thierry Reding <thierry.reding@gmail.com>
> > Cc: Sam Ravnborg <sam@ravnborg.org>
> > Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Fixed up changelog when applied to drm-misc-next.

	Sam
> > ---
> >  drivers/gpu/drm/panel/panel-elida-kd35t133.c       | 4 ++--
> >  drivers/gpu/drm/panel/panel-leadtek-ltk050h3146w.c | 4 ++--
> >  drivers/gpu/drm/panel/panel-xinpeng-xpp055c272.c   | 4 ++--
> >  3 files changed, 6 insertions(+), 6 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/panel/panel-elida-kd35t133.c b/drivers/gpu/drm/panel/panel-elida-kd35t133.c
> > index 711ded453c44..00e3d67af812 100644
> > --- a/drivers/gpu/drm/panel/panel-elida-kd35t133.c
> > +++ b/drivers/gpu/drm/panel/panel-elida-kd35t133.c
> > @@ -52,9 +52,9 @@ static inline struct kd35t133 *panel_to_kd35t133(struct drm_panel *panel)
> >  }
> >
> >  #define dsi_dcs_write_seq(dsi, cmd, seq...) do {                       \
> > -               static const u8 d[] = { seq };                          \
> > +               static const u8 b[] = { cmd, seq };                     \
> >                 int ret;                                                \
> > -               ret = mipi_dsi_dcs_write(dsi, cmd, d, ARRAY_SIZE(d));   \
> > +               ret = mipi_dsi_dcs_write_buffer(dsi, b, ARRAY_SIZE(b)); \
> >                 if (ret < 0)                                            \
> >                         return ret;                                     \
> >         } while (0)
> > diff --git a/drivers/gpu/drm/panel/panel-leadtek-ltk050h3146w.c b/drivers/gpu/drm/panel/panel-leadtek-ltk050h3146w.c
> > index 5a7a31c8513e..eaa9da3ebbea 100644
> > --- a/drivers/gpu/drm/panel/panel-leadtek-ltk050h3146w.c
> > +++ b/drivers/gpu/drm/panel/panel-leadtek-ltk050h3146w.c
> > @@ -246,9 +246,9 @@ struct ltk050h3146w *panel_to_ltk050h3146w(struct drm_panel *panel)
> >  }
> >
> >  #define dsi_dcs_write_seq(dsi, cmd, seq...) do {                       \
> > -               static const u8 d[] = { seq };                          \
> > +               static const u8 b[] = { cmd, seq };                     \
> >                 int ret;                                                \
> > -               ret = mipi_dsi_dcs_write(dsi, cmd, d, ARRAY_SIZE(d));   \
> > +               ret = mipi_dsi_dcs_write_buffer(dsi, b, ARRAY_SIZE(b)); \
> >                 if (ret < 0)                                            \
> >                         return ret;                                     \
> >         } while (0)
> > diff --git a/drivers/gpu/drm/panel/panel-xinpeng-xpp055c272.c b/drivers/gpu/drm/panel/panel-xinpeng-xpp055c272.c
> > index 1645aceab597..9e07d7e86807 100644
> > --- a/drivers/gpu/drm/panel/panel-xinpeng-xpp055c272.c
> > +++ b/drivers/gpu/drm/panel/panel-xinpeng-xpp055c272.c
> > @@ -62,9 +62,9 @@ static inline struct xpp055c272 *panel_to_xpp055c272(struct drm_panel *panel)
> >  }
> >
> >  #define dsi_generic_write_seq(dsi, cmd, seq...) do {                   \
> > -               static const u8 d[] = { seq };                          \
> > +               static const u8 b[] = { cmd, seq };                     \
> >                 int ret;                                                \
> > -               ret = mipi_dsi_dcs_write(dsi, cmd, d, ARRAY_SIZE(d));   \
> > +               ret = mipi_dsi_dcs_write_buffer(dsi, b, ARRAY_SIZE(b)); \
> >                 if (ret < 0)                                            \
> >                         return ret;                                     \
> >         } while (0)
> > --
> > 2.25.1
> >
> 
> Humble poke?
> 
> -Emil
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
diff mbox series

Patch

diff --git a/drivers/gpu/drm/panel/panel-elida-kd35t133.c b/drivers/gpu/drm/panel/panel-elida-kd35t133.c
index 711ded453c44..00e3d67af812 100644
--- a/drivers/gpu/drm/panel/panel-elida-kd35t133.c
+++ b/drivers/gpu/drm/panel/panel-elida-kd35t133.c
@@ -52,9 +52,9 @@  static inline struct kd35t133 *panel_to_kd35t133(struct drm_panel *panel)
 }
 
 #define dsi_dcs_write_seq(dsi, cmd, seq...) do {			\
-		static const u8 d[] = { seq };				\
+		static const u8 b[] = { cmd, seq };			\
 		int ret;						\
-		ret = mipi_dsi_dcs_write(dsi, cmd, d, ARRAY_SIZE(d));	\
+		ret = mipi_dsi_dcs_write_buffer(dsi, b, ARRAY_SIZE(b));	\
 		if (ret < 0)						\
 			return ret;					\
 	} while (0)
diff --git a/drivers/gpu/drm/panel/panel-leadtek-ltk050h3146w.c b/drivers/gpu/drm/panel/panel-leadtek-ltk050h3146w.c
index 5a7a31c8513e..eaa9da3ebbea 100644
--- a/drivers/gpu/drm/panel/panel-leadtek-ltk050h3146w.c
+++ b/drivers/gpu/drm/panel/panel-leadtek-ltk050h3146w.c
@@ -246,9 +246,9 @@  struct ltk050h3146w *panel_to_ltk050h3146w(struct drm_panel *panel)
 }
 
 #define dsi_dcs_write_seq(dsi, cmd, seq...) do {			\
-		static const u8 d[] = { seq };				\
+		static const u8 b[] = { cmd, seq };			\
 		int ret;						\
-		ret = mipi_dsi_dcs_write(dsi, cmd, d, ARRAY_SIZE(d));	\
+		ret = mipi_dsi_dcs_write_buffer(dsi, b, ARRAY_SIZE(b));	\
 		if (ret < 0)						\
 			return ret;					\
 	} while (0)
diff --git a/drivers/gpu/drm/panel/panel-xinpeng-xpp055c272.c b/drivers/gpu/drm/panel/panel-xinpeng-xpp055c272.c
index 1645aceab597..9e07d7e86807 100644
--- a/drivers/gpu/drm/panel/panel-xinpeng-xpp055c272.c
+++ b/drivers/gpu/drm/panel/panel-xinpeng-xpp055c272.c
@@ -62,9 +62,9 @@  static inline struct xpp055c272 *panel_to_xpp055c272(struct drm_panel *panel)
 }
 
 #define dsi_generic_write_seq(dsi, cmd, seq...) do {			\
-		static const u8 d[] = { seq };				\
+		static const u8 b[] = { cmd, seq };			\
 		int ret;						\
-		ret = mipi_dsi_dcs_write(dsi, cmd, d, ARRAY_SIZE(d));	\
+		ret = mipi_dsi_dcs_write_buffer(dsi, b, ARRAY_SIZE(b));	\
 		if (ret < 0)						\
 			return ret;					\
 	} while (0)