staging: lustre: remove top level ccflags variable
[deliverable/linux.git] / drivers / staging / lustre / include / linux / libcfs / params_tree.h
CommitLineData
d7e09d03
PT
1/*
2 * GPL HEADER START
3 *
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
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 only,
8 * as published by the Free Software Foundation.
9 *
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 version 2 for more details (a copy is included
14 * in the LICENSE file that accompanied this code).
15 *
16 * You should have received a copy of the GNU General Public License
17 * version 2 along with this program; If not, see
18 * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
19 *
20 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
21 * CA 95054 USA or visit www.sun.com if you need additional information or
22 * have any questions.
23 *
24 * GPL HEADER END
25 */
26/*
27 * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
28 * Use is subject to license terms.
29 *
30 * Copyright (c) 2012, Intel Corporation.
31 */
32/*
33 * This file is part of Lustre, http://www.lustre.org/
34 * Lustre is a trademark of Sun Microsystems, Inc.
35 *
36 * API and structure definitions for params_tree.
37 *
38 * Author: LiuYing <emoly.liu@oracle.com>
39 */
40#ifndef __PARAMS_TREE_H__
41#define __PARAMS_TREE_H__
42
9fdaf8c0 43#include "libcfs.h"
d7e09d03
PT
44
45#undef LPROCFS
46#if defined(CONFIG_PROC_FS)
47# define LPROCFS
48#endif
49
50#ifdef LPROCFS
51typedef struct file cfs_param_file_t;
52typedef struct inode cfs_inode_t;
53typedef struct proc_inode cfs_proc_inode_t;
54typedef struct seq_file cfs_seq_file_t;
55typedef struct seq_operations cfs_seq_ops_t;
56typedef struct file_operations cfs_param_file_ops_t;
d7e09d03
PT
57typedef struct proc_dir_entry cfs_param_dentry_t;
58typedef struct poll_table_struct cfs_poll_table_t;
59#define CFS_PARAM_MODULE THIS_MODULE
d7e09d03
PT
60#define cfs_file_private(file) (file->private_data)
61#define cfs_dentry_data(dentry) (dentry->data)
62#define cfs_proc_inode_pde(proc_inode) (proc_inode->pde)
63#define cfs_proc_inode(proc_inode) (proc_inode->vfs_inode)
64#define cfs_seq_read_common seq_read
65#define cfs_seq_lseek_common seq_lseek
66#define cfs_seq_private(seq) (seq->private)
67#define cfs_seq_printf(seq, format, ...) seq_printf(seq, format, \
68 ## __VA_ARGS__)
69#define cfs_seq_release(inode, file) seq_release(inode, file)
70#define cfs_seq_puts(seq, s) seq_puts(seq, s)
71#define cfs_seq_putc(seq, s) seq_putc(seq, s)
72#define cfs_seq_read(file, buf, count, ppos, rc) (rc = seq_read(file, buf, \
73 count, ppos))
74#define cfs_seq_open(file, ops, rc) (rc = seq_open(file, ops))
75
d7e09d03
PT
76#else /* !LPROCFS */
77
78typedef struct cfs_params_file {
79 void *param_private;
80 loff_t param_pos;
81 unsigned int param_flags;
82} cfs_param_file_t;
83
84typedef struct cfs_param_inode {
85 void *param_private;
86} cfs_inode_t;
87
88typedef struct cfs_param_dentry {
89 void *param_data;
90} cfs_param_dentry_t;
91
92typedef struct cfs_proc_inode {
93 cfs_param_dentry_t *param_pde;
94 cfs_inode_t param_inode;
95} cfs_proc_inode_t;
96
97struct cfs_seq_operations;
98typedef struct cfs_seq_file {
99 char *buf;
100 size_t size;
101 size_t from;
102 size_t count;
103 loff_t index;
104 loff_t version;
105 struct mutex lock;
106 struct cfs_seq_operations *op;
107 void *private;
108} cfs_seq_file_t;
109
110typedef struct cfs_seq_operations {
111 void *(*start) (cfs_seq_file_t *m, loff_t *pos);
112 void (*stop) (cfs_seq_file_t *m, void *v);
113 void *(*next) (cfs_seq_file_t *m, void *v, loff_t *pos);
114 int (*show) (cfs_seq_file_t *m, void *v);
115} cfs_seq_ops_t;
116
d7e09d03
PT
117typedef void *cfs_poll_table_t;
118
119typedef struct cfs_param_file_ops {
c34d9cd8 120 struct module *owner;
d7e09d03
PT
121 int (*open) (cfs_inode_t *, struct file *);
122 loff_t (*llseek)(struct file *, loff_t, int);
123 int (*release) (cfs_inode_t *, cfs_param_file_t *);
124 unsigned int (*poll) (struct file *, cfs_poll_table_t *);
125 ssize_t (*write) (struct file *, const char *, size_t, loff_t *);
126 ssize_t (*read)(struct file *, char *, size_t, loff_t *);
127} cfs_param_file_ops_t;
128typedef cfs_param_file_ops_t *cfs_lproc_filep_t;
129
130static inline cfs_proc_inode_t *FAKE_PROC_I(const cfs_inode_t *inode)
131{
132 return container_of(inode, cfs_proc_inode_t, param_inode);
133}
134
d7e09d03 135#define CFS_PARAM_MODULE NULL
d7e09d03
PT
136#define cfs_file_private(file) (file->param_private)
137#define cfs_dentry_data(dentry) (dentry->param_data)
138#define cfs_proc_inode(proc_inode) (proc_inode->param_inode)
139#define cfs_proc_inode_pde(proc_inode) (proc_inode->param_pde)
140#define cfs_seq_read_common NULL
141#define cfs_seq_lseek_common NULL
142#define cfs_seq_private(seq) (seq->private)
143#define cfs_seq_read(file, buf, count, ppos, rc) do {} while(0)
144#define cfs_seq_open(file, ops, rc) \
145do { \
146 cfs_seq_file_t *p = cfs_file_private(file); \
147 if (!p) { \
148 LIBCFS_ALLOC(p, sizeof(*p)); \
149 if (!p) { \
150 rc = -ENOMEM; \
151 break; \
152 } \
153 cfs_file_private(file) = p; \
154 } \
155 memset(p, 0, sizeof(*p)); \
156 p->op = ops; \
157 rc = 0; \
158} while(0)
159
d7e09d03
PT
160#endif /* LPROCFS */
161
162/* XXX: params_tree APIs */
163
164#endif /* __PARAMS_TREE_H__ */
This page took 0.14207 seconds and 5 git commands to generate.