aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/nsc_gpio.c
diff options
context:
space:
mode:
authorJim Cromie <jim.cromie@gmail.com>2006-06-27 05:54:23 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-06-27 20:32:43 -0400
commitf31000e573da052b6b8bcc21faff520b4e2eda7a (patch)
tree670d5e6e00da615f70d99a950cfe7b8603edad26 /drivers/char/nsc_gpio.c
parent58b087cda1e9e46c7061c2282f92bd8e1970bfe7 (diff)
[PATCH] chardev: GPIO for SCx200 & PC-8736x: use dev_dbg in common module
Use of dev_dbg() and friends is considered good practice. dev_dbg() needs a struct device *devp, but nsc_gpio is only a helper module, so it doesnt have/need its own. To provide devp to the user-modules (scx200 & pc8736x _gpio), we add it to the vtable, and set it during init. Also squeeze nsc_gpio_dump()'s format a little. [ 199.259879] pc8736x_gpio.0: io09: 0x0044 TS OD PUE EDGE LO DEBOUNCE Signed-off-by: Jim Cromie <jim.cromie@gmail.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/char/nsc_gpio.c')
-rw-r--r--drivers/char/nsc_gpio.c45
1 files changed, 25 insertions, 20 deletions
diff --git a/drivers/char/nsc_gpio.c b/drivers/char/nsc_gpio.c
index 929d68486c1a..d0b5d65a73fb 100644
--- a/drivers/char/nsc_gpio.c
+++ b/drivers/char/nsc_gpio.c
@@ -14,22 +14,27 @@
14#include <linux/kernel.h> 14#include <linux/kernel.h>
15#include <linux/init.h> 15#include <linux/init.h>
16#include <linux/nsc_gpio.h> 16#include <linux/nsc_gpio.h>
17#include <linux/platform_device.h>
17#include <asm/uaccess.h> 18#include <asm/uaccess.h>
18#include <asm/io.h> 19#include <asm/io.h>
19 20
20#define NAME "nsc_gpio" 21#define NAME "nsc_gpio"
21 22
22void nsc_gpio_dump(unsigned index, u32 config) 23void nsc_gpio_dump(struct nsc_gpio_ops *amp, unsigned index)
23{ 24{
24 printk(KERN_INFO NAME ": GPIO-%02u: 0x%08lx %s %s %s %s %s %s %s\n", 25 /* retrieve current config w/o changing it */
25 index, (unsigned long)config, 26 u32 config = amp->gpio_config(index, ~0, 0);
26 (config & 1) ? "OE" : "TS", /* output-enabled/tristate */ 27
27 (config & 2) ? "PP" : "OD", /* push pull / open drain */ 28 /* user requested via 'v' command, so its INFO */
28 (config & 4) ? "PUE" : "PUD", /* pull up enabled/disabled */ 29 dev_info(amp->dev, "io%02u: 0x%04x %s %s %s %s %s %s %s\n",
29 (config & 8) ? "LOCKED" : "", /* locked / unlocked */ 30 index, config,
30 (config & 16) ? "LEVEL" : "EDGE",/* level/edge input */ 31 (config & 1) ? "OE" : "TS", /* output-enabled/tristate */
31 (config & 32) ? "HI" : "LO", /* trigger on rise/fall edge */ 32 (config & 2) ? "PP" : "OD", /* push pull / open drain */
32 (config & 64) ? "DEBOUNCE" : ""); /* debounce */ 33 (config & 4) ? "PUE" : "PUD", /* pull up enabled/disabled */
34 (config & 8) ? "LOCKED" : "", /* locked / unlocked */
35 (config & 16) ? "LEVEL" : "EDGE",/* level/edge input */
36 (config & 32) ? "HI" : "LO", /* trigger on rise/fall edge */
37 (config & 64) ? "DEBOUNCE" : ""); /* debounce */
33} 38}
34 39
35ssize_t nsc_gpio_write(struct file *file, const char __user *data, 40ssize_t nsc_gpio_write(struct file *file, const char __user *data,
@@ -37,6 +42,7 @@ ssize_t nsc_gpio_write(struct file *file, const char __user *data,
37{ 42{
38 unsigned m = iminor(file->f_dentry->d_inode); 43 unsigned m = iminor(file->f_dentry->d_inode);
39 struct nsc_gpio_ops *amp = file->private_data; 44 struct nsc_gpio_ops *amp = file->private_data;
45 struct device *dev = amp->dev;
40 size_t i; 46 size_t i;
41 int err = 0; 47 int err = 0;
42 48
@@ -52,42 +58,41 @@ ssize_t nsc_gpio_write(struct file *file, const char __user *data,
52 amp->gpio_set(m, 1); 58 amp->gpio_set(m, 1);
53 break; 59 break;
54 case 'O': 60 case 'O':
55 printk(KERN_INFO NAME ": GPIO%d output enabled\n", m); 61 dev_dbg(dev, "GPIO%d output enabled\n", m);
56 amp->gpio_config(m, ~1, 1); 62 amp->gpio_config(m, ~1, 1);
57 break; 63 break;
58 case 'o': 64 case 'o':
59 printk(KERN_INFO NAME ": GPIO%d output disabled\n", m); 65 dev_dbg(dev, "GPIO%d output disabled\n", m);
60 amp->gpio_config(m, ~1, 0); 66 amp->gpio_config(m, ~1, 0);
61 break; 67 break;
62 case 'T': 68 case 'T':
63 printk(KERN_INFO NAME ": GPIO%d output is push pull\n", 69 dev_dbg(dev, "GPIO%d output is push pull\n",
64 m); 70 m);
65 amp->gpio_config(m, ~2, 2); 71 amp->gpio_config(m, ~2, 2);
66 break; 72 break;
67 case 't': 73 case 't':
68 printk(KERN_INFO NAME ": GPIO%d output is open drain\n", 74 dev_dbg(dev, "GPIO%d output is open drain\n",
69 m); 75 m);
70 amp->gpio_config(m, ~2, 0); 76 amp->gpio_config(m, ~2, 0);
71 break; 77 break;
72 case 'P': 78 case 'P':
73 printk(KERN_INFO NAME ": GPIO%d pull up enabled\n", m); 79 dev_dbg(dev, "GPIO%d pull up enabled\n", m);
74 amp->gpio_config(m, ~4, 4); 80 amp->gpio_config(m, ~4, 4);
75 break; 81 break;
76 case 'p': 82 case 'p':
77 printk(KERN_INFO NAME ": GPIO%d pull up disabled\n", m); 83 dev_dbg(dev, "GPIO%d pull up disabled\n", m);
78 amp->gpio_config(m, ~4, 0); 84 amp->gpio_config(m, ~4, 0);
79 break; 85 break;
80 case 'v': 86 case 'v':
81 /* View Current pin settings */ 87 /* View Current pin settings */
82 amp->gpio_dump(m); 88 amp->gpio_dump(amp, m);
83 break; 89 break;
84 case '\n': 90 case '\n':
85 /* end of settings string, do nothing */ 91 /* end of settings string, do nothing */
86 break; 92 break;
87 default: 93 default:
88 printk(KERN_ERR NAME 94 dev_err(dev, "io%2d bad setting: chr<0x%2x>\n",
89 ": GPIO-%2d bad setting: chr<0x%2x>\n", m, 95 m, (int)c);
90 (int)c);
91 err++; 96 err++;
92 } 97 }
93 } 98 }