Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/fdt Only read gpio pin if the pin is valid



details:   https://anonhg.NetBSD.org/src/rev/a55d596428c7
branches:  trunk
changeset: 825268:a55d596428c7
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Thu Jul 06 14:26:00 2017 +0000

description:
Only read gpio pin if the pin is valid

diffstat:

 sys/dev/fdt/gpiokeys.c |  7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diffs (28 lines):

diff -r eb0610a77e2b -r a55d596428c7 sys/dev/fdt/gpiokeys.c
--- a/sys/dev/fdt/gpiokeys.c    Thu Jul 06 14:01:38 2017 +0000
+++ b/sys/dev/fdt/gpiokeys.c    Thu Jul 06 14:26:00 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: gpiokeys.c,v 1.3 2017/07/06 14:01:38 jmcneill Exp $ */
+/* $NetBSD: gpiokeys.c,v 1.4 2017/07/06 14:26:00 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2015 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: gpiokeys.c,v 1.3 2017/07/06 14:01:38 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gpiokeys.c,v 1.4 2017/07/06 14:26:00 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -128,7 +128,8 @@
                key->key_debounce = debounce;
                key->key_pin = fdtbus_gpio_acquire(child, "gpios",
                    GPIO_PIN_INPUT);
-               key->key_state = fdtbus_gpio_read(key->key_pin);
+               if (key->key_pin)
+                       key->key_state = fdtbus_gpio_read(key->key_pin);
 
                key->key_pswitch.smpsw_name = key->key_label;
                switch (code) {



Home | Main Index | Thread Index | Old Index