From: Grant Likely <grant.likely@secretlab.ca>
To: netdev@vger.kernel.org, linuxppc-dev@ozlabs.org
Cc: olof@lixom.net, afleming@freescale.com,
Joakim Tjernlund <Joakim.Tjernlund@transmode.se>
Subject: [PATCH 08/14] net: rework fsl_pq_mdio driver to use of_mdio infrastructure
Date: Tue, 31 Mar 2009 02:27:25 -0600 [thread overview]
Message-ID: <20090331082725.1427.76321.stgit@localhost.localdomain> (raw)
In-Reply-To: <20090331075537.1427.7819.stgit@localhost.localdomain>
From: Grant Likely <grant.likely@secretlab.ca>
This patch simplifies the driver by making use of more common code.
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
---
drivers/net/fsl_pq_mdio.c | 53 +++------------------------------------------
1 files changed, 4 insertions(+), 49 deletions(-)
diff --git a/drivers/net/fsl_pq_mdio.c b/drivers/net/fsl_pq_mdio.c
index b3079a5..83a98f4 100644
--- a/drivers/net/fsl_pq_mdio.c
+++ b/drivers/net/fsl_pq_mdio.c
@@ -34,6 +34,7 @@
#include <linux/mii.h>
#include <linux/phy.h>
#include <linux/of.h>
+#include <linux/of_mdio.h>
#include <linux/of_platform.h>
#include <asm/io.h>
@@ -154,44 +155,6 @@ static int fsl_pq_mdio_reset(struct mii_bus *bus)
return 0;
}
-/* Allocate an array which provides irq #s for each PHY on the given bus */
-static int *create_irq_map(struct device_node *np)
-{
- int *irqs;
- int i;
- struct device_node *child = NULL;
-
- irqs = kcalloc(PHY_MAX_ADDR, sizeof(int), GFP_KERNEL);
-
- if (!irqs)
- return NULL;
-
- for (i = 0; i < PHY_MAX_ADDR; i++)
- irqs[i] = PHY_POLL;
-
- while ((child = of_get_next_child(np, child)) != NULL) {
- int irq = irq_of_parse_and_map(child, 0);
- const u32 *id;
-
- if (irq == NO_IRQ)
- continue;
-
- id = of_get_property(child, "reg", NULL);
-
- if (!id)
- continue;
-
- if (*id < PHY_MAX_ADDR && *id >= 0)
- irqs[*id] = irq;
- else
- printk(KERN_WARNING "%s: "
- "%d is not a valid PHY address\n",
- np->full_name, *id);
- }
-
- return irqs;
-}
-
void fsl_pq_mdio_bus_name(char *name, struct device_node *np)
{
const u32 *addr;
@@ -314,7 +277,7 @@ static int fsl_pq_mdio_probe(struct of_device *ofdev,
new_bus->priv = (void __force *)regs;
- new_bus->irq = create_irq_map(np);
+ new_bus->irq = kcalloc(PHY_MAX_ADDR, sizeof(int), GFP_KERNEL);
if (NULL == new_bus->irq) {
err = -ENOMEM;
@@ -383,16 +346,8 @@ static int fsl_pq_mdio_probe(struct of_device *ofdev,
out_be32(tbipa, tbiaddr);
- /*
- * The TBIPHY-only buses will find PHYs at every address,
- * so we mask them all but the TBI
- */
- if (!of_device_is_compatible(np, "fsl,gianfar-mdio"))
- new_bus->phy_mask = ~(1 << tbiaddr);
-
- err = mdiobus_register(new_bus);
-
- if (err) {
+ err = of_mdiobus_register(new_bus, np);
+ if (err != 0) {
printk (KERN_ERR "%s: Cannot register as MDIO bus\n",
new_bus->name);
goto err_free_irqs;
WARNING: multiple messages have this Message-ID (diff)
From: Grant Likely <grant.likely@secretlab.ca>
To: netdev@vger.kernel.org, linuxppc-dev@ozlabs.org
Cc: olof@lixom.net, afleming@freescale.com,
galak@kernel.crashing.org,
Anton Vorontsov <avorontsov@ru.mvista.com>,
Joakim Tjernlund <Joakim.Tjernlund@transmode.se>
Subject: [PATCH 08/14] net: rework fsl_pq_mdio driver to use of_mdio infrastructure
Date: Tue, 31 Mar 2009 02:27:25 -0600 [thread overview]
Message-ID: <20090331082725.1427.76321.stgit@localhost.localdomain> (raw)
In-Reply-To: <20090331075537.1427.7819.stgit@localhost.localdomain>
From: Grant Likely <grant.likely@secretlab.ca>
This patch simplifies the driver by making use of more common code.
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
---
drivers/net/fsl_pq_mdio.c | 53 +++------------------------------------------
1 files changed, 4 insertions(+), 49 deletions(-)
diff --git a/drivers/net/fsl_pq_mdio.c b/drivers/net/fsl_pq_mdio.c
index b3079a5..83a98f4 100644
--- a/drivers/net/fsl_pq_mdio.c
+++ b/drivers/net/fsl_pq_mdio.c
@@ -34,6 +34,7 @@
#include <linux/mii.h>
#include <linux/phy.h>
#include <linux/of.h>
+#include <linux/of_mdio.h>
#include <linux/of_platform.h>
#include <asm/io.h>
@@ -154,44 +155,6 @@ static int fsl_pq_mdio_reset(struct mii_bus *bus)
return 0;
}
-/* Allocate an array which provides irq #s for each PHY on the given bus */
-static int *create_irq_map(struct device_node *np)
-{
- int *irqs;
- int i;
- struct device_node *child = NULL;
-
- irqs = kcalloc(PHY_MAX_ADDR, sizeof(int), GFP_KERNEL);
-
- if (!irqs)
- return NULL;
-
- for (i = 0; i < PHY_MAX_ADDR; i++)
- irqs[i] = PHY_POLL;
-
- while ((child = of_get_next_child(np, child)) != NULL) {
- int irq = irq_of_parse_and_map(child, 0);
- const u32 *id;
-
- if (irq == NO_IRQ)
- continue;
-
- id = of_get_property(child, "reg", NULL);
-
- if (!id)
- continue;
-
- if (*id < PHY_MAX_ADDR && *id >= 0)
- irqs[*id] = irq;
- else
- printk(KERN_WARNING "%s: "
- "%d is not a valid PHY address\n",
- np->full_name, *id);
- }
-
- return irqs;
-}
-
void fsl_pq_mdio_bus_name(char *name, struct device_node *np)
{
const u32 *addr;
@@ -314,7 +277,7 @@ static int fsl_pq_mdio_probe(struct of_device *ofdev,
new_bus->priv = (void __force *)regs;
- new_bus->irq = create_irq_map(np);
+ new_bus->irq = kcalloc(PHY_MAX_ADDR, sizeof(int), GFP_KERNEL);
if (NULL == new_bus->irq) {
err = -ENOMEM;
@@ -383,16 +346,8 @@ static int fsl_pq_mdio_probe(struct of_device *ofdev,
out_be32(tbipa, tbiaddr);
- /*
- * The TBIPHY-only buses will find PHYs at every address,
- * so we mask them all but the TBI
- */
- if (!of_device_is_compatible(np, "fsl,gianfar-mdio"))
- new_bus->phy_mask = ~(1 << tbiaddr);
-
- err = mdiobus_register(new_bus);
-
- if (err) {
+ err = of_mdiobus_register(new_bus, np);
+ if (err != 0) {
printk (KERN_ERR "%s: Cannot register as MDIO bus\n",
new_bus->name);
goto err_free_irqs;
next prev parent reply other threads:[~2009-03-31 8:27 UTC|newest]
Thread overview: 53+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-31 8:26 [PATCH 00/14] Add common OF device tree support for MDIO busses Grant Likely
2009-03-31 8:26 ` [PATCH 01/14] of: add of_parse_phandle() helper for parsing phandle properties Grant Likely
2009-03-31 8:26 ` Grant Likely
2009-03-31 8:26 ` [PATCH 02/14] net/fec_mpc52xx: Migrate to net_device_ops Grant Likely
2009-03-31 8:26 ` Grant Likely
2009-03-31 8:26 ` [PATCH 03/14] net/fec_mpc52xx: Don't dereference phy_device if it is NULL Grant Likely
2009-03-31 8:26 ` Grant Likely
2009-03-31 8:27 ` [PATCH 04/14] phylib: rework to prepare for OF registration of PHYs Grant Likely
2009-03-31 8:27 ` Grant Likely
2009-03-31 8:27 ` [PATCH 05/14] phylib: add *_direct() variants of phy_connect and phy_attach functions Grant Likely
2009-03-31 8:27 ` Grant Likely
2009-04-15 21:10 ` Andy Fleming
2009-04-18 6:08 ` Grant Likely
2009-04-18 6:08 ` Grant Likely
2009-04-18 6:18 ` Grant Likely
2009-04-18 6:18 ` Grant Likely
2009-03-31 8:27 ` [PATCH 06/14] openfirmware: Add OF phylib support code Grant Likely
2009-03-31 8:27 ` Grant Likely
2009-03-31 8:27 ` [PATCH 07/14] net: Rework mpc5200 fec driver to use of_mdio infrastructure Grant Likely
2009-03-31 8:27 ` Grant Likely
2009-03-31 8:27 ` Grant Likely [this message]
2009-03-31 8:27 ` [PATCH 08/14] net: rework fsl_pq_mdio " Grant Likely
2009-03-31 8:27 ` [PATCH 09/14] net: Rework gianfar " Grant Likely
2009-03-31 8:27 ` Grant Likely
2009-04-15 23:01 ` Andy Fleming
2009-04-18 6:34 ` Grant Likely
2009-04-18 6:34 ` Grant Likely
2009-03-31 8:27 ` [PATCH 10/14] net: Rework ucc_geth " Grant Likely
2009-03-31 8:27 ` Grant Likely
2009-03-31 8:27 ` [PATCH 11/14] net: Rework pasemi_mac " Grant Likely
2009-03-31 8:27 ` Grant Likely
2009-03-31 8:27 ` [PATCH 12/14] powerpc/82xx: Rework Embedded Planet ep8248e platform to use of_mdio Grant Likely
2009-03-31 8:27 ` Grant Likely
2009-03-31 8:27 ` [PATCH 13/14] net: Rework fs_enet driver to use of_mdio infrastructure Grant Likely
2009-03-31 8:27 ` Grant Likely
2009-03-31 8:27 ` [PATCH 14/14] net: add Xilinx ll_temac device driver Grant Likely
2009-03-31 8:27 ` Grant Likely
2009-03-31 21:57 ` [PATCH 00/14] Add common OF device tree support for MDIO busses David Miller
2009-03-31 22:19 ` Grant Likely
2009-03-31 22:19 ` Grant Likely
2009-03-31 22:22 ` David Miller
2009-03-31 22:22 ` David Miller
2009-04-01 1:45 ` Grant Likely
2009-04-01 1:45 ` Grant Likely
2009-04-01 3:38 ` David Miller
2009-04-01 3:38 ` David Miller
2009-04-01 4:56 ` Grant Likely
2009-04-01 4:56 ` Grant Likely
2009-04-01 5:16 ` David Miller
2009-04-01 5:16 ` David Miller
2009-04-01 5:21 ` Grant Likely
2009-04-01 5:21 ` Grant Likely
2009-04-15 23:06 ` Andy Fleming
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20090331082725.1427.76321.stgit@localhost.localdomain \
--to=grant.likely@secretlab.ca \
--cc=Joakim.Tjernlund@transmode.se \
--cc=afleming@freescale.com \
--cc=linuxppc-dev@ozlabs.org \
--cc=netdev@vger.kernel.org \
--cc=olof@lixom.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.