35 #include <linux/module.h>
44 #define QIBFS_MAGIC 0x726a77
48 #define private2dd(file) ((file)->f_dentry->d_inode->i_private)
96 error = qibfs_mknod(parent->
d_inode, *dentry,
99 error = PTR_ERR(*dentry);
106 size_t count, loff_t *ppos)
119 static const char qib_statnames[] =
133 size_t count, loff_t *ppos)
136 sizeof qib_statnames - 1);
146 size_t count, loff_t *ppos)
157 static ssize_t dev_names_read(
struct file *file,
char __user *buf,
158 size_t count, loff_t *ppos)
179 static ssize_t portnames_read(
struct file *file,
char __user *buf,
180 size_t count, loff_t *ppos)
191 static ssize_t portcntrs_1_read(
struct file *file,
char __user *buf,
192 size_t count, loff_t *ppos)
203 static ssize_t portcntrs_2_read(
struct file *file,
char __user *buf,
204 size_t count, loff_t *ppos)
223 static ssize_t qsfp_1_read(
struct file *file,
char __user *buf,
224 size_t count, loff_t *ppos)
244 static ssize_t qsfp_2_read(
struct file *file,
char __user *buf,
245 size_t count, loff_t *ppos)
270 static ssize_t flash_read(
struct file *file,
char __user *buf,
271 size_t count, loff_t *ppos)
290 if (count >
sizeof(
struct qib_flash) - pos)
322 size_t count, loff_t *ppos)
386 pr_err(
"create_file(%s) failed: %d\n", unit, ret);
394 pr_err(
"create_file(%s/counters) failed: %d\n",
401 pr_err(
"create_file(%s/counter_names) failed: %d\n",
405 ret = create_file(
"portcounter_names",
S_IFREG|
S_IRUGO, dir, &tmp,
406 &portcntr_ops[0], dd);
408 pr_err(
"create_file(%s/%s) failed: %d\n",
409 unit,
"portcounter_names", ret);
415 sprintf(fname,
"port%dcounters", i);
418 &portcntr_ops[i], dd);
420 pr_err(
"create_file(%s/%s) failed: %d\n",
428 &qsfp_ops[i - 1], dd);
430 pr_err(
"create_file(%s/%s) failed: %d\n",
439 pr_err(
"create_file(%s/flash) failed: %d\n",
445 static int remove_file(
struct dentry *parent,
char *name)
458 if (!(d_unhashed(tmp) && tmp->
d_inode)) {
461 spin_unlock(&tmp->
d_lock);
464 spin_unlock(&tmp->
d_lock);
476 static int remove_device_files(
struct super_block *sb,
479 struct dentry *dir, *
root;
490 pr_err(
"Lookup of %s failed\n", unit);
494 remove_file(dir,
"counters");
495 remove_file(dir,
"counter_names");
496 remove_file(dir,
"portcounter_names");
500 sprintf(fname,
"port%dcounters", i + 1);
501 remove_file(dir, fname);
503 sprintf(fname,
"qsfp%d", i + 1);
504 remove_file(dir, fname);
507 remove_file(dir,
"flash");
522 static int qibfs_fill_super(
struct super_block *sb,
void *data,
int silent)
529 [2] = {
"driver_stats", &driver_ops[0],
S_IRUGO},
530 [3] = {
"driver_stats_names", &driver_ops[1],
S_IRUGO},
536 pr_err(
"simple_fill_super failed: %d\n", ret);
543 spin_unlock_irqrestore(&qib_devs_lock, flags);
544 ret = add_cntr_files(sb, dd);
550 spin_unlock_irqrestore(&qib_devs_lock, flags);
556 static struct dentry *qibfs_mount(
struct file_system_type *fs_type,
int flags,
557 const char *dev_name,
void *data)
560 ret =
mount_single(fs_type, flags, data, qibfs_fill_super);
562 qib_super = ret->
d_sb;
584 if (qib_super ==
NULL)
587 ret = add_cntr_files(qib_super, dd);
596 ret = remove_device_files(qib_super, dd);
604 .mount = qibfs_mount,
605 .kill_sb = qibfs_kill_super,