Author: avg
Date: Mon Aug 12 09:20:02 2019
New Revision: 350892
URL: https://svnweb.freebsd.org/changeset/base/350892

Log:
  MFC r349571: upgrade the warning printf-s in bus accessors to KASSERT-s, take 
2
  
  After this change sys/bus.h includes sys/systm.h when _KERNEL is
  defined.

Modified:
  stable/12/sys/sys/bus.h
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/sys/bus.h
==============================================================================
--- stable/12/sys/sys/bus.h     Mon Aug 12 08:45:26 2019        (r350891)
+++ stable/12/sys/sys/bus.h     Mon Aug 12 09:20:02 2019        (r350892)
@@ -152,6 +152,7 @@ struct devreq {
 
 #include <sys/eventhandler.h>
 #include <sys/kobj.h>
+#include <sys/systm.h>
 
 /**
  * devctl hooks.  Typically one should use the devctl_notify
@@ -810,12 +811,9 @@ static __inline type varp ## _get_ ## var(device_t dev
        int e;                                                          \
        e = BUS_READ_IVAR(device_get_parent(dev), dev,                  \
            ivarp ## _IVAR_ ## ivar, &v);                               \
-       if (e != 0) {                                                   \
-               device_printf(dev, "failed to read ivar "               \
-                   __XSTRING(ivarp ## _IVAR_ ## ivar) " on bus %s, "   \
-                   "error = %d\n",                                     \
-                   device_get_nameunit(device_get_parent(dev)), e);    \
-       }                                                               \
+       KASSERT(e == 0, ("%s failed for %s on bus %s, error = %d",      \
+           __func__, device_get_nameunit(dev),                         \
+           device_get_nameunit(device_get_parent(dev)), e));           \
        return ((type) v);                                              \
 }                                                                      \
                                                                        \
@@ -825,12 +823,9 @@ static __inline void varp ## _set_ ## var(device_t dev
        int e;                                                          \
        e = BUS_WRITE_IVAR(device_get_parent(dev), dev,                 \
            ivarp ## _IVAR_ ## ivar, v);                                \
-       if (e != 0) {                                                   \
-               device_printf(dev, "failed to write ivar "              \
-                   __XSTRING(ivarp ## _IVAR_ ## ivar) " on bus %s, "   \
-                   "error = %d\n",                                     \
-                   device_get_nameunit(device_get_parent(dev)), e);    \
-       }                                                               \
+       KASSERT(e == 0, ("%s failed for %s on bus %s, error = %d",      \
+           __func__, device_get_nameunit(dev),                         \
+           device_get_nameunit(device_get_parent(dev)), e));           \
 }
 
 /**
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to