From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from mail-yw0-f49.google.com ([209.85.213.49]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1Sgg8R-0006e8-O5 for barebox@lists.infradead.org; Mon, 18 Jun 2012 17:53:08 +0000 Received: by yhjj52 with SMTP id j52so4422787yhj.36 for ; Mon, 18 Jun 2012 10:53:05 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <1340030880-10062-2-git-send-email-js@sig21.net> References: <1340030880-10062-1-git-send-email-js@sig21.net> <1340030880-10062-2-git-send-email-js@sig21.net> From: Roberto Nibali Date: Mon, 18 Jun 2012 19:52:44 +0200 Message-ID: List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: multipart/mixed; boundary="===============7204043577796299369==" Sender: barebox-bounces@lists.infradead.org Errors-To: barebox-bounces+u.kleine-koenig=pengutronix.de@lists.infradead.org Subject: Re: [PATCH 1/6] miidev: fix auto negotiation To: Johannes Stezenbach Cc: barebox@lists.infradead.org --===============7204043577796299369== Content-Type: multipart/alternative; boundary=14dae93408ab7f0f4204c2c2d69d --14dae93408ab7f0f4204c2c2d69d Content-Type: text/plain; charset=ISO-8859-1 Hi On Mon, Jun 18, 2012 at 4:47 PM, Johannes Stezenbach wrote: > The auto negotiation result is the intersect > of the advertised abilities and the link partner abilities. > > Signed-off-by: Johannes Stezenbach > --- > 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 --14dae93408ab7f0f4204c2c2d69d Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Hi

On Mon, Jun 18, 2012 at 4:47 PM, Johan= nes Stezenbach <js@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@s= ig21.net>
---
=A0drivers/net/miidev.c | =A0 16 ++++++++++------
=A01 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)

=A0int miidev_get_status(struct mii_device *mdev)
=A0{
+ =A0 =A0 =A0 int ret, status, adv, lpa;
=A0 =A0 =A0 =A0int ret, status;

=A0 =A0 =A0 =A0ret =3D mii_read(mdev, mdev->address, MII_BMSR);
@@ -136,13 +137,16 @@ int miidev_get_status(struct mii_device *mdev)
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0goto err_out;

=A0 =A0 =A0 =A0if (ret & BMCR_ANENABLE) {
- =A0 =A0 =A0 =A0 =A0 =A0 =A0 ret =3D mii_read(mdev, mdev->address, MII_= LPA);
- =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (ret < 0)
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 lpa =3D mii_read(mdev, mdev->address, MII_= LPA);
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (lpa < 0)
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0goto err_out;
-
- =A0 =A0 =A0 =A0 =A0 =A0 =A0 status |=3D ret & LPA_DUPLEX ? MIIDEV_STA= TUS_IS_FULL_DUPLEX : 0;
- =A0 =A0 =A0 =A0 =A0 =A0 =A0 status |=3D ret & LPA_100 ? MIIDEV_STATUS= _IS_100MBIT :
- =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 MIIDEV_STATUS= _IS_10MBIT;
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 adv =3D mii_read(mdev, mdev->address, MII_= ADVERTISE);
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (adv < 0)
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 goto err_out;
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 lpa &=3D adv;

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

Best regards
Roberto
--14dae93408ab7f0f4204c2c2d69d-- --===============7204043577796299369== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox --===============7204043577796299369==--