drm/amd/display: Simplify hdmi_automation debugfs with debugfs_create_bool
Subsystems (3)
PATCH 1/1 drm/amd/display: Simplify hdmi_automation debugfs with debugfs_create_bool
Follow-up fix for commit 442b2e9dc9e9 ("drm/amd/display: Add Support for HDMI Compliance Automation"), whose hdmi_automation debugfs entry hand-rolled the boolean parsing (scratch buffer, parse_write_buffer_into_params(), a switch and kfree) that the debugfs core already provides.
hdmi_comp_auto is a plain bool, so bind it directly with debugfs_create_bool() and drop the custom write handler, its file_operations and the hdmi_debugfs_entries[] row.
--- .../amd/display/amdgpu_dm/amdgpu_dm_debugfs.c | 69 +------------------ 1 file changed, 3 insertions(+), 66 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c +3 -66
@@ -2981,64 +2981,6 @@ static ssize_t hdmi_cec_state_write(struct file *f, const char __user *buf,return size; } -/** -* hdmi_automation_enable - Enable/Disable HDMI automation feature -* @f: file structure. -* @buf: userspace buffer. set to '1' to enable; '0' to disable automation feature. -* @size: size of buffer from userpsace. -* @pos: unused. -* -* Return size on success, error code on failure -*/ -static ssize_t hdmi_automation_enable (struct file *f,const char __user *buf, -size_t size,loff_t *pos) -{ -struct amdgpu_dm_connector *aconnector =file_inode (f)->i_private; -char *wr_buf =NULL ; -const uint32_t wr_buf_size =40 ; -int max_param_num =1 ; -uint8_t param_nums =0 ; -long param[2 ]; -bool hdmi_comp_auto; - -if (size ==0 ) -return -EINVAL ; - - wr_buf =kcalloc (wr_buf_size,sizeof (char ),GFP_KERNEL ); -if (!wr_buf) -return -ENOSPC ; - -if (parse_write_buffer_into_params (wr_buf, wr_buf_size, - (long *)param, buf, - max_param_num, - ¶m_nums)) { -kfree (wr_buf); -return -EINVAL ; - } - -if (param_nums <=0 ) { -kfree (wr_buf); -DRM_DEBUG_DRIVER ("user data not be read\n" ); -return -EINVAL ; - } - -switch (param[0 ]) { -case 0 : - hdmi_comp_auto = false; -break ; -case 1 : -default : - hdmi_comp_auto = true; -break ; - } - -/* Persist setting across sink re-detection/hotplug. */ - aconnector->hdmi_comp_auto = hdmi_comp_auto; - -kfree (wr_buf); -return size; -} -DEFINE_SHOW_ATTRIBUTE (dp_dsc_fec_support);DEFINE_SHOW_ATTRIBUTE (dmub_fw_state);DEFINE_SHOW_ATTRIBUTE (dmub_tracebuffer);
@@ -3156,12 +3098,6 @@ static const struct file_operations dp_mst_link_settings_debugfs_fops = { .llseek = default_llseek }; -static const struct file_operations hdmi_automation_debugfs_fops = { - .owner =THIS_MODULE , - .write = hdmi_automation_enable, - .llseek = default_llseek -}; - static const struct { char *name; const struct file_operations *fops;
@@ -3194,8 +3130,7 @@ static const struct {const struct file_operations *fops; } hdmi_debugfs_entries[] = { {"hdcp_sink_capability", &hdcp_sink_capability_fops}, - {"hdmi_cec_state", &hdmi_cec_state_fops}, - {"hdmi_automation", &hdmi_automation_debugfs_fops} + {"hdmi_cec_state", &hdmi_cec_state_fops} };/*
@@ -3908,6 +3843,8 @@ void connector_debugfs_init(struct amdgpu_dm_connector *connector)0644 , dir, connector, hdmi_debugfs_entries[i].fops); } + +debugfs_create_bool ("hdmi_automation" ,0644 , dir, &connector->hdmi_comp_auto); } }
Signature · 1 line
2.53.0
Quoted 6 lines · Fangzhi Zuo
Follow-up fix for commit
442b2e9dc9e9("drm/amd/display: Add Support for HDMI Compliance Automation"), whosehdmi_automationdebugfs entry hand-rolled the boolean parsing (scratch buffer,parse_write_buffer_into_params(), a switch and kfree) that the debugfs core already provides.
Quoted 6 lines
hdmi_comp_autois a plain bool, so bind it directly withdebugfs_create_bool()and drop the custom write handler, itsfile_operationsand the hdmi_debugfs_entries[] row.Fixes 442b2e9dc9e9 ("drm/amd/display: Add Support for HDMI Compliance Automation")Signed-off-by Fangzhi Zuo <[email protected]>
Harry
Quoted 105 lines
--- .../amd/display/amdgpu_dm/amdgpu_dm_debugfs.c | 69 +------------------ 1 file changed, 3 insertions(+), 66 deletions(-)drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c +3
-66@@ -2981,64 +2981,6 @@ static ssize_t hdmi_cec_state_write(struct file *f, const char __user *buf,return size; } -/** -* hdmi_automation_enable - Enable/Disable HDMI automation feature -* @f: file structure. -* @buf: userspace buffer. set to '1' to enable; '0' to disable automation feature. -* @size: size of buffer from userpsace. -* @pos: unused. -* -* Return size on success, error code on failure -*/ -static ssize_t hdmi_automation_enable (struct file *f,const char __user *buf, -size_t size,loff_t *pos) -{ -struct amdgpu_dm_connector *aconnector =file_inode (f)->i_private; -char *wr_buf =NULL ; -const uint32_t wr_buf_size =40 ; -int max_param_num =1 ; -uint8_t param_nums =0 ; -long param[2 ]; -bool hdmi_comp_auto; - -if (size ==0 ) -return -EINVAL ; - - wr_buf =kcalloc (wr_buf_size,sizeof (char ),GFP_KERNEL ); -if (!wr_buf) -return -ENOSPC ; - -if (parse_write_buffer_into_params (wr_buf, wr_buf_size, - (long *)param, buf, - max_param_num, - ¶m_nums)) { -kfree (wr_buf); -return -EINVAL ; - } - -if (param_nums <=0 ) { -kfree (wr_buf); -DRM_DEBUG_DRIVER ("user data not be read\n" ); -return -EINVAL ; - } - -switch (param[0 ]) { -case 0 : - hdmi_comp_auto = false; -break ; -case 1 : -default : - hdmi_comp_auto = true; -break ; - } - -/* Persist setting across sink re-detection/hotplug. */ - aconnector->hdmi_comp_auto = hdmi_comp_auto; - -kfree (wr_buf); -return size; -} -DEFINE_SHOW_ATTRIBUTE (dp_dsc_fec_support);DEFINE_SHOW_ATTRIBUTE (dmub_fw_state);DEFINE_SHOW_ATTRIBUTE (dmub_tracebuffer);@@ -3156,12 +3098,6 @@ static const struct file_operations dp_mst_link_settings_debugfs_fops = { .llseek = default_llseek }; -static const struct file_operations hdmi_automation_debugfs_fops = { - .owner =THIS_MODULE , - .write = hdmi_automation_enable, - .llseek = default_llseek -}; - static const struct { char *name; const struct file_operations *fops;@@ -3194,8 +3130,7 @@ static const struct {const struct file_operations *fops; } hdmi_debugfs_entries[] = { {"hdcp_sink_capability", &hdcp_sink_capability_fops}, - {"hdmi_cec_state", &hdmi_cec_state_fops}, - {"hdmi_automation", &hdmi_automation_debugfs_fops} + {"hdmi_cec_state", &hdmi_cec_state_fops} };/* @@ -3908,6 +3843,8 @@ void connector_debugfs_init(struct amdgpu_dm_connector *connector)0644 , dir, connector, hdmi_debugfs_entries[i].fops); } + +debugfs_create_bool ("hdmi_automation" ,0644 , dir, &connector->hdmi_comp_auto); } }