diff options
author | Joe Hershberger <joe.hershberger@ni.com> | 2016-08-08 11:28:38 -0500 |
---|---|---|
committer | Joe Hershberger <joe.hershberger@ni.com> | 2016-08-15 15:26:33 -0500 |
commit | 5a49f17481bb9dcab1431c663d35cc1cace16825 (patch) | |
tree | 239447b5c4c6da4f9ca2c298f33ed73c39a9020d /drivers/net/ep93xx_eth.c | |
parent | 63d985985e383111e082c78398444941a0b9fadf (diff) | |
download | u-boot-5a49f17481bb9dcab1431c663d35cc1cace16825.tar.gz |
net: mii: Use spatch to update miiphy_register
Run scripts/coccinelle/net/mdio_register.cocci on the U-Boot code base.
Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Diffstat (limited to 'drivers/net/ep93xx_eth.c')
-rw-r--r-- | drivers/net/ep93xx_eth.c | 41 |
1 files changed, 27 insertions, 14 deletions
diff --git a/drivers/net/ep93xx_eth.c b/drivers/net/ep93xx_eth.c index a3721c5513..0021911dc8 100644 --- a/drivers/net/ep93xx_eth.c +++ b/drivers/net/ep93xx_eth.c @@ -30,10 +30,10 @@ #define GET_REGS(eth_dev) (GET_PRIV(eth_dev)->regs) /* ep93xx_miiphy ops forward declarations */ -static int ep93xx_miiphy_read(const char * const dev, unsigned char const addr, - unsigned char const reg, unsigned short * const value); -static int ep93xx_miiphy_write(const char * const dev, unsigned char const addr, - unsigned char const reg, unsigned short const value); +static int ep93xx_miiphy_read(struct mii_dev *bus, int addr, int devad, + int reg); +static int ep93xx_miiphy_write(struct mii_dev *bus, int addr, int devad, + int reg, u16 value); #if defined(EP93XX_MAC_DEBUG) /** @@ -421,7 +421,17 @@ eth_send_out: #if defined(CONFIG_MII) int ep93xx_miiphy_initialize(bd_t * const bd) { - miiphy_register("ep93xx_eth0", ep93xx_miiphy_read, ep93xx_miiphy_write); + int retval; + struct mii_dev *mdiodev = mdio_alloc(); + if (!mdiodev) + return -ENOMEM; + strncpy(mdiodev->name, "ep93xx_eth0", MDIO_NAME_LEN); + mdiodev->read = ep93xx_miiphy_read; + mdiodev->write = ep93xx_miiphy_write; + + retval = mdio_register(mdiodev); + if (retval < 0) + return retval; return 0; } #endif @@ -542,9 +552,10 @@ eth_init_done: /** * Read a 16-bit value from an MII register. */ -static int ep93xx_miiphy_read(const char * const dev, unsigned char const addr, - unsigned char const reg, unsigned short * const value) +static int ep93xx_miiphy_read(struct mii_dev *bus, int addr, int devad, + int reg) { + unsigned short value = 0; struct mac_regs *mac = (struct mac_regs *)MAC_BASE; int ret = -1; uint32_t self_ctl; @@ -552,10 +563,10 @@ static int ep93xx_miiphy_read(const char * const dev, unsigned char const addr, debug("+ep93xx_miiphy_read"); /* Parameter checks */ - BUG_ON(dev == NULL); + BUG_ON(bus->name == NULL); BUG_ON(addr > MII_ADDRESS_MAX); BUG_ON(reg > MII_REGISTER_MAX); - BUG_ON(value == NULL); + BUG_ON(&value == NULL); /* * Save the current SelfCTL register value. Set MAC to suppress @@ -579,7 +590,7 @@ static int ep93xx_miiphy_read(const char * const dev, unsigned char const addr, while (readl(&mac->miists) & MIISTS_BUSY) ; /* noop */ - *value = (unsigned short)readl(&mac->miidata); + value = (unsigned short)readl(&mac->miidata); /* Restore the saved SelfCTL value and return. */ writel(self_ctl, &mac->selfctl); @@ -588,14 +599,16 @@ static int ep93xx_miiphy_read(const char * const dev, unsigned char const addr, /* Fall through */ debug("-ep93xx_miiphy_read"); - return ret; + if (ret < 0) + return ret; + return value; } /** * Write a 16-bit value to an MII register. */ -static int ep93xx_miiphy_write(const char * const dev, unsigned char const addr, - unsigned char const reg, unsigned short const value) +static int ep93xx_miiphy_write(struct mii_dev *bus, int addr, int devad, + int reg, u16 value) { struct mac_regs *mac = (struct mac_regs *)MAC_BASE; int ret = -1; @@ -604,7 +617,7 @@ static int ep93xx_miiphy_write(const char * const dev, unsigned char const addr, debug("+ep93xx_miiphy_write"); /* Parameter checks */ - BUG_ON(dev == NULL); + BUG_ON(bus->name == NULL); BUG_ON(addr > MII_ADDRESS_MAX); BUG_ON(reg > MII_REGISTER_MAX); |