aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/iommu/omap-iommu-debug.c48
1 files changed, 2 insertions, 46 deletions
diff --git a/drivers/iommu/omap-iommu-debug.c b/drivers/iommu/omap-iommu-debug.c
index a520438182db..28de657e38c0 100644
--- a/drivers/iommu/omap-iommu-debug.c
+++ b/drivers/iommu/omap-iommu-debug.c
@@ -24,8 +24,6 @@
24#include "omap-iopgtable.h" 24#include "omap-iopgtable.h"
25#include "omap-iommu.h" 25#include "omap-iommu.h"
26 26
27#define MAXCOLUMN 100 /* for short messages */
28
29static DEFINE_MUTEX(iommu_debug_lock); 27static DEFINE_MUTEX(iommu_debug_lock);
30 28
31static struct dentry *iommu_debug_root; 29static struct dentry *iommu_debug_root;
@@ -82,39 +80,6 @@ static ssize_t debug_read_tlb(struct file *file, char __user *userbuf,
82 return bytes; 80 return bytes;
83} 81}
84 82
85static ssize_t debug_write_pagetable(struct file *file,
86 const char __user *userbuf, size_t count, loff_t *ppos)
87{
88 struct iotlb_entry e;
89 struct cr_regs cr;
90 int err;
91 struct device *dev = file->private_data;
92 struct omap_iommu *obj = dev_to_omap_iommu(dev);
93 char buf[MAXCOLUMN], *p = buf;
94
95 count = min(count, sizeof(buf));
96
97 mutex_lock(&iommu_debug_lock);
98 if (copy_from_user(p, userbuf, count)) {
99 mutex_unlock(&iommu_debug_lock);
100 return -EFAULT;
101 }
102
103 sscanf(p, "%x %x", &cr.cam, &cr.ram);
104 if (!cr.cam || !cr.ram) {
105 mutex_unlock(&iommu_debug_lock);
106 return -EINVAL;
107 }
108
109 omap_iotlb_cr_to_e(&cr, &e);
110 err = omap_iopgtable_store_entry(obj, &e);
111 if (err)
112 dev_err(obj->dev, "%s: fail to store cr\n", __func__);
113
114 mutex_unlock(&iommu_debug_lock);
115 return count;
116}
117
118#define dump_ioptable_entry_one(lv, da, val) \ 83#define dump_ioptable_entry_one(lv, da, val) \
119 ({ \ 84 ({ \
120 int __err = 0; \ 85 int __err = 0; \
@@ -202,14 +167,6 @@ static ssize_t debug_read_pagetable(struct file *file, char __user *userbuf,
202 return bytes; 167 return bytes;
203} 168}
204 169
205#define DEBUG_FOPS(name) \
206 static const struct file_operations debug_##name##_fops = { \
207 .open = simple_open, \
208 .read = debug_read_##name, \
209 .write = debug_write_##name, \
210 .llseek = generic_file_llseek, \
211 };
212
213#define DEBUG_FOPS_RO(name) \ 170#define DEBUG_FOPS_RO(name) \
214 static const struct file_operations debug_##name##_fops = { \ 171 static const struct file_operations debug_##name##_fops = { \
215 .open = simple_open, \ 172 .open = simple_open, \
@@ -219,7 +176,7 @@ static ssize_t debug_read_pagetable(struct file *file, char __user *userbuf,
219 176
220DEBUG_FOPS_RO(regs); 177DEBUG_FOPS_RO(regs);
221DEBUG_FOPS_RO(tlb); 178DEBUG_FOPS_RO(tlb);
222DEBUG_FOPS(pagetable); 179DEBUG_FOPS_RO(pagetable);
223 180
224#define __DEBUG_ADD_FILE(attr, mode) \ 181#define __DEBUG_ADD_FILE(attr, mode) \
225 { \ 182 { \
@@ -230,7 +187,6 @@ DEBUG_FOPS(pagetable);
230 return -ENOMEM; \ 187 return -ENOMEM; \
231 } 188 }
232 189
233#define DEBUG_ADD_FILE(name) __DEBUG_ADD_FILE(name, 0600)
234#define DEBUG_ADD_FILE_RO(name) __DEBUG_ADD_FILE(name, 0400) 190#define DEBUG_ADD_FILE_RO(name) __DEBUG_ADD_FILE(name, 0400)
235 191
236static int iommu_debug_register(struct device *dev, void *data) 192static int iommu_debug_register(struct device *dev, void *data)
@@ -263,7 +219,7 @@ static int iommu_debug_register(struct device *dev, void *data)
263 219
264 DEBUG_ADD_FILE_RO(regs); 220 DEBUG_ADD_FILE_RO(regs);
265 DEBUG_ADD_FILE_RO(tlb); 221 DEBUG_ADD_FILE_RO(tlb);
266 DEBUG_ADD_FILE(pagetable); 222 DEBUG_ADD_FILE_RO(pagetable);
267 223
268 return 0; 224 return 0;
269 225