2020-05-06 12:45:32

by 赵军奎

[permalink] [raw]
Subject: [PATCH] drm/mediatek: eliminate the magic number in array size

Eiminate the magic number in array size, there macro defines in
hdmi.h.

Signed-off-by: Bernard Zhao <[email protected]>
---
drivers/gpu/drm/mediatek/mtk_hdmi.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/mediatek/mtk_hdmi.c b/drivers/gpu/drm/mediatek/mtk_hdmi.c
index ff43a3d80410..4c962c7f06e5 100644
--- a/drivers/gpu/drm/mediatek/mtk_hdmi.c
+++ b/drivers/gpu/drm/mediatek/mtk_hdmi.c
@@ -982,7 +982,7 @@ static int mtk_hdmi_setup_avi_infoframe(struct mtk_hdmi *hdmi,
struct drm_display_mode *mode)
{
struct hdmi_avi_infoframe frame;
- u8 buffer[17];
+ u8 buffer[HDMI_INFOFRAME_HEADER_SIZE + HDMI_AVI_INFOFRAME_SIZE];
ssize_t err;

err = drm_hdmi_avi_infoframe_from_display_mode(&frame,
@@ -1008,7 +1008,7 @@ static int mtk_hdmi_setup_spd_infoframe(struct mtk_hdmi *hdmi,
const char *product)
{
struct hdmi_spd_infoframe frame;
- u8 buffer[29];
+ u8 buffer[HDMI_INFOFRAME_HEADER_SIZE + HDMI_SPD_INFOFRAME_SIZE];
ssize_t err;

err = hdmi_spd_infoframe_init(&frame, vendor, product);
@@ -1031,7 +1031,7 @@ static int mtk_hdmi_setup_spd_infoframe(struct mtk_hdmi *hdmi,
static int mtk_hdmi_setup_audio_infoframe(struct mtk_hdmi *hdmi)
{
struct hdmi_audio_infoframe frame;
- u8 buffer[14];
+ u8 buffer[HDMI_INFOFRAME_HEADER_SIZE + HDMI_AUDIO_INFOFRAME_SIZE];
ssize_t err;

err = hdmi_audio_infoframe_init(&frame);
--
2.26.2


2020-05-06 13:12:13

by Chun-Kuang Hu

[permalink] [raw]
Subject: Re: [PATCH] drm/mediatek: eliminate the magic number in array size

Hi, Bernard:

Bernard Zhao <[email protected]> 於 2020年5月6日 週三 下午8:43寫道:
>
> Eiminate the magic number in array size, there macro defines in
> hdmi.h.

Reviewed-by: Chun-Kuang Hu <[email protected]>

>
> Signed-off-by: Bernard Zhao <[email protected]>
> ---
> drivers/gpu/drm/mediatek/mtk_hdmi.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/mediatek/mtk_hdmi.c b/drivers/gpu/drm/mediatek/mtk_hdmi.c
> index ff43a3d80410..4c962c7f06e5 100644
> --- a/drivers/gpu/drm/mediatek/mtk_hdmi.c
> +++ b/drivers/gpu/drm/mediatek/mtk_hdmi.c
> @@ -982,7 +982,7 @@ static int mtk_hdmi_setup_avi_infoframe(struct mtk_hdmi *hdmi,
> struct drm_display_mode *mode)
> {
> struct hdmi_avi_infoframe frame;
> - u8 buffer[17];
> + u8 buffer[HDMI_INFOFRAME_HEADER_SIZE + HDMI_AVI_INFOFRAME_SIZE];
> ssize_t err;
>
> err = drm_hdmi_avi_infoframe_from_display_mode(&frame,
> @@ -1008,7 +1008,7 @@ static int mtk_hdmi_setup_spd_infoframe(struct mtk_hdmi *hdmi,
> const char *product)
> {
> struct hdmi_spd_infoframe frame;
> - u8 buffer[29];
> + u8 buffer[HDMI_INFOFRAME_HEADER_SIZE + HDMI_SPD_INFOFRAME_SIZE];
> ssize_t err;
>
> err = hdmi_spd_infoframe_init(&frame, vendor, product);
> @@ -1031,7 +1031,7 @@ static int mtk_hdmi_setup_spd_infoframe(struct mtk_hdmi *hdmi,
> static int mtk_hdmi_setup_audio_infoframe(struct mtk_hdmi *hdmi)
> {
> struct hdmi_audio_infoframe frame;
> - u8 buffer[14];
> + u8 buffer[HDMI_INFOFRAME_HEADER_SIZE + HDMI_AUDIO_INFOFRAME_SIZE];
> ssize_t err;
>
> err = hdmi_audio_infoframe_init(&frame);
> --
> 2.26.2
>

2020-05-10 01:32:54

by Chun-Kuang Hu

[permalink] [raw]
Subject: Re: [PATCH] drm/mediatek: eliminate the magic number in array size

Hi, Bernard:

Bernard Zhao <[email protected]> 於 2020年5月6日 週三 下午8:43寫道:
>
> Eiminate the magic number in array size, there macro defines in
> hdmi.h.

Applied to mediatek-drm-next [1], thanks.

[1] https://git.kernel.org/pub/scm/linux/kernel/git/chunkuang.hu/linux.git/log/?h=mediatek-drm-next

Regards,
Chun-Kuang

>
> Signed-off-by: Bernard Zhao <[email protected]>
> ---
> drivers/gpu/drm/mediatek/mtk_hdmi.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/mediatek/mtk_hdmi.c b/drivers/gpu/drm/mediatek/mtk_hdmi.c
> index ff43a3d80410..4c962c7f06e5 100644
> --- a/drivers/gpu/drm/mediatek/mtk_hdmi.c
> +++ b/drivers/gpu/drm/mediatek/mtk_hdmi.c
> @@ -982,7 +982,7 @@ static int mtk_hdmi_setup_avi_infoframe(struct mtk_hdmi *hdmi,
> struct drm_display_mode *mode)
> {
> struct hdmi_avi_infoframe frame;
> - u8 buffer[17];
> + u8 buffer[HDMI_INFOFRAME_HEADER_SIZE + HDMI_AVI_INFOFRAME_SIZE];
> ssize_t err;
>
> err = drm_hdmi_avi_infoframe_from_display_mode(&frame,
> @@ -1008,7 +1008,7 @@ static int mtk_hdmi_setup_spd_infoframe(struct mtk_hdmi *hdmi,
> const char *product)
> {
> struct hdmi_spd_infoframe frame;
> - u8 buffer[29];
> + u8 buffer[HDMI_INFOFRAME_HEADER_SIZE + HDMI_SPD_INFOFRAME_SIZE];
> ssize_t err;
>
> err = hdmi_spd_infoframe_init(&frame, vendor, product);
> @@ -1031,7 +1031,7 @@ static int mtk_hdmi_setup_spd_infoframe(struct mtk_hdmi *hdmi,
> static int mtk_hdmi_setup_audio_infoframe(struct mtk_hdmi *hdmi)
> {
> struct hdmi_audio_infoframe frame;
> - u8 buffer[14];
> + u8 buffer[HDMI_INFOFRAME_HEADER_SIZE + HDMI_AUDIO_INFOFRAME_SIZE];
> ssize_t err;
>
> err = hdmi_audio_infoframe_init(&frame);
> --
> 2.26.2
>