]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
b43: stop embedding struct file_operations into their objects
authorAl Viro <viro@zeniv.linux.org.uk>
Sun, 12 Jan 2025 08:06:52 +0000 (08:06 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 15 Jan 2025 12:14:36 +0000 (13:14 +0100)
Use debugfs_get_aux() instead.  And switch to debugfs_short_fops, while we
are at it...

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Link: https://lore.kernel.org/r/20250112080705.141166-8-viro@zeniv.linux.org.uk
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/wireless/broadcom/b43/debugfs.c

index efa98444e3fb0cb8d18dc68959a8583479d4cd5f..5a49970afc8cd2ca3577e3fe68e4d24fd449c82d 100644 (file)
@@ -30,7 +30,6 @@ static struct dentry *rootdir;
 struct b43_debugfs_fops {
        ssize_t (*read)(struct b43_wldev *dev, char *buf, size_t bufsize);
        int (*write)(struct b43_wldev *dev, const char *buf, size_t count);
-       struct file_operations fops;
        /* Offset of struct b43_dfs_file in struct b43_dfsentry */
        size_t file_struct_offset;
 };
@@ -491,7 +490,7 @@ static ssize_t b43_debugfs_read(struct file *file, char __user *userbuf,
                                size_t count, loff_t *ppos)
 {
        struct b43_wldev *dev;
-       struct b43_debugfs_fops *dfops;
+       const struct b43_debugfs_fops *dfops;
        struct b43_dfs_file *dfile;
        ssize_t ret;
        char *buf;
@@ -511,8 +510,7 @@ static ssize_t b43_debugfs_read(struct file *file, char __user *userbuf,
                goto out_unlock;
        }
 
-       dfops = container_of(debugfs_real_fops(file),
-                            struct b43_debugfs_fops, fops);
+       dfops = debugfs_get_aux(file);
        if (!dfops->read) {
                err = -ENOSYS;
                goto out_unlock;
@@ -555,7 +553,7 @@ static ssize_t b43_debugfs_write(struct file *file,
                                 size_t count, loff_t *ppos)
 {
        struct b43_wldev *dev;
-       struct b43_debugfs_fops *dfops;
+       const struct b43_debugfs_fops *dfops;
        char *buf;
        int err = 0;
 
@@ -573,8 +571,7 @@ static ssize_t b43_debugfs_write(struct file *file,
                goto out_unlock;
        }
 
-       dfops = container_of(debugfs_real_fops(file),
-                            struct b43_debugfs_fops, fops);
+       dfops = debugfs_get_aux(file);
        if (!dfops->write) {
                err = -ENOSYS;
                goto out_unlock;
@@ -602,16 +599,16 @@ out_unlock:
 }
 
 
+static struct debugfs_short_fops debugfs_ops = {
+       .read   = b43_debugfs_read,
+       .write  = b43_debugfs_write,
+       .llseek = generic_file_llseek,
+};
+
 #define B43_DEBUGFS_FOPS(name, _read, _write)                  \
        static struct b43_debugfs_fops fops_##name = {          \
                .read   = _read,                                \
                .write  = _write,                               \
-               .fops   = {                                     \
-                       .open   = simple_open,                  \
-                       .read   = b43_debugfs_read,             \
-                       .write  = b43_debugfs_write,            \
-                       .llseek = generic_file_llseek,          \
-               },                                              \
                .file_struct_offset = offsetof(struct b43_dfsentry, \
                                               file_##name),    \
        }
@@ -703,9 +700,9 @@ void b43_debugfs_add_device(struct b43_wldev *dev)
 
 #define ADD_FILE(name, mode)   \
        do {                                                    \
-               debugfs_create_file(__stringify(name),          \
+               debugfs_create_file_aux(__stringify(name),      \
                                mode, e->subdir, dev,           \
-                               &fops_##name.fops);             \
+                               &fops_##name, &debugfs_ops);    \
        } while (0)