]> err.no Git - linux-2.6/commitdiff
[PATCH] chardev: GPIO for SCx200 & PC-8736x: add 'v' command to device-file
authorJim Cromie <jim.cromie@gmail.com>
Tue, 27 Jun 2006 09:54:16 +0000 (02:54 -0700)
committerLinus Torvalds <torvalds@g5.osdl.org>
Wed, 28 Jun 2006 00:32:42 +0000 (17:32 -0700)
Add a new driver command: 'v' which calls gpio_dump() on the pin.  The output
goes to the log, like all other INFO messages in the original driver.  Giving
the user control over the feedback they 'need' is construed to be a
user-friendly feature, and allows us (later) to dial down many INFO messages
to DEBUG log-level.

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>
arch/i386/kernel/scx200.c
drivers/char/scx200_gpio.c

index 9e96a785dd058f3c9447b49c47dfa5bb6b00e8e8..009e6aa16f738d1a45ea6d4cabba45d5eef565e0 100644 (file)
@@ -105,7 +105,6 @@ u32 scx200_gpio_configure(unsigned index, u32 mask, u32 bits)
        return config;
 }
 
-#if 0
 void scx200_gpio_dump(unsigned index)
 {
         u32 config = scx200_gpio_configure(index, ~0, 0);
@@ -120,7 +119,6 @@ void scx200_gpio_dump(unsigned index)
                (config & 32) ? "HI"     : "LO",                /* trigger on rising/falling edge */
                (config & 64) ? "DEBOUNCE" : "");       /* debounce */
 }
-#endif  /*  0  */
 
 static int __init scx200_init(void)
 {
@@ -141,4 +139,5 @@ module_exit(scx200_cleanup);
 EXPORT_SYMBOL(scx200_gpio_base);
 EXPORT_SYMBOL(scx200_gpio_shadow);
 EXPORT_SYMBOL(scx200_gpio_configure);
+EXPORT_SYMBOL(scx200_gpio_dump);
 EXPORT_SYMBOL(scx200_cb_base);
index e6e52c48697bc3093c29c66d4fdfde76af5f856a..a1a56c5c8a84be6908d42aeaa8a0b63d257ae3a8 100644 (file)
@@ -41,6 +41,7 @@ static ssize_t scx200_gpio_write(struct file *file, const char __user *data,
 {
        unsigned m = iminor(file->f_dentry->d_inode);
        size_t i;
+       int err = 0;
 
        for (i = 0; i < len; ++i) {
                char c;
@@ -77,8 +78,23 @@ static ssize_t scx200_gpio_write(struct file *file, const char __user *data,
                        printk(KERN_INFO NAME ": GPIO%d pull up disabled\n", m);
                        scx200_gpio_configure(m, ~4, 0);
                        break;
+
+               case 'v':
+                       /* View Current pin settings */
+                       scx200_gpio_dump(m);
+                       break;
+               case '\n':
+                       /* end of settings string, do nothing */
+                       break;
+               default:
+                       printk(KERN_ERR NAME
+                              ": GPIO-%2d bad setting: chr<0x%2x>\n", m,
+                              (int)c);
+                       err++;
                }
        }
+       if (err)
+               return -EINVAL; /* full string handled, report error */
 
        return len;
 }