aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char
diff options
context:
space:
mode:
authorJim Cromie <jim.cromie@gmail.com>2006-06-27 05:54:18 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-06-27 20:32:42 -0400
commitc3dc8071eedaac8c8a05c30fe20b78452a818dd9 (patch)
tree8cd247bf39b47273b7a1a7aa06cc0fc4c16dd7cd /drivers/char
parentfe3a168a2ce1c93837cdf8fe27a3e67795155f90 (diff)
[PATCH] chardev: GPIO for SCx200 & PC-8736x: dispatch via vtable
Now actually call the gpio operations thru the vtable. 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')
-rw-r--r--drivers/char/scx200_gpio.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/drivers/char/scx200_gpio.c b/drivers/char/scx200_gpio.c
index f9994ed01816..15dfb95ebc7e 100644
--- a/drivers/char/scx200_gpio.c
+++ b/drivers/char/scx200_gpio.c
@@ -53,6 +53,7 @@ static ssize_t scx200_gpio_write(struct file *file, const char __user *data,
53 size_t len, loff_t *ppos) 53 size_t len, loff_t *ppos)
54{ 54{
55 unsigned m = iminor(file->f_dentry->d_inode); 55 unsigned m = iminor(file->f_dentry->d_inode);
56 struct nsc_gpio_ops *amp = file->private_data;
56 size_t i; 57 size_t i;
57 int err = 0; 58 int err = 0;
58 59
@@ -62,39 +63,39 @@ static ssize_t scx200_gpio_write(struct file *file, const char __user *data,
62 return -EFAULT; 63 return -EFAULT;
63 switch (c) { 64 switch (c) {
64 case '0': 65 case '0':
65 scx200_gpio_set(m, 0); 66 amp->gpio_set(m, 0);
66 break; 67 break;
67 case '1': 68 case '1':
68 scx200_gpio_set(m, 1); 69 amp->gpio_set(m, 1);
69 break; 70 break;
70 case 'O': 71 case 'O':
71 printk(KERN_INFO NAME ": GPIO%d output enabled\n", m); 72 printk(KERN_INFO NAME ": GPIO%d output enabled\n", m);
72 scx200_gpio_configure(m, ~1, 1); 73 amp->gpio_config(m, ~1, 1);
73 break; 74 break;
74 case 'o': 75 case 'o':
75 printk(KERN_INFO NAME ": GPIO%d output disabled\n", m); 76 printk(KERN_INFO NAME ": GPIO%d output disabled\n", m);
76 scx200_gpio_configure(m, ~1, 0); 77 amp->gpio_config(m, ~1, 0);
77 break; 78 break;
78 case 'T': 79 case 'T':
79 printk(KERN_INFO NAME ": GPIO%d output is push pull\n", m); 80 printk(KERN_INFO NAME ": GPIO%d output is push pull\n", m);
80 scx200_gpio_configure(m, ~2, 2); 81 amp->gpio_config(m, ~2, 2);
81 break; 82 break;
82 case 't': 83 case 't':
83 printk(KERN_INFO NAME ": GPIO%d output is open drain\n", m); 84 printk(KERN_INFO NAME ": GPIO%d output is open drain\n", m);
84 scx200_gpio_configure(m, ~2, 0); 85 amp->gpio_config(m, ~2, 0);
85 break; 86 break;
86 case 'P': 87 case 'P':
87 printk(KERN_INFO NAME ": GPIO%d pull up enabled\n", m); 88 printk(KERN_INFO NAME ": GPIO%d pull up enabled\n", m);
88 scx200_gpio_configure(m, ~4, 4); 89 amp->gpio_config(m, ~4, 4);
89 break; 90 break;
90 case 'p': 91 case 'p':
91 printk(KERN_INFO NAME ": GPIO%d pull up disabled\n", m); 92 printk(KERN_INFO NAME ": GPIO%d pull up disabled\n", m);
92 scx200_gpio_configure(m, ~4, 0); 93 amp->gpio_config(m, ~4, 0);
93 break; 94 break;
94 95
95 case 'v': 96 case 'v':
96 /* View Current pin settings */ 97 /* View Current pin settings */
97 scx200_gpio_dump(m); 98 amp->gpio_dump(m);
98 break; 99 break;
99 case '\n': 100 case '\n':
100 /* end of settings string, do nothing */ 101 /* end of settings string, do nothing */
@@ -117,8 +118,9 @@ static ssize_t scx200_gpio_read(struct file *file, char __user *buf,
117{ 118{
118 unsigned m = iminor(file->f_dentry->d_inode); 119 unsigned m = iminor(file->f_dentry->d_inode);
119 int value; 120 int value;
121 struct nsc_gpio_ops *amp = file->private_data;
120 122
121 value = scx200_gpio_get(m); 123 value = amp->gpio_get(m);
122 if (put_user(value ? '1' : '0', buf)) 124 if (put_user(value ? '1' : '0', buf))
123 return -EFAULT; 125 return -EFAULT;
124 126
@@ -128,6 +130,8 @@ static ssize_t scx200_gpio_read(struct file *file, char __user *buf,
128static int scx200_gpio_open(struct inode *inode, struct file *file) 130static int scx200_gpio_open(struct inode *inode, struct file *file)
129{ 131{
130 unsigned m = iminor(inode); 132 unsigned m = iminor(inode);
133 file->private_data = &scx200_access;
134
131 if (m > 63) 135 if (m > 63)
132 return -EINVAL; 136 return -EINVAL;
133 return nonseekable_open(inode, file); 137 return nonseekable_open(inode, file);