| .. | .. |
|---|
| 113 | 113 | void usnic_debugfs_init(void) |
|---|
| 114 | 114 | { |
|---|
| 115 | 115 | debugfs_root = debugfs_create_dir(DRV_NAME, NULL); |
|---|
| 116 | | - if (IS_ERR(debugfs_root)) { |
|---|
| 117 | | - usnic_err("Failed to create debugfs root dir, check if debugfs is enabled in kernel configuration\n"); |
|---|
| 118 | | - goto out_clear_root; |
|---|
| 119 | | - } |
|---|
| 120 | 116 | |
|---|
| 121 | 117 | flows_dentry = debugfs_create_dir("flows", debugfs_root); |
|---|
| 122 | | - if (IS_ERR_OR_NULL(flows_dentry)) { |
|---|
| 123 | | - usnic_err("Failed to create debugfs flow dir with err %ld\n", |
|---|
| 124 | | - PTR_ERR(flows_dentry)); |
|---|
| 125 | | - goto out_free_root; |
|---|
| 126 | | - } |
|---|
| 127 | 118 | |
|---|
| 128 | 119 | debugfs_create_file("build-info", S_IRUGO, debugfs_root, |
|---|
| 129 | 120 | NULL, &usnic_debugfs_buildinfo_ops); |
|---|
| 130 | | - return; |
|---|
| 131 | | - |
|---|
| 132 | | -out_free_root: |
|---|
| 133 | | - debugfs_remove_recursive(debugfs_root); |
|---|
| 134 | | -out_clear_root: |
|---|
| 135 | | - debugfs_root = NULL; |
|---|
| 136 | 121 | } |
|---|
| 137 | 122 | |
|---|
| 138 | 123 | void usnic_debugfs_exit(void) |
|---|
| 139 | 124 | { |
|---|
| 140 | | - if (!debugfs_root) |
|---|
| 141 | | - return; |
|---|
| 142 | | - |
|---|
| 143 | 125 | debugfs_remove_recursive(debugfs_root); |
|---|
| 144 | 126 | debugfs_root = NULL; |
|---|
| 145 | 127 | } |
|---|
| 146 | 128 | |
|---|
| 147 | 129 | void usnic_debugfs_flow_add(struct usnic_ib_qp_grp_flow *qp_flow) |
|---|
| 148 | 130 | { |
|---|
| 149 | | - if (IS_ERR_OR_NULL(flows_dentry)) |
|---|
| 150 | | - return; |
|---|
| 151 | | - |
|---|
| 152 | 131 | scnprintf(qp_flow->dentry_name, sizeof(qp_flow->dentry_name), |
|---|
| 153 | 132 | "%u", qp_flow->flow->flow_id); |
|---|
| 154 | 133 | qp_flow->dbgfs_dentry = debugfs_create_file(qp_flow->dentry_name, |
|---|
| .. | .. |
|---|
| 156 | 135 | flows_dentry, |
|---|
| 157 | 136 | qp_flow, |
|---|
| 158 | 137 | &flowinfo_ops); |
|---|
| 159 | | - if (IS_ERR_OR_NULL(qp_flow->dbgfs_dentry)) { |
|---|
| 160 | | - usnic_err("Failed to create dbg fs entry for flow %u with error %ld\n", |
|---|
| 161 | | - qp_flow->flow->flow_id, |
|---|
| 162 | | - PTR_ERR(qp_flow->dbgfs_dentry)); |
|---|
| 163 | | - } |
|---|
| 164 | 138 | } |
|---|
| 165 | 139 | |
|---|
| 166 | 140 | void usnic_debugfs_flow_remove(struct usnic_ib_qp_grp_flow *qp_flow) |
|---|
| 167 | 141 | { |
|---|
| 168 | | - if (!IS_ERR_OR_NULL(qp_flow->dbgfs_dentry)) |
|---|
| 169 | | - debugfs_remove(qp_flow->dbgfs_dentry); |
|---|
| 142 | + debugfs_remove(qp_flow->dbgfs_dentry); |
|---|
| 170 | 143 | } |
|---|