From: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
To: "Andrew F. Davis" <afd@ti.com>,
Florian Fainelli <f.fainelli@gmail.com>,
"David S . Miller" <davem@davemloft.net>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 3/5] net: phy: dp83848: Reorganize code for readability and safety
Date: Sun, 7 Feb 2016 21:13:56 +0300 [thread overview]
Message-ID: <56B78964.4030606@cogentembedded.com> (raw)
In-Reply-To: <1454867241-20928-4-git-send-email-afd@ti.com>
Hello.
On 02/07/2016 08:47 PM, Andrew F. Davis wrote:
> Reorganize code by moving the desired interrupt mask definition
> out of function. Also rearrange the enable/disable interrupt function
> to prevent accidental over-writing of values in registers.
>
> Signed-off-by: Andrew F. Davis <afd@ti.com>
> ---
> drivers/net/phy/dp83848.c | 33 ++++++++++++++++++++-------------
> 1 file changed, 20 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/net/phy/dp83848.c b/drivers/net/phy/dp83848.c
> index d4686d5f..20d3b9d 100644
> --- a/drivers/net/phy/dp83848.c
> +++ b/drivers/net/phy/dp83848.c
[...]
> @@ -46,23 +52,24 @@ static int dp83848_ack_interrupt(struct phy_device *phydev)
>
> static int dp83848_config_intr(struct phy_device *phydev)
> {
> - int err;
> + int control, ret;
> +
> + control = phy_read(phydev, DP83848_MICR);
> + if (control < 0)
> + return control;
>
> if (phydev->interrupts == PHY_INTERRUPT_ENABLED) {
> - err = phy_write(phydev, DP83848_MICR,
> - DP83848_MICR_INT_OE |
> - DP83848_MICR_INTEN);
> - if (err < 0)
> - return err;
> -
> - return phy_write(phydev, DP83848_MISR,
> - DP83848_MISR_ANC_INT_EN |
> - DP83848_MISR_DUP_INT_EN |
> - DP83848_MISR_SPD_INT_EN |
> - DP83848_MISR_LINK_INT_EN);
> + control |= DP83848_MICR_INT_OE;
> + control |= DP83848_MICR_INTEN;
I'd have written this on a single line.
[...]
MBR, Sergei
next prev parent reply other threads:[~2016-02-07 18:13 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-07 17:47 [PATCH v2 0/5] net: phy: dp83848: Add support for TI TLK10x Ethernet PHYs Andrew F. Davis
2016-02-07 17:47 ` [PATCH v2 1/5] net: phy: dp83848: Add macro for dp83848 compatible devices Andrew F. Davis
2016-02-07 17:47 ` [PATCH v2 2/5] net: phy: dp83848: Add PHY ID for TI version of DP83848C Andrew F. Davis
2016-02-17 23:37 ` Andrew F. Davis
2016-02-17 23:44 ` Florian Fainelli
2016-02-07 17:47 ` [PATCH v2 3/5] net: phy: dp83848: Reorganize code for readability and safety Andrew F. Davis
2016-02-07 18:13 ` Sergei Shtylyov [this message]
2016-02-07 17:47 ` [PATCH v2 4/5] net: phy: dp83848: Add support for TI TLK10x Ethernet PHYs Andrew F. Davis
2016-02-07 17:47 ` [PATCH v2 5/5] net: phy: dp83848: Add comments for register definitions Andrew F. Davis
2016-02-07 22:31 ` [PATCH v2 0/5] net: phy: dp83848: Add support for TI TLK10x Ethernet PHYs Florian Fainelli
2016-02-11 16:53 ` David Miller
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=56B78964.4030606@cogentembedded.com \
--to=sergei.shtylyov@cogentembedded.com \
--cc=afd@ti.com \
--cc=davem@davemloft.net \
--cc=f.fainelli@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).