Commit c3dc8071 authored by Jim Cromie's avatar Jim Cromie Committed by Linus Torvalds

[PATCH] chardev: GPIO for SCx200 & PC-8736x: dispatch via vtable

Now actually call the gpio operations thru the vtable.
Signed-off-by: default avatarJim Cromie <jim.cromie@gmail.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent fe3a168a
...@@ -53,6 +53,7 @@ static ssize_t scx200_gpio_write(struct file *file, const char __user *data, ...@@ -53,6 +53,7 @@ static ssize_t scx200_gpio_write(struct file *file, const char __user *data,
size_t len, loff_t *ppos) size_t len, loff_t *ppos)
{ {
unsigned m = iminor(file->f_dentry->d_inode); unsigned m = iminor(file->f_dentry->d_inode);
struct nsc_gpio_ops *amp = file->private_data;
size_t i; size_t i;
int err = 0; int err = 0;
...@@ -62,39 +63,39 @@ static ssize_t scx200_gpio_write(struct file *file, const char __user *data, ...@@ -62,39 +63,39 @@ static ssize_t scx200_gpio_write(struct file *file, const char __user *data,
return -EFAULT; return -EFAULT;
switch (c) { switch (c) {
case '0': case '0':
scx200_gpio_set(m, 0); amp->gpio_set(m, 0);
break; break;
case '1': case '1':
scx200_gpio_set(m, 1); amp->gpio_set(m, 1);
break; break;
case 'O': case 'O':
printk(KERN_INFO NAME ": GPIO%d output enabled\n", m); printk(KERN_INFO NAME ": GPIO%d output enabled\n", m);
scx200_gpio_configure(m, ~1, 1); amp->gpio_config(m, ~1, 1);
break; break;
case 'o': case 'o':
printk(KERN_INFO NAME ": GPIO%d output disabled\n", m); printk(KERN_INFO NAME ": GPIO%d output disabled\n", m);
scx200_gpio_configure(m, ~1, 0); amp->gpio_config(m, ~1, 0);
break; break;
case 'T': case 'T':
printk(KERN_INFO NAME ": GPIO%d output is push pull\n", m); 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; break;
case 't': case 't':
printk(KERN_INFO NAME ": GPIO%d output is open drain\n", m); 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; break;
case 'P': case 'P':
printk(KERN_INFO NAME ": GPIO%d pull up enabled\n", m); printk(KERN_INFO NAME ": GPIO%d pull up enabled\n", m);
scx200_gpio_configure(m, ~4, 4); amp->gpio_config(m, ~4, 4);
break; break;
case 'p': case 'p':
printk(KERN_INFO NAME ": GPIO%d pull up disabled\n", m); printk(KERN_INFO NAME ": GPIO%d pull up disabled\n", m);
scx200_gpio_configure(m, ~4, 0); amp->gpio_config(m, ~4, 0);
break; break;
case 'v': case 'v':
/* View Current pin settings */ /* View Current pin settings */
scx200_gpio_dump(m); amp->gpio_dump(m);
break; break;
case '\n': case '\n':
/* end of settings string, do nothing */ /* end of settings string, do nothing */
...@@ -117,8 +118,9 @@ static ssize_t scx200_gpio_read(struct file *file, char __user *buf, ...@@ -117,8 +118,9 @@ static ssize_t scx200_gpio_read(struct file *file, char __user *buf,
{ {
unsigned m = iminor(file->f_dentry->d_inode); unsigned m = iminor(file->f_dentry->d_inode);
int value; 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)) if (put_user(value ? '1' : '0', buf))
return -EFAULT; return -EFAULT;
...@@ -128,6 +130,8 @@ static ssize_t scx200_gpio_read(struct file *file, char __user *buf, ...@@ -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) static int scx200_gpio_open(struct inode *inode, struct file *file)
{ {
unsigned m = iminor(inode); unsigned m = iminor(inode);
file->private_data = &scx200_access;
if (m > 63) if (m > 63)
return -EINVAL; return -EINVAL;
return nonseekable_open(inode, file); return nonseekable_open(inode, file);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment