> OK, i found the missing package: kmod-gpio-dev
> After installing this, gpioctl works.

FWIW, I've used the following patch which adds /proc/diag/button
directory where you can read the state of each button, making gpioctl
and kmod-gpio-dev unnecessary.  Another advantage over gpioctl is that
those /proc/diag/button entries have actual names rather than being
just numbered.


        Stefan


Index: package/broadcom-diag/src/diag.c
===================================================================
--- package/broadcom-diag/src/diag.c    (revision 14605)
+++ package/broadcom-diag/src/diag.c    (working copy)
@@ -910,9 +910,25 @@
 
 static void register_buttons(struct button_t *b)
 {
-       for (; b->name; b++)
+       buttons = proc_mkdir("button", diag);
+       if (!buttons)
+               return;
+
+       for (; b->name; b++) {
+               struct proc_dir_entry *p;
                platform.button_mask |= b->gpio;
 
+               if (b->gpio & gpiomask)
+                       continue;
+
+               if ((p = create_proc_entry(b->name, S_IRUSR, buttons))) {
+                       b->proc.type = PROC_BUTTON;
+                       b->proc.ptr = b;
+                       p->data = (void *) &b->proc;
+                       p->proc_fops = &diag_proc_fops;
+               }
+       }
+
        platform.button_mask &= ~gpiomask;
 
        gpio_outen(platform.button_mask, 0);
@@ -926,6 +942,9 @@
 
 static void unregister_buttons(struct button_t *b)
 {
+       for(; b->name; b++)
+               remove_proc_entry(b->name, buttons);
+
        gpio_intmask(platform.button_mask, 0);
 
        gpio_set_irqenable(0, button_handler);
@@ -1179,6 +1198,12 @@
                                }
                                break;
                        }
+                       case PROC_BUTTON: {
+                               struct button_t * button = (struct button_t *) 
handler->ptr;
+                               u32 in = (gpio_in() & button->gpio ? 1 : 0);
+                               len = sprintf(page, "%d\n", in);
+                               break;
+                       }
                        case PROC_MODEL:
                                len = sprintf(page, "%s\n", platform.name);
                                break;
Index: package/broadcom-diag/src/diag.h
===================================================================
--- package/broadcom-diag/src/diag.h    (revision 14605)
+++ package/broadcom-diag/src/diag.h    (working copy)
@@ -125,7 +125,7 @@
 
 /* proc */
 
-static struct proc_dir_entry *diag, *leds;
+static struct proc_dir_entry *diag, *leds, *buttons;
 
 static ssize_t diag_proc_read(struct file *file, char *buf, size_t count, 
loff_t *ppos);
 static ssize_t diag_proc_write(struct file *file, const char *buf, size_t 
count, loff_t *ppos);

_______________________________________________
openwrt-users mailing list
[email protected]
https://lists.openwrt.org/mailman/listinfo/openwrt-users

Reply via email to