drm/mediatek: Optimize functions which do not need to return
Subsystems (3)
PATCH 1/1 drm/mediatek: Optimize functions which do not need to return
Function mtk_hdmi_aud_set_input always return 0, no need to keep the return value. Functions mtk_hdmi_aud_enable_packet & mtk_hdmi_aud_on_off_hw_ncts are the same, these two functions just call next functions. Maybe it`s a bit better to just call the inner function.
--- drivers/gpu/drm/mediatek/mtk_hdmi.c | 27 +++++++-------------------- 1 file changed, 7 insertions(+), 20 deletions(-)
drivers/gpu/drm/mediatek/mtk_hdmi.c +7 -20
@@ -870,19 +870,8 @@ static void mtk_hdmi_video_set_display_mode(struct mtk_hdmi *hdmi,mtk_hdmi_hw_msic_setting (hdmi, mode); } -static int mtk_hdmi_aud_enable_packet (struct mtk_hdmi *hdmi,bool enable) -{ -mtk_hdmi_hw_send_aud_packet (hdmi, enable); -return 0 ; -} -static int mtk_hdmi_aud_on_off_hw_ncts (struct mtk_hdmi *hdmi,bool on) -{ -mtk_hdmi_hw_ncts_enable (hdmi, on); -return 0 ; -} - -static int mtk_hdmi_aud_set_input (struct mtk_hdmi *hdmi) +static void mtk_hdmi_aud_set_input (struct mtk_hdmi *hdmi) {enum hdmi_aud_channel_type chan_type;u8 chan_count;
@@ -912,8 +901,6 @@ static int mtk_hdmi_aud_set_input(struct mtk_hdmi *hdmi) chan_count =mtk_hdmi_aud_get_chnl_count (chan_type);mtk_hdmi_hw_aud_set_i2s_chan_num (hdmi, chan_type, chan_count);mtk_hdmi_hw_aud_set_input_type (hdmi, hdmi->aud_param.aud_input_type); - -return 0 ; } static int mtk_hdmi_aud_set_src(struct mtk_hdmi *hdmi,
@@ -921,7 +908,7 @@ static int mtk_hdmi_aud_set_src(struct mtk_hdmi *hdmi, {unsigned int sample_rate = hdmi->aud_param.codec_params.sample_rate; -mtk_hdmi_aud_on_off_hw_ncts (hdmi, false); +mtk_hdmi_hw_ncts_enable (hdmi, false);mtk_hdmi_hw_aud_src_disable (hdmi);mtk_hdmi_clear_bits (hdmi,GRL_CFG2 ,CFG2_ACLK_INV );
@@ -959,7 +946,7 @@ static int mtk_hdmi_aud_output_config(struct mtk_hdmi *hdmi, struct drm_display_mode *display_mode) {mtk_hdmi_hw_aud_mute (hdmi); -mtk_hdmi_aud_enable_packet (hdmi, false); +mtk_hdmi_hw_send_aud_packet (hdmi, false);mtk_hdmi_aud_set_input (hdmi);mtk_hdmi_aud_set_src (hdmi, display_mode);
@@ -968,8 +955,8 @@ static int mtk_hdmi_aud_output_config(struct mtk_hdmi *hdmi,usleep_range (50 ,100 ); -mtk_hdmi_aud_on_off_hw_ncts (hdmi, true); -mtk_hdmi_aud_enable_packet (hdmi, true); +mtk_hdmi_hw_ncts_enable (hdmi, true); +mtk_hdmi_hw_send_aud_packet (hdmi, true);mtk_hdmi_hw_aud_unmute (hdmi);return 0 ; }
@@ -1097,13 +1084,13 @@ static int mtk_hdmi_output_init(struct mtk_hdmi *hdmi)static void mtk_hdmi_audio_enable (struct mtk_hdmi *hdmi) { -mtk_hdmi_aud_enable_packet (hdmi, true); +mtk_hdmi_hw_send_aud_packet (hdmi, true); hdmi->audio_enable = true; }static void mtk_hdmi_audio_disable (struct mtk_hdmi *hdmi) { -mtk_hdmi_aud_enable_packet (hdmi, false); +mtk_hdmi_hw_send_aud_packet (hdmi, false); hdmi->audio_enable = false; }
Signature · 1 line
2.28.0
Bernard Zhao <[email protected]> 於 2020年10月13日 週二 下午4:55寫道:
Quoted 6 lines
Function
mtk_hdmi_aud_set_inputalways return 0, no need to keep the return value. Functionsmtk_hdmi_aud_enable_packet&mtk_hdmi_aud_on_off_hw_nctsare the same, these two functions just call next functions. Maybe it`s a bit better to just call the inner function.
Quoted 86 lines
Signed-off-by Bernard Zhao <[email protected]>--- drivers/gpu/drm/mediatek/mtk_hdmi.c | 27 +++++++-------------------- 1 file changed, 7 insertions(+), 20 deletions(-)drivers/gpu/drm/mediatek/mtk_hdmi.c +7
-21@@ -870,19 +870,8 @@ static void mtk_hdmi_video_set_display_mode(struct mtk_hdmi *hdmi,mtk_hdmi_hw_msic_setting (hdmi, mode); } -static int mtk_hdmi_aud_enable_packet (struct mtk_hdmi *hdmi,bool enable) -{ -mtk_hdmi_hw_send_aud_packet (hdmi, enable); -return 0 ; -} -static int mtk_hdmi_aud_on_off_hw_ncts (struct mtk_hdmi *hdmi,bool on) -{ -mtk_hdmi_hw_ncts_enable (hdmi, on); -return 0 ; -} - -static int mtk_hdmi_aud_set_input (struct mtk_hdmi *hdmi) +static void mtk_hdmi_aud_set_input (struct mtk_hdmi *hdmi) {enum hdmi_aud_channel_type chan_type;u8 chan_count;@@ -912,8 +901,6 @@ static int mtk_hdmi_aud_set_input(struct mtk_hdmi *hdmi) chan_count =mtk_hdmi_aud_get_chnl_count (chan_type);mtk_hdmi_hw_aud_set_i2s_chan_num (hdmi, chan_type, chan_count);mtk_hdmi_hw_aud_set_input_type (hdmi, hdmi->aud_param.aud_input_type); - -return 0 ; } static int mtk_hdmi_aud_set_src(struct mtk_hdmi *hdmi,@@ -921,7 +908,7 @@ static int mtk_hdmi_aud_set_src(struct mtk_hdmi *hdmi, {unsigned int sample_rate = hdmi->aud_param.codec_params.sample_rate; -mtk_hdmi_aud_on_off_hw_ncts (hdmi, false); +mtk_hdmi_hw_ncts_enable (hdmi, false);mtk_hdmi_hw_aud_src_disable (hdmi);mtk_hdmi_clear_bits (hdmi,GRL_CFG2 ,CFG2_ACLK_INV );@@ -959,7 +946,7 @@ static int mtk_hdmi_aud_output_config(struct mtk_hdmi *hdmi, struct drm_display_mode *display_mode) {mtk_hdmi_hw_aud_mute (hdmi); -mtk_hdmi_aud_enable_packet (hdmi, false); +mtk_hdmi_hw_send_aud_packet (hdmi, false);mtk_hdmi_aud_set_input (hdmi);mtk_hdmi_aud_set_src (hdmi, display_mode);@@ -968,8 +955,8 @@ static int mtk_hdmi_aud_output_config(struct mtk_hdmi *hdmi,usleep_range (50 ,100 ); -mtk_hdmi_aud_on_off_hw_ncts (hdmi, true); -mtk_hdmi_aud_enable_packet (hdmi, true); +mtk_hdmi_hw_ncts_enable (hdmi, true); +mtk_hdmi_hw_send_aud_packet (hdmi, true);mtk_hdmi_hw_aud_unmute (hdmi);return 0 ; }@@ -1097,13 +1084,13 @@ static int mtk_hdmi_output_init(struct mtk_hdmi *hdmi)static void mtk_hdmi_audio_enable (struct mtk_hdmi *hdmi) { -mtk_hdmi_aud_enable_packet (hdmi, true); +mtk_hdmi_hw_send_aud_packet (hdmi, true); hdmi->audio_enable = true; }static void mtk_hdmi_audio_disable (struct mtk_hdmi *hdmi) { -mtk_hdmi_aud_enable_packet (hdmi, false); +mtk_hdmi_hw_send_aud_packet (hdmi, false); hdmi->audio_enable = false; } --
Quoted 2 lines
2.28.0
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Hi, Bernard:
Chun-Kuang Hu <[email protected]> 於 2020年10月17日 週六 上午10:50寫道:
Quoted 11 lines
Bernard Zhao <[email protected]> 於 2020年10月13日 週二 下午4:55寫道:
Quoted 6 lines
Function
mtk_hdmi_aud_set_inputalways return 0, no need to keep the return value. Functionsmtk_hdmi_aud_enable_packet&mtk_hdmi_aud_on_off_hw_nctsare the same, these two functions just call next functions. Maybe it`s a bit better to just call the inner function.Reviewed-by Chun-Kuang Hu <[email protected]>
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.
Quoted 85 lines
Quoted 85 lines
Signed-off-by Bernard Zhao <[email protected]>--- drivers/gpu/drm/mediatek/mtk_hdmi.c | 27 +++++++-------------------- 1 file changed, 7 insertions(+), 20 deletions(-)drivers/gpu/drm/mediatek/mtk_hdmi.c +7
-20@@ -870,19 +870,8 @@ static void mtk_hdmi_video_set_display_mode(struct mtk_hdmi *hdmi,mtk_hdmi_hw_msic_setting (hdmi, mode); } -static int mtk_hdmi_aud_enable_packet (struct mtk_hdmi *hdmi,bool enable) -{ -mtk_hdmi_hw_send_aud_packet (hdmi, enable); -return 0 ; -} -static int mtk_hdmi_aud_on_off_hw_ncts (struct mtk_hdmi *hdmi,bool on) -{ -mtk_hdmi_hw_ncts_enable (hdmi, on); -return 0 ; -} - -static int mtk_hdmi_aud_set_input (struct mtk_hdmi *hdmi) +static void mtk_hdmi_aud_set_input (struct mtk_hdmi *hdmi) {enum hdmi_aud_channel_type chan_type;u8 chan_count;@@ -912,8 +901,6 @@ static int mtk_hdmi_aud_set_input(struct mtk_hdmi *hdmi) chan_count =mtk_hdmi_aud_get_chnl_count (chan_type);mtk_hdmi_hw_aud_set_i2s_chan_num (hdmi, chan_type, chan_count);mtk_hdmi_hw_aud_set_input_type (hdmi, hdmi->aud_param.aud_input_type); - -return 0 ; } static int mtk_hdmi_aud_set_src(struct mtk_hdmi *hdmi,@@ -921,7 +908,7 @@ static int mtk_hdmi_aud_set_src(struct mtk_hdmi *hdmi, {unsigned int sample_rate = hdmi->aud_param.codec_params.sample_rate; -mtk_hdmi_aud_on_off_hw_ncts (hdmi, false); +mtk_hdmi_hw_ncts_enable (hdmi, false);mtk_hdmi_hw_aud_src_disable (hdmi);mtk_hdmi_clear_bits (hdmi,GRL_CFG2 ,CFG2_ACLK_INV );@@ -959,7 +946,7 @@ static int mtk_hdmi_aud_output_config(struct mtk_hdmi *hdmi, struct drm_display_mode *display_mode) {mtk_hdmi_hw_aud_mute (hdmi); -mtk_hdmi_aud_enable_packet (hdmi, false); +mtk_hdmi_hw_send_aud_packet (hdmi, false);mtk_hdmi_aud_set_input (hdmi);mtk_hdmi_aud_set_src (hdmi, display_mode);@@ -968,8 +955,8 @@ static int mtk_hdmi_aud_output_config(struct mtk_hdmi *hdmi,usleep_range (50 ,100 ); -mtk_hdmi_aud_on_off_hw_ncts (hdmi, true); -mtk_hdmi_aud_enable_packet (hdmi, true); +mtk_hdmi_hw_ncts_enable (hdmi, true); +mtk_hdmi_hw_send_aud_packet (hdmi, true);mtk_hdmi_hw_aud_unmute (hdmi);return 0 ; }@@ -1097,13 +1084,13 @@ static int mtk_hdmi_output_init(struct mtk_hdmi *hdmi)static void mtk_hdmi_audio_enable (struct mtk_hdmi *hdmi) { -mtk_hdmi_aud_enable_packet (hdmi, true); +mtk_hdmi_hw_send_aud_packet (hdmi, true); hdmi->audio_enable = true; }static void mtk_hdmi_audio_disable (struct mtk_hdmi *hdmi) { -mtk_hdmi_aud_enable_packet (hdmi, false); +mtk_hdmi_hw_send_aud_packet (hdmi, false); hdmi->audio_enable = false; }
Quoted 3 lines
Quoted 3 lines
--
2.28.0
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel