From patchwork Mon Apr 4 09:07:37 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Hershberger X-Patchwork-Id: 605774 X-Patchwork-Delegate: joe.hershberger@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 3qdmc34T8Jz9s9W for ; Mon, 4 Apr 2016 19:17:55 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id A89A2A748A; Mon, 4 Apr 2016 11:17:53 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 7I4JjcZbTEIM; Mon, 4 Apr 2016 11:17:53 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 44876A756F; Mon, 4 Apr 2016 11:17:53 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 8CD04A756F for ; Mon, 4 Apr 2016 11:17:49 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id hc9br0qSU0PX for ; Mon, 4 Apr 2016 11:17:49 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from ni.com (skprod3.natinst.com [130.164.80.24]) by theia.denx.de (Postfix) with ESMTPS id 177BAA748A for ; Mon, 4 Apr 2016 11:17:46 +0200 (CEST) Received: from us-aus-mgwout1.amer.corp.natinst.com (nb-snip2-1338.natinst.com [130.164.19.135]) by us-aus-skprod3.natinst.com (8.15.0.59/8.15.0.59) with ESMTP id u348A9XO006863; Mon, 4 Apr 2016 03:10:09 -0500 Received: from linux-xvxi.natinst.com ([130.164.14.198]) by us-aus-mgwout1.amer.corp.natinst.com (Lotus Domino Release 8.5.3FP6 HF1218) with ESMTP id 2016040403100981-514572 ; Mon, 4 Apr 2016 03:10:09 -0500 From: Joe Hershberger To: u-boot@lists.denx.de Date: Mon, 4 Apr 2016 04:07:37 -0500 Message-Id: <1459760858-25071-6-git-send-email-joe.hershberger@ni.com> X-Mailer: git-send-email 1.7.11.5 In-Reply-To: <1459760858-25071-1-git-send-email-joe.hershberger@ni.com> References: <1459760858-25071-1-git-send-email-joe.hershberger@ni.com> X-MIMETrack: Itemize by SMTP Server on US-AUS-MGWOut1/AUS/H/NIC(Release 8.5.3FP6 HF1218|December 12, 2014) at 04/04/2016 03:10:09 AM, Serialize by Router on US-AUS-MGWOut1/AUS/H/NIC(Release 8.5.3FP6 HF1218|December 12, 2014) at 04/04/2016 03:10:09 AM, Serialize complete at 04/04/2016 03:10:09 AM X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-04-04_02:, , signatures=0 Cc: Dirk Eibach , Joe Hershberger , Qianyu Gong Subject: [U-Boot] [PATCH 5/6] net: mii: Fix changes made by spatch X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Some of the changes were a bit too complex. Signed-off-by: Joe Hershberger Reviewed-by: Bin Meng --- arch/powerpc/cpu/mpc8xx/fec.c | 6 ++++-- board/gdsys/405ex/io64.c | 3 +-- drivers/net/bfin_mac.c | 21 +++++++++++++++------ drivers/net/davinci_emac.c | 17 +++++++---------- drivers/net/ep93xx_eth.c | 1 - drivers/net/lpc32xx_eth.c | 23 ++--------------------- drivers/net/smc911x.c | 10 ++++------ drivers/qe/uec.c | 2 +- 8 files changed, 34 insertions(+), 49 deletions(-) diff --git a/arch/powerpc/cpu/mpc8xx/fec.c b/arch/powerpc/cpu/mpc8xx/fec.c index b2cac82..ca373a8 100644 --- a/arch/powerpc/cpu/mpc8xx/fec.c +++ b/arch/powerpc/cpu/mpc8xx/fec.c @@ -6,10 +6,12 @@ */ #include -#include +#include #include +#include #include -#include + +#include DECLARE_GLOBAL_DATA_PTR; diff --git a/board/gdsys/405ex/io64.c b/board/gdsys/405ex/io64.c index 6a83788..848cdde 100644 --- a/board/gdsys/405ex/io64.c +++ b/board/gdsys/405ex/io64.c @@ -264,8 +264,7 @@ int last_stage_init(void) putc(slash[k % 8]); } - int retval; - struct mii_dev *mdiodev = mdio_alloc(); + mdiodev = mdio_alloc(); if (!mdiodev) return -ENOMEM; strncpy(mdiodev->name, CONFIG_SYS_GBIT_MII1_BUSNAME, MDIO_NAME_LEN); diff --git a/drivers/net/bfin_mac.c b/drivers/net/bfin_mac.c index 26b19d5..1307c80 100644 --- a/drivers/net/bfin_mac.c +++ b/drivers/net/bfin_mac.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include @@ -128,6 +129,8 @@ int bfin_EMAC_initialize(bd_t *bis) retval = mdio_register(mdiodev); if (retval < 0) return retval; + + dev->priv = mdiodev; #endif return 0; @@ -236,8 +239,9 @@ static int bfin_EMAC_recv(struct eth_device *dev) static int bfin_miiphy_init(struct eth_device *dev, int *opmode) { const unsigned short pins[] = CONFIG_BFIN_MAC_PINS; - u16 phydat; + int phydat; size_t count; + struct mii_dev *mdiodev = dev->priv; /* Enable PHY output */ bfin_write_VR_CTL(bfin_read_VR_CTL() | CLKBUFOE); @@ -250,12 +254,15 @@ static int bfin_miiphy_init(struct eth_device *dev, int *opmode) bfin_write_EMAC_SYSCTL(RXDWA | RXCKS | SET_MDCDIV(MDC_FREQ_TO_DIV(CONFIG_PHY_CLOCK_FREQ))); /* turn on auto-negotiation and wait for link to come up */ - bfin_miiphy_write(dev->name, CONFIG_PHY_ADDR, MII_BMCR, BMCR_ANENABLE); + bfin_miiphy_write(mdiodev, CONFIG_PHY_ADDR, MDIO_DEVAD_NONE, MII_BMCR, + BMCR_ANENABLE); count = 0; while (1) { ++count; - if (bfin_miiphy_read(dev->name, CONFIG_PHY_ADDR, MII_BMSR, &phydat)) - return -1; + phydat = bfin_miiphy_read(mdiodev, CONFIG_PHY_ADDR, + MDIO_DEVAD_NONE, MII_BMSR); + if (phydat < 0) + return phydat; if (phydat & BMSR_LSTATUS) break; if (count > 30000) { @@ -266,8 +273,10 @@ static int bfin_miiphy_init(struct eth_device *dev, int *opmode) } /* see what kind of link we have */ - if (bfin_miiphy_read(dev->name, CONFIG_PHY_ADDR, MII_LPA, &phydat)) - return -1; + phydat = bfin_miiphy_read(mdiodev, CONFIG_PHY_ADDR, MDIO_DEVAD_NONE, + MII_LPA); + if (phydat < 0) + return phydat; if (phydat & LPA_DUPLEX) *opmode = FDMODE; else diff --git a/drivers/net/davinci_emac.c b/drivers/net/davinci_emac.c index 127f53c..ca457b8 100644 --- a/drivers/net/davinci_emac.c +++ b/drivers/net/davinci_emac.c @@ -243,11 +243,10 @@ int davinci_eth_phy_read(u_int8_t phy_addr, u_int8_t reg_num, u_int16_t *data) if (tmp & MDIO_USERACCESS0_ACK) { *data = tmp & 0xffff; - return(1); + return 0; } - *data = -1; - return(0); + return -EIO; } /* Write to a PHY register via MDIO inteface. Blocks until operation is complete. */ @@ -268,7 +267,7 @@ int davinci_eth_phy_write(u_int8_t phy_addr, u_int8_t reg_num, u_int16_t data) while (readl(&adap_mdio->USERACCESS0) & MDIO_USERACCESS0_GO) ; - return(1); + return 0; } /* PHY functions for a generic PHY */ @@ -391,21 +390,19 @@ static int gen_auto_negotiate(int phy_addr) #if defined(CONFIG_MII) || defined(CONFIG_CMD_MII) static int davinci_mii_phy_read(struct mii_dev *bus, int addr, int devad, - int reg - ) + int reg) { unsigned short value = 0; - int retval = (davinci_eth_phy_read(addr, reg, &value) ? 0 : 1); + int retval = davinci_eth_phy_read(addr, reg, &value); if (retval < 0) return retval; return value; } static int davinci_mii_phy_write(struct mii_dev *bus, int addr, int devad, - int reg, u16 value - ) + int reg, u16 value) { - return(davinci_eth_phy_write(addr, reg, value) ? 0 : 1); + return davinci_eth_phy_write(addr, reg, value); } #endif diff --git a/drivers/net/ep93xx_eth.c b/drivers/net/ep93xx_eth.c index 592f565..8082cf7 100644 --- a/drivers/net/ep93xx_eth.c +++ b/drivers/net/ep93xx_eth.c @@ -569,7 +569,6 @@ static int ep93xx_miiphy_read(struct mii_dev *bus, int addr, int devad, BUG_ON(bus->name == NULL); BUG_ON(addr > MII_ADDRESS_MAX); BUG_ON(reg > MII_REGISTER_MAX); - BUG_ON(&value == NULL); /* * Save the current SelfCTL register value. Set MAC to suppress diff --git a/drivers/net/lpc32xx_eth.c b/drivers/net/lpc32xx_eth.c index 6bdfe5c..8db9886 100644 --- a/drivers/net/lpc32xx_eth.c +++ b/drivers/net/lpc32xx_eth.c @@ -338,25 +338,6 @@ static int mii_reg_write(struct mii_dev *bus, int phy_adr, int devad, } #endif -#if defined(CONFIG_PHYLIB) -int lpc32xx_eth_phy_read(struct mii_dev *bus, int phy_addr, int dev_addr, - int reg_addr) -{ - u16 data; - int ret; - ret = mii_reg_read(bus->name, phy_addr, reg_addr, &data); - if (ret) - return ret; - return data; -} - -int lpc32xx_eth_phy_write(struct mii_dev *bus, int phy_addr, int dev_addr, - int reg_addr, u16 data) -{ - return mii_reg_write(bus->name, phy_addr, reg_addr, data); -} -#endif - /* * Provide default Ethernet buffers base address if target did not. * Locate buffers in SRAM at 0x00001000 to avoid cache issues and @@ -585,8 +566,8 @@ int lpc32xx_eth_phylib_init(struct eth_device *dev, int phyid) printf("mdio_alloc failed\n"); return -ENOMEM; } - bus->read = lpc32xx_eth_phy_read; - bus->write = lpc32xx_eth_phy_write; + bus->read = mii_reg_read; + bus->write = mii_reg_write; strcpy(bus->name, dev->name); ret = mdio_register(bus); diff --git a/drivers/net/smc911x.c b/drivers/net/smc911x.c index f6f8e58..feae8c0 100644 --- a/drivers/net/smc911x.c +++ b/drivers/net/smc911x.c @@ -220,8 +220,7 @@ static int smc911x_rx(struct eth_device *dev) #if defined(CONFIG_MII) || defined(CONFIG_CMD_MII) /* wrapper for smc911x_eth_phy_read */ static int smc911x_miiphy_read(struct mii_dev *bus, int phy, int devad, - int reg - ) + int reg) { u16 val = 0; struct eth_device *dev = eth_get_dev_by_name(bus->name); @@ -231,17 +230,16 @@ static int smc911x_miiphy_read(struct mii_dev *bus, int phy, int devad, return retval; return val; } - return -1; + return -ENODEV; } /* wrapper for smc911x_eth_phy_write */ static int smc911x_miiphy_write(struct mii_dev *bus, int phy, int devad, - int reg, u16 val - ) + int reg, u16 val) { struct eth_device *dev = eth_get_dev_by_name(bus->name); if (dev) return smc911x_eth_phy_write(dev, phy, reg, val); - return -1; + return -ENODEV; } #endif diff --git a/drivers/qe/uec.c b/drivers/qe/uec.c index 1295f99..c2bec58 100644 --- a/drivers/qe/uec.c +++ b/drivers/qe/uec.c @@ -629,7 +629,7 @@ static int uec_miiphy_read(struct mii_dev *bus, int addr, int devad, int reg unsigned short value = 0; int devindex = 0; - if (bus->name == NULL || &value == NULL) { + if (bus->name == NULL) { debug("%s: NULL pointer given\n", __FUNCTION__); } else { devindex = uec_miiphy_find_dev_by_name(bus->name);