netdevsim: don't embed file_operations into your structs
authorAl Viro <viro@zeniv.linux.org.uk>
Sun, 12 Jan 2025 08:06:54 +0000 (08:06 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 15 Jan 2025 12:14:36 +0000 (13:14 +0100)
Just use debugfs_get_aux() instead of debugfs_real_fops().

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Link: https://lore.kernel.org/r/20250112080705.141166-10-viro@zeniv.linux.org.uk
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/netdevsim/hwstats.c

index 0e58aa7f0374eefefe583b10f73266b19ba2a79c..66b3215db3acdec5d737c03e163fc66e471bcca5 100644 (file)
@@ -331,7 +331,6 @@ enum nsim_dev_hwstats_do {
 };
 
 struct nsim_dev_hwstats_fops {
-       const struct file_operations fops;
        enum nsim_dev_hwstats_do action;
        enum netdev_offload_xstats_type type;
 };
@@ -342,13 +341,12 @@ nsim_dev_hwstats_do_write(struct file *file,
                          size_t count, loff_t *ppos)
 {
        struct nsim_dev_hwstats *hwstats = file->private_data;
-       struct nsim_dev_hwstats_fops *hwsfops;
+       const struct nsim_dev_hwstats_fops *hwsfops;
        struct list_head *hwsdev_list;
        int ifindex;
        int err;
 
-       hwsfops = container_of(debugfs_real_fops(file),
-                              struct nsim_dev_hwstats_fops, fops);
+       hwsfops = debugfs_get_aux(file);
 
        err = kstrtoint_from_user(data, count, 0, &ifindex);
        if (err)
@@ -381,14 +379,13 @@ nsim_dev_hwstats_do_write(struct file *file,
        return count;
 }
 
+static struct debugfs_short_fops debugfs_ops = {
+       .write = nsim_dev_hwstats_do_write,
+       .llseek = generic_file_llseek,
+};
+
 #define NSIM_DEV_HWSTATS_FOPS(ACTION, TYPE)                    \
        {                                                       \
-               .fops = {                                       \
-                       .open = simple_open,                    \
-                       .write = nsim_dev_hwstats_do_write,     \
-                       .llseek = generic_file_llseek,          \
-                       .owner = THIS_MODULE,                   \
-               },                                              \
                .action = ACTION,                               \
                .type = TYPE,                                   \
        }
@@ -433,12 +430,12 @@ int nsim_dev_hwstats_init(struct nsim_dev *nsim_dev)
                goto err_remove_hwstats_recursive;
        }
 
-       debugfs_create_file("enable_ifindex", 0200, hwstats->l3_ddir, hwstats,
-                           &nsim_dev_hwstats_l3_enable_fops.fops);
-       debugfs_create_file("disable_ifindex", 0200, hwstats->l3_ddir, hwstats,
-                           &nsim_dev_hwstats_l3_disable_fops.fops);
-       debugfs_create_file("fail_next_enable", 0200, hwstats->l3_ddir, hwstats,
-                           &nsim_dev_hwstats_l3_fail_fops.fops);
+       debugfs_create_file_aux("enable_ifindex", 0200, hwstats->l3_ddir, hwstats,
+                           &nsim_dev_hwstats_l3_enable_fops, &debugfs_ops);
+       debugfs_create_file_aux("disable_ifindex", 0200, hwstats->l3_ddir, hwstats,
+                           &nsim_dev_hwstats_l3_disable_fops, &debugfs_ops);
+       debugfs_create_file_aux("fail_next_enable", 0200, hwstats->l3_ddir, hwstats,
+                           &nsim_dev_hwstats_l3_fail_fops, &debugfs_ops);
 
        INIT_DELAYED_WORK(&hwstats->traffic_dw,
                          &nsim_dev_hwstats_traffic_work);