On Sun, Jun 26, 2016 at 10:09:05PM +1000, Jonathan Matthew wrote:
> I recently picked up a cheap Cherry View based mini-pc and found its onboard
> RTL8152 (usb) ethernet wasn't supported, so I ported ure(4) from freebsd.
> 
> I'm fairly sure there are some endianness issues, but I can't test on a
> big endian platform as this is the only hardware I have.  It also leaves the
> chip in some terrible state where it can't be recognised after a reboot,
> and you have to remove power before it'll work again.
> 
> Aside from those problems, the driver does actually work on amd64 so I'd like
> to get it in the tree.

> +int
> +ure_miibus_readreg(struct device *dev, int phy, int reg)
> +{
> +     struct ure_softc        *sc = (void *)dev;
> +     uint16_t                val;
> +
> +     if (usbd_is_dying(sc->ure_udev))
> +             return 0;
> +
> +     if (sc->ure_phyno != phy)
> +             return 0;
> +
> +     ure_lock_mii(sc);
> +     val = ure_ocp_reg_read(sc, URE_OCP_BASE_MII + reg * 2);
> +     ure_unlock_mii(sc);
> +
> +     return val;     /* letoh16? */
> +}
> +
> +void
> +ure_miibus_writereg(struct device *dev, int phy, int reg, int val)
> +{
> +     struct ure_softc        *sc = (void *)dev;
> +
> +     if (sc->ure_phyno != phy)
> +             return;
> +
> +     ure_lock_mii(sc);
> +     ure_ocp_reg_write(sc, URE_OCP_BASE_MII + reg * 2, val); /* htole16? */
> +     ure_unlock_mii(sc);
> +}
> +

Wouldn't it be easier to specify the phy id in mii_attach() instead
of MII_PHY_ANY and these checks?

Reply via email to