aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block/rsxx
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2014-08-19 14:42:04 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2014-10-09 02:39:07 -0400
commit8e3fb059ae7c246ff906c3b988d0de1d66809e84 (patch)
tree913a2c18c0276d3393e48bc3d716dd2f655ea833 /drivers/block/rsxx
parentd88c242623e90c99864317baae1e192bece2af57 (diff)
rsxx debugfs inanity
check with the author of that horror... Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'drivers/block/rsxx')
-rw-r--r--drivers/block/rsxx/core.c81
1 files changed, 16 insertions, 65 deletions
diff --git a/drivers/block/rsxx/core.c b/drivers/block/rsxx/core.c
index 820b4009d5f7..3265ce94d282 100644
--- a/drivers/block/rsxx/core.c
+++ b/drivers/block/rsxx/core.c
@@ -62,12 +62,6 @@ static DEFINE_SPINLOCK(rsxx_ida_lock);
62 62
63/* --------------------Debugfs Setup ------------------- */ 63/* --------------------Debugfs Setup ------------------- */
64 64
65struct rsxx_cram {
66 u32 f_pos;
67 u32 offset;
68 void *i_private;
69};
70
71static int rsxx_attr_pci_regs_show(struct seq_file *m, void *p) 65static int rsxx_attr_pci_regs_show(struct seq_file *m, void *p)
72{ 66{
73 struct rsxx_cardinfo *card = m->private; 67 struct rsxx_cardinfo *card = m->private;
@@ -184,93 +178,50 @@ static int rsxx_attr_pci_regs_open(struct inode *inode, struct file *file)
184static ssize_t rsxx_cram_read(struct file *fp, char __user *ubuf, 178static ssize_t rsxx_cram_read(struct file *fp, char __user *ubuf,
185 size_t cnt, loff_t *ppos) 179 size_t cnt, loff_t *ppos)
186{ 180{
187 struct rsxx_cram *info = fp->private_data; 181 struct rsxx_cardinfo *card = file_inode(fp)->i_private;
188 struct rsxx_cardinfo *card = info->i_private;
189 char *buf; 182 char *buf;
190 int st; 183 ssize_t st;
191 184
192 buf = kzalloc(sizeof(*buf) * cnt, GFP_KERNEL); 185 buf = kzalloc(cnt, GFP_KERNEL);
193 if (!buf) 186 if (!buf)
194 return -ENOMEM; 187 return -ENOMEM;
195 188
196 info->f_pos = (u32)*ppos + info->offset; 189 st = rsxx_creg_read(card, CREG_ADD_CRAM + (u32)*ppos, cnt, buf, 1);
197 190 if (!st)
198 st = rsxx_creg_read(card, CREG_ADD_CRAM + info->f_pos, cnt, buf, 1); 191 st = copy_to_user(ubuf, buf, cnt);
199 if (st) 192 kfree(buf);
200 return st;
201
202 st = copy_to_user(ubuf, buf, cnt);
203 if (st) 193 if (st)
204 return st; 194 return st;
205 195 *ppos += cnt;
206 info->offset += cnt;
207
208 kfree(buf);
209
210 return cnt; 196 return cnt;
211} 197}
212 198
213static ssize_t rsxx_cram_write(struct file *fp, const char __user *ubuf, 199static ssize_t rsxx_cram_write(struct file *fp, const char __user *ubuf,
214 size_t cnt, loff_t *ppos) 200 size_t cnt, loff_t *ppos)
215{ 201{
216 struct rsxx_cram *info = fp->private_data; 202 struct rsxx_cardinfo *card = file_inode(fp)->i_private;
217 struct rsxx_cardinfo *card = info->i_private;
218 char *buf; 203 char *buf;
219 int st; 204 ssize_t st;
220 205
221 buf = kzalloc(sizeof(*buf) * cnt, GFP_KERNEL); 206 buf = kzalloc(cnt, GFP_KERNEL);
222 if (!buf) 207 if (!buf)
223 return -ENOMEM; 208 return -ENOMEM;
224 209
225 st = copy_from_user(buf, ubuf, cnt); 210 st = copy_from_user(buf, ubuf, cnt);
211 if (!st)
212 st = rsxx_creg_write(card, CREG_ADD_CRAM + (u32)*ppos, cnt,
213 buf, 1);
214 kfree(buf);
226 if (st) 215 if (st)
227 return st; 216 return st;
228 217 *ppos += cnt;
229 info->f_pos = (u32)*ppos + info->offset;
230
231 st = rsxx_creg_write(card, CREG_ADD_CRAM + info->f_pos, cnt, buf, 1);
232 if (st)
233 return st;
234
235 info->offset += cnt;
236
237 kfree(buf);
238
239 return cnt; 218 return cnt;
240} 219}
241 220
242static int rsxx_cram_open(struct inode *inode, struct file *file)
243{
244 struct rsxx_cram *info = kzalloc(sizeof(*info), GFP_KERNEL);
245 if (!info)
246 return -ENOMEM;
247
248 info->i_private = inode->i_private;
249 info->f_pos = file->f_pos;
250 file->private_data = info;
251
252 return 0;
253}
254
255static int rsxx_cram_release(struct inode *inode, struct file *file)
256{
257 struct rsxx_cram *info = file->private_data;
258
259 if (!info)
260 return 0;
261
262 kfree(info);
263 file->private_data = NULL;
264
265 return 0;
266}
267
268static const struct file_operations debugfs_cram_fops = { 221static const struct file_operations debugfs_cram_fops = {
269 .owner = THIS_MODULE, 222 .owner = THIS_MODULE,
270 .open = rsxx_cram_open,
271 .read = rsxx_cram_read, 223 .read = rsxx_cram_read,
272 .write = rsxx_cram_write, 224 .write = rsxx_cram_write,
273 .release = rsxx_cram_release,
274}; 225};
275 226
276static const struct file_operations debugfs_stats_fops = { 227static const struct file_operations debugfs_stats_fops = {