carl9170: stop embedding file_operations into their objects
authorAl Viro <viro@zeniv.linux.org.uk>
Sun, 12 Jan 2025 08:06:51 +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; switch to debugfs_short_ops as well.

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

index bb40889d7c720d4ebfe4713540f273d8a3394665..2d734567000a4b593b135223a2900e7d9693970e 100644 (file)
@@ -54,7 +54,6 @@ struct carl9170_debugfs_fops {
        char *(*read)(struct ar9170 *ar, char *buf, size_t bufsize,
                      ssize_t *len);
        ssize_t (*write)(struct ar9170 *aru, const char *buf, size_t size);
-       const struct file_operations fops;
 
        enum carl9170_device_state req_dev_state;
 };
@@ -62,7 +61,7 @@ struct carl9170_debugfs_fops {
 static ssize_t carl9170_debugfs_read(struct file *file, char __user *userbuf,
                                     size_t count, loff_t *ppos)
 {
-       struct carl9170_debugfs_fops *dfops;
+       const struct carl9170_debugfs_fops *dfops;
        struct ar9170 *ar;
        char *buf = NULL, *res_buf = NULL;
        ssize_t ret = 0;
@@ -75,8 +74,7 @@ static ssize_t carl9170_debugfs_read(struct file *file, char __user *userbuf,
 
        if (!ar)
                return -ENODEV;
-       dfops = container_of(debugfs_real_fops(file),
-                            struct carl9170_debugfs_fops, fops);
+       dfops = debugfs_get_aux(file);
 
        if (!dfops->read)
                return -ENOSYS;
@@ -113,7 +111,7 @@ out_free:
 static ssize_t carl9170_debugfs_write(struct file *file,
        const char __user *userbuf, size_t count, loff_t *ppos)
 {
-       struct carl9170_debugfs_fops *dfops;
+       const struct carl9170_debugfs_fops *dfops;
        struct ar9170 *ar;
        char *buf = NULL;
        int err = 0;
@@ -128,8 +126,7 @@ static ssize_t carl9170_debugfs_write(struct file *file,
 
        if (!ar)
                return -ENODEV;
-       dfops = container_of(debugfs_real_fops(file),
-                            struct carl9170_debugfs_fops, fops);
+       dfops = debugfs_get_aux(file);
 
        if (!dfops->write)
                return -ENOSYS;
@@ -165,6 +162,11 @@ out_free:
        return err;
 }
 
+static struct debugfs_short_fops debugfs_fops = {
+       .read   = carl9170_debugfs_read,
+       .write  = carl9170_debugfs_write,
+};
+
 #define __DEBUGFS_DECLARE_FILE(name, _read, _write, _read_bufsize,     \
                               _attr, _dstate)                          \
 static const struct carl9170_debugfs_fops carl_debugfs_##name ##_ops = {\
@@ -173,12 +175,6 @@ static const struct carl9170_debugfs_fops carl_debugfs_##name ##_ops = {\
        .write = _write,                                                \
        .attr = _attr,                                                  \
        .req_dev_state = _dstate,                                       \
-       .fops = {                                                       \
-               .open   = simple_open,                                  \
-               .read   = carl9170_debugfs_read,                        \
-               .write  = carl9170_debugfs_write,                       \
-               .owner  = THIS_MODULE                                   \
-       },                                                              \
 }
 
 #define DEBUGFS_DECLARE_FILE(name, _read, _write, _read_bufsize, _attr)        \
@@ -816,9 +812,9 @@ void carl9170_debugfs_register(struct ar9170 *ar)
                ar->hw->wiphy->debugfsdir);
 
 #define DEBUGFS_ADD(name)                                              \
-       debugfs_create_file(#name, carl_debugfs_##name ##_ops.attr,     \
-                           ar->debug_dir, ar,                          \
-                           &carl_debugfs_##name ## _ops.fops)
+       debugfs_create_file_aux(#name, carl_debugfs_##name ##_ops.attr, \
+                           ar->debug_dir, ar, &carl_debugfs_##name ## _ops, \
+                           &debugfs_fops)
 
        DEBUGFS_ADD(usb_tx_anch_urbs);
        DEBUGFS_ADD(usb_rx_pool_urbs);