| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Qualcomm Technologies HIDMA debug file |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * 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. |
|---|
| 14 | 6 | */ |
|---|
| 15 | 7 | |
|---|
| 16 | 8 | #include <linux/debugfs.h> |
|---|
| .. | .. |
|---|
| 85 | 77 | } |
|---|
| 86 | 78 | |
|---|
| 87 | 79 | /* |
|---|
| 88 | | - * hidma_chan_stats: display HIDMA channel statistics |
|---|
| 80 | + * hidma_chan_show: display HIDMA channel statistics |
|---|
| 89 | 81 | * |
|---|
| 90 | 82 | * Display the statistics for the current HIDMA virtual channel device. |
|---|
| 91 | 83 | */ |
|---|
| 92 | | -static int hidma_chan_stats(struct seq_file *s, void *unused) |
|---|
| 84 | +static int hidma_chan_show(struct seq_file *s, void *unused) |
|---|
| 93 | 85 | { |
|---|
| 94 | 86 | struct hidma_chan *mchan = s->private; |
|---|
| 95 | 87 | struct hidma_desc *mdesc; |
|---|
| .. | .. |
|---|
| 117 | 109 | } |
|---|
| 118 | 110 | |
|---|
| 119 | 111 | /* |
|---|
| 120 | | - * hidma_dma_info: display HIDMA device info |
|---|
| 112 | + * hidma_dma_show: display HIDMA device info |
|---|
| 121 | 113 | * |
|---|
| 122 | 114 | * Display the info for the current HIDMA device. |
|---|
| 123 | 115 | */ |
|---|
| 124 | | -static int hidma_dma_info(struct seq_file *s, void *unused) |
|---|
| 116 | +static int hidma_dma_show(struct seq_file *s, void *unused) |
|---|
| 125 | 117 | { |
|---|
| 126 | 118 | struct hidma_dev *dmadev = s->private; |
|---|
| 127 | 119 | resource_size_t sz; |
|---|
| .. | .. |
|---|
| 138 | 130 | return 0; |
|---|
| 139 | 131 | } |
|---|
| 140 | 132 | |
|---|
| 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); |
|---|
| 164 | 135 | |
|---|
| 165 | 136 | void hidma_debug_uninit(struct hidma_dev *dmadev) |
|---|
| 166 | 137 | { |
|---|
| 167 | 138 | debugfs_remove_recursive(dmadev->debugfs); |
|---|
| 168 | 139 | } |
|---|
| 169 | 140 | |
|---|
| 170 | | -int hidma_debug_init(struct hidma_dev *dmadev) |
|---|
| 141 | +void hidma_debug_init(struct hidma_dev *dmadev) |
|---|
| 171 | 142 | { |
|---|
| 172 | | - int rc = 0; |
|---|
| 173 | 143 | int chidx = 0; |
|---|
| 174 | 144 | struct list_head *position = NULL; |
|---|
| 145 | + struct dentry *dir; |
|---|
| 175 | 146 | |
|---|
| 176 | 147 | dmadev->debugfs = debugfs_create_dir(dev_name(dmadev->ddev.dev), NULL); |
|---|
| 177 | | - if (!dmadev->debugfs) { |
|---|
| 178 | | - rc = -ENODEV; |
|---|
| 179 | | - return rc; |
|---|
| 180 | | - } |
|---|
| 181 | 148 | |
|---|
| 182 | 149 | /* walk through the virtual channel list */ |
|---|
| 183 | 150 | list_for_each(position, &dmadev->ddev.channels) { |
|---|
| .. | .. |
|---|
| 186 | 153 | chan = list_entry(position, struct hidma_chan, |
|---|
| 187 | 154 | chan.device_node); |
|---|
| 188 | 155 | sprintf(chan->dbg_name, "chan%d", chidx); |
|---|
| 189 | | - chan->debugfs = debugfs_create_dir(chan->dbg_name, |
|---|
| 156 | + dir = debugfs_create_dir(chan->dbg_name, |
|---|
| 190 | 157 | 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); |
|---|
| 202 | 160 | chidx++; |
|---|
| 203 | 161 | } |
|---|
| 204 | 162 | |
|---|
| 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); |
|---|
| 217 | 165 | } |
|---|