+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);
+ size_t i;
+
+ for (i = 0; i < len; ++i) {
+ char c;
+ if (get_user(c, data+i))
+ return -EFAULT;
+ switch (c)
+ {
+ case '0':
+ scx200_gpio_set(m, 0);
+ break;
+ case '1':
+ scx200_gpio_set(m, 1);
+ break;
+ case 'O':
+ printk(KERN_INFO NAME ": GPIO%d output enabled\n", m);
+ scx200_gpio_configure(m, ~1, 1);
+ break;
+ case 'o':
+ printk(KERN_INFO NAME ": GPIO%d output disabled\n", m);
+ scx200_gpio_configure(m, ~1, 0);
+ break;
+ case 'T':
+ printk(KERN_INFO NAME ": GPIO%d output is push pull\n", m);
+ scx200_gpio_configure(m, ~2, 2);
+ break;
+ case 't':
+ printk(KERN_INFO NAME ": GPIO%d output is open drain\n", m);
+ scx200_gpio_configure(m, ~2, 0);
+ break;
+ case 'P':
+ printk(KERN_INFO NAME ": GPIO%d pull up enabled\n", m);
+ scx200_gpio_configure(m, ~4, 4);
+ break;
+ case 'p':
+ printk(KERN_INFO NAME ": GPIO%d pull up disabled\n", m);
+ scx200_gpio_configure(m, ~4, 0);
+ break;
+ }
+ }