lists.openwall.net | lists / announce owl-users owl-dev john-users john-dev passwdqc-users yescrypt popa3d-users / oss-security kernel-hardening musl sabotage tlsify passwords / crypt-dev xvendor / Bugtraq Full-Disclosure linux-kernel linux-netdev linux-ext4 linux-hardening linux-cve-announce PHC | |
Open Source and information security mailing list archives
| ||
|
Date: Thu, 4 Oct 2018 17:16:30 +0200 From: Andrew Lunn <andrew@...n.ch> To: Quentin Schulz <quentin.schulz@...tlin.com> Cc: davem@...emloft.net, f.fainelli@...il.com, allan.nielsen@...rochip.com, linux-kernel@...r.kernel.org, netdev@...r.kernel.org, thomas.petazzoni@...tlin.com, alexandre.belloni@...tlin.com Subject: Re: [PATCH net-next v2 1/6] net: phy: mscc: migrate to phy_select/restore_page functions On Thu, Oct 04, 2018 at 02:47:23PM +0200, Quentin Schulz wrote: > @@ -197,25 +199,30 @@ static int vsc85xx_mdix_set(struct phy_device *phydev, u8 mdix) > if (rc != 0) > return rc; > > - rc = vsc85xx_phy_page_set(phydev, MSCC_PHY_PAGE_EXTENDED); > - if (rc != 0) > - return rc; > + oldpage = phy_select_page(phydev, MSCC_PHY_PAGE_EXTENDED); > + if (oldpage < 0) { > + rc = oldpage; > + goto out; > + } > > - reg_val = phy_read(phydev, MSCC_PHY_EXT_MODE_CNTL); > + reg_val = __phy_read(phydev, MSCC_PHY_EXT_MODE_CNTL); > reg_val &= ~(FORCE_MDI_CROSSOVER_MASK); > if (mdix == ETH_TP_MDI) > reg_val |= FORCE_MDI_CROSSOVER_MDI; > else if (mdix == ETH_TP_MDI_X) > reg_val |= FORCE_MDI_CROSSOVER_MDIX; Hi Quentin Could you use phy_modify_paged() here? This function only accesses a single register, so using the wrapper should not have any disadvantages. The same should apply for any function modifying a single register. > - rc = phy_write(phydev, MSCC_PHY_EXT_MODE_CNTL, reg_val); > + rc = __phy_write(phydev, MSCC_PHY_EXT_MODE_CNTL, reg_val); > if (rc != 0) > - return rc; > + goto out; > > - rc = vsc85xx_phy_page_set(phydev, MSCC_PHY_PAGE_STANDARD); > - if (rc != 0) > + rc = phy_restore_page(phydev, oldpage, rc); > + if (rc < 0) > return rc; > > return genphy_restart_aneg(phydev); > + > +out: > + return phy_restore_page(phydev, oldpage, rc); > } > > static int vsc85xx_downshift_get(struct phy_device *phydev, u8 *count) > @@ -223,25 +230,24 @@ static int vsc85xx_downshift_get(struct phy_device *phydev, u8 *count) > int rc; > u16 reg_val; > > - rc = vsc85xx_phy_page_set(phydev, MSCC_PHY_PAGE_EXTENDED); > - if (rc != 0) > + rc = phy_select_page(phydev, MSCC_PHY_PAGE_EXTENDED); > + if (rc < 0) > goto out; > > - reg_val = phy_read(phydev, MSCC_PHY_ACTIPHY_CNTL); > + reg_val = __phy_read(phydev, MSCC_PHY_ACTIPHY_CNTL); > reg_val &= DOWNSHIFT_CNTL_MASK; > if (!(reg_val & DOWNSHIFT_EN)) > *count = DOWNSHIFT_DEV_DISABLE; > else > *count = ((reg_val & ~DOWNSHIFT_EN) >> DOWNSHIFT_CNTL_POS) + 2; phy_read_paged()? Any function which just accesses a single register should try to use phy_read_paged(), phy_write_paged() or phy_modify_paged() to avoid a lot of boilerplate code. Andrew
Powered by blists - more mailing lists