Merge branch 'r6040-next'
[linux/fpc-iii.git] / drivers / misc / mic / card / mic_debugfs.c
blob421b3d7911df8dc478cea0f8351f8a22b2e28bb6
1 /*
2 * Intel MIC Platform Software Stack (MPSS)
4 * Copyright(c) 2013 Intel Corporation.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License, version 2, as
8 * published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * The full GNU General Public License is included in this distribution in
16 * the file called "COPYING".
18 * Disclaimer: The codes contained in these modules may be specific to
19 * the Intel Software Development Platform codenamed: Knights Ferry, and
20 * the Intel product codenamed: Knights Corner, and are not backward
21 * compatible with other Intel products. Additionally, Intel will NOT
22 * support the codes or instruction set in future products.
24 * Intel MIC Card driver.
27 #include <linux/debugfs.h>
28 #include <linux/delay.h>
29 #include <linux/seq_file.h>
30 #include <linux/interrupt.h>
31 #include <linux/device.h>
33 #include "../common/mic_dev.h"
34 #include "mic_device.h"
36 /* Debugfs parent dir */
37 static struct dentry *mic_dbg;
39 /**
40 * mic_intr_test - Send interrupts to host.
42 static int mic_intr_test(struct seq_file *s, void *unused)
44 struct mic_driver *mdrv = s->private;
45 struct mic_device *mdev = &mdrv->mdev;
47 mic_send_intr(mdev, 0);
48 msleep(1000);
49 mic_send_intr(mdev, 1);
50 msleep(1000);
51 mic_send_intr(mdev, 2);
52 msleep(1000);
53 mic_send_intr(mdev, 3);
54 msleep(1000);
56 return 0;
59 static int mic_intr_test_open(struct inode *inode, struct file *file)
61 return single_open(file, mic_intr_test, inode->i_private);
64 static int mic_intr_test_release(struct inode *inode, struct file *file)
66 return single_release(inode, file);
69 static const struct file_operations intr_test_ops = {
70 .owner = THIS_MODULE,
71 .open = mic_intr_test_open,
72 .read = seq_read,
73 .llseek = seq_lseek,
74 .release = mic_intr_test_release
77 /**
78 * mic_create_card_debug_dir - Initialize MIC debugfs entries.
80 void __init mic_create_card_debug_dir(struct mic_driver *mdrv)
82 struct dentry *d;
84 if (!mic_dbg)
85 return;
87 mdrv->dbg_dir = debugfs_create_dir(mdrv->name, mic_dbg);
88 if (!mdrv->dbg_dir) {
89 dev_err(mdrv->dev, "Cant create dbg_dir %s\n", mdrv->name);
90 return;
93 d = debugfs_create_file("intr_test", 0444, mdrv->dbg_dir,
94 mdrv, &intr_test_ops);
96 if (!d) {
97 dev_err(mdrv->dev,
98 "Cant create dbg intr_test %s\n", mdrv->name);
99 return;
104 * mic_delete_card_debug_dir - Uninitialize MIC debugfs entries.
106 void mic_delete_card_debug_dir(struct mic_driver *mdrv)
108 if (!mdrv->dbg_dir)
109 return;
111 debugfs_remove_recursive(mdrv->dbg_dir);
115 * mic_init_card_debugfs - Initialize global debugfs entry.
117 void __init mic_init_card_debugfs(void)
119 mic_dbg = debugfs_create_dir(KBUILD_MODNAME, NULL);
120 if (!mic_dbg)
121 pr_err("can't create debugfs dir\n");
125 * mic_exit_card_debugfs - Uninitialize global debugfs entry
127 void mic_exit_card_debugfs(void)
129 debugfs_remove(mic_dbg);