DragonFly commits List (threaded) for 2005-06
[
Date Prev][
Date Next]
[
Thread Prev][
Thread Next]
[
Date Index][
Thread Index]
Re: cvs commit: src/sys/dev/netif/wb if_wb.c
@@ -862,11 +841,18 @@ wb_attach(device_t dev)
*/
ether_ifattach(ifp, eaddr);
-fail:
- if (error)
- device_delete_child(dev, sc->wb_miibus);
- crit_exit();
+ error = bus_setup_intr(dev, sc->wb_irq, INTR_TYPE_NET,
+ wb_intr, sc, &sc->wb_intrhand, NULL);
+ if (error) {
+ device_printf(dev, "couldn't set up irq\n");
We should add ether_ifdetach() here, since we have called
ether_ifattach() here. wb_detach() will not call ether_ifdetach(), if
we enter wb_detach() from here.
+ goto fail;
+ }
+
+ return(0);
+
+fail:
+ wb_detach(dev);
return(error);
}
@@ -878,21 +864,25 @@ wb_detach(device_t dev)
crit_enter();
- wb_stop(sc);
- ether_ifdetach(ifp);
-
- /* Delete any miibus and phy devices attached to this interface */
- bus_generic_detach(dev);
- device_delete_child(dev, sc->wb_miibus);
-
- bus_teardown_intr(dev, sc->wb_irq, sc->wb_intrhand);
- bus_release_resource(dev, SYS_RES_IRQ, 0, sc->wb_irq);
- bus_release_resource(dev, WB_RES, WB_RID, sc->wb_res);
-
- contigfree(sc->wb_ldata_ptr, sizeof(struct wb_list_data) + 8,
- M_DEVBUF);
+ if (device_is_attached(dev)) {
+ if (bus_child_present(dev))
+ wb_stop(sc);
+ ether_ifdetach(ifp);
+ device_delete_child(dev, sc->wb_miibus);
IMHO, we should call device_delete_child() based on (sc->wb_miibus !=
NULL), not on device_is_attached(), given that in wb_attach()
mii_phy_probe() may fail.
+ bus_generic_detach(dev);
+ }
Best Regards
sephe
On 6/9/05, Joerg Sonnenberger <joerg@xxxxxxxxxxxxxxxxxxxxxxx> wrote:
> joerg 2005/06/08 12:20:09 PDT
>
> DragonFly src repository
>
> Modified files:
> sys/dev/netif/wb if_wb.c
> Log:
> Reorder initialisation to make protection unnecessary.
>
> Use device_printf in wb_attach. Leave critical section ASAP in wb_detach.
> Use M_WAITOK for contigmalloc.
>
> Partly-obtained-from: FreeBSD (first part).
>
> Revision Changes Path
> 1.26 +36 -46 src/sys/dev/netif/wb/if_wb.c
>
>
> http://www.dragonflybsd.org/cvsweb/src/sys/dev/netif/wb/if_wb.c.diff?r1=1.25&r2=1.26&f=u
>
--
Live Free or Die
[
Date Prev][
Date Next]
[
Thread Prev][
Thread Next]
[
Date Index][
Thread Index]