summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@cvs.openbsd.org>2020-04-07 09:06:53 +0000
committerMark Kettenis <kettenis@cvs.openbsd.org>2020-04-07 09:06:53 +0000
commit168d2b807e0f18d56ed6804f6a90338a6018a112 (patch)
tree0c0bad9b6bf20f4ce1a532ed57a2e7818d255c23 /sys
parent20eaa568f29f572177b38a6811ee2dc82ae1a6ea (diff)
Fix off-by-one in check for valid pin numbers and use the existing
#define in the check.
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/fdt/rkgpio.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/sys/dev/fdt/rkgpio.c b/sys/dev/fdt/rkgpio.c
index ba37340446c..536fc4e9bf5 100644
--- a/sys/dev/fdt/rkgpio.c
+++ b/sys/dev/fdt/rkgpio.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rkgpio.c,v 1.2 2019/05/11 14:56:12 patrick Exp $ */
+/* $OpenBSD: rkgpio.c,v 1.3 2020/04/07 09:06:52 kettenis Exp $ */
/*
* Copyright (c) 2017 Mark Kettenis <kettenis@openbsd.org>
* Copyright (c) 2019 Patrick Wildt <patrick@blueri.se>
@@ -159,7 +159,7 @@ rkgpio_config_pin(void *cookie, uint32_t *cells, int config)
struct rkgpio_softc *sc = cookie;
uint32_t pin = cells[0];
- if (pin > 32)
+ if (pin >= GPIO_NUM_PINS)
return;
if (config & GPIO_CONFIG_OUTPUT)
@@ -177,7 +177,7 @@ rkgpio_get_pin(void *cookie, uint32_t *cells)
uint32_t reg;
int val;
- if (pin > 32)
+ if (pin >= GPIO_NUM_PINS)
return 0;
reg = HREAD4(sc, GPIO_EXT_PORTA);
@@ -195,7 +195,7 @@ rkgpio_set_pin(void *cookie, uint32_t *cells, int val)
uint32_t pin = cells[0];
uint32_t flags = cells[1];
- if (pin > 32)
+ if (pin >= GPIO_NUM_PINS)
return;
if (flags & GPIO_ACTIVE_LOW)