mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] mii-tool fixes
@ 2014-05-21 12:09 Sascha Hauer
  2014-05-21 12:09 ` [PATCH 1/3] mii-tool: Fix string length Sascha Hauer
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Sascha Hauer @ 2014-05-21 12:09 UTC (permalink / raw)
  To: barebox

The mii-tool command has several bugs in the gigabit support.
This series has some fixes for them.

----------------------------------------------------------------
Sascha Hauer (3):
      mii-tool: Fix string length
      mii-tool: Fix gigabit link test
      mii-tool: Fix gigabit advertise / link partner ability mixup

 commands/miitool.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/3] mii-tool: Fix string length
  2014-05-21 12:09 [PATCH] mii-tool fixes Sascha Hauer
@ 2014-05-21 12:09 ` Sascha Hauer
  2014-05-21 12:09 ` [PATCH 2/3] mii-tool: Fix gigabit link test Sascha Hauer
  2014-05-21 12:09 ` [PATCH 3/3] mii-tool: Fix gigabit advertise / link partner ability mixup Sascha Hauer
  2 siblings, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2014-05-21 12:09 UTC (permalink / raw)
  To: barebox

media_list writes into a static string. Worst case length of this string
is 125 bytes, but the function only allocates 100 bytes. Use 256 bytes which
is long enough for some extensions.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 commands/miitool.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/commands/miitool.c b/commands/miitool.c
index 1e5d4eb..81b5a25 100644
--- a/commands/miitool.c
+++ b/commands/miitool.c
@@ -61,7 +61,7 @@ const struct {
 
 static const char *media_list(unsigned mask, unsigned mask2, int best)
 {
-	static char buf[100];
+	static char buf[256];
 	int i;
 
 	*buf = '\0';
-- 
2.0.0.rc0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 2/3] mii-tool: Fix gigabit link test
  2014-05-21 12:09 [PATCH] mii-tool fixes Sascha Hauer
  2014-05-21 12:09 ` [PATCH 1/3] mii-tool: Fix string length Sascha Hauer
@ 2014-05-21 12:09 ` Sascha Hauer
  2014-05-21 12:09 ` [PATCH 3/3] mii-tool: Fix gigabit advertise / link partner ability mixup Sascha Hauer
  2 siblings, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2014-05-21 12:09 UTC (permalink / raw)
  To: barebox

media_list tests for gigabit phys like this:

if (mask & BMCR_SPEED1000)

mask does not contain the value of the BMCR register though, so the
test is completely bogus. Test for mask2 instead which is only
nonzero when the phy has gigabit capabilities.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 commands/miitool.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/commands/miitool.c b/commands/miitool.c
index 81b5a25..341506c 100644
--- a/commands/miitool.c
+++ b/commands/miitool.c
@@ -66,7 +66,7 @@ static const char *media_list(unsigned mask, unsigned mask2, int best)
 
 	*buf = '\0';
 
-	if (mask & BMCR_SPEED1000) {
+	if (mask2) {
 		if (mask2 & ADVERTISE_1000FULL) {
 			strcat(buf, " ");
 			strcat(buf, "1000baseT-FD");
-- 
2.0.0.rc0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 3/3] mii-tool: Fix gigabit advertise / link partner ability mixup
  2014-05-21 12:09 [PATCH] mii-tool fixes Sascha Hauer
  2014-05-21 12:09 ` [PATCH 1/3] mii-tool: Fix string length Sascha Hauer
  2014-05-21 12:09 ` [PATCH 2/3] mii-tool: Fix gigabit link test Sascha Hauer
@ 2014-05-21 12:09 ` Sascha Hauer
  2 siblings, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2014-05-21 12:09 UTC (permalink / raw)
  To: barebox

bmcr2 contains the gigabit advertise bits and lpa2 contains the gigabit
link partner ability bits, not the other way round.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 commands/miitool.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/commands/miitool.c b/commands/miitool.c
index 341506c..64c2a93 100644
--- a/commands/miitool.c
+++ b/commands/miitool.c
@@ -209,7 +209,7 @@ static int show_basic_mii(struct mii_bus *mii, struct phy_device *phydev,
 			printf("remote fault, ");
 		printf((bmsr & BMSR_LSTATUS) ? "link ok" : "no link");
 		printf("\n  capabilities:%s", media_list(bmsr >> 6, bmcr2, 0));
-		printf("\n  advertising: %s", media_list(advert, lpa2 >> 2, 0));
+		printf("\n  advertising: %s", media_list(advert, bmcr2, 0));
 
 #define LPA_ABILITY_MASK	(LPA_10HALF | LPA_10FULL \
 				| LPA_100HALF | LPA_100FULL \
@@ -217,7 +217,7 @@ static int show_basic_mii(struct mii_bus *mii, struct phy_device *phydev,
 
 		if (lkpar & LPA_ABILITY_MASK)
 			printf("\n  link partner:%s",
-				media_list(lkpar, bmcr2, 0));
+				media_list(lkpar, lpa2 >> 2, 0));
 		printf("\n");
 	}
 
-- 
2.0.0.rc0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-05-21 12:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-21 12:09 [PATCH] mii-tool fixes Sascha Hauer
2014-05-21 12:09 ` [PATCH 1/3] mii-tool: Fix string length Sascha Hauer
2014-05-21 12:09 ` [PATCH 2/3] mii-tool: Fix gigabit link test Sascha Hauer
2014-05-21 12:09 ` [PATCH 3/3] mii-tool: Fix gigabit advertise / link partner ability mixup Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox