From: Andrew Lunn <andrew@lunn.ch>
To: Quentin Schulz <quentin.schulz@bootlin.com>
Cc: davem@davemloft.net, f.fainelli@gmail.com,
allan.nielsen@microchip.com, linux-kernel@vger.kernel.org,
netdev@vger.kernel.org, thomas.petazzoni@bootlin.com,
alexandre.belloni@bootlin.com
Subject: Re: [PATCH net-next v2 1/6] net: phy: mscc: migrate to phy_select/restore_page functions
Date: Thu, 4 Oct 2018 17:16:30 +0200 [thread overview]
Message-ID: <20181004151630.GE4730@lunn.ch> (raw)
In-Reply-To: <20181004124728.9821-2-quentin.schulz@bootlin.com>
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
next prev parent reply other threads:[~2018-10-04 15:16 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-04 12:47 [PATCH net-next v2 0/6] net: phy: mscc: various improvements to Microsemi PHY driver Quentin Schulz
2018-10-04 12:47 ` [PATCH net-next v2 1/6] net: phy: mscc: migrate to phy_select/restore_page functions Quentin Schulz
2018-10-04 15:16 ` Andrew Lunn [this message]
2018-10-04 15:57 ` Quentin Schulz
2018-10-04 12:47 ` [PATCH net-next v2 2/6] net: phy: mscc: add ethtool statistics counters Quentin Schulz
2018-10-04 15:22 ` Andrew Lunn
2018-10-04 12:47 ` [PATCH net-next v2 3/6] net: phy: mscc: Add EEE init sequence Quentin Schulz
2018-10-04 12:47 ` [PATCH net-next v2 4/6] net: phy: mscc: remove unneeded parenthesis Quentin Schulz
2018-10-04 12:47 ` [PATCH net-next v2 5/6] net: phy: mscc: shorten `x != 0` condition to `x` Quentin Schulz
2018-10-04 12:47 ` [PATCH net-next v2 6/6] net: phy: mscc: remove unneeded temporary variable Quentin Schulz
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=20181004151630.GE4730@lunn.ch \
--to=andrew@lunn.ch \
--cc=alexandre.belloni@bootlin.com \
--cc=allan.nielsen@microchip.com \
--cc=davem@davemloft.net \
--cc=f.fainelli@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=quentin.schulz@bootlin.com \
--cc=thomas.petazzoni@bootlin.com \
/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.