]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
octeontx2: don't mess with ->d_parent or ->d_parent->d_name
authorAl Viro <viro@zeniv.linux.org.uk>
Sun, 12 Jan 2025 08:07:03 +0000 (08:07 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 15 Jan 2025 12:14:37 +0000 (13:14 +0100)
use debugfs_{create_file,get}_aux_num() instead.

[and for fsck sake, don't call variables filp - especially the
ones that are not even struct file *]

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Link: https://lore.kernel.org/r/20250112080705.141166-19-viro@zeniv.linux.org.uk
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c

index 148144f5b61df7b9b76885c6d10ba3812433b5c6..a1f9ec03c2ce69c11c528b8bba3764f23fc1fac5 100644 (file)
@@ -917,19 +917,18 @@ static void print_npa_qsize(struct seq_file *m, struct rvu_pfvf *pfvf)
 /* The 'qsize' entry dumps current Aura/Pool context Qsize
  * and each context's current enable/disable status in a bitmap.
  */
-static int rvu_dbg_qsize_display(struct seq_file *filp, void *unsused,
+static int rvu_dbg_qsize_display(struct seq_file *s, void *unsused,
                                 int blktype)
 {
-       void (*print_qsize)(struct seq_file *filp,
+       void (*print_qsize)(struct seq_file *s,
                            struct rvu_pfvf *pfvf) = NULL;
-       struct dentry *current_dir;
        struct rvu_pfvf *pfvf;
        struct rvu *rvu;
        int qsize_id;
        u16 pcifunc;
        int blkaddr;
 
-       rvu = filp->private;
+       rvu = s->private;
        switch (blktype) {
        case BLKTYPE_NPA:
                qsize_id = rvu->rvu_dbg.npa_qsize_id;
@@ -945,32 +944,28 @@ static int rvu_dbg_qsize_display(struct seq_file *filp, void *unsused,
                return -EINVAL;
        }
 
-       if (blktype == BLKTYPE_NPA) {
+       if (blktype == BLKTYPE_NPA)
                blkaddr = BLKADDR_NPA;
-       } else {
-               current_dir = filp->file->f_path.dentry->d_parent;
-               blkaddr = (!strcmp(current_dir->d_name.name, "nix1") ?
-                                  BLKADDR_NIX1 : BLKADDR_NIX0);
-       }
+       else
+               blkaddr = debugfs_get_aux_num(s->file);
 
        if (!rvu_dbg_is_valid_lf(rvu, blkaddr, qsize_id, &pcifunc))
                return -EINVAL;
 
        pfvf = rvu_get_pfvf(rvu, pcifunc);
-       print_qsize(filp, pfvf);
+       print_qsize(s, pfvf);
 
        return 0;
 }
 
-static ssize_t rvu_dbg_qsize_write(struct file *filp,
+static ssize_t rvu_dbg_qsize_write(struct file *file,
                                   const char __user *buffer, size_t count,
                                   loff_t *ppos, int blktype)
 {
        char *blk_string = (blktype == BLKTYPE_NPA) ? "npa" : "nix";
-       struct seq_file *seqfile = filp->private_data;
+       struct seq_file *seqfile = file->private_data;
        char *cmd_buf, *cmd_buf_tmp, *subtoken;
        struct rvu *rvu = seqfile->private;
-       struct dentry *current_dir;
        int blkaddr;
        u16 pcifunc;
        int ret, lf;
@@ -996,13 +991,10 @@ static ssize_t rvu_dbg_qsize_write(struct file *filp,
                goto qsize_write_done;
        }
 
-       if (blktype == BLKTYPE_NPA) {
+       if (blktype == BLKTYPE_NPA)
                blkaddr = BLKADDR_NPA;
-       } else {
-               current_dir = filp->f_path.dentry->d_parent;
-               blkaddr = (!strcmp(current_dir->d_name.name, "nix1") ?
-                                  BLKADDR_NIX1 : BLKADDR_NIX0);
-       }
+       else
+               blkaddr = debugfs_get_aux_num(file);
 
        if (!rvu_dbg_is_valid_lf(rvu, blkaddr, lf, &pcifunc)) {
                ret = -EINVAL;
@@ -2704,8 +2696,8 @@ static void rvu_dbg_nix_init(struct rvu *rvu, int blkaddr)
                            &rvu_dbg_nix_ndc_tx_hits_miss_fops);
        debugfs_create_file("ndc_rx_hits_miss", 0600, rvu->rvu_dbg.nix, nix_hw,
                            &rvu_dbg_nix_ndc_rx_hits_miss_fops);
-       debugfs_create_file("qsize", 0600, rvu->rvu_dbg.nix, rvu,
-                           &rvu_dbg_nix_qsize_fops);
+       debugfs_create_file_aux_num("qsize", 0600, rvu->rvu_dbg.nix, rvu,
+                           blkaddr, &rvu_dbg_nix_qsize_fops);
        debugfs_create_file("ingress_policer_ctx", 0600, rvu->rvu_dbg.nix, nix_hw,
                            &rvu_dbg_nix_band_prof_ctx_fops);
        debugfs_create_file("ingress_policer_rsrc", 0600, rvu->rvu_dbg.nix, nix_hw,
@@ -2854,28 +2846,14 @@ static int cgx_print_stats(struct seq_file *s, int lmac_id)
        return err;
 }
 
-static int rvu_dbg_derive_lmacid(struct seq_file *filp, int *lmac_id)
+static int rvu_dbg_derive_lmacid(struct seq_file *s)
 {
-       struct dentry *current_dir;
-       char *buf;
-
-       current_dir = filp->file->f_path.dentry->d_parent;
-       buf = strrchr(current_dir->d_name.name, 'c');
-       if (!buf)
-               return -EINVAL;
-
-       return kstrtoint(buf + 1, 10, lmac_id);
+       return debugfs_get_aux_num(s->file);
 }
 
-static int rvu_dbg_cgx_stat_display(struct seq_file *filp, void *unused)
+static int rvu_dbg_cgx_stat_display(struct seq_file *s, void *unused)
 {
-       int lmac_id, err;
-
-       err = rvu_dbg_derive_lmacid(filp, &lmac_id);
-       if (!err)
-               return cgx_print_stats(filp, lmac_id);
-
-       return err;
+       return cgx_print_stats(s, rvu_dbg_derive_lmacid(s));
 }
 
 RVU_DEBUG_SEQ_FOPS(cgx_stat, cgx_stat_display, NULL);
@@ -2933,15 +2911,9 @@ static int cgx_print_dmac_flt(struct seq_file *s, int lmac_id)
        return 0;
 }
 
-static int rvu_dbg_cgx_dmac_flt_display(struct seq_file *filp, void *unused)
+static int rvu_dbg_cgx_dmac_flt_display(struct seq_file *s, void *unused)
 {
-       int err, lmac_id;
-
-       err = rvu_dbg_derive_lmacid(filp, &lmac_id);
-       if (!err)
-               return cgx_print_dmac_flt(filp, lmac_id);
-
-       return err;
+       return cgx_print_dmac_flt(s, rvu_dbg_derive_lmacid(s));
 }
 
 RVU_DEBUG_SEQ_FOPS(cgx_dmac_flt, cgx_dmac_flt_display, NULL);
@@ -2980,10 +2952,10 @@ static void rvu_dbg_cgx_init(struct rvu *rvu)
                        rvu->rvu_dbg.lmac =
                                debugfs_create_dir(dname, rvu->rvu_dbg.cgx);
 
-                       debugfs_create_file("stats", 0600, rvu->rvu_dbg.lmac,
-                                           cgx, &rvu_dbg_cgx_stat_fops);
-                       debugfs_create_file("mac_filter", 0600,
-                                           rvu->rvu_dbg.lmac, cgx,
+                       debugfs_create_file_aux_num("stats", 0600, rvu->rvu_dbg.lmac,
+                                           cgx, lmac_id, &rvu_dbg_cgx_stat_fops);
+                       debugfs_create_file_aux_num("mac_filter", 0600,
+                                           rvu->rvu_dbg.lmac, cgx, lmac_id,
                                            &rvu_dbg_cgx_dmac_flt_fops);
                }
        }