b43legacy: make use of debugfs_get_aux()
authorAl Viro <viro@zeniv.linux.org.uk>
Sun, 12 Jan 2025 08:06:53 +0000 (08:06 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 15 Jan 2025 12:14:36 +0000 (13:14 +0100)
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Link: https://lore.kernel.org/r/20250112080705.141166-9-viro@zeniv.linux.org.uk
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/wireless/broadcom/b43legacy/debugfs.c

index 6b0e8d1170611f6ac7eaca2969b2e35cb063b308..5d04bcc216e5cf0ce13d0d45a65ec3522c22d4eb 100644 (file)
@@ -31,7 +31,6 @@ static struct dentry *rootdir;
 struct b43legacy_debugfs_fops {
        ssize_t (*read)(struct b43legacy_wldev *dev, char *buf, size_t bufsize);
        int (*write)(struct b43legacy_wldev *dev, const char *buf, size_t count);
-       struct file_operations fops;
        /* Offset of struct b43legacy_dfs_file in struct b43legacy_dfsentry */
        size_t file_struct_offset;
        /* Take wl->irq_lock before calling read/write? */
@@ -188,7 +187,7 @@ static ssize_t b43legacy_debugfs_read(struct file *file, char __user *userbuf,
                                size_t count, loff_t *ppos)
 {
        struct b43legacy_wldev *dev;
-       struct b43legacy_debugfs_fops *dfops;
+       const struct b43legacy_debugfs_fops *dfops;
        struct b43legacy_dfs_file *dfile;
        ssize_t ret;
        char *buf;
@@ -208,8 +207,7 @@ static ssize_t b43legacy_debugfs_read(struct file *file, char __user *userbuf,
                goto out_unlock;
        }
 
-       dfops = container_of(debugfs_real_fops(file),
-                            struct b43legacy_debugfs_fops, fops);
+       dfops = debugfs_get_aux(file);
        if (!dfops->read) {
                err = -ENOSYS;
                goto out_unlock;
@@ -257,7 +255,7 @@ static ssize_t b43legacy_debugfs_write(struct file *file,
                                 size_t count, loff_t *ppos)
 {
        struct b43legacy_wldev *dev;
-       struct b43legacy_debugfs_fops *dfops;
+       const struct b43legacy_debugfs_fops *dfops;
        char *buf;
        int err = 0;
 
@@ -275,8 +273,7 @@ static ssize_t b43legacy_debugfs_write(struct file *file,
                goto out_unlock;
        }
 
-       dfops = container_of(debugfs_real_fops(file),
-                            struct b43legacy_debugfs_fops, fops);
+       dfops = debugfs_get_aux(file);
        if (!dfops->write) {
                err = -ENOSYS;
                goto out_unlock;
@@ -308,17 +305,16 @@ out_unlock:
        return err ? err : count;
 }
 
+static struct debugfs_short_fops debugfs_ops = {
+       .read   = b43legacy_debugfs_read,
+       .write  = b43legacy_debugfs_write,
+       .llseek = generic_file_llseek
+};
 
 #define B43legacy_DEBUGFS_FOPS(name, _read, _write, _take_irqlock)     \
        static struct b43legacy_debugfs_fops fops_##name = {            \
                .read   = _read,                                \
                .write  = _write,                               \
-               .fops   = {                                     \
-                       .open   = simple_open,                          \
-                       .read   = b43legacy_debugfs_read,               \
-                       .write  = b43legacy_debugfs_write,              \
-                       .llseek = generic_file_llseek,                  \
-               },                                              \
                .file_struct_offset = offsetof(struct b43legacy_dfsentry, \
                                               file_##name),    \
                .take_irqlock   = _take_irqlock,                \
@@ -386,9 +382,9 @@ void b43legacy_debugfs_add_device(struct b43legacy_wldev *dev)
 
 #define ADD_FILE(name, mode)   \
        do {                                                    \
-               debugfs_create_file(__stringify(name), mode,    \
+               debugfs_create_file_aux(__stringify(name), mode,        \
                                    e->subdir, dev,             \
-                                   &fops_##name.fops);         \
+                                   &fops_##name, &debugfs_ops);        \
        } while (0)