Don't panic if the pin is not available in pin_reserve() but return false

instead.
This commit is contained in:
reinoud 2014-05-21 12:18:24 +00:00
parent 8230922b1a
commit a44d7f7416

View File

@ -32,7 +32,7 @@
#include "gpio.h"
#include <sys/cdefs.h>
__KERNEL_RCSID(1, "$NetBSD: exynos_gpio.c,v 1.5 2014/05/16 10:02:24 reinoud Exp $");
__KERNEL_RCSID(1, "$NetBSD: exynos_gpio.c,v 1.6 2014/05/21 12:18:24 reinoud Exp $");
#include <sys/param.h>
#include <sys/bus.h>
@ -725,8 +725,15 @@ exynos_gpio_pin_reserve(const char *name, struct exynos_gpio_pindata *pd)
}
KASSERT(grp);
KASSERT(pinnr < grp->grp_bits);
KASSERT(grp->grp_pin_mask & __BIT(pinnr));
/* in range? */
if (pinnr >= grp->grp_bits)
return false;
/* marked as connected? */
if ((grp->grp_pin_mask & __BIT(pinnr)) == 0)
return false;
/* it better not be used!! this is not taken lightly */
KASSERT((grp->grp_pin_inuse_mask & __BIT(pinnr)) == 0);
/* update our pin configuration */