drm/amd/display: Return the number of bytes parsed than allocated
authorEryk Brol <eryk.brol@amd.com>
Thu, 27 Aug 2020 20:48:38 +0000 (16:48 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 15 Sep 2020 21:52:42 +0000 (17:52 -0400)
[why & how]
Previously we were returning the number of bytes allocated
for a write buffer from debugfs and when manually used it wouldn't
rise any errors, but it wouldn't match the size of the parameters
passed from userspace.

In successful case return the size passed by usermode otherwise
the error code is returned. That simplifies the parser helper
and removes a potential error of returning mismatched input size.

Signed-off-by: Eryk Brol <eryk.brol@amd.com>
Signed-off-by: Mikita Lipski <mikita.lipski@amd.com>
Acked-by: Aurabindo Pillai <aurabindo.pillai@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c

index 7c7f937..240a4fc 100644 (file)
@@ -264,7 +264,7 @@ static ssize_t dp_link_settings_write(struct file *f, const char __user *buf,
        if (!wr_buf)
                return -ENOSPC;
 
-       if (parse_write_buffer_into_params(wr_buf, wr_buf_size,
+       if (parse_write_buffer_into_params(wr_buf, size,
                                           (long *)param, buf,
                                           max_param_num,
                                           &param_nums)) {
@@ -423,7 +423,7 @@ static ssize_t dp_phy_settings_write(struct file *f, const char __user *buf,
        if (!wr_buf)
                return -ENOSPC;
 
-       if (parse_write_buffer_into_params(wr_buf, wr_buf_size,
+       if (parse_write_buffer_into_params(wr_buf, size,
                                           (long *)param, buf,
                                           max_param_num,
                                           &param_nums)) {
@@ -575,7 +575,7 @@ static ssize_t dp_phy_test_pattern_debugfs_write(struct file *f, const char __us
        if (!wr_buf)
                return -ENOSPC;
 
-       if (parse_write_buffer_into_params(wr_buf, wr_buf_size,
+       if (parse_write_buffer_into_params(wr_buf, size,
                                           (long *)param, buf,
                                           max_param_num,
                                           &param_nums)) {
@@ -1090,7 +1090,7 @@ static ssize_t dp_trigger_hotplug(struct file *f, const char __user *buf,
                return -ENOSPC;
        }
 
-       if (parse_write_buffer_into_params(wr_buf, wr_buf_size,
+       if (parse_write_buffer_into_params(wr_buf, size,
                                                (long *)param, buf,
                                                max_param_num,
                                                &param_nums))
@@ -1269,7 +1269,7 @@ static ssize_t dp_dsc_clock_en_write(struct file *f, const char __user *buf,
                return -ENOSPC;
        }
 
-       if (parse_write_buffer_into_params(wr_buf, wr_buf_size,
+       if (parse_write_buffer_into_params(wr_buf, size,
                                            (long *)param, buf,
                                            max_param_num,
                                            &param_nums)) {
@@ -1423,7 +1423,7 @@ static ssize_t dp_dsc_slice_width_write(struct file *f, const char __user *buf,
                return -ENOSPC;
        }
 
-       if (parse_write_buffer_into_params(wr_buf, wr_buf_size,
+       if (parse_write_buffer_into_params(wr_buf, size,
                                            (long *)param, buf,
                                            max_param_num,
                                            &param_nums)) {
@@ -1572,7 +1572,7 @@ static ssize_t dp_dsc_slice_height_write(struct file *f, const char __user *buf,
                return -ENOSPC;
        }
 
-       if (parse_write_buffer_into_params(wr_buf, wr_buf_size,
+       if (parse_write_buffer_into_params(wr_buf, size,
                                            (long *)param, buf,
                                            max_param_num,
                                            &param_nums)) {
@@ -1714,7 +1714,7 @@ static ssize_t dp_dsc_bits_per_pixel_write(struct file *f, const char __user *bu
                return -ENOSPC;
        }
 
-       if (parse_write_buffer_into_params(wr_buf, wr_buf_size,
+       if (parse_write_buffer_into_params(wr_buf, size,
                                            (long *)param, buf,
                                            max_param_num,
                                            &param_nums)) {