From 168d2b807e0f18d56ed6804f6a90338a6018a112 Mon Sep 17 00:00:00 2001 From: Mark Kettenis Date: Tue, 7 Apr 2020 09:06:53 +0000 Subject: Fix off-by-one in check for valid pin numbers and use the existing #define in the check. --- sys/dev/fdt/rkgpio.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'sys/dev/fdt') 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 * Copyright (c) 2019 Patrick Wildt @@ -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) -- cgit v1.2.3