Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 179073
b: refs/heads/master
c: b3319b1
h: refs/heads/master
i:
  179071: 268e057
v: v3
  • Loading branch information
Anton Vorontsov authored and David S. Miller committed Dec 31, 2009
1 parent 1b5d70d commit a902e47
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 29fb00e047eae927a3f1a0367c0cfed7ad5228ef
refs/heads/master: b3319b10523d8dac82b134a05de2a403119abebd
30 changes: 23 additions & 7 deletions trunk/drivers/net/fsl_pq_mdio.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@
#include "gianfar.h"
#include "fsl_pq_mdio.h"

struct fsl_pq_mdio_priv {
void __iomem *map;
struct fsl_pq_mdio __iomem *regs;
};

/*
* Write value to the PHY at mii_id at register regnum,
* on the bus attached to the local interface, which may be different from the
Expand Down Expand Up @@ -105,7 +110,9 @@ int fsl_pq_local_mdio_read(struct fsl_pq_mdio __iomem *regs,

static struct fsl_pq_mdio __iomem *fsl_pq_mdio_get_regs(struct mii_bus *bus)
{
return (void __iomem __force *)bus->priv;
struct fsl_pq_mdio_priv *priv = bus->priv;

return priv->regs;
}

/*
Expand Down Expand Up @@ -266,6 +273,7 @@ static int fsl_pq_mdio_probe(struct of_device *ofdev,
{
struct device_node *np = ofdev->node;
struct device_node *tbi;
struct fsl_pq_mdio_priv *priv;
struct fsl_pq_mdio __iomem *regs = NULL;
void __iomem *map;
u32 __iomem *tbipa;
Expand All @@ -274,14 +282,19 @@ static int fsl_pq_mdio_probe(struct of_device *ofdev,
u64 addr = 0, size = 0;
int err = 0;

priv = kzalloc(sizeof(*priv), GFP_KERNEL);
if (!priv)
return -ENOMEM;

new_bus = mdiobus_alloc();
if (NULL == new_bus)
return -ENOMEM;
goto err_free_priv;

new_bus->name = "Freescale PowerQUICC MII Bus",
new_bus->read = &fsl_pq_mdio_read,
new_bus->write = &fsl_pq_mdio_write,
new_bus->reset = &fsl_pq_mdio_reset,
new_bus->priv = priv;
fsl_pq_mdio_bus_name(new_bus->id, np);

/* Set the PHY base address */
Expand All @@ -291,15 +304,15 @@ static int fsl_pq_mdio_probe(struct of_device *ofdev,
err = -ENOMEM;
goto err_free_bus;
}
priv->map = map;

if (of_device_is_compatible(np, "fsl,gianfar-mdio") ||
of_device_is_compatible(np, "fsl,gianfar-tbi") ||
of_device_is_compatible(np, "fsl,ucc-mdio") ||
of_device_is_compatible(np, "ucc_geth_phy"))
map -= offsetof(struct fsl_pq_mdio, miimcfg);
regs = map;

new_bus->priv = (void __force *)regs;
priv->regs = regs;

new_bus->irq = kcalloc(PHY_MAX_ADDR, sizeof(int), GFP_KERNEL);

Expand Down Expand Up @@ -392,10 +405,11 @@ static int fsl_pq_mdio_probe(struct of_device *ofdev,
err_free_irqs:
kfree(new_bus->irq);
err_unmap_regs:
iounmap(regs);
iounmap(priv->map);
err_free_bus:
kfree(new_bus);

err_free_priv:
kfree(priv);
return err;
}

Expand All @@ -404,14 +418,16 @@ static int fsl_pq_mdio_remove(struct of_device *ofdev)
{
struct device *device = &ofdev->dev;
struct mii_bus *bus = dev_get_drvdata(device);
struct fsl_pq_mdio_priv *priv = bus->priv;

mdiobus_unregister(bus);

dev_set_drvdata(device, NULL);

iounmap(fsl_pq_mdio_get_regs(bus));
iounmap(priv->map);
bus->priv = NULL;
mdiobus_free(bus);
kfree(priv);

return 0;
}
Expand Down

0 comments on commit a902e47

Please sign in to comment.