| 1 |
/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ |
| 2 |
/* |
| 3 |
* Copyright(c) 2015, 2016, 2018 Intel Corporation. |
| 4 |
*/ |
| 5 |
|
| 6 |
#ifndef _HFI1_DEBUGFS_H |
| 7 |
#define _HFI1_DEBUGFS_H |
| 8 |
|
| 9 |
struct hfi1_ibdev; |
| 10 |
|
| 11 |
#define DEBUGFS_SEQ_FILE_OPS(name) \ |
| 12 |
static const struct seq_operations _##name##_seq_ops = { \ |
| 13 |
.start = _##name##_seq_start, \ |
| 14 |
.next = _##name##_seq_next, \ |
| 15 |
.stop = _##name##_seq_stop, \ |
| 16 |
.show = _##name##_seq_show \ |
| 17 |
} |
| 18 |
|
| 19 |
#define DEBUGFS_SEQ_FILE_OPEN(name) \ |
| 20 |
static int _##name##_open(struct inode *inode, struct file *s) \ |
| 21 |
{ \ |
| 22 |
struct seq_file *seq; \ |
| 23 |
int ret; \ |
| 24 |
ret = seq_open(s, &_##name##_seq_ops); \ |
| 25 |
if (ret) \ |
| 26 |
return ret; \ |
| 27 |
seq = s->private_data; \ |
| 28 |
seq->private = inode->i_private; \ |
| 29 |
return 0; \ |
| 30 |
} |
| 31 |
|
| 32 |
#define DEBUGFS_FILE_OPS(name) \ |
| 33 |
static const struct file_operations _##name##_file_ops = { \ |
| 34 |
.owner = THIS_MODULE, \ |
| 35 |
.open = _##name##_open, \ |
| 36 |
.read = seq_read, \ |
| 37 |
.llseek = seq_lseek, \ |
| 38 |
.release = seq_release \ |
| 39 |
} |
| 40 |
|
| 41 |
#ifdef CONFIG_DEBUG_FS |
| 42 |
void hfi1_dbg_ibdev_init(struct hfi1_ibdev *ibd); |
| 43 |
void hfi1_dbg_ibdev_exit(struct hfi1_ibdev *ibd); |
| 44 |
void hfi1_dbg_init(void); |
| 45 |
void hfi1_dbg_exit(void); |
| 46 |
|
| 47 |
#else |
| 48 |
static inline void hfi1_dbg_ibdev_init(struct hfi1_ibdev *ibd) |
| 49 |
{ |
| 50 |
} |
| 51 |
|
| 52 |
static inline void hfi1_dbg_ibdev_exit(struct hfi1_ibdev *ibd) |
| 53 |
{ |
| 54 |
} |
| 55 |
|
| 56 |
static inline void hfi1_dbg_init(void) |
| 57 |
{ |
| 58 |
} |
| 59 |
|
| 60 |
static inline void hfi1_dbg_exit(void) |
| 61 |
{ |
| 62 |
} |
| 63 |
#endif |
| 64 |
|
| 65 |
#endif /* _HFI1_DEBUGFS_H */ |