Re: Updated pci/if_* attach patches

From: M. Warner Losh <imp_at_bsdimp.com>
Date: Thu, 27 Mar 2003 23:53:06 -0700 (MST)
In message: <Pine.BSF.4.21.0303271519390.30498-100000_at_root.org>
            Nate Lawson <nate_at_root.org> writes:
: * Add bus_child_present check to calls to *_stop in the detach method for
: devices that have children (i.e. miibus).

bus_child_present isn't quite right for this.  bus_child_present means
"this child is still there in hardware" not "this node has children"

+	if (device_is_alive(dev)) {
+		if (bus_child_present(dev)) {
+			dc_stop(sc);
+			device_delete_child(dev, sc->dc_miibus);
+		}
+		ether_ifdetach(ifp);
+		bus_generic_detach(dev);
+	}

should be just:

+	if (device_is_alive(dev)) {
+		if (bus_child_present(dev))
+			dc_stop(sc);
+		device_delete_child(dev, sc->dc_miibus);
+		ether_ifdetach(ifp);
+		bus_generic_detach(dev);
+	}

since it says 'if the card is still there, stop it' which is what you
want in the cardbus case (and one day hotplug pci) since the card
might not be there, in which case trying to do anything with it is
doomed to failure.  Please fix this issue before commit.

# guess this is my fault for never writing a bus_child_present man
# page :-(

Also, on a stylistic note:

-	free(sc->dc_srom, M_DEVBUF);
+	if (sc->dc_srom)
+		free(sc->dc_srom, M_DEVBUF);

The kernel free, just like its ANSI-89 userland counterpart, can
tolerate free(NULL) now.  I know some of the other frees check, some
don't, but none should.  I'd not hold up the commit on this issue,
however.

from kern_malloc.c:
void
free(addr, type)
	void *addr;
	struct malloc_type *type;
{
...
	/* free(NULL, ...) does nothing */
	if (addr == NULL)
		return;
...

Warner
Received on Thu Mar 27 2003 - 21:53:27 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:37:02 UTC