On Mon, Sep 17, 2012 at 07:59:28AM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote: > Adapt phylib from linux > > switch all the driver to it > > This will allow to have > - phy drivers > - to only connect the phy at then opening of the device > - if the phy is not ready or not up fail on open > > Same behaviour as in linux and will allow to share code and simplify porting. > > Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@xxxxxxxxxxxx> > --- [...] > +/* Automatically gets and returns the PHY device */ > +int phy_device_connect(struct eth_device *edev, struct mii_device *bus, int addr, > + void (*adjust_link) (struct eth_device *edev), > + u32 flags, phy_interface_t interface) > +{ > + struct phy_driver* drv; > + struct phy_device* dev = NULL; > + unsigned int i; > + int ret = -EINVAL; > + > + if (!edev->phydev) { > + if (addr >= 0) { > + dev = get_phy_device(bus, addr); > + if (IS_ERR(dev)) { > + ret = PTR_ERR(dev); > + goto fail; > + } > + > + dev->attached_dev = edev; > + dev->interface = interface; > + dev->dev_flags = flags; > + > + ret = register_device(&dev->dev); > + if (ret) > + goto fail; > + } else { > + for (i = 0; i < PHY_MAX_ADDR && !edev->phydev; i++) { > + dev = get_phy_device(bus, i); > + if (IS_ERR(dev)) > + continue; > + > + dev->attached_dev = edev; > + dev->interface = interface; > + dev->dev_flags = flags; > + > + ret = register_device(&dev->dev); > + if (ret) > + goto fail; > + } > + > + if (i == 32) { > + ret = -EIO; > + goto fail; > + } I just found out the hard way that this does not work with a phy_id of 31. I don't know exactly the intention of this code, but I would just test for !edev->phydev instead of i==32. Sascha -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list barebox@xxxxxxxxxxxxxxxxxxx http://lists.infradead.org/mailman/listinfo/barebox