if (mii_val[MII_BMCR] == 0xffff) {
if (mii_val[MII_BMCR] == 0xffff  || mii_val[MII_BMSR] == 0x0000) {
int show_basic_mii(int sock, int phy_id){    char buf[100];    int i, mii_val[32];    int bmcr, bmsr, advert, lkpar;    /* Some bits in the BMSR are latched, but we can't rely on being       the only reader, so only the current values are meaningful */    mdio_read(sock, MII_BMSR);    for (i = 0; i < ((verbose > 1) ? 32 : 8); i++)	mii_val[i] = mdio_read(sock, i);    if (mii_val[MII_BMCR] == 0xffff) {	fprintf(stderr, "  No MII transceiver present!.\n");	return -1;    }    /* Descriptive rename. */    bmcr = mii_val[MII_BMCR]; bmsr = mii_val[MII_BMSR];    advert = mii_val[MII_ANAR]; lkpar = mii_val[MII_ANLPAR];    sprintf(buf, "%s: ", ifr.ifr_name);    if (bmcr & MII_BMCR_AN_ENA) {	if (bmsr & MII_BMSR_AN_COMPLETE) {	    if (advert & lkpar) {		strcat(buf, (lkpar & MII_AN_ACK) ?		       "negotiated" : "no autonegotiation,");		strcat(buf, media_list(advert & lkpar, 1));		strcat(buf, ", ");	    } else {		strcat(buf, "autonegotiation failed, ");	    }	} else if (bmcr & MII_BMCR_RESTART) {	    strcat(buf, "autonegotiation restarted, ");	}    } else {	sprintf(buf+strlen(buf), "%s Mbit, %s duplex, ",	       (bmcr & MII_BMCR_100MBIT) ? "100" : "10",	       (bmcr & MII_BMCR_DUPLEX) ? "full" : "half");    }    strcat(buf, (bmsr & MII_BMSR_LINK_VALID) ? "link ok" : "no link");    if (opt_watch) {	if (opt_log) {	    syslog(LOG_INFO, buf);	} else {	    char s[20];	    time_t t = time(NULL);	    strftime(s, sizeof(s), "%T", localtime(&t));	    printf("%s %s\n", s, buf);	}    } else {	printf("%s\n", buf);    }    if (verbose > 1) {	printf("  registers for MII PHY %d: ", phy_id);	for (i = 0; i < 32; i++)	    printf("%s %4.4x", ((i % 8) ? "" : "\n   "), mii_val[i]);	printf("\n");    }    if (verbose) {	printf("  product info: ");	for (i = 0; i < NMII; i++)	    if ((mii_id[i].id1 == mii_val[2]) &&		(mii_id[i].id2 == (mii_val[3] & 0xfff0)))		break;	if (i < NMII)	    printf("%s rev %d\n", mii_id[i].name, mii_val[3]&0x0f);	else	    printf("vendor %02x:%02x:%02x, model %d rev %d\n",		   mii_val[2]>>10, (mii_val[2]>>2)&0xff,		   ((mii_val[2]<<6)|(mii_val[3]>>10))&0xff,		   (mii_val[3]>>4)&0x3f, mii_val[3]&0x0f);	printf("  basic mode:   ");	if (bmcr & MII_BMCR_RESET)	    printf("software reset, ");	if (bmcr & MII_BMCR_LOOPBACK)	    printf("loopback, ");	if (bmcr & MII_BMCR_ISOLATE)	    printf("isolate, ");	if (bmcr & MII_BMCR_COLTEST)	    printf("collision test, ");	if (bmcr & MII_BMCR_AN_ENA) {	    printf("autonegotiation enabled\n");	} else {	    printf("%s Mbit, %s duplex\n",		   (bmcr & MII_BMCR_100MBIT) ? "100" : "10",		   (bmcr & MII_BMCR_DUPLEX) ? "full" : "half");	}	printf("  basic status: ");	if (bmsr & MII_BMSR_AN_COMPLETE)	    printf("autonegotiation complete, ");	else if (bmcr & MII_BMCR_RESTART)	    printf("autonegotiation restarted, ");	if (bmsr & MII_BMSR_REMOTE_FAULT)	    printf("remote fault, ");	printf((bmsr & MII_BMSR_LINK_VALID) ? "link ok" : "no link");	printf("\n  capabilities:%s", media_list(bmsr >> 6, 0));	printf("\n  advertising: %s", media_list(advert, 0));	if (lkpar & MII_AN_ABILITY_MASK)	    printf("\n  link partner:%s", media_list(lkpar, 0));	printf("\n");    }    fflush(stdout);    return 0;}