From owner-svn-src-stable@FreeBSD.ORG Sun Oct 17 13:07:35 2010 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 860E5106564A; Sun, 17 Oct 2010 13:07:35 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5918C8FC17; Sun, 17 Oct 2010 13:07:35 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o9HD7ZMq031653; Sun, 17 Oct 2010 13:07:35 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o9HD7ZnI031651; Sun, 17 Oct 2010 13:07:35 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <201010171307.o9HD7ZnI031651@svn.freebsd.org> From: Marius Strobl Date: Sun, 17 Oct 2010 13:07:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r213968 - stable/7/sys/dev/mii X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 17 Oct 2010 13:07:35 -0000 Author: marius Date: Sun Oct 17 13:07:35 2010 New Revision: 213968 URL: http://svn.freebsd.org/changeset/base/213968 Log: MFC: r182067 Move the code that looks for the companion phy to a subroutine to make sure we get the error handling right in both places. This also simplifies the code somewhat. Modified: stable/7/sys/dev/mii/mlphy.c Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/dev/mii/mlphy.c ============================================================================== --- stable/7/sys/dev/mii/mlphy.c Sun Oct 17 13:06:18 2010 (r213967) +++ stable/7/sys/dev/mii/mlphy.c Sun Oct 17 13:07:35 2010 (r213968) @@ -177,6 +177,25 @@ mlphy_attach(dev) return (0); } +static struct mii_softc * +mlphy_find_other(device_t mii) +{ + device_t *devlist; + struct mii_softc *retval; + int i, devs; + + retval = NULL; + if (device_get_children(mii, &devlist, &devs)) + return (NULL); + for (i = 0; i < devs; i++) + if (strcmp(device_get_name(devlist[i]), "mlphy")) { + retval = device_get_softc(devlist[i]); + break; + } + free(devlist, M_TEMP); + return (retval); +} + static int mlphy_service(xsc, mii, cmd) struct mii_softc *xsc; @@ -187,22 +206,13 @@ mlphy_service(xsc, mii, cmd) struct mii_softc *other = NULL; struct mlphy_softc *msc = (struct mlphy_softc *)xsc; struct mii_softc *sc = (struct mii_softc *)&msc->ml_mii; - device_t *devlist; - int devs, i, other_inst, reg; + int other_inst, reg; /* * See if there's another PHY on this bus with us. * If so, we may need it for 10Mbps modes. */ - if (device_get_children(msc->ml_mii.mii_dev, &devlist, &devs) == 0) { - for (i = 0; i < devs; i++) { - if (strcmp(device_get_name(devlist[i]), "mlphy")) { - other = device_get_softc(devlist[i]); - break; - } - } - free(devlist, M_TEMP); - } + other = mlphy_find_other(msc->ml_mii.mii_dev); switch (cmd) { case MII_POLLSTAT: @@ -397,20 +407,9 @@ mlphy_status(sc) struct mlphy_softc *msc = (struct mlphy_softc *)sc; struct mii_data *mii = msc->ml_mii.mii_pdata; struct mii_softc *other = NULL; - device_t *devlist; - int devs, i; /* See if there's another PHY on the bus with us. */ - devs = 0; - device_get_children(msc->ml_mii.mii_dev, &devlist, &devs); - for (i = 0; i < devs; i++) { - if (strcmp(device_get_name(devlist[i]), "mlphy")) { - other = device_get_softc(devlist[i]); - break; - } - } - free(devlist, M_TEMP); - + other = mlphy_find_other(msc->ml_mii.mii_dev); if (other == NULL) return;