svn commit: r356522 - head/sys/dev/iicbus/mux
Ian Lepore
ian at FreeBSD.org
Wed Jan 8 22:48:15 UTC 2020
Author: ian
Date: Wed Jan 8 22:48:14 2020
New Revision: 356522
URL: https://svnweb.freebsd.org/changeset/base/356522
Log:
Change some KASSERT to device_printf + return EINVAL. There's no need to
bring the whole kernel down due to a configuration error detected when a
module is loaded, it suffices to just not attach the device.
Modified:
head/sys/dev/iicbus/mux/iicmux.c
Modified: head/sys/dev/iicbus/mux/iicmux.c
==============================================================================
--- head/sys/dev/iicbus/mux/iicmux.c Wed Jan 8 22:45:32 2020 (r356521)
+++ head/sys/dev/iicbus/mux/iicmux.c Wed Jan 8 22:48:14 2020 (r356522)
@@ -222,10 +222,16 @@ iicmux_add_child(device_t dev, device_t child, int bus
{
struct iicmux_softc *sc = device_get_softc(dev);
- KASSERT(busidx < sc->numbuses,
- ("iicmux_add_child: bus idx %d too big", busidx));
- KASSERT(sc->childdevs[busidx] == NULL,
- ("iicmux_add_child: bus idx %d already added", busidx));
+ if (busidx >= sc->numbuses) {
+ device_printf(dev,
+ "iicmux_add_child: bus idx %d too big", busidx);
+ return (EINVAL);
+ }
+ if (sc->childdevs[busidx] != NULL) {
+ device_printf(dev, "iicmux_add_child: bus idx %d already added",
+ busidx);
+ return (EINVAL);
+ }
sc->childdevs[busidx] = child;
if (sc->maxbus < busidx)
@@ -240,12 +246,11 @@ iicmux_attach(device_t dev, device_t busdev, int numbu
struct iicmux_softc *sc = device_get_softc(dev);
int i, numadded;
- /*
- * Init the softc...
- */
- KASSERT(numbuses <= IICMUX_MAX_BUSES,
- ("iicmux_attach: numbuses %d exceeds max %d\n",
- numbuses, IICMUX_MAX_BUSES));
+ if (numbuses >= IICMUX_MAX_BUSES) {
+ device_printf(dev, "iicmux_attach: numbuses %d > max %d\n",
+ numbuses, IICMUX_MAX_BUSES);
+ return (EINVAL);
+ }
sc->dev = dev;
sc->busdev = busdev;
More information about the svn-src-head
mailing list