[U-Boot] [PATCH v2] NET: add ENC28J60 driver using SPI framework

Mike Frysinger vapier at gentoo.org
Mon Sep 6 22:37:22 CEST 2010


On Monday, September 06, 2010 10:59:16 Reinhard Meyer wrote:
> +int enc_miiphy_read(const char *devname, u8 phy_adr, u8 reg, u16 *value)
> +{
> +	struct eth_device *dev = eth_get_dev_by_name(devname);
> +	if (dev) {
> +		enc_dev_t *enc = to_enc(dev);
> +
> +		if (phy_adr != 0)
> +			return -1;
> +		spi_claim_bus(enc->slave);
> +		*value = phy_read(enc, reg);
> +		spi_release_bus(enc->slave);
> +		return 0;
> +	}
> +	return -1;
> +}

seems like this (and the write func) would be nicer if it were:
if (!dev)
	return -1;
...

> +static int enc_init(struct eth_device *dev, bd_t *bis)
> +{
> +	enc_dev_t *enc = to_enc(dev);
> +	u8 status;
> +	uint64_t etime;
> +
> +	spi_claim_bus(enc->slave);

check the return value

otherwise this looks pretty good ... i'll try and test on my hardware this 
week
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20100906/12f3258f/attachment.pgp 


More information about the U-Boot mailing list