Subject: Re: [PATCH 2/6] phylib: add the ICPlus IP175C PHY driver

From: Jeff Garzik <[email-masked]>
Date: Wed, 09 May 2007 19:35:35 -0400

Kim Phillips wrote:
> +		/* master reset */
> +		err = phydev->bus->write(phydev->bus, 30, 0, 0x175c);
> +		if (err < 0)
> +			return err;
> +
> +		/* data sheet specifies reset period is 2 msec */
> +		udelay(3000);
> +
> +		/* enable IP175C mode */
> +		err = phydev->bus->write(phydev->bus, 29, 31, 0x175c);
> +		if (err < 0)
> +			return err;

1) use mdelay()

2) write-followed-by-delay does not guarantee the delay, because you 
have not factored in PCI posting (or other bus delays)

> +		/* Set MII0 speed and duplex (in PHY mode) */
> +		err = phydev->bus->write(phydev->bus, 29, 22, 0x420);
> +		if (err < 0)
> +			return err;
> +
> +		for (i=0; i<5; i++) {
> +			err = phydev->bus->write(phydev->bus, i, MII_BMCR, BMCR_RESET);
> +		}
> +		udelay(3000);

ditto

> +		full_reset_performed = 1;
> +	}
> +
> +	if (phydev->addr != 4) {
> +		phydev->state = PHY_RUNNING;
> +		phydev->speed = SPEED_100;
> +		phydev->duplex = DUPLEX_FULL;
> +		phydev->link = 1;
> +		netif_carrier_on(phydev->attached_dev);
> +	}
> +
> +	return 0;
> +}
> +
> +static int ip175c_read_status(struct phy_device *phydev)
> +{
> +	if (phydev->addr == 4) { /* if WAN port */
> +		genphy_read_status(phydev);
> +	} else {
> +		/* Don't need to read status for switch ports */
> +		phydev->irq = PHY_IGNORE_INTERRUPT;
> +	}
> +
> +	return 0;
> +}
> +
> +
> +static int ip175c_config_aneg(struct phy_device *phydev)
> +{
> +	if (phydev->addr == 4) { /* if WAN port */
> +		genphy_config_aneg(phydev);
> +	}

codingstyle: remove braces around single C statements