Skip to content

Commit cf81a75

Browse files
committed
sof-client-ipc-flood-test: don't mess with ->d_name
JIRA: https://issues.redhat.com/browse/RHEL-101627 commit 74e5a20 Author: Al Viro <viro@zeniv.linux.org.uk> Date: Sun Jan 12 08:07:00 2025 +0000 sof-client-ipc-flood-test: don't mess with ->d_name 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> Signed-off-by: Jaroslav Kysela <jkysela@redhat.com>
1 parent 5fd2ef7 commit cf81a75

File tree

1 file changed

+12
-27
lines changed

1 file changed

+12
-27
lines changed

sound/soc/sof/sof-client-ipc-flood-test.c

Lines changed: 12 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,6 @@ static ssize_t sof_ipc_flood_dfs_write(struct file *file, const char __user *buf
158158
unsigned long ipc_duration_ms = 0;
159159
bool flood_duration_test = false;
160160
unsigned long ipc_count = 0;
161-
struct dentry *dentry;
162161
int err;
163162
char *string;
164163
int ret;
@@ -182,14 +181,7 @@ static ssize_t sof_ipc_flood_dfs_write(struct file *file, const char __user *buf
182181
* ipc_duration_ms test floods the DSP for the time specified
183182
* in the debugfs entry.
184183
*/
185-
dentry = file->f_path.dentry;
186-
if (strcmp(dentry->d_name.name, DEBUGFS_IPC_FLOOD_COUNT) &&
187-
strcmp(dentry->d_name.name, DEBUGFS_IPC_FLOOD_DURATION)) {
188-
ret = -EINVAL;
189-
goto out;
190-
}
191-
192-
if (!strcmp(dentry->d_name.name, DEBUGFS_IPC_FLOOD_DURATION))
184+
if (debugfs_get_aux_num(file))
193185
flood_duration_test = true;
194186

195187
/* test completion criterion */
@@ -252,22 +244,15 @@ static ssize_t sof_ipc_flood_dfs_read(struct file *file, char __user *buffer,
252244
struct sof_ipc_flood_priv *priv = cdev->data;
253245
size_t size_ret;
254246

255-
struct dentry *dentry;
247+
if (*ppos)
248+
return 0;
256249

257-
dentry = file->f_path.dentry;
258-
if (!strcmp(dentry->d_name.name, DEBUGFS_IPC_FLOOD_COUNT) ||
259-
!strcmp(dentry->d_name.name, DEBUGFS_IPC_FLOOD_DURATION)) {
260-
if (*ppos)
261-
return 0;
250+
count = min_t(size_t, count, strlen(priv->buf));
251+
size_ret = copy_to_user(buffer, priv->buf, count);
252+
if (size_ret)
253+
return -EFAULT;
262254

263-
count = min_t(size_t, count, strlen(priv->buf));
264-
size_ret = copy_to_user(buffer, priv->buf, count);
265-
if (size_ret)
266-
return -EFAULT;
267-
268-
*ppos += count;
269-
return count;
270-
}
255+
*ppos += count;
271256
return count;
272257
}
273258

@@ -320,12 +305,12 @@ static int sof_ipc_flood_probe(struct auxiliary_device *auxdev,
320305
priv->dfs_root = debugfs_create_dir(dev_name(dev), debugfs_root);
321306
if (!IS_ERR_OR_NULL(priv->dfs_root)) {
322307
/* create read-write ipc_flood_count debugfs entry */
323-
debugfs_create_file(DEBUGFS_IPC_FLOOD_COUNT, 0644, priv->dfs_root,
324-
cdev, &sof_ipc_flood_fops);
308+
debugfs_create_file_aux_num(DEBUGFS_IPC_FLOOD_COUNT, 0644,
309+
priv->dfs_root, cdev, 0, &sof_ipc_flood_fops);
325310

326311
/* create read-write ipc_flood_duration_ms debugfs entry */
327-
debugfs_create_file(DEBUGFS_IPC_FLOOD_DURATION, 0644,
328-
priv->dfs_root, cdev, &sof_ipc_flood_fops);
312+
debugfs_create_file_aux_num(DEBUGFS_IPC_FLOOD_DURATION, 0644,
313+
priv->dfs_root, cdev, 1, &sof_ipc_flood_fops);
329314

330315
if (auxdev->id == 0) {
331316
/*

0 commit comments

Comments
 (0)