aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mfd
diff options
context:
space:
mode:
authorMattias Wallin <mattias.wallin@stericsson.com>2010-11-26 07:06:39 -0500
committerSamuel Ortiz <sameo@linux.intel.com>2011-01-14 06:37:42 -0500
commitd7b9f3220fd97522559316cdd72778f42ac4de04 (patch)
tree8256ad4387ff9c5d592a8b2f8513e98649f0b7d8 /drivers/mfd
parentbaa3f63b88c9138bb923a29a3d5fddc204d1f5e6 (diff)
mfd: Fix ab8500-debug indentation errors
Replace spaces with proper tabs. Signed-off-by: Mattias Wallin <mattias.wallin@stericsson.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers/mfd')
-rw-r--r--drivers/mfd/ab8500-debugfs.c1016
1 files changed, 508 insertions, 508 deletions
diff --git a/drivers/mfd/ab8500-debugfs.c b/drivers/mfd/ab8500-debugfs.c
index 8d1e05a39815..dfdc76e0b96e 100644
--- a/drivers/mfd/ab8500-debugfs.c
+++ b/drivers/mfd/ab8500-debugfs.c
@@ -24,9 +24,9 @@ static u32 debug_address;
24 * @perm: access permissions for the range 24 * @perm: access permissions for the range
25 */ 25 */
26struct ab8500_reg_range { 26struct ab8500_reg_range {
27 u8 first; 27 u8 first;
28 u8 last; 28 u8 last;
29 u8 perm; 29 u8 perm;
30}; 30};
31 31
32/** 32/**
@@ -36,9 +36,9 @@ struct ab8500_reg_range {
36 * @range: the list of register ranges 36 * @range: the list of register ranges
37 */ 37 */
38struct ab8500_i2c_ranges { 38struct ab8500_i2c_ranges {
39 u8 num_ranges; 39 u8 num_ranges;
40 u8 bankid; 40 u8 bankid;
41 const struct ab8500_reg_range *range; 41 const struct ab8500_reg_range *range;
42}; 42};
43 43
44#define AB8500_NAME_STRING "ab8500" 44#define AB8500_NAME_STRING "ab8500"
@@ -47,521 +47,521 @@ struct ab8500_i2c_ranges {
47#define AB8500_REV_REG 0x80 47#define AB8500_REV_REG 0x80
48 48
49static struct ab8500_i2c_ranges debug_ranges[AB8500_NUM_BANKS] = { 49static struct ab8500_i2c_ranges debug_ranges[AB8500_NUM_BANKS] = {
50 [0x0] = { 50 [0x0] = {
51 .num_ranges = 0, 51 .num_ranges = 0,
52 .range = 0, 52 .range = 0,
53 }, 53 },
54 [AB8500_SYS_CTRL1_BLOCK] = { 54 [AB8500_SYS_CTRL1_BLOCK] = {
55 .num_ranges = 3, 55 .num_ranges = 3,
56 .range = (struct ab8500_reg_range[]) { 56 .range = (struct ab8500_reg_range[]) {
57 { 57 {
58 .first = 0x00, 58 .first = 0x00,
59 .last = 0x02, 59 .last = 0x02,
60 }, 60 },
61 { 61 {
62 .first = 0x42, 62 .first = 0x42,
63 .last = 0x42, 63 .last = 0x42,
64 }, 64 },
65 { 65 {
66 .first = 0x80, 66 .first = 0x80,
67 .last = 0x81, 67 .last = 0x81,
68 }, 68 },
69 }, 69 },
70 }, 70 },
71 [AB8500_SYS_CTRL2_BLOCK] = { 71 [AB8500_SYS_CTRL2_BLOCK] = {
72 .num_ranges = 4, 72 .num_ranges = 4,
73 .range = (struct ab8500_reg_range[]) { 73 .range = (struct ab8500_reg_range[]) {
74 { 74 {
75 .first = 0x00, 75 .first = 0x00,
76 .last = 0x0D, 76 .last = 0x0D,
77 }, 77 },
78 { 78 {
79 .first = 0x0F, 79 .first = 0x0F,
80 .last = 0x17, 80 .last = 0x17,
81 }, 81 },
82 { 82 {
83 .first = 0x30, 83 .first = 0x30,
84 .last = 0x30, 84 .last = 0x30,
85 }, 85 },
86 { 86 {
87 .first = 0x32, 87 .first = 0x32,
88 .last = 0x33, 88 .last = 0x33,
89 }, 89 },
90 }, 90 },
91 }, 91 },
92 [AB8500_REGU_CTRL1] = { 92 [AB8500_REGU_CTRL1] = {
93 .num_ranges = 3, 93 .num_ranges = 3,
94 .range = (struct ab8500_reg_range[]) { 94 .range = (struct ab8500_reg_range[]) {
95 { 95 {
96 .first = 0x00, 96 .first = 0x00,
97 .last = 0x00, 97 .last = 0x00,
98 }, 98 },
99 { 99 {
100 .first = 0x03, 100 .first = 0x03,
101 .last = 0x10, 101 .last = 0x10,
102 }, 102 },
103 { 103 {
104 .first = 0x80, 104 .first = 0x80,
105 .last = 0x84, 105 .last = 0x84,
106 }, 106 },
107 }, 107 },
108 }, 108 },
109 [AB8500_REGU_CTRL2] = { 109 [AB8500_REGU_CTRL2] = {
110 .num_ranges = 5, 110 .num_ranges = 5,
111 .range = (struct ab8500_reg_range[]) { 111 .range = (struct ab8500_reg_range[]) {
112 { 112 {
113 .first = 0x00, 113 .first = 0x00,
114 .last = 0x15, 114 .last = 0x15,
115 }, 115 },
116 { 116 {
117 .first = 0x17, 117 .first = 0x17,
118 .last = 0x19, 118 .last = 0x19,
119 }, 119 },
120 { 120 {
121 .first = 0x1B, 121 .first = 0x1B,
122 .last = 0x1D, 122 .last = 0x1D,
123 }, 123 },
124 { 124 {
125 .first = 0x1F, 125 .first = 0x1F,
126 .last = 0x22, 126 .last = 0x22,
127 }, 127 },
128 { 128 {
129 .first = 0x40, 129 .first = 0x40,
130 .last = 0x44, 130 .last = 0x44,
131 }, 131 },
132 /* 0x80-0x8B is SIM registers and should 132 /* 0x80-0x8B is SIM registers and should
133 * not be accessed from here */ 133 * not be accessed from here */
134 }, 134 },
135 }, 135 },
136 [AB8500_USB] = { 136 [AB8500_USB] = {
137 .num_ranges = 2, 137 .num_ranges = 2,
138 .range = (struct ab8500_reg_range[]) { 138 .range = (struct ab8500_reg_range[]) {
139 { 139 {
140 .first = 0x80, 140 .first = 0x80,
141 .last = 0x83, 141 .last = 0x83,
142 }, 142 },
143 { 143 {
144 .first = 0x87, 144 .first = 0x87,
145 .last = 0x8A, 145 .last = 0x8A,
146 }, 146 },
147 }, 147 },
148 }, 148 },
149 [AB8500_TVOUT] = { 149 [AB8500_TVOUT] = {
150 .num_ranges = 9, 150 .num_ranges = 9,
151 .range = (struct ab8500_reg_range[]) { 151 .range = (struct ab8500_reg_range[]) {
152 { 152 {
153 .first = 0x00, 153 .first = 0x00,
154 .last = 0x12, 154 .last = 0x12,
155 }, 155 },
156 { 156 {
157 .first = 0x15, 157 .first = 0x15,
158 .last = 0x17, 158 .last = 0x17,
159 }, 159 },
160 { 160 {
161 .first = 0x19, 161 .first = 0x19,
162 .last = 0x21, 162 .last = 0x21,
163 }, 163 },
164 { 164 {
165 .first = 0x27, 165 .first = 0x27,
166 .last = 0x2C, 166 .last = 0x2C,
167 }, 167 },
168 { 168 {
169 .first = 0x41, 169 .first = 0x41,
170 .last = 0x41, 170 .last = 0x41,
171 }, 171 },
172 { 172 {
173 .first = 0x45, 173 .first = 0x45,
174 .last = 0x5B, 174 .last = 0x5B,
175 }, 175 },
176 { 176 {
177 .first = 0x5D, 177 .first = 0x5D,
178 .last = 0x5D, 178 .last = 0x5D,
179 }, 179 },
180 { 180 {
181 .first = 0x69, 181 .first = 0x69,
182 .last = 0x69, 182 .last = 0x69,
183 }, 183 },
184 { 184 {
185 .first = 0x80, 185 .first = 0x80,
186 .last = 0x81, 186 .last = 0x81,
187 }, 187 },
188 }, 188 },
189 }, 189 },
190 [AB8500_DBI] = { 190 [AB8500_DBI] = {
191 .num_ranges = 0, 191 .num_ranges = 0,
192 .range = 0, 192 .range = 0,
193 }, 193 },
194 [AB8500_ECI_AV_ACC] = { 194 [AB8500_ECI_AV_ACC] = {
195 .num_ranges = 1, 195 .num_ranges = 1,
196 .range = (struct ab8500_reg_range[]) { 196 .range = (struct ab8500_reg_range[]) {
197 { 197 {
198 .first = 0x80, 198 .first = 0x80,
199 .last = 0x82, 199 .last = 0x82,
200 }, 200 },
201 }, 201 },
202 }, 202 },
203 [0x9] = { 203 [0x9] = {
204 .num_ranges = 0, 204 .num_ranges = 0,
205 .range = 0, 205 .range = 0,
206 }, 206 },
207 [AB8500_GPADC] = { 207 [AB8500_GPADC] = {
208 .num_ranges = 1, 208 .num_ranges = 1,
209 .range = (struct ab8500_reg_range[]) { 209 .range = (struct ab8500_reg_range[]) {
210 { 210 {
211 .first = 0x00, 211 .first = 0x00,
212 .last = 0x08, 212 .last = 0x08,
213 }, 213 },
214 }, 214 },
215 }, 215 },
216 [AB8500_CHARGER] = { 216 [AB8500_CHARGER] = {
217 .num_ranges = 8, 217 .num_ranges = 8,
218 .range = (struct ab8500_reg_range[]) { 218 .range = (struct ab8500_reg_range[]) {
219 { 219 {
220 .first = 0x00, 220 .first = 0x00,
221 .last = 0x03, 221 .last = 0x03,
222 }, 222 },
223 { 223 {
224 .first = 0x05, 224 .first = 0x05,
225 .last = 0x05, 225 .last = 0x05,
226 }, 226 },
227 { 227 {
228 .first = 0x40, 228 .first = 0x40,
229 .last = 0x40, 229 .last = 0x40,
230 }, 230 },
231 { 231 {
232 .first = 0x42, 232 .first = 0x42,
233 .last = 0x42, 233 .last = 0x42,
234 }, 234 },
235 { 235 {
236 .first = 0x44, 236 .first = 0x44,
237 .last = 0x44, 237 .last = 0x44,
238 }, 238 },
239 { 239 {
240 .first = 0x50, 240 .first = 0x50,
241 .last = 0x55, 241 .last = 0x55,
242 }, 242 },
243 { 243 {
244 .first = 0x80, 244 .first = 0x80,
245 .last = 0x82, 245 .last = 0x82,
246 }, 246 },
247 { 247 {
248 .first = 0xC0, 248 .first = 0xC0,
249 .last = 0xC2, 249 .last = 0xC2,
250 }, 250 },
251 }, 251 },
252 }, 252 },
253 [AB8500_GAS_GAUGE] = { 253 [AB8500_GAS_GAUGE] = {
254 .num_ranges = 3, 254 .num_ranges = 3,
255 .range = (struct ab8500_reg_range[]) { 255 .range = (struct ab8500_reg_range[]) {
256 { 256 {
257 .first = 0x00, 257 .first = 0x00,
258 .last = 0x00, 258 .last = 0x00,
259 }, 259 },
260 { 260 {
261 .first = 0x07, 261 .first = 0x07,
262 .last = 0x0A, 262 .last = 0x0A,
263 }, 263 },
264 { 264 {
265 .first = 0x10, 265 .first = 0x10,
266 .last = 0x14, 266 .last = 0x14,
267 }, 267 },
268 }, 268 },
269 }, 269 },
270 [AB8500_AUDIO] = { 270 [AB8500_AUDIO] = {
271 .num_ranges = 1, 271 .num_ranges = 1,
272 .range = (struct ab8500_reg_range[]) { 272 .range = (struct ab8500_reg_range[]) {
273 { 273 {
274 .first = 0x00, 274 .first = 0x00,
275 .last = 0x6F, 275 .last = 0x6F,
276 }, 276 },
277 }, 277 },
278 }, 278 },
279 [AB8500_INTERRUPT] = { 279 [AB8500_INTERRUPT] = {
280 .num_ranges = 0, 280 .num_ranges = 0,
281 .range = 0, 281 .range = 0,
282 }, 282 },
283 [AB8500_RTC] = { 283 [AB8500_RTC] = {
284 .num_ranges = 1, 284 .num_ranges = 1,
285 .range = (struct ab8500_reg_range[]) { 285 .range = (struct ab8500_reg_range[]) {
286 { 286 {
287 .first = 0x00, 287 .first = 0x00,
288 .last = 0x0F, 288 .last = 0x0F,
289 }, 289 },
290 }, 290 },
291 }, 291 },
292 [AB8500_MISC] = { 292 [AB8500_MISC] = {
293 .num_ranges = 8, 293 .num_ranges = 8,
294 .range = (struct ab8500_reg_range[]) { 294 .range = (struct ab8500_reg_range[]) {
295 { 295 {
296 .first = 0x00, 296 .first = 0x00,
297 .last = 0x05, 297 .last = 0x05,
298 }, 298 },
299 { 299 {
300 .first = 0x10, 300 .first = 0x10,
301 .last = 0x15, 301 .last = 0x15,
302 }, 302 },
303 { 303 {
304 .first = 0x20, 304 .first = 0x20,
305 .last = 0x25, 305 .last = 0x25,
306 }, 306 },
307 { 307 {
308 .first = 0x30, 308 .first = 0x30,
309 .last = 0x35, 309 .last = 0x35,
310 }, 310 },
311 { 311 {
312 .first = 0x40, 312 .first = 0x40,
313 .last = 0x45, 313 .last = 0x45,
314 }, 314 },
315 { 315 {
316 .first = 0x50, 316 .first = 0x50,
317 .last = 0x50, 317 .last = 0x50,
318 }, 318 },
319 { 319 {
320 .first = 0x60, 320 .first = 0x60,
321 .last = 0x67, 321 .last = 0x67,
322 }, 322 },
323 { 323 {
324 .first = 0x80, 324 .first = 0x80,
325 .last = 0x80, 325 .last = 0x80,
326 }, 326 },
327 }, 327 },
328 }, 328 },
329 [0x11] = { 329 [0x11] = {
330 .num_ranges = 0, 330 .num_ranges = 0,
331 .range = 0, 331 .range = 0,
332 }, 332 },
333 [0x12] = { 333 [0x12] = {
334 .num_ranges = 0, 334 .num_ranges = 0,
335 .range = 0, 335 .range = 0,
336 }, 336 },
337 [0x13] = { 337 [0x13] = {
338 .num_ranges = 0, 338 .num_ranges = 0,
339 .range = 0, 339 .range = 0,
340 }, 340 },
341 [0x14] = { 341 [0x14] = {
342 .num_ranges = 0, 342 .num_ranges = 0,
343 .range = 0, 343 .range = 0,
344 }, 344 },
345 [AB8500_OTP_EMUL] = { 345 [AB8500_OTP_EMUL] = {
346 .num_ranges = 1, 346 .num_ranges = 1,
347 .range = (struct ab8500_reg_range[]) { 347 .range = (struct ab8500_reg_range[]) {
348 { 348 {
349 .first = 0x01, 349 .first = 0x01,
350 .last = 0x0F, 350 .last = 0x0F,
351 }, 351 },
352 }, 352 },
353 }, 353 },
354}; 354};
355 355
356static int ab8500_registers_print(struct seq_file *s, void *p) 356static int ab8500_registers_print(struct seq_file *s, void *p)
357{ 357{
358 struct device *dev = s->private; 358 struct device *dev = s->private;
359 unsigned int i; 359 unsigned int i;
360 u32 bank = debug_bank; 360 u32 bank = debug_bank;
361 361
362 seq_printf(s, AB8500_NAME_STRING " register values:\n"); 362 seq_printf(s, AB8500_NAME_STRING " register values:\n");
363 363
364 seq_printf(s, " bank %u:\n", bank); 364 seq_printf(s, " bank %u:\n", bank);
365 for (i = 0; i < debug_ranges[bank].num_ranges; i++) { 365 for (i = 0; i < debug_ranges[bank].num_ranges; i++) {
366 u32 reg; 366 u32 reg;
367 367
368 for (reg = debug_ranges[bank].range[i].first; 368 for (reg = debug_ranges[bank].range[i].first;
369 reg <= debug_ranges[bank].range[i].last; 369 reg <= debug_ranges[bank].range[i].last;
370 reg++) { 370 reg++) {
371 u8 value; 371 u8 value;
372 int err; 372 int err;
373 373
374 err = abx500_get_register_interruptible(dev, 374 err = abx500_get_register_interruptible(dev,
375 (u8)bank, (u8)reg, &value); 375 (u8)bank, (u8)reg, &value);
376 if (err < 0) { 376 if (err < 0) {
377 dev_err(dev, "ab->read fail %d\n", err); 377 dev_err(dev, "ab->read fail %d\n", err);
378 return err; 378 return err;
379 } 379 }
380 380
381 err = seq_printf(s, " [%u/0x%02X]: 0x%02X\n", bank, 381 err = seq_printf(s, " [%u/0x%02X]: 0x%02X\n", bank,
382 reg, value); 382 reg, value);
383 if (err < 0) { 383 if (err < 0) {
384 dev_err(dev, "seq_printf overflow\n"); 384 dev_err(dev, "seq_printf overflow\n");
385 /* Error is not returned here since 385 /* Error is not returned here since
386 * the output is wanted in any case */ 386 * the output is wanted in any case */
387 return 0; 387 return 0;
388 } 388 }
389 } 389 }
390 } 390 }
391 return 0; 391 return 0;
392} 392}
393 393
394static int ab8500_registers_open(struct inode *inode, struct file *file) 394static int ab8500_registers_open(struct inode *inode, struct file *file)
395{ 395{
396 return single_open(file, ab8500_registers_print, inode->i_private); 396 return single_open(file, ab8500_registers_print, inode->i_private);
397} 397}
398 398
399static const struct file_operations ab8500_registers_fops = { 399static const struct file_operations ab8500_registers_fops = {
400 .open = ab8500_registers_open, 400 .open = ab8500_registers_open,
401 .read = seq_read, 401 .read = seq_read,
402 .llseek = seq_lseek, 402 .llseek = seq_lseek,
403 .release = single_release, 403 .release = single_release,
404 .owner = THIS_MODULE, 404 .owner = THIS_MODULE,
405}; 405};
406 406
407static int ab8500_bank_print(struct seq_file *s, void *p) 407static int ab8500_bank_print(struct seq_file *s, void *p)
408{ 408{
409 return seq_printf(s, "%d\n", debug_bank); 409 return seq_printf(s, "%d\n", debug_bank);
410} 410}
411 411
412static int ab8500_bank_open(struct inode *inode, struct file *file) 412static int ab8500_bank_open(struct inode *inode, struct file *file)
413{ 413{
414 return single_open(file, ab8500_bank_print, inode->i_private); 414 return single_open(file, ab8500_bank_print, inode->i_private);
415} 415}
416 416
417static ssize_t ab8500_bank_write(struct file *file, 417static ssize_t ab8500_bank_write(struct file *file,
418 const char __user *user_buf, 418 const char __user *user_buf,
419 size_t count, loff_t *ppos) 419 size_t count, loff_t *ppos)
420{ 420{
421 struct device *dev = ((struct seq_file *)(file->private_data))->private; 421 struct device *dev = ((struct seq_file *)(file->private_data))->private;
422 char buf[32]; 422 char buf[32];
423 int buf_size; 423 int buf_size;
424 unsigned long user_bank; 424 unsigned long user_bank;
425 int err; 425 int err;
426 426
427 /* Get userspace string and assure termination */ 427 /* Get userspace string and assure termination */
428 buf_size = min(count, (sizeof(buf) - 1)); 428 buf_size = min(count, (sizeof(buf) - 1));
429 if (copy_from_user(buf, user_buf, buf_size)) 429 if (copy_from_user(buf, user_buf, buf_size))
430 return -EFAULT; 430 return -EFAULT;
431 buf[buf_size] = 0; 431 buf[buf_size] = 0;
432 432
433 err = strict_strtoul(buf, 0, &user_bank); 433 err = strict_strtoul(buf, 0, &user_bank);
434 if (err) 434 if (err)
435 return -EINVAL; 435 return -EINVAL;
436 436
437 if (user_bank >= AB8500_NUM_BANKS) { 437 if (user_bank >= AB8500_NUM_BANKS) {
438 dev_err(dev, "debugfs error input > number of banks\n"); 438 dev_err(dev, "debugfs error input > number of banks\n");
439 return -EINVAL; 439 return -EINVAL;
440 } 440 }
441 441
442 debug_bank = user_bank; 442 debug_bank = user_bank;
443 443
444 return buf_size; 444 return buf_size;
445} 445}
446 446
447static int ab8500_address_print(struct seq_file *s, void *p) 447static int ab8500_address_print(struct seq_file *s, void *p)
448{ 448{
449 return seq_printf(s, "0x%02X\n", debug_address); 449 return seq_printf(s, "0x%02X\n", debug_address);
450} 450}
451 451
452static int ab8500_address_open(struct inode *inode, struct file *file) 452static int ab8500_address_open(struct inode *inode, struct file *file)
453{ 453{
454 return single_open(file, ab8500_address_print, inode->i_private); 454 return single_open(file, ab8500_address_print, inode->i_private);
455} 455}
456 456
457static ssize_t ab8500_address_write(struct file *file, 457static ssize_t ab8500_address_write(struct file *file,
458 const char __user *user_buf, 458 const char __user *user_buf,
459 size_t count, loff_t *ppos) 459 size_t count, loff_t *ppos)
460{ 460{
461 struct device *dev = ((struct seq_file *)(file->private_data))->private; 461 struct device *dev = ((struct seq_file *)(file->private_data))->private;
462 char buf[32]; 462 char buf[32];
463 int buf_size; 463 int buf_size;
464 unsigned long user_address; 464 unsigned long user_address;
465 int err; 465 int err;
466 466
467 /* Get userspace string and assure termination */ 467 /* Get userspace string and assure termination */
468 buf_size = min(count, (sizeof(buf) - 1)); 468 buf_size = min(count, (sizeof(buf) - 1));
469 if (copy_from_user(buf, user_buf, buf_size)) 469 if (copy_from_user(buf, user_buf, buf_size))
470 return -EFAULT; 470 return -EFAULT;
471 buf[buf_size] = 0; 471 buf[buf_size] = 0;
472 472
473 err = strict_strtoul(buf, 0, &user_address); 473 err = strict_strtoul(buf, 0, &user_address);
474 if (err) 474 if (err)
475 return -EINVAL; 475 return -EINVAL;
476 if (user_address > 0xff) { 476 if (user_address > 0xff) {
477 dev_err(dev, "debugfs error input > 0xff\n"); 477 dev_err(dev, "debugfs error input > 0xff\n");
478 return -EINVAL; 478 return -EINVAL;
479 } 479 }
480 debug_address = user_address; 480 debug_address = user_address;
481 return buf_size; 481 return buf_size;
482} 482}
483 483
484static int ab8500_val_print(struct seq_file *s, void *p) 484static int ab8500_val_print(struct seq_file *s, void *p)
485{ 485{
486 struct device *dev = s->private; 486 struct device *dev = s->private;
487 int ret; 487 int ret;
488 u8 regvalue; 488 u8 regvalue;
489 489
490 ret = abx500_get_register_interruptible(dev, 490 ret = abx500_get_register_interruptible(dev,
491 (u8)debug_bank, (u8)debug_address, &regvalue); 491 (u8)debug_bank, (u8)debug_address, &regvalue);
492 if (ret < 0) { 492 if (ret < 0) {
493 dev_err(dev, "abx500_get_reg fail %d, %d\n", 493 dev_err(dev, "abx500_get_reg fail %d, %d\n",
494 ret, __LINE__); 494 ret, __LINE__);
495 return -EINVAL; 495 return -EINVAL;
496 } 496 }
497 seq_printf(s, "0x%02X\n", regvalue); 497 seq_printf(s, "0x%02X\n", regvalue);
498 498
499 return 0; 499 return 0;
500} 500}
501 501
502static int ab8500_val_open(struct inode *inode, struct file *file) 502static int ab8500_val_open(struct inode *inode, struct file *file)
503{ 503{
504 return single_open(file, ab8500_val_print, inode->i_private); 504 return single_open(file, ab8500_val_print, inode->i_private);
505} 505}
506 506
507static ssize_t ab8500_val_write(struct file *file, 507static ssize_t ab8500_val_write(struct file *file,
508 const char __user *user_buf, 508 const char __user *user_buf,
509 size_t count, loff_t *ppos) 509 size_t count, loff_t *ppos)
510{ 510{
511 struct device *dev = ((struct seq_file *)(file->private_data))->private; 511 struct device *dev = ((struct seq_file *)(file->private_data))->private;
512 char buf[32]; 512 char buf[32];
513 int buf_size; 513 int buf_size;
514 unsigned long user_val; 514 unsigned long user_val;
515 int err; 515 int err;
516 516
517 /* Get userspace string and assure termination */ 517 /* Get userspace string and assure termination */
518 buf_size = min(count, (sizeof(buf)-1)); 518 buf_size = min(count, (sizeof(buf)-1));
519 if (copy_from_user(buf, user_buf, buf_size)) 519 if (copy_from_user(buf, user_buf, buf_size))
520 return -EFAULT; 520 return -EFAULT;
521 buf[buf_size] = 0; 521 buf[buf_size] = 0;
522 522
523 err = strict_strtoul(buf, 0, &user_val); 523 err = strict_strtoul(buf, 0, &user_val);
524 if (err) 524 if (err)
525 return -EINVAL; 525 return -EINVAL;
526 if (user_val > 0xff) { 526 if (user_val > 0xff) {
527 dev_err(dev, "debugfs error input > 0xff\n"); 527 dev_err(dev, "debugfs error input > 0xff\n");
528 return -EINVAL; 528 return -EINVAL;
529 } 529 }
530 err = abx500_set_register_interruptible(dev, 530 err = abx500_set_register_interruptible(dev,
531 (u8)debug_bank, debug_address, (u8)user_val); 531 (u8)debug_bank, debug_address, (u8)user_val);
532 if (err < 0) { 532 if (err < 0) {
533 printk(KERN_ERR "abx500_set_reg failed %d, %d", err, __LINE__); 533 printk(KERN_ERR "abx500_set_reg failed %d, %d", err, __LINE__);
534 return -EINVAL; 534 return -EINVAL;
535 } 535 }
536 536
537 return buf_size; 537 return buf_size;
538} 538}
539 539
540static const struct file_operations ab8500_bank_fops = { 540static const struct file_operations ab8500_bank_fops = {
541 .open = ab8500_bank_open, 541 .open = ab8500_bank_open,
542 .write = ab8500_bank_write, 542 .write = ab8500_bank_write,
543 .read = seq_read, 543 .read = seq_read,
544 .llseek = seq_lseek, 544 .llseek = seq_lseek,
545 .release = single_release, 545 .release = single_release,
546 .owner = THIS_MODULE, 546 .owner = THIS_MODULE,
547}; 547};
548 548
549static const struct file_operations ab8500_address_fops = { 549static const struct file_operations ab8500_address_fops = {
550 .open = ab8500_address_open, 550 .open = ab8500_address_open,
551 .write = ab8500_address_write, 551 .write = ab8500_address_write,
552 .read = seq_read, 552 .read = seq_read,
553 .llseek = seq_lseek, 553 .llseek = seq_lseek,
554 .release = single_release, 554 .release = single_release,
555 .owner = THIS_MODULE, 555 .owner = THIS_MODULE,
556}; 556};
557 557
558static const struct file_operations ab8500_val_fops = { 558static const struct file_operations ab8500_val_fops = {
559 .open = ab8500_val_open, 559 .open = ab8500_val_open,
560 .write = ab8500_val_write, 560 .write = ab8500_val_write,
561 .read = seq_read, 561 .read = seq_read,
562 .llseek = seq_lseek, 562 .llseek = seq_lseek,
563 .release = single_release, 563 .release = single_release,
564 .owner = THIS_MODULE, 564 .owner = THIS_MODULE,
565}; 565};
566 566
567static struct dentry *ab8500_dir; 567static struct dentry *ab8500_dir;
@@ -572,77 +572,77 @@ static struct dentry *ab8500_val_file;
572 572
573static int __devinit ab8500_debug_probe(struct platform_device *plf) 573static int __devinit ab8500_debug_probe(struct platform_device *plf)
574{ 574{
575 debug_bank = AB8500_MISC; 575 debug_bank = AB8500_MISC;
576 debug_address = AB8500_REV_REG & 0x00FF; 576 debug_address = AB8500_REV_REG & 0x00FF;
577 577
578 ab8500_dir = debugfs_create_dir(AB8500_NAME_STRING, NULL); 578 ab8500_dir = debugfs_create_dir(AB8500_NAME_STRING, NULL);
579 if (!ab8500_dir) 579 if (!ab8500_dir)
580 goto exit_no_debugfs; 580 goto exit_no_debugfs;
581 581
582 ab8500_reg_file = debugfs_create_file("all-bank-registers", 582 ab8500_reg_file = debugfs_create_file("all-bank-registers",
583 S_IRUGO, ab8500_dir, &plf->dev, &ab8500_registers_fops); 583 S_IRUGO, ab8500_dir, &plf->dev, &ab8500_registers_fops);
584 if (!ab8500_reg_file) 584 if (!ab8500_reg_file)
585 goto exit_destroy_dir; 585 goto exit_destroy_dir;
586 586
587 ab8500_bank_file = debugfs_create_file("register-bank", 587 ab8500_bank_file = debugfs_create_file("register-bank",
588 (S_IRUGO | S_IWUGO), ab8500_dir, &plf->dev, &ab8500_bank_fops); 588 (S_IRUGO | S_IWUGO), ab8500_dir, &plf->dev, &ab8500_bank_fops);
589 if (!ab8500_bank_file) 589 if (!ab8500_bank_file)
590 goto exit_destroy_reg; 590 goto exit_destroy_reg;
591 591
592 ab8500_address_file = debugfs_create_file("register-address", 592 ab8500_address_file = debugfs_create_file("register-address",
593 (S_IRUGO | S_IWUGO), ab8500_dir, &plf->dev, 593 (S_IRUGO | S_IWUGO), ab8500_dir, &plf->dev,
594 &ab8500_address_fops); 594 &ab8500_address_fops);
595 if (!ab8500_address_file) 595 if (!ab8500_address_file)
596 goto exit_destroy_bank; 596 goto exit_destroy_bank;
597 597
598 ab8500_val_file = debugfs_create_file("register-value", 598 ab8500_val_file = debugfs_create_file("register-value",
599 (S_IRUGO | S_IWUGO), ab8500_dir, &plf->dev, &ab8500_val_fops); 599 (S_IRUGO | S_IWUGO), ab8500_dir, &plf->dev, &ab8500_val_fops);
600 if (!ab8500_val_file) 600 if (!ab8500_val_file)
601 goto exit_destroy_address; 601 goto exit_destroy_address;
602 602
603 return 0; 603 return 0;
604 604
605exit_destroy_address: 605exit_destroy_address:
606 debugfs_remove(ab8500_address_file); 606 debugfs_remove(ab8500_address_file);
607exit_destroy_bank: 607exit_destroy_bank:
608 debugfs_remove(ab8500_bank_file); 608 debugfs_remove(ab8500_bank_file);
609exit_destroy_reg: 609exit_destroy_reg:
610 debugfs_remove(ab8500_reg_file); 610 debugfs_remove(ab8500_reg_file);
611exit_destroy_dir: 611exit_destroy_dir:
612 debugfs_remove(ab8500_dir); 612 debugfs_remove(ab8500_dir);
613exit_no_debugfs: 613exit_no_debugfs:
614 dev_err(&plf->dev, "failed to create debugfs entries.\n"); 614 dev_err(&plf->dev, "failed to create debugfs entries.\n");
615 return -ENOMEM; 615 return -ENOMEM;
616} 616}
617 617
618static int __devexit ab8500_debug_remove(struct platform_device *plf) 618static int __devexit ab8500_debug_remove(struct platform_device *plf)
619{ 619{
620 debugfs_remove(ab8500_val_file); 620 debugfs_remove(ab8500_val_file);
621 debugfs_remove(ab8500_address_file); 621 debugfs_remove(ab8500_address_file);
622 debugfs_remove(ab8500_bank_file); 622 debugfs_remove(ab8500_bank_file);
623 debugfs_remove(ab8500_reg_file); 623 debugfs_remove(ab8500_reg_file);
624 debugfs_remove(ab8500_dir); 624 debugfs_remove(ab8500_dir);
625 625
626 return 0; 626 return 0;
627} 627}
628 628
629static struct platform_driver ab8500_debug_driver = { 629static struct platform_driver ab8500_debug_driver = {
630 .driver = { 630 .driver = {
631 .name = "ab8500-debug", 631 .name = "ab8500-debug",
632 .owner = THIS_MODULE, 632 .owner = THIS_MODULE,
633 }, 633 },
634 .probe = ab8500_debug_probe, 634 .probe = ab8500_debug_probe,
635 .remove = __devexit_p(ab8500_debug_remove) 635 .remove = __devexit_p(ab8500_debug_remove)
636}; 636};
637 637
638static int __init ab8500_debug_init(void) 638static int __init ab8500_debug_init(void)
639{ 639{
640 return platform_driver_register(&ab8500_debug_driver); 640 return platform_driver_register(&ab8500_debug_driver);
641} 641}
642 642
643static void __exit ab8500_debug_exit(void) 643static void __exit ab8500_debug_exit(void)
644{ 644{
645 platform_driver_unregister(&ab8500_debug_driver); 645 platform_driver_unregister(&ab8500_debug_driver);
646} 646}
647subsys_initcall(ab8500_debug_init); 647subsys_initcall(ab8500_debug_init);
648module_exit(ab8500_debug_exit); 648module_exit(ab8500_debug_exit);