logo       

[patch 08/19] chardev: pc8736x_gpio - add 'v'iewpins command to scx200_gpio: msg#00017

Subject: [patch 08/19] chardev: pc8736x_gpio - add 'v'iewpins command to scx200_gpio
GPIO SUPPORT FOR SCx200 & PC8736x

This patch-set reworks the 2.4 vintage scx200_gpio driver for modern
2.6, and refactors GPIO support to reuse it in a new driver for the
GPIO on PC-8736x chips.

08/19. patch.viewpins

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
user-friendly, and allows us (later) to dial down many INFO messages
to DEBUG log-level.

Signed-off-by:  Jim Cromie <jim.cromie@xxxxxxxxx>

diffstat patch.viewpins
arch/i386/kernel/scx200.c  |    3 +--
drivers/char/scx200_gpio.c |   16 ++++++++++++++++
2 files changed, 17 insertions(+), 2 deletions(-)

diff -ruNp -X dontdiff -X exclude-diffs k16r-6/arch/i386/kernel/scx200.c 
k16r-7/arch/i386/kernel/scx200.c
--- k16r-6/arch/i386/kernel/scx200.c    2006-05-28 12:20:37.000000000 -0600
+++ k16r-7/arch/i386/kernel/scx200.c    2006-05-28 12:20:50.000000000 -0600
@@ -105,7 +105,6 @@ u32 scx200_gpio_configure(unsigned index
        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,6 +139,7 @@ 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);

/*
diff -ruNp -X dontdiff -X exclude-diffs k16r-6/drivers/char/scx200_gpio.c 
k16r-7/drivers/char/scx200_gpio.c
--- k16r-6/drivers/char/scx200_gpio.c   2006-05-28 12:19:54.000000000 -0600
+++ k16r-7/drivers/char/scx200_gpio.c   2006-05-28 12:20:50.000000000 -0600
@@ -41,6 +41,7 @@ static ssize_t scx200_gpio_write(struct {
        unsigned m = iminor(file->f_dentry->d_inode);
        size_t i;
+       int err = 0;

        for (i = 0; i < len; ++i) {
                char c;
@@ -79,8 +80,23 @@ static ssize_t scx200_gpio_write(struct 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;
}


<Prev in Thread] Current Thread [Next in Thread>