Skip to content

Commit 1eb8700

Browse files
Al Virogregkh
authored andcommitted
netdevsim: don't embed file_operations into your structs
Just use debugfs_get_aux() instead of debugfs_real_fops(). Signed-off-by: Al Viro <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 231e9f0 commit 1eb8700

File tree

1 file changed

+13
-16
lines changed

1 file changed

+13
-16
lines changed

drivers/net/netdevsim/hwstats.c

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,6 @@ enum nsim_dev_hwstats_do {
331331
};
332332

333333
struct nsim_dev_hwstats_fops {
334-
const struct file_operations fops;
335334
enum nsim_dev_hwstats_do action;
336335
enum netdev_offload_xstats_type type;
337336
};
@@ -342,13 +341,12 @@ nsim_dev_hwstats_do_write(struct file *file,
342341
size_t count, loff_t *ppos)
343342
{
344343
struct nsim_dev_hwstats *hwstats = file->private_data;
345-
struct nsim_dev_hwstats_fops *hwsfops;
344+
const struct nsim_dev_hwstats_fops *hwsfops;
346345
struct list_head *hwsdev_list;
347346
int ifindex;
348347
int err;
349348

350-
hwsfops = container_of(debugfs_real_fops(file),
351-
struct nsim_dev_hwstats_fops, fops);
349+
hwsfops = debugfs_get_aux(file);
352350

353351
err = kstrtoint_from_user(data, count, 0, &ifindex);
354352
if (err)
@@ -381,14 +379,13 @@ nsim_dev_hwstats_do_write(struct file *file,
381379
return count;
382380
}
383381

382+
static struct debugfs_short_fops debugfs_ops = {
383+
.write = nsim_dev_hwstats_do_write,
384+
.llseek = generic_file_llseek,
385+
};
386+
384387
#define NSIM_DEV_HWSTATS_FOPS(ACTION, TYPE) \
385388
{ \
386-
.fops = { \
387-
.open = simple_open, \
388-
.write = nsim_dev_hwstats_do_write, \
389-
.llseek = generic_file_llseek, \
390-
.owner = THIS_MODULE, \
391-
}, \
392389
.action = ACTION, \
393390
.type = TYPE, \
394391
}
@@ -433,12 +430,12 @@ int nsim_dev_hwstats_init(struct nsim_dev *nsim_dev)
433430
goto err_remove_hwstats_recursive;
434431
}
435432

436-
debugfs_create_file("enable_ifindex", 0200, hwstats->l3_ddir, hwstats,
437-
&nsim_dev_hwstats_l3_enable_fops.fops);
438-
debugfs_create_file("disable_ifindex", 0200, hwstats->l3_ddir, hwstats,
439-
&nsim_dev_hwstats_l3_disable_fops.fops);
440-
debugfs_create_file("fail_next_enable", 0200, hwstats->l3_ddir, hwstats,
441-
&nsim_dev_hwstats_l3_fail_fops.fops);
433+
debugfs_create_file_aux("enable_ifindex", 0200, hwstats->l3_ddir, hwstats,
434+
&nsim_dev_hwstats_l3_enable_fops, &debugfs_ops);
435+
debugfs_create_file_aux("disable_ifindex", 0200, hwstats->l3_ddir, hwstats,
436+
&nsim_dev_hwstats_l3_disable_fops, &debugfs_ops);
437+
debugfs_create_file_aux("fail_next_enable", 0200, hwstats->l3_ddir, hwstats,
438+
&nsim_dev_hwstats_l3_fail_fops, &debugfs_ops);
442439

443440
INIT_DELAYED_WORK(&hwstats->traffic_dw,
444441
&nsim_dev_hwstats_traffic_work);

0 commit comments

Comments
 (0)