[PATCH 1/6] miidev: fix auto negotiation

Roberto Nibali rnibali at gmail.com
Mon Jun 18 13:52:44 EDT 2012


Hi

On Mon, Jun 18, 2012 at 4:47 PM, Johannes Stezenbach <js at sig21.net> wrote:

> The auto negotiation result is the intersect
> of the advertised abilities and the link partner abilities.
>
> Signed-off-by: Johannes Stezenbach <js at sig21.net>
> ---
>  drivers/net/miidev.c |   16 ++++++++++------
>  1 file changed, 10 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/net/miidev.c b/drivers/net/miidev.c
> index f47fc9e..272234e 100644
> --- a/drivers/net/miidev.c
> +++ b/drivers/net/miidev.c
> @@ -123,6 +123,7 @@ int miidev_wait_aneg(struct mii_device *mdev)
>
>  int miidev_get_status(struct mii_device *mdev)
>  {
> +       int ret, status, adv, lpa;
>        int ret, status;
>
>        ret = mii_read(mdev, mdev->address, MII_BMSR);
> @@ -136,13 +137,16 @@ int miidev_get_status(struct mii_device *mdev)
>                goto err_out;
>
>        if (ret & BMCR_ANENABLE) {
> -               ret = mii_read(mdev, mdev->address, MII_LPA);
> -               if (ret < 0)
> +               lpa = mii_read(mdev, mdev->address, MII_LPA);
> +               if (lpa < 0)
>                        goto err_out;
> -
> -               status |= ret & LPA_DUPLEX ? MIIDEV_STATUS_IS_FULL_DUPLEX
> : 0;
> -               status |= ret & LPA_100 ? MIIDEV_STATUS_IS_100MBIT :
> -                               MIIDEV_STATUS_IS_10MBIT;
> +               adv = mii_read(mdev, mdev->address, MII_ADVERTISE);
> +               if (adv < 0)
> +                       goto err_out;
> +               lpa &= adv;
>

Good catch and obviously correct. I reckon since nowadays most PHY's
advertise ADVERTISE_FULL or ADVERTISE_ALL, this has never been an issue for
anybody so far.

Best regards
Roberto
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.infradead.org/pipermail/barebox/attachments/20120618/189042cd/attachment.html>


More information about the barebox mailing list