Add a helper routine for ethernet drivers, mii_ifmedia_change().

Remove an mii_softc from its mii_data in mii_phy_detach(), not in
mii_detach(), so that we do not leave dangling pointers to a PHY
in an mii_data.
This commit is contained in:
dyoung 2008-01-10 07:29:41 +00:00
parent 49df706f87
commit c329a611cb
3 changed files with 14 additions and 6 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: mii.c,v 1.43 2007/12/29 19:34:55 dyoung Exp $ */
/* $NetBSD: mii.c,v 1.44 2008/01/10 07:29:41 dyoung Exp $ */
/*-
* Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@ -43,7 +43,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: mii.c,v 1.43 2007/12/29 19:34:55 dyoung Exp $");
__KERNEL_RCSID(0, "$NetBSD: mii.c,v 1.44 2008/01/10 07:29:41 dyoung Exp $");
#include <sys/param.h>
#include <sys/device.h>
@ -212,7 +212,6 @@ mii_detach(struct mii_data *mii, int phyloc, int offloc)
offloc != child->mii_offset)
continue;
}
LIST_REMOVE(child, mii_list);
(void) config_detach(&child->mii_dev, DETACH_FORCE);
}
}
@ -239,6 +238,12 @@ phy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
return PHY_SERVICE(sc, mii, cmd);
}
int
mii_ifmedia_change(struct mii_data *mii)
{
return ifmedia_change(&mii->mii_media, mii->mii_ifp);
}
/*
* Media changed; notify all PHYs.
*/

View File

@ -1,4 +1,4 @@
/* $NetBSD: mii_physubr.c,v 1.55 2007/12/29 19:34:55 dyoung Exp $ */
/* $NetBSD: mii_physubr.c,v 1.56 2008/01/10 07:29:41 dyoung Exp $ */
/*-
* Copyright (c) 1998, 1999, 2000, 2001 The NetBSD Foundation, Inc.
@ -42,7 +42,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: mii_physubr.c,v 1.55 2007/12/29 19:34:55 dyoung Exp $");
__KERNEL_RCSID(0, "$NetBSD: mii_physubr.c,v 1.56 2008/01/10 07:29:41 dyoung Exp $");
#include <sys/param.h>
#include <sys/device.h>
@ -572,6 +572,7 @@ mii_phy_detach(struct device *self, int flags)
callout_stop(&sc->mii_nway_ch);
mii_phy_delete_media(sc);
LIST_REMOVE(sc, mii_list);
return (0);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: miivar.h,v 1.48 2007/12/09 20:28:03 jmcneill Exp $ */
/* $NetBSD: miivar.h,v 1.49 2008/01/10 07:29:42 dyoung Exp $ */
/*-
* Copyright (c) 1998, 1999, 2000, 2001 The NetBSD Foundation, Inc.
@ -240,6 +240,8 @@ void mii_tick(struct mii_data *);
void mii_pollstat(struct mii_data *);
void mii_down(struct mii_data *);
int mii_ifmedia_change(struct mii_data *);
int mii_phy_activate(struct device *, enum devact);
int mii_phy_detach(struct device *, int);