From 02fe2c3f5e66fd5a7b5ce433297d3181bfcf9e18 Mon Sep 17 00:00:00 2001 From: cognet Date: Sat, 19 Nov 2016 15:43:22 +0000 Subject: [PATCH] The only remaining offender that used ti_chip() without checking for compatibility first was the gpio code, so change that, and re-assert that the TI chip is a known chip --- sys/arm/ti/am335x/am335x_gpio.c | 5 +++-- sys/arm/ti/omap4/omap4_gpio.c | 4 ++-- sys/arm/ti/ti_cpuid.h | 1 + 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/sys/arm/ti/am335x/am335x_gpio.c b/sys/arm/ti/am335x/am335x_gpio.c index 6cee0970aa6a..cbfde175c2e7 100644 --- a/sys/arm/ti/am335x/am335x_gpio.c +++ b/sys/arm/ti/am335x/am335x_gpio.c @@ -65,8 +65,6 @@ static struct ofw_compat_data compat_data[] = { static int am335x_gpio_probe(device_t dev) { - if (ti_chip() != CHIP_AM335X) - return (ENXIO); if (!ofw_bus_status_okay(dev)) return (ENXIO); @@ -74,6 +72,9 @@ am335x_gpio_probe(device_t dev) if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0) return (ENXIO); + if (ti_chip() != CHIP_AM335X) + return (ENXIO); + device_set_desc(dev, "TI AM335x General Purpose I/O (GPIO)"); return (0); diff --git a/sys/arm/ti/omap4/omap4_gpio.c b/sys/arm/ti/omap4/omap4_gpio.c index 9f0f55b62ac9..faf2339411b6 100644 --- a/sys/arm/ti/omap4/omap4_gpio.c +++ b/sys/arm/ti/omap4/omap4_gpio.c @@ -59,14 +59,14 @@ static struct ofw_compat_data compat_data[] = { static int omap4_gpio_probe(device_t dev) { - if (ti_chip() != CHIP_OMAP_4) - return (ENXIO); if (!ofw_bus_status_okay(dev)) return (ENXIO); if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0) return (ENXIO); + if (ti_chip() != CHIP_OMAP_4) + return (ENXIO); device_set_desc(dev, "TI OMAP4 General Purpose I/O (GPIO)"); diff --git a/sys/arm/ti/ti_cpuid.h b/sys/arm/ti/ti_cpuid.h index 147a3617248f..715f080e5ff7 100644 --- a/sys/arm/ti/ti_cpuid.h +++ b/sys/arm/ti/ti_cpuid.h @@ -74,6 +74,7 @@ extern int _ti_chip; static __inline int ti_chip(void) { + KASSERT(_ti_chip != -1, ("Can't determine TI Chip")); return _ti_chip; }