sof-client-ipc-flood-test: don't mess with ->d_name
authorAl Viro <viro@zeniv.linux.org.uk>
Sun, 12 Jan 2025 08:07:00 +0000 (08:07 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 15 Jan 2025 12:14:37 +0000 (13:14 +0100)
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Link: https://lore.kernel.org/r/20250112080705.141166-16-viro@zeniv.linux.org.uk
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
sound/soc/sof/sof-client-ipc-flood-test.c

index b35c98896968140256e7349dd37c133bb2f9eefe..11b6f7da28826b7b5e19365c68df317a0dc1920f 100644 (file)
@@ -158,7 +158,6 @@ static ssize_t sof_ipc_flood_dfs_write(struct file *file, const char __user *buf
        unsigned long ipc_duration_ms = 0;
        bool flood_duration_test = false;
        unsigned long ipc_count = 0;
-       struct dentry *dentry;
        int err;
        char *string;
        int ret;
@@ -182,14 +181,7 @@ static ssize_t sof_ipc_flood_dfs_write(struct file *file, const char __user *buf
         * ipc_duration_ms test floods the DSP for the time specified
         * in the debugfs entry.
         */
-       dentry = file->f_path.dentry;
-       if (strcmp(dentry->d_name.name, DEBUGFS_IPC_FLOOD_COUNT) &&
-           strcmp(dentry->d_name.name, DEBUGFS_IPC_FLOOD_DURATION)) {
-               ret = -EINVAL;
-               goto out;
-       }
-
-       if (!strcmp(dentry->d_name.name, DEBUGFS_IPC_FLOOD_DURATION))
+       if (debugfs_get_aux_num(file))
                flood_duration_test = true;
 
        /* test completion criterion */
@@ -252,22 +244,15 @@ static ssize_t sof_ipc_flood_dfs_read(struct file *file, char __user *buffer,
        struct sof_ipc_flood_priv *priv = cdev->data;
        size_t size_ret;
 
-       struct dentry *dentry;
+       if (*ppos)
+               return 0;
 
-       dentry = file->f_path.dentry;
-       if (!strcmp(dentry->d_name.name, DEBUGFS_IPC_FLOOD_COUNT) ||
-           !strcmp(dentry->d_name.name, DEBUGFS_IPC_FLOOD_DURATION)) {
-               if (*ppos)
-                       return 0;
+       count = min_t(size_t, count, strlen(priv->buf));
+       size_ret = copy_to_user(buffer, priv->buf, count);
+       if (size_ret)
+               return -EFAULT;
 
-               count = min_t(size_t, count, strlen(priv->buf));
-               size_ret = copy_to_user(buffer, priv->buf, count);
-               if (size_ret)
-                       return -EFAULT;
-
-               *ppos += count;
-               return count;
-       }
+       *ppos += count;
        return count;
 }
 
@@ -320,12 +305,12 @@ static int sof_ipc_flood_probe(struct auxiliary_device *auxdev,
        priv->dfs_root = debugfs_create_dir(dev_name(dev), debugfs_root);
        if (!IS_ERR_OR_NULL(priv->dfs_root)) {
                /* create read-write ipc_flood_count debugfs entry */
-               debugfs_create_file(DEBUGFS_IPC_FLOOD_COUNT, 0644, priv->dfs_root,
-                                   cdev, &sof_ipc_flood_fops);
+               debugfs_create_file_aux_num(DEBUGFS_IPC_FLOOD_COUNT, 0644,
+                                   priv->dfs_root, cdev, 0, &sof_ipc_flood_fops);
 
                /* create read-write ipc_flood_duration_ms debugfs entry */
-               debugfs_create_file(DEBUGFS_IPC_FLOOD_DURATION, 0644,
-                                   priv->dfs_root, cdev, &sof_ipc_flood_fops);
+               debugfs_create_file_aux_num(DEBUGFS_IPC_FLOOD_DURATION, 0644,
+                                   priv->dfs_root, cdev, 1, &sof_ipc_flood_fops);
 
                if (auxdev->id == 0) {
                        /*