summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJim Cromie <jim.cromie@gmail.com>2006-06-27 02:54:18 -0700
committerLinus Torvalds <torvalds@g5.osdl.org>2006-06-27 17:32:42 -0700
commitc3dc8071eedaac8c8a05c30fe20b78452a818dd9 (patch)
tree8cd247bf39b47273b7a1a7aa06cc0fc4c16dd7cd
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>
-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 f9994ed0181..15dfb95ebc7 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,
size_t len, loff_t *ppos)
{
unsigned m = iminor(file->f_dentry->d_inode);
+ struct nsc_gpio_ops *amp = file->private_data;
size_t i;
int err = 0;
@@ -62,39 +63,39 @@ static ssize_t scx200_gpio_write(struct file *file, const char __user *data,
return -EFAULT;
switch (c) {
case '0':
- scx200_gpio_set(m, 0);
+ amp->gpio_set(m, 0);
break;
case '1':
- scx200_gpio_set(m, 1);
+ amp->gpio_set(m, 1);
break;
case 'O':
printk(KERN_INFO NAME ": GPIO%d output enabled\n", m);
- scx200_gpio_configure(m, ~1, 1);
+ amp->gpio_config(m, ~1, 1);
break;
case 'o':
printk(KERN_INFO NAME ": GPIO%d output disabled\n", m);
- scx200_gpio_configure(m, ~1, 0);
+ amp->gpio_config(m, ~1, 0);
break;
case 'T':
printk(KERN_INFO NAME ": GPIO%d output is push pull\n", m);
- scx200_gpio_configure(m, ~2, 2);
+ amp->gpio_config(m, ~2, 2);
break;
case 't':
printk(KERN_INFO NAME ": GPIO%d output is open drain\n", m);
- scx200_gpio_configure(m, ~2, 0);
+ amp->gpio_config(m, ~2, 0);
break;
case 'P':
printk(KERN_INFO NAME ": GPIO%d pull up enabled\n", m);
- scx200_gpio_configure(m, ~4, 4);
+ amp->gpio_config(m, ~4, 4);
break;
case 'p':
printk(KERN_INFO NAME ": GPIO%d pull up disabled\n", m);
- scx200_gpio_configure(m, ~4, 0);
+ amp->gpio_config(m, ~4, 0);
break;
case 'v':
/* View Current pin settings */
- scx200_gpio_dump(m);
+ amp->gpio_dump(m);
break;
case '\n':
/* end of settings string, do nothing */
@@ -117,8 +118,9 @@ static ssize_t scx200_gpio_read(struct file *file, char __user *buf,
{
unsigned m = iminor(file->f_dentry->d_inode);
int value;
+ struct nsc_gpio_ops *amp = file->private_data;
- value = scx200_gpio_get(m);
+ value = amp->gpio_get(m);
if (put_user(value ? '1' : '0', buf))
return -EFAULT;
@@ -128,6 +130,8 @@ static ssize_t scx200_gpio_read(struct file *file, char __user *buf,
static int scx200_gpio_open(struct inode *inode, struct file *file)
{
unsigned m = iminor(inode);
+ file->private_data = &scx200_access;
+
if (m > 63)
return -EINVAL;
return nonseekable_open(inode, file);