Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/kern split out the check whether a driver supports a giv...



details:   https://anonhg.NetBSD.org/src/rev/c6b0b854fbdd
branches:  trunk
changeset: 569694:c6b0b854fbdd
user:      drochner <drochner%NetBSD.org@localhost>
date:      Mon Aug 30 09:48:05 2004 +0000

description:
split out the check whether a driver supports a given interface
attribure, and add a diagnostic assertion to config_search_loc()
which ensures that a supplied attribute name is correct

diffstat:

 sys/kern/subr_autoconf.c |  39 +++++++++++++++++++++++++--------------
 1 files changed, 25 insertions(+), 14 deletions(-)

diffs (81 lines):

diff -r c801405b6928 -r c6b0b854fbdd sys/kern/subr_autoconf.c
--- a/sys/kern/subr_autoconf.c  Mon Aug 30 09:43:32 2004 +0000
+++ b/sys/kern/subr_autoconf.c  Mon Aug 30 09:48:05 2004 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: subr_autoconf.c,v 1.90 2004/08/17 22:13:18 drochner Exp $ */
+/* $NetBSD: subr_autoconf.c,v 1.91 2004/08/30 09:48:05 drochner Exp $ */
 
 /*
  * Copyright (c) 1996, 2000 Christopher G. Demetriou
@@ -77,7 +77,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_autoconf.c,v 1.90 2004/08/17 22:13:18 drochner Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_autoconf.c,v 1.91 2004/08/30 09:48:05 drochner Exp $");
 
 #include "opt_ddb.h"
 
@@ -466,6 +466,26 @@
 }
 
 /*
+ * Helper function: check whether the driver supports the interface attribute.
+ */
+static int
+cfdriver_has_iattr(const struct cfdriver *cd, const char *ia)
+{
+       const char * const *cpp;
+
+       if (cd->cd_attrs == NULL)
+               return (0);
+
+       for (cpp = cd->cd_attrs; *cpp; cpp++) {
+               if (STREQ(*cpp, ia)) {
+                       /* Match. */
+                       return (1);
+               }
+       }
+       return (0);
+}
+
+/*
  * Determine if `parent' is a potential parent for a device spec based
  * on `cfp'.
  */
@@ -473,8 +493,6 @@
 cfparent_match(const struct device *parent, const struct cfparent *cfp)
 {
        struct cfdriver *pcd;
-       const char * const *cpp;
-       const char *cp;
 
        /* We don't match root nodes here. */
        if (cfp == NULL)
@@ -487,16 +505,8 @@
         * First, ensure this parent has the correct interface
         * attribute.
         */
-       if (pcd->cd_attrs == NULL)
-               return (0);     /* no interface attributes -> no children */
-       for (cpp = pcd->cd_attrs; (cp = *cpp) != NULL; cpp++) {
-               if (STREQ(cp, cfp->cfp_iattr)) {
-                       /* Match. */
-                       break;
-               }
-       }
-       if (cp == NULL)
-               return (0);     /* doesn't carry the req'd attribute */
+       if (!cfdriver_has_iattr(pcd, cfp->cfp_iattr))
+               return (0);
 
        /*
         * If no specific parent device instance was specified (i.e.
@@ -697,6 +707,7 @@
        struct matchinfo m;
 
        KASSERT(config_initialized);
+       KASSERT(!ifattr || cfdriver_has_iattr(parent->dv_cfdriver, ifattr));
 
        m.fn = NULL;
        m.fn_loc = fn;



Home | Main Index | Thread Index | Old Index