mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/2] net phy: Add support for finding a mdio bus by its name
@ 2013-02-07 11:09 Sascha Hauer
  2013-02-07 11:09 ` [PATCH 2/2] miitool: Add support for examing mdio bus Sascha Hauer
  2013-02-07 12:02 ` [PATCH 1/2] net phy: Add support for finding a mdio bus by its name Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 2 replies; 10+ messages in thread
From: Sascha Hauer @ 2013-02-07 11:09 UTC (permalink / raw)
  To: barebox

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/net/phy/mdio_bus.c |   19 +++++++++++++++++++
 include/linux/phy.h        |    3 +++
 2 files changed, 22 insertions(+)

diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
index d1d802b..3c4be1c 100644
--- a/drivers/net/phy/mdio_bus.c
+++ b/drivers/net/phy/mdio_bus.c
@@ -25,6 +25,8 @@
 #include <linux/phy.h>
 #include <linux/err.h>
 
+static LIST_HEAD(mii_bus_list);
+
 /**
  * mdiobus_register - bring up all the PHYs on a given bus and attach them to bus
  * @bus: target mii_bus
@@ -57,6 +59,8 @@ int mdiobus_register(struct mii_bus *bus)
 	if (bus->reset)
 		bus->reset(bus);
 
+	list_add_tail(&bus->list, &mii_bus_list);
+
 	pr_info("%s: probed\n", dev_name(&bus->dev));
 	return 0;
 }
@@ -71,9 +75,24 @@ void mdiobus_unregister(struct mii_bus *bus)
 			unregister_device(&bus->phy_map[i]->dev);
 		bus->phy_map[i] = NULL;
 	}
+
+	list_del(&bus->list);
 }
 EXPORT_SYMBOL(mdiobus_unregister);
 
+struct mii_bus *mdiobus_find(const char *name)
+{
+	struct mii_bus *bus;
+
+	list_for_each_entry(bus, &mii_bus_list, list) {
+		if (!strcmp(dev_name(&bus->dev), name))
+			return bus;
+	}
+
+	return NULL;
+}
+EXPORT_SYMBOL(mdiobus_find);
+
 struct phy_device *mdiobus_scan(struct mii_bus *bus, int addr)
 {
 	struct phy_device *phydev;
diff --git a/include/linux/phy.h b/include/linux/phy.h
index 6c9cac9..9ab6e06 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -84,11 +84,14 @@ struct mii_bus {
 
 	/* PHY addresses to be ignored when probing */
 	u32 phy_mask;
+
+	struct list_head list;
 };
 #define to_mii_bus(d) container_of(d, struct mii_bus, dev)
 
 int mdiobus_register(struct mii_bus *bus);
 void mdiobus_unregister(struct mii_bus *bus);
+struct mii_bus *mdiobus_find(const char *name);
 struct phy_device *mdiobus_scan(struct mii_bus *bus, int addr);
 
 /**
-- 
1.7.10.4


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

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

* [PATCH 2/2] miitool: Add support for examing mdio bus
  2013-02-07 11:09 [PATCH 1/2] net phy: Add support for finding a mdio bus by its name Sascha Hauer
@ 2013-02-07 11:09 ` Sascha Hauer
  2013-02-07 12:02 ` [PATCH 1/2] net phy: Add support for finding a mdio bus by its name Jean-Christophe PLAGNIOL-VILLARD
  1 sibling, 0 replies; 10+ messages in thread
From: Sascha Hauer @ 2013-02-07 11:09 UTC (permalink / raw)
  To: barebox

Current miitool usage is limited to a single phy on a mdio bus.

For debugging purposes it is useful to be able to examine a mdio bus
instead of a single phy only.

This adds support for this to the miitool command.

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

diff --git a/commands/miitool.c b/commands/miitool.c
index 3a9ac45..b9e2333 100644
--- a/commands/miitool.c
+++ b/commands/miitool.c
@@ -37,23 +37,36 @@
 #include <linux/stat.h>
 #include <xfuncs.h>
 #include <linux/mii.h>
+#include <linux/phy.h>
 
-static u16 mdio_read(int fd, int offset)
+static int phy_fd;
+
+static u16 mdio_file_read(int offset)
 {
 	int ret;
 	u16 buf;
 
-	ret = lseek(fd, offset << 1, SEEK_SET);
+	ret = lseek(phy_fd, offset << 1, SEEK_SET);
 	if (ret < 0)
 		return 0;
 
-	ret = read(fd, &buf, sizeof(u16));
+	ret = read(phy_fd, &buf, sizeof(u16));
 	if (ret < 0)
 		return 0;
 
 	return buf;
 }
 
+static struct mii_bus *mii_bus;
+static int mii_address;
+
+static u16 mdio_bus_read(int offset)
+{
+	return mdiobus_read(mii_bus, mii_address, offset);
+}
+
+static u16 (*mdio_read)(int offset);
+
 /* Table of known MII's */
 static const struct {
 	u_short	id1, id2;
@@ -101,7 +114,7 @@ static char *media_list(int mask, int best)
 	return buf;
 }
 
-static int show_basic_mii(int fd, int verbose)
+static int show_basic_mii(int verbose)
 {
 	char buf[100];
 	int i, mii_val[32];
@@ -109,9 +122,9 @@ static int show_basic_mii(int fd, int verbose)
 
 	/* Some bits in the BMSR are latched, but we can't rely on being
 	   the only reader, so only the current values are meaningful */
-	mdio_read(fd, MII_BMSR);
+	mdio_read(MII_BMSR);
 	for (i = 0; i < ((verbose > 1) ? 32 : 8); i++)
-		mii_val[i] = mdio_read(fd, i);
+		mii_val[i] = mdio_read(i);
 
 	if (mii_val[MII_BMCR] == 0xffff) {
 		fprintf(stderr, "  No MII transceiver present!.\n");
@@ -213,18 +226,25 @@ static int show_basic_mii(int fd, int verbose)
 
 static int do_miitool(int argc, char *argv[])
 {
-	char *filename;
+	char *filename = NULL;
+	char *devname = NULL;
 	int opt;
 	int argc_min;
-	int fd;
 	int verbose;
+	int address = -1;
 
 	verbose = 0;
-	while ((opt = getopt(argc, argv, "v")) > 0) {
+	while ((opt = getopt(argc, argv, "vd:a:")) > 0) {
 		switch (opt) {
 		case 'v':
 			verbose++;
 			break;
+		case 'd':
+			devname = optarg;
+			break;
+		case 'a':
+			address = simple_strtoul(optarg, NULL, 0);
+			break;
 		default:
 			return COMMAND_ERROR_USAGE;
 		}
@@ -232,27 +252,63 @@ static int do_miitool(int argc, char *argv[])
 
 	argc_min = optind + 1;
 
-	if (argc < argc_min)
+	if (argc >= argc_min)
+		filename = argv[optind];
+
+	if (filename && devname) {
+		printf("both filename and devicename given\n");
 		return COMMAND_ERROR_USAGE;
+	}
 
-	filename = argv[optind];
+	if (!filename && !devname) {
+		printf("no filename or devicename given\n");
+		return COMMAND_ERROR_USAGE;
+	}
+
+	if (filename) {
+		phy_fd = open(filename, O_RDONLY);
+		if (phy_fd < 0) {
+			printf("unable to read %s\n", filename);
+			return COMMAND_ERROR;
+		}
+
+		mdio_read = mdio_file_read;
+
+		show_basic_mii(verbose);
+	} else {
+		mii_bus = mdiobus_find(devname);
+
+		if (!mii_bus)
+			return -ENODEV;
 
-	fd = open(filename, O_RDONLY);
-	if (fd < 0) {
-		printf("unable to read %s\n", filename);
-		return COMMAND_ERROR;
+		mdio_read = mdio_bus_read;
+		if (address < 0) {
+			for (mii_address = 0; mii_address < PHY_MAX_ADDR; mii_address++) {
+				printf("`---- phyadr %d:\n",
+						mii_address);
+				show_basic_mii(verbose);
+			}
+		} else {
+			mii_address = address;
+			show_basic_mii(verbose);
+		}
 	}
 
-	show_basic_mii(fd, verbose);
 
-	close(fd);
+	if (filename)
+		close(phy_fd);
 
 	return COMMAND_SUCCESS;
 }
 
 BAREBOX_CMD_HELP_START(miitool)
-BAREBOX_CMD_HELP_USAGE("miitool [[[-v] -v] -v] <phy>\n")
-BAREBOX_CMD_HELP_SHORT("view status for MII <phy>.\n")
+BAREBOX_CMD_HELP_USAGE("miitool [OPTIONS] [phy]\n")
+BAREBOX_CMD_HELP_SHORT("view status mii phy device status\n")
+BAREBOX_CMD_HELP_SHORT("Use [phy] to view a phy connected to an ethernet device\n")
+BAREBOX_CMD_HELP_SHORT("or -d <devname> [-a <phyadr>] to examine a mii bus\n")
+BAREBOX_CMD_HELP_OPT("-v", "\tverbose, may be given multiple times\n")
+BAREBOX_CMD_HELP_OPT("-d <devname>", "work on miibus <devname>\n")
+BAREBOX_CMD_HELP_OPT("-a <phyadr>", "Use phy address <phyadr>, used together with -d\n")
 BAREBOX_CMD_HELP_END
 
 /**
-- 
1.7.10.4


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

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

* Re: [PATCH 1/2] net phy: Add support for finding a mdio bus by its name
  2013-02-07 11:09 [PATCH 1/2] net phy: Add support for finding a mdio bus by its name Sascha Hauer
  2013-02-07 11:09 ` [PATCH 2/2] miitool: Add support for examing mdio bus Sascha Hauer
@ 2013-02-07 12:02 ` Jean-Christophe PLAGNIOL-VILLARD
  2013-02-07 12:20   ` Sascha Hauer
  1 sibling, 1 reply; 10+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2013-02-07 12:02 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

On 12:09 Thu 07 Feb     , Sascha Hauer wrote:
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> ---
>  drivers/net/phy/mdio_bus.c |   19 +++++++++++++++++++
>  include/linux/phy.h        |    3 +++
>  2 files changed, 22 insertions(+)
> 
> diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
> index d1d802b..3c4be1c 100644
> --- a/drivers/net/phy/mdio_bus.c
> +++ b/drivers/net/phy/mdio_bus.c
> @@ -25,6 +25,8 @@
>  #include <linux/phy.h>
>  #include <linux/err.h>
>  
> +static LIST_HEAD(mii_bus_list);
> +
>  /**
>   * mdiobus_register - bring up all the PHYs on a given bus and attach them to bus
>   * @bus: target mii_bus
> @@ -57,6 +59,8 @@ int mdiobus_register(struct mii_bus *bus)
>  	if (bus->reset)
>  		bus->reset(bus);
>  
> +	list_add_tail(&bus->list, &mii_bus_list);
> +
>  	pr_info("%s: probed\n", dev_name(&bus->dev));
>  	return 0;
>  }
> @@ -71,9 +75,24 @@ void mdiobus_unregister(struct mii_bus *bus)
>  			unregister_device(&bus->phy_map[i]->dev);
>  		bus->phy_map[i] = NULL;
>  	}
> +
> +	list_del(&bus->list);
>  }
>  EXPORT_SYMBOL(mdiobus_unregister);
>  
> +struct mii_bus *mdiobus_find(const char *name)
> +{
> +	struct mii_bus *bus;
> +
> +	list_for_each_entry(bus, &mii_bus_list, list) {
	no use bus_for_each

Best Regards,
J.
> +		if (!strcmp(dev_name(&bus->dev), name))
> +			return bus;
> +	}
> +
> +	return NULL;
> +}
> +EXPORT_SYMBOL(mdiobus_find);
> +
>  struct phy_device *mdiobus_scan(struct mii_bus *bus, int addr)
>  {
>  	struct phy_device *phydev;
> diff --git a/include/linux/phy.h b/include/linux/phy.h
> index 6c9cac9..9ab6e06 100644
> --- a/include/linux/phy.h
> +++ b/include/linux/phy.h
> @@ -84,11 +84,14 @@ struct mii_bus {
>  
>  	/* PHY addresses to be ignored when probing */
>  	u32 phy_mask;
> +
> +	struct list_head list;
>  };
>  #define to_mii_bus(d) container_of(d, struct mii_bus, dev)
>  
>  int mdiobus_register(struct mii_bus *bus);
>  void mdiobus_unregister(struct mii_bus *bus);
> +struct mii_bus *mdiobus_find(const char *name);
>  struct phy_device *mdiobus_scan(struct mii_bus *bus, int addr);
>  
>  /**
> -- 
> 1.7.10.4
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox

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

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

* Re: [PATCH 1/2] net phy: Add support for finding a mdio bus by its name
  2013-02-07 12:02 ` [PATCH 1/2] net phy: Add support for finding a mdio bus by its name Jean-Christophe PLAGNIOL-VILLARD
@ 2013-02-07 12:20   ` Sascha Hauer
  2013-02-07 12:26     ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 1 reply; 10+ messages in thread
From: Sascha Hauer @ 2013-02-07 12:20 UTC (permalink / raw)
  To: Jean-Christophe PLAGNIOL-VILLARD; +Cc: barebox

On Thu, Feb 07, 2013 at 01:02:06PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> On 12:09 Thu 07 Feb     , Sascha Hauer wrote:
> > Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> > ---
> >  drivers/net/phy/mdio_bus.c |   19 +++++++++++++++++++
> >  include/linux/phy.h        |    3 +++
> >  2 files changed, 22 insertions(+)
> > 
> > diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
> > index d1d802b..3c4be1c 100644
> > --- a/drivers/net/phy/mdio_bus.c
> > +++ b/drivers/net/phy/mdio_bus.c
> > @@ -25,6 +25,8 @@
> >  #include <linux/phy.h>
> >  #include <linux/err.h>
> >  
> > +static LIST_HEAD(mii_bus_list);
> > +
> >  /**
> >   * mdiobus_register - bring up all the PHYs on a given bus and attach them to bus
> >   * @bus: target mii_bus
> > @@ -57,6 +59,8 @@ int mdiobus_register(struct mii_bus *bus)
> >  	if (bus->reset)
> >  		bus->reset(bus);
> >  
> > +	list_add_tail(&bus->list, &mii_bus_list);
> > +
> >  	pr_info("%s: probed\n", dev_name(&bus->dev));
> >  	return 0;
> >  }
> > @@ -71,9 +75,24 @@ void mdiobus_unregister(struct mii_bus *bus)
> >  			unregister_device(&bus->phy_map[i]->dev);
> >  		bus->phy_map[i] = NULL;
> >  	}
> > +
> > +	list_del(&bus->list);
> >  }
> >  EXPORT_SYMBOL(mdiobus_unregister);
> >  
> > +struct mii_bus *mdiobus_find(const char *name)
> > +{
> > +	struct mii_bus *bus;
> > +
> > +	list_for_each_entry(bus, &mii_bus_list, list) {
> 	no use bus_for_each

That was my first try until I realized that not the mdio buses are
registered on the mdio_bus_type, but instead the phy devices.

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@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH 1/2] net phy: Add support for finding a mdio bus by its name
  2013-02-07 12:20   ` Sascha Hauer
@ 2013-02-07 12:26     ` Jean-Christophe PLAGNIOL-VILLARD
  2013-02-07 12:46       ` Sascha Hauer
  0 siblings, 1 reply; 10+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2013-02-07 12:26 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

On 13:20 Thu 07 Feb     , Sascha Hauer wrote:
> On Thu, Feb 07, 2013 at 01:02:06PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > On 12:09 Thu 07 Feb     , Sascha Hauer wrote:
> > > Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> > > ---
> > >  drivers/net/phy/mdio_bus.c |   19 +++++++++++++++++++
> > >  include/linux/phy.h        |    3 +++
> > >  2 files changed, 22 insertions(+)
> > > 
> > > diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
> > > index d1d802b..3c4be1c 100644
> > > --- a/drivers/net/phy/mdio_bus.c
> > > +++ b/drivers/net/phy/mdio_bus.c
> > > @@ -25,6 +25,8 @@
> > >  #include <linux/phy.h>
> > >  #include <linux/err.h>
> > >  
> > > +static LIST_HEAD(mii_bus_list);
> > > +
> > >  /**
> > >   * mdiobus_register - bring up all the PHYs on a given bus and attach them to bus
> > >   * @bus: target mii_bus
> > > @@ -57,6 +59,8 @@ int mdiobus_register(struct mii_bus *bus)
> > >  	if (bus->reset)
> > >  		bus->reset(bus);
> > >  
> > > +	list_add_tail(&bus->list, &mii_bus_list);
> > > +
> > >  	pr_info("%s: probed\n", dev_name(&bus->dev));
> > >  	return 0;
> > >  }
> > > @@ -71,9 +75,24 @@ void mdiobus_unregister(struct mii_bus *bus)
> > >  			unregister_device(&bus->phy_map[i]->dev);
> > >  		bus->phy_map[i] = NULL;
> > >  	}
> > > +
> > > +	list_del(&bus->list);
> > >  }
> > >  EXPORT_SYMBOL(mdiobus_unregister);
> > >  
> > > +struct mii_bus *mdiobus_find(const char *name)
> > > +{
> > > +	struct mii_bus *bus;
> > > +
> > > +	list_for_each_entry(bus, &mii_bus_list, list) {
> > 	no use bus_for_each
> 
> That was my first try until I realized that not the mdio buses are
> registered on the mdio_bus_type, but instead the phy devices.
so add bus_type the list is already in the device_d so we jsut hav to populate
it

Best Regards,
J.
> 
> 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@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH 1/2] net phy: Add support for finding a mdio bus by its name
  2013-02-07 12:26     ` Jean-Christophe PLAGNIOL-VILLARD
@ 2013-02-07 12:46       ` Sascha Hauer
  2013-02-07 16:05         ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 1 reply; 10+ messages in thread
From: Sascha Hauer @ 2013-02-07 12:46 UTC (permalink / raw)
  To: Jean-Christophe PLAGNIOL-VILLARD; +Cc: barebox

On Thu, Feb 07, 2013 at 01:26:13PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> On 13:20 Thu 07 Feb     , Sascha Hauer wrote:
> > On Thu, Feb 07, 2013 at 01:02:06PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > > On 12:09 Thu 07 Feb     , Sascha Hauer wrote:
> > > > Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> > > > ---
> > > >  drivers/net/phy/mdio_bus.c |   19 +++++++++++++++++++
> > > >  include/linux/phy.h        |    3 +++
> > > >  2 files changed, 22 insertions(+)
> > > > 
> > > > diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
> > > > index d1d802b..3c4be1c 100644
> > > > --- a/drivers/net/phy/mdio_bus.c
> > > > +++ b/drivers/net/phy/mdio_bus.c
> > > > @@ -25,6 +25,8 @@
> > > >  #include <linux/phy.h>
> > > >  #include <linux/err.h>
> > > >  
> > > > +static LIST_HEAD(mii_bus_list);
> > > > +
> > > >  /**
> > > >   * mdiobus_register - bring up all the PHYs on a given bus and attach them to bus
> > > >   * @bus: target mii_bus
> > > > @@ -57,6 +59,8 @@ int mdiobus_register(struct mii_bus *bus)
> > > >  	if (bus->reset)
> > > >  		bus->reset(bus);
> > > >  
> > > > +	list_add_tail(&bus->list, &mii_bus_list);
> > > > +
> > > >  	pr_info("%s: probed\n", dev_name(&bus->dev));
> > > >  	return 0;
> > > >  }
> > > > @@ -71,9 +75,24 @@ void mdiobus_unregister(struct mii_bus *bus)
> > > >  			unregister_device(&bus->phy_map[i]->dev);
> > > >  		bus->phy_map[i] = NULL;
> > > >  	}
> > > > +
> > > > +	list_del(&bus->list);
> > > >  }
> > > >  EXPORT_SYMBOL(mdiobus_unregister);
> > > >  
> > > > +struct mii_bus *mdiobus_find(const char *name)
> > > > +{
> > > > +	struct mii_bus *bus;
> > > > +
> > > > +	list_for_each_entry(bus, &mii_bus_list, list) {
> > > 	no use bus_for_each
> > 
> > That was my first try until I realized that not the mdio buses are
> > registered on the mdio_bus_type, but instead the phy devices.
> so add bus_type the list is already in the device_d so we jsut hav to populate
> it

You want to put both the phys and the buses on mdio_bus_type? Or you
want to introduce a mdio_bus_bus_type?

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@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH 1/2] net phy: Add support for finding a mdio bus by its name
  2013-02-07 12:46       ` Sascha Hauer
@ 2013-02-07 16:05         ` Jean-Christophe PLAGNIOL-VILLARD
  2013-02-07 17:43           ` Sascha Hauer
  0 siblings, 1 reply; 10+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2013-02-07 16:05 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

On 13:46 Thu 07 Feb     , Sascha Hauer wrote:
> On Thu, Feb 07, 2013 at 01:26:13PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > On 13:20 Thu 07 Feb     , Sascha Hauer wrote:
> > > On Thu, Feb 07, 2013 at 01:02:06PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > > > On 12:09 Thu 07 Feb     , Sascha Hauer wrote:
> > > > > Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> > > > > ---
> > > > >  drivers/net/phy/mdio_bus.c |   19 +++++++++++++++++++
> > > > >  include/linux/phy.h        |    3 +++
> > > > >  2 files changed, 22 insertions(+)
> > > > > 
> > > > > diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
> > > > > index d1d802b..3c4be1c 100644
> > > > > --- a/drivers/net/phy/mdio_bus.c
> > > > > +++ b/drivers/net/phy/mdio_bus.c
> > > > > @@ -25,6 +25,8 @@
> > > > >  #include <linux/phy.h>
> > > > >  #include <linux/err.h>
> > > > >  
> > > > > +static LIST_HEAD(mii_bus_list);
> > > > > +
> > > > >  /**
> > > > >   * mdiobus_register - bring up all the PHYs on a given bus and attach them to bus
> > > > >   * @bus: target mii_bus
> > > > > @@ -57,6 +59,8 @@ int mdiobus_register(struct mii_bus *bus)
> > > > >  	if (bus->reset)
> > > > >  		bus->reset(bus);
> > > > >  
> > > > > +	list_add_tail(&bus->list, &mii_bus_list);
> > > > > +
> > > > >  	pr_info("%s: probed\n", dev_name(&bus->dev));
> > > > >  	return 0;
> > > > >  }
> > > > > @@ -71,9 +75,24 @@ void mdiobus_unregister(struct mii_bus *bus)
> > > > >  			unregister_device(&bus->phy_map[i]->dev);
> > > > >  		bus->phy_map[i] = NULL;
> > > > >  	}
> > > > > +
> > > > > +	list_del(&bus->list);
> > > > >  }
> > > > >  EXPORT_SYMBOL(mdiobus_unregister);
> > > > >  
> > > > > +struct mii_bus *mdiobus_find(const char *name)
> > > > > +{
> > > > > +	struct mii_bus *bus;
> > > > > +
> > > > > +	list_for_each_entry(bus, &mii_bus_list, list) {
> > > > 	no use bus_for_each
> > > 
> > > That was my first try until I realized that not the mdio buses are
> > > registered on the mdio_bus_type, but instead the phy devices.
> > so add bus_type the list is already in the device_d so we jsut hav to populate
> > it
> 
> You want to put both the phys and the buses on mdio_bus_type? Or you
> want to introduce a mdio_bus_bus_type?
different

I want to be able to use bus_for_each on each of them seperatly

Best Regards,
J.
> 
> 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@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH 1/2] net phy: Add support for finding a mdio bus by its name
  2013-02-07 16:05         ` Jean-Christophe PLAGNIOL-VILLARD
@ 2013-02-07 17:43           ` Sascha Hauer
  2013-02-07 18:23             ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 1 reply; 10+ messages in thread
From: Sascha Hauer @ 2013-02-07 17:43 UTC (permalink / raw)
  To: Jean-Christophe PLAGNIOL-VILLARD; +Cc: barebox

On Thu, Feb 07, 2013 at 05:05:35PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> On 13:46 Thu 07 Feb     , Sascha Hauer wrote:
> > On Thu, Feb 07, 2013 at 01:26:13PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > > On 13:20 Thu 07 Feb     , Sascha Hauer wrote:
> > > > On Thu, Feb 07, 2013 at 01:02:06PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > > > > On 12:09 Thu 07 Feb     , Sascha Hauer wrote:
> > > > > > Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> > > > > > ---
> > > > > >  drivers/net/phy/mdio_bus.c |   19 +++++++++++++++++++
> > > > > >  include/linux/phy.h        |    3 +++
> > > > > >  2 files changed, 22 insertions(+)
> > > > > > 
> > > > > > diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
> > > > > > index d1d802b..3c4be1c 100644
> > > > > > --- a/drivers/net/phy/mdio_bus.c
> > > > > > +++ b/drivers/net/phy/mdio_bus.c
> > > > > > @@ -25,6 +25,8 @@
> > > > > >  #include <linux/phy.h>
> > > > > >  #include <linux/err.h>
> > > > > >  
> > > > > > +static LIST_HEAD(mii_bus_list);
> > > > > > +
> > > > > >  /**
> > > > > >   * mdiobus_register - bring up all the PHYs on a given bus and attach them to bus
> > > > > >   * @bus: target mii_bus
> > > > > > @@ -57,6 +59,8 @@ int mdiobus_register(struct mii_bus *bus)
> > > > > >  	if (bus->reset)
> > > > > >  		bus->reset(bus);
> > > > > >  
> > > > > > +	list_add_tail(&bus->list, &mii_bus_list);
> > > > > > +
> > > > > >  	pr_info("%s: probed\n", dev_name(&bus->dev));
> > > > > >  	return 0;
> > > > > >  }
> > > > > > @@ -71,9 +75,24 @@ void mdiobus_unregister(struct mii_bus *bus)
> > > > > >  			unregister_device(&bus->phy_map[i]->dev);
> > > > > >  		bus->phy_map[i] = NULL;
> > > > > >  	}
> > > > > > +
> > > > > > +	list_del(&bus->list);
> > > > > >  }
> > > > > >  EXPORT_SYMBOL(mdiobus_unregister);
> > > > > >  
> > > > > > +struct mii_bus *mdiobus_find(const char *name)
> > > > > > +{
> > > > > > +	struct mii_bus *bus;
> > > > > > +
> > > > > > +	list_for_each_entry(bus, &mii_bus_list, list) {
> > > > > 	no use bus_for_each
> > > > 
> > > > That was my first try until I realized that not the mdio buses are
> > > > registered on the mdio_bus_type, but instead the phy devices.
> > > so add bus_type the list is already in the device_d so we jsut hav to populate
> > > it
> > 
> > You want to put both the phys and the buses on mdio_bus_type? Or you
> > want to introduce a mdio_bus_bus_type?
> different

different what?

> 
> I want to be able to use bus_for_each on each of them seperatly

I have no idea what you are talking about.

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@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH 1/2] net phy: Add support for finding a mdio bus by its name
  2013-02-07 17:43           ` Sascha Hauer
@ 2013-02-07 18:23             ` Jean-Christophe PLAGNIOL-VILLARD
  2013-02-07 18:29               ` Sascha Hauer
  0 siblings, 1 reply; 10+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2013-02-07 18:23 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

On 18:43 Thu 07 Feb     , Sascha Hauer wrote:
> On Thu, Feb 07, 2013 at 05:05:35PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > On 13:46 Thu 07 Feb     , Sascha Hauer wrote:
> > > On Thu, Feb 07, 2013 at 01:26:13PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > > > On 13:20 Thu 07 Feb     , Sascha Hauer wrote:
> > > > > On Thu, Feb 07, 2013 at 01:02:06PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > > > > > On 12:09 Thu 07 Feb     , Sascha Hauer wrote:
> > > > > > > Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> > > > > > > ---
> > > > > > >  drivers/net/phy/mdio_bus.c |   19 +++++++++++++++++++
> > > > > > >  include/linux/phy.h        |    3 +++
> > > > > > >  2 files changed, 22 insertions(+)
> > > > > > > 
> > > > > > > diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
> > > > > > > index d1d802b..3c4be1c 100644
> > > > > > > --- a/drivers/net/phy/mdio_bus.c
> > > > > > > +++ b/drivers/net/phy/mdio_bus.c
> > > > > > > @@ -25,6 +25,8 @@
> > > > > > >  #include <linux/phy.h>
> > > > > > >  #include <linux/err.h>
> > > > > > >  
> > > > > > > +static LIST_HEAD(mii_bus_list);
> > > > > > > +
> > > > > > >  /**
> > > > > > >   * mdiobus_register - bring up all the PHYs on a given bus and attach them to bus
> > > > > > >   * @bus: target mii_bus
> > > > > > > @@ -57,6 +59,8 @@ int mdiobus_register(struct mii_bus *bus)
> > > > > > >  	if (bus->reset)
> > > > > > >  		bus->reset(bus);
> > > > > > >  
> > > > > > > +	list_add_tail(&bus->list, &mii_bus_list);
> > > > > > > +
> > > > > > >  	pr_info("%s: probed\n", dev_name(&bus->dev));
> > > > > > >  	return 0;
> > > > > > >  }
> > > > > > > @@ -71,9 +75,24 @@ void mdiobus_unregister(struct mii_bus *bus)
> > > > > > >  			unregister_device(&bus->phy_map[i]->dev);
> > > > > > >  		bus->phy_map[i] = NULL;
> > > > > > >  	}
> > > > > > > +
> > > > > > > +	list_del(&bus->list);
> > > > > > >  }
> > > > > > >  EXPORT_SYMBOL(mdiobus_unregister);
> > > > > > >  
> > > > > > > +struct mii_bus *mdiobus_find(const char *name)
> > > > > > > +{
> > > > > > > +	struct mii_bus *bus;
> > > > > > > +
> > > > > > > +	list_for_each_entry(bus, &mii_bus_list, list) {
> > > > > > 	no use bus_for_each
> > > > > 
> > > > > That was my first try until I realized that not the mdio buses are
> > > > > registered on the mdio_bus_type, but instead the phy devices.
> > > > so add bus_type the list is already in the device_d so we jsut hav to populate
> > > > it
> > > 
> > > You want to put both the phys and the buses on mdio_bus_type? Or you
> > > want to introduce a mdio_bus_bus_type?
> > different
> 
> different what?
> 
> > 
> > I want to be able to use bus_for_each on each of them seperatly
> 
> I have no idea what you are talking about.

create a new bus_type for mdio

so you can use bus_for_each

Best Regards,
J.
> 
> 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@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH 1/2] net phy: Add support for finding a mdio bus by its name
  2013-02-07 18:23             ` Jean-Christophe PLAGNIOL-VILLARD
@ 2013-02-07 18:29               ` Sascha Hauer
  0 siblings, 0 replies; 10+ messages in thread
From: Sascha Hauer @ 2013-02-07 18:29 UTC (permalink / raw)
  To: Jean-Christophe PLAGNIOL-VILLARD; +Cc: barebox

On Thu, Feb 07, 2013 at 07:23:47PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> On 18:43 Thu 07 Feb     , Sascha Hauer wrote:
> > On Thu, Feb 07, 2013 at 05:05:35PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > > On 13:46 Thu 07 Feb     , Sascha Hauer wrote:
> > > > On Thu, Feb 07, 2013 at 01:26:13PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > > > > On 13:20 Thu 07 Feb     , Sascha Hauer wrote:
> > > > > > On Thu, Feb 07, 2013 at 01:02:06PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > > > > > > On 12:09 Thu 07 Feb     , Sascha Hauer wrote:
> > > > > > > > Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> > > > > > > > ---
> > > > > > > >  drivers/net/phy/mdio_bus.c |   19 +++++++++++++++++++
> > > > > > > >  include/linux/phy.h        |    3 +++
> > > > > > > >  2 files changed, 22 insertions(+)
> > > > > > > > 
> > > > > > > > diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
> > > > > > > > index d1d802b..3c4be1c 100644
> > > > > > > > --- a/drivers/net/phy/mdio_bus.c
> > > > > > > > +++ b/drivers/net/phy/mdio_bus.c
> > > > > > > > @@ -25,6 +25,8 @@
> > > > > > > >  #include <linux/phy.h>
> > > > > > > >  #include <linux/err.h>
> > > > > > > >  
> > > > > > > > +static LIST_HEAD(mii_bus_list);
> > > > > > > > +
> > > > > > > >  /**
> > > > > > > >   * mdiobus_register - bring up all the PHYs on a given bus and attach them to bus
> > > > > > > >   * @bus: target mii_bus
> > > > > > > > @@ -57,6 +59,8 @@ int mdiobus_register(struct mii_bus *bus)
> > > > > > > >  	if (bus->reset)
> > > > > > > >  		bus->reset(bus);
> > > > > > > >  
> > > > > > > > +	list_add_tail(&bus->list, &mii_bus_list);
> > > > > > > > +
> > > > > > > >  	pr_info("%s: probed\n", dev_name(&bus->dev));
> > > > > > > >  	return 0;
> > > > > > > >  }
> > > > > > > > @@ -71,9 +75,24 @@ void mdiobus_unregister(struct mii_bus *bus)
> > > > > > > >  			unregister_device(&bus->phy_map[i]->dev);
> > > > > > > >  		bus->phy_map[i] = NULL;
> > > > > > > >  	}
> > > > > > > > +
> > > > > > > > +	list_del(&bus->list);
> > > > > > > >  }
> > > > > > > >  EXPORT_SYMBOL(mdiobus_unregister);
> > > > > > > >  
> > > > > > > > +struct mii_bus *mdiobus_find(const char *name)
> > > > > > > > +{
> > > > > > > > +	struct mii_bus *bus;
> > > > > > > > +
> > > > > > > > +	list_for_each_entry(bus, &mii_bus_list, list) {
> > > > > > > 	no use bus_for_each
> > > > > > 
> > > > > > That was my first try until I realized that not the mdio buses are
> > > > > > registered on the mdio_bus_type, but instead the phy devices.
> > > > > so add bus_type the list is already in the device_d so we jsut hav to populate
> > > > > it
> > > > 
> > > > You want to put both the phys and the buses on mdio_bus_type? Or you
> > > > want to introduce a mdio_bus_bus_type?
> > > different
> > 
> > different what?
> > 
> > > 
> > > I want to be able to use bus_for_each on each of them seperatly
> > 
> > I have no idea what you are talking about.
> 
> create a new bus_type for mdio
> 
> so you can use bus_for_each

So a mdio_bus_bus_type. I already asked whether this is what you meant.

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@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

end of thread, other threads:[~2013-02-07 18:29 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-07 11:09 [PATCH 1/2] net phy: Add support for finding a mdio bus by its name Sascha Hauer
2013-02-07 11:09 ` [PATCH 2/2] miitool: Add support for examing mdio bus Sascha Hauer
2013-02-07 12:02 ` [PATCH 1/2] net phy: Add support for finding a mdio bus by its name Jean-Christophe PLAGNIOL-VILLARD
2013-02-07 12:20   ` Sascha Hauer
2013-02-07 12:26     ` Jean-Christophe PLAGNIOL-VILLARD
2013-02-07 12:46       ` Sascha Hauer
2013-02-07 16:05         ` Jean-Christophe PLAGNIOL-VILLARD
2013-02-07 17:43           ` Sascha Hauer
2013-02-07 18:23             ` Jean-Christophe PLAGNIOL-VILLARD
2013-02-07 18:29               ` Sascha Hauer

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