forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-04 1543e317f1da31b75942316931e8f491a8920811
kernel/drivers/dma/qcom/hidma_dbg.c
....@@ -1,16 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Qualcomm Technologies HIDMA debug file
34 *
45 * Copyright (c) 2015-2016, The Linux Foundation. All rights reserved.
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 and
8
- * only version 2 as published by the Free Software Foundation.
9
- *
10
- * This program is distributed in the hope that it will be useful,
11
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
- * GNU General Public License for more details.
146 */
157
168 #include <linux/debugfs.h>
....@@ -85,11 +77,11 @@
8577 }
8678
8779 /*
88
- * hidma_chan_stats: display HIDMA channel statistics
80
+ * hidma_chan_show: display HIDMA channel statistics
8981 *
9082 * Display the statistics for the current HIDMA virtual channel device.
9183 */
92
-static int hidma_chan_stats(struct seq_file *s, void *unused)
84
+static int hidma_chan_show(struct seq_file *s, void *unused)
9385 {
9486 struct hidma_chan *mchan = s->private;
9587 struct hidma_desc *mdesc;
....@@ -117,11 +109,11 @@
117109 }
118110
119111 /*
120
- * hidma_dma_info: display HIDMA device info
112
+ * hidma_dma_show: display HIDMA device info
121113 *
122114 * Display the info for the current HIDMA device.
123115 */
124
-static int hidma_dma_info(struct seq_file *s, void *unused)
116
+static int hidma_dma_show(struct seq_file *s, void *unused)
125117 {
126118 struct hidma_dev *dmadev = s->private;
127119 resource_size_t sz;
....@@ -138,46 +130,21 @@
138130 return 0;
139131 }
140132
141
-static int hidma_chan_stats_open(struct inode *inode, struct file *file)
142
-{
143
- return single_open(file, hidma_chan_stats, inode->i_private);
144
-}
145
-
146
-static int hidma_dma_info_open(struct inode *inode, struct file *file)
147
-{
148
- return single_open(file, hidma_dma_info, inode->i_private);
149
-}
150
-
151
-static const struct file_operations hidma_chan_fops = {
152
- .open = hidma_chan_stats_open,
153
- .read = seq_read,
154
- .llseek = seq_lseek,
155
- .release = single_release,
156
-};
157
-
158
-static const struct file_operations hidma_dma_fops = {
159
- .open = hidma_dma_info_open,
160
- .read = seq_read,
161
- .llseek = seq_lseek,
162
- .release = single_release,
163
-};
133
+DEFINE_SHOW_ATTRIBUTE(hidma_chan);
134
+DEFINE_SHOW_ATTRIBUTE(hidma_dma);
164135
165136 void hidma_debug_uninit(struct hidma_dev *dmadev)
166137 {
167138 debugfs_remove_recursive(dmadev->debugfs);
168139 }
169140
170
-int hidma_debug_init(struct hidma_dev *dmadev)
141
+void hidma_debug_init(struct hidma_dev *dmadev)
171142 {
172
- int rc = 0;
173143 int chidx = 0;
174144 struct list_head *position = NULL;
145
+ struct dentry *dir;
175146
176147 dmadev->debugfs = debugfs_create_dir(dev_name(dmadev->ddev.dev), NULL);
177
- if (!dmadev->debugfs) {
178
- rc = -ENODEV;
179
- return rc;
180
- }
181148
182149 /* walk through the virtual channel list */
183150 list_for_each(position, &dmadev->ddev.channels) {
....@@ -186,32 +153,13 @@
186153 chan = list_entry(position, struct hidma_chan,
187154 chan.device_node);
188155 sprintf(chan->dbg_name, "chan%d", chidx);
189
- chan->debugfs = debugfs_create_dir(chan->dbg_name,
156
+ dir = debugfs_create_dir(chan->dbg_name,
190157 dmadev->debugfs);
191
- if (!chan->debugfs) {
192
- rc = -ENOMEM;
193
- goto cleanup;
194
- }
195
- chan->stats = debugfs_create_file("stats", S_IRUGO,
196
- chan->debugfs, chan,
197
- &hidma_chan_fops);
198
- if (!chan->stats) {
199
- rc = -ENOMEM;
200
- goto cleanup;
201
- }
158
+ debugfs_create_file("stats", S_IRUGO, dir, chan,
159
+ &hidma_chan_fops);
202160 chidx++;
203161 }
204162
205
- dmadev->stats = debugfs_create_file("stats", S_IRUGO,
206
- dmadev->debugfs, dmadev,
207
- &hidma_dma_fops);
208
- if (!dmadev->stats) {
209
- rc = -ENOMEM;
210
- goto cleanup;
211
- }
212
-
213
- return 0;
214
-cleanup:
215
- hidma_debug_uninit(dmadev);
216
- return rc;
163
+ debugfs_create_file("stats", S_IRUGO, dmadev->debugfs, dmadev,
164
+ &hidma_dma_fops);
217165 }