Similar to control_read(), sched_group_engines_read() constructs a
space-separated list of hardware engine names in a stack buffer using
repeated strlcat() calls inside a loop.

In preparation for removing the deprecated strlcat() API[1], refactor
sched_group_engines_read() to use struct seq_buf and seq_buf_printf().

Link: https://github.com/KSPP/linux/issues/370 [1]
Cc: [email protected]
Assisted-by: Developer:Gemini [editor_update_file, 
make_kernel_build_single_file, shell_command_run]
Signed-off-by: Bill Wendling <[email protected]>
---
Cc: Russell King <[email protected]>
Cc: Huacai Chen <[email protected]>
Cc: WANG Xuerui <[email protected]>
Cc: Thomas Bogendoerfer <[email protected]>
Cc: "James E.J. Bottomley" <[email protected]>
Cc: Helge Deller <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Borislav Petkov <[email protected]>
Cc: Dave Hansen <[email protected]>
Cc: [email protected]
Cc: "H. Peter Anvin" <[email protected]>
Cc: Ian Abbott <[email protected]>
Cc: H Hartley Sweeten <[email protected]>
Cc: Tony Luck <[email protected]>
Cc: Maarten Lankhorst <[email protected]>
Cc: Maxime Ripard <[email protected]>
Cc: Thomas Zimmermann <[email protected]>
Cc: David Airlie <[email protected]>
Cc: Simona Vetter <[email protected]>
Cc: Matthew Brost <[email protected]>
Cc: "Thomas Hellström" <[email protected]>
Cc: Rodrigo Vivi <[email protected]>
Cc: Dmitry Torokhov <[email protected]>
Cc: Matthias Schwarzott <[email protected]>
Cc: Mauro Carvalho Chehab <[email protected]>
Cc: Tony Nguyen <[email protected]>
Cc: Przemek Kitszel <[email protected]>
Cc: Andrew Lunn <[email protected]>
Cc: "David S. Miller" <[email protected]>
Cc: Eric Dumazet <[email protected]>
Cc: Jakub Kicinski <[email protected]>
Cc: Paolo Abeni <[email protected]>
Cc: Arend van Spriel <[email protected]>
Cc: Rob Herring <[email protected]>
Cc: Saravana Kannan <[email protected]>
Cc: Krzysztof Kozlowski <[email protected]>
Cc: Sylwester Nawrocki <[email protected]>
Cc: Peter Griffin <[email protected]>
Cc: Alim Akhtar <[email protected]>
Cc: Linus Walleij <[email protected]>
Cc: Anil Gurumurthy <[email protected]>
Cc: Sudarsana Kalluru <[email protected]>
Cc: "Martin K. Petersen" <[email protected]>
Cc: Trond Myklebust <[email protected]>
Cc: Anna Schumaker <[email protected]>
Cc: Mike Marshall <[email protected]>
Cc: Martin Brandenburg <[email protected]>
Cc: Kees Cook <[email protected]>
Cc: Jiri Pirko <[email protected]>
Cc: Simon Horman <[email protected]>
Cc: Chuck Lever <[email protected]>
Cc: Jeff Layton <[email protected]>
Cc: NeilBrown <[email protected]>
Cc: Olga Kornievskaia <[email protected]>
Cc: Dai Ngo <[email protected]>
Cc: Tom Talpey <[email protected]>
Cc: Jaroslav Kysela <[email protected]>
Cc: Takashi Iwai <[email protected]>
Cc: Bill Wendling <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: "Mike Rapoport (Microsoft)" <[email protected]>
Cc: Kanglong Wang <[email protected]>
Cc: Tiezhu Yang <[email protected]>
Cc: Qiang Ma <[email protected]>
Cc: Randy Dunlap <[email protected]>
Cc: Pengpeng Hou <[email protected]>
Cc: Ard Biesheuvel <[email protected]>
Cc: Breno Leitao <[email protected]>
Cc: Thorsten Blum <[email protected]>
Cc: Harshit Mogalapalli <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
Cc: Lyude Paul <[email protected]>
Cc: Ashutosh Desai <[email protected]>
Cc: Imre Deak <[email protected]>
Cc: Dmitry Baryshkov <[email protected]>
Cc: Johan Hovold <[email protected]>
Cc: Johannes Berg <[email protected]>
Cc: Miri Korenblit <[email protected]>
Cc: Alexander Stein <[email protected]>
Cc: Cryolitia PukNgae <[email protected]>
Cc: Jiaming Zhang <[email protected]>
Cc: Will Porter <[email protected]>
Cc: Cen Zhang <[email protected]>
Cc: "Cássio Gabriel" <[email protected]>
Cc: Rong Zhang <[email protected]>
Cc: Arun Raghavan <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
---
 drivers/gpu/drm/xe/xe_gt_sriov_pf_debugfs.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/xe/xe_gt_sriov_pf_debugfs.c 
b/drivers/gpu/drm/xe/xe_gt_sriov_pf_debugfs.c
index 5db7fc067c4d..548a50f74422 100644
--- a/drivers/gpu/drm/xe/xe_gt_sriov_pf_debugfs.c
+++ b/drivers/gpu/drm/xe/xe_gt_sriov_pf_debugfs.c
@@ -377,8 +377,10 @@ static ssize_t sched_group_engines_read(struct file *file, 
char __user *buf,
        struct xe_hw_engine *hwe;
        enum xe_hw_engine_id id;
        char engines[128];
+       struct seq_buf s;
+       const char *s_str;
 
-       engines[0] = '\0';
+       seq_buf_init(&s, engines, sizeof(engines));
 
        if (group < num_groups) {
                for_each_hw_engine(hwe, gt, id) {
@@ -386,15 +388,14 @@ static ssize_t sched_group_engines_read(struct file 
*file, char __user *buf,
                        u16 guc_logical_instance = 
xe_hwe_guc_logical_instance(hwe);
                        u32 mask = groups[group].engines[guc_class];
 
-                       if (mask & BIT(guc_logical_instance)) {
-                               strlcat(engines, hwe->name, sizeof(engines));
-                               strlcat(engines, " ", sizeof(engines));
-                       }
+                       if (mask & BIT(guc_logical_instance))
+                               seq_buf_printf(&s, "%s ", hwe->name);
                }
-               strlcat(engines, "\n", sizeof(engines));
+               seq_buf_puts(&s, "\n");
        }
 
-       return simple_read_from_buffer(buf, count, ppos, engines, 
strlen(engines));
+       s_str = seq_buf_str(&s);
+       return simple_read_from_buffer(buf, count, ppos, s_str, strlen(s_str));
 }
 
 static const struct file_operations sched_group_engines_fops = {
-- 
2.55.0.1032.g73a4cd73de-goog

Reply via email to