• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /netgear-R7000-V1.0.7.12_1.2.5/components/opensource/linux/linux-2.6.36/drivers/misc/iwmc3200top/
1/*
2 * iwmc3200top - Intel Wireless MultiCom 3200 Top Driver
3 * drivers/misc/iwmc3200top/debufs.c
4 *
5 * Copyright (C) 2009 Intel Corporation. All rights reserved.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License version
9 * 2 as published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 * 02110-1301, USA.
20 *
21 *
22 * Author Name: Maxim Grabarnik <maxim.grabarnink@intel.com>
23 *  -
24 *
25 */
26
27#include <linux/kernel.h>
28#include <linux/slab.h>
29#include <linux/string.h>
30#include <linux/ctype.h>
31#include <linux/mmc/sdio_func.h>
32#include <linux/mmc/sdio.h>
33#include <linux/debugfs.h>
34
35#include "iwmc3200top.h"
36#include "fw-msg.h"
37#include "log.h"
38#include "debugfs.h"
39
40
41
42/*      Constants definition        */
43#define HEXADECIMAL_RADIX	16
44
45/*      Functions definition        */
46
47
48#define DEBUGFS_ADD(name, parent) do {					\
49	dbgfs->dbgfs_##parent##_files.file_##name =			\
50	debugfs_create_file(#name, 0644, dbgfs->dir_##parent, priv,	\
51				&iwmct_dbgfs_##name##_ops);		\
52} while (0)
53
54#define DEBUGFS_RM(name)  do {		\
55	debugfs_remove(name);		\
56	name = NULL;			\
57} while (0)
58
59#define DEBUGFS_READ_FUNC(name)						\
60ssize_t iwmct_dbgfs_##name##_read(struct file *file,			\
61				  char __user *user_buf,		\
62				  size_t count, loff_t *ppos);
63
64#define DEBUGFS_WRITE_FUNC(name)					\
65ssize_t iwmct_dbgfs_##name##_write(struct file *file,			\
66				   const char __user *user_buf,		\
67				   size_t count, loff_t *ppos);
68
69#define DEBUGFS_READ_FILE_OPS(name)					\
70	DEBUGFS_READ_FUNC(name)						\
71	static const struct file_operations iwmct_dbgfs_##name##_ops = {  \
72		.read = iwmct_dbgfs_##name##_read,			\
73		.open = iwmct_dbgfs_open_file_generic,			\
74	};
75
76#define DEBUGFS_WRITE_FILE_OPS(name)					\
77	DEBUGFS_WRITE_FUNC(name)					\
78	static const struct file_operations iwmct_dbgfs_##name##_ops = {  \
79		.write = iwmct_dbgfs_##name##_write,			\
80		.open = iwmct_dbgfs_open_file_generic,			\
81	};
82
83#define DEBUGFS_READ_WRITE_FILE_OPS(name)				\
84	DEBUGFS_READ_FUNC(name)						\
85	DEBUGFS_WRITE_FUNC(name)					\
86	static const struct file_operations iwmct_dbgfs_##name##_ops = {\
87		.write = iwmct_dbgfs_##name##_write,			\
88		.read = iwmct_dbgfs_##name##_read,			\
89		.open = iwmct_dbgfs_open_file_generic,			\
90	};
91
92
93/*      Debugfs file ops definitions        */
94
95/*
96 * Create the debugfs files and directories
97 *
98 */
99void iwmct_dbgfs_register(struct iwmct_priv *priv, const char *name)
100{
101	struct iwmct_debugfs *dbgfs;
102
103	dbgfs = kzalloc(sizeof(struct iwmct_debugfs), GFP_KERNEL);
104	if (!dbgfs) {
105		LOG_ERROR(priv, DEBUGFS, "failed to allocate %zd bytes\n",
106					sizeof(struct iwmct_debugfs));
107		return;
108	}
109
110	priv->dbgfs = dbgfs;
111	dbgfs->name = name;
112	dbgfs->dir_drv = debugfs_create_dir(name, NULL);
113	if (!dbgfs->dir_drv) {
114		LOG_ERROR(priv, DEBUGFS, "failed to create debugfs dir\n");
115		return;
116	}
117
118	return;
119}
120
121/**
122 * Remove the debugfs files and directories
123 *
124 */
125void iwmct_dbgfs_unregister(struct iwmct_debugfs *dbgfs)
126{
127	if (!dbgfs)
128		return;
129
130	DEBUGFS_RM(dbgfs->dir_drv);
131	kfree(dbgfs);
132	dbgfs = NULL;
133}
134