Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1328552
| From | Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH v2 3/5] net: phy: dp83848: Reorganize code for readability and safety |
| Date | 2016-02-07 19:20 +0100 |
| Message-ID | <qZC6e-1yh-11@gated-at.bofh.it> (permalink) |
| References | <qZBDb-130-5@gated-at.bofh.it> <qZBDd-130-33@gated-at.bofh.it> |
| Organization | Cogent Embedded |
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
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH v2 0/5] net: phy: dp83848: Add support for TI TLK10x Ethernet PHYs "Andrew F. Davis" <afd@ti.com> - 2016-02-07 18:50 +0100
[PATCH v2 1/5] net: phy: dp83848: Add macro for dp83848 compatible devices "Andrew F. Davis" <afd@ti.com> - 2016-02-07 18:50 +0100
[PATCH v2 3/5] net: phy: dp83848: Reorganize code for readability and safety "Andrew F. Davis" <afd@ti.com> - 2016-02-07 18:50 +0100
Re: [PATCH v2 3/5] net: phy: dp83848: Reorganize code for readability and safety Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> - 2016-02-07 19:20 +0100
[PATCH v2 5/5] net: phy: dp83848: Add comments for register definitions "Andrew F. Davis" <afd@ti.com> - 2016-02-07 18:50 +0100
[PATCH v2 4/5] net: phy: dp83848: Add support for TI TLK10x Ethernet PHYs "Andrew F. Davis" <afd@ti.com> - 2016-02-07 18:50 +0100
[PATCH v2 2/5] net: phy: dp83848: Add PHY ID for TI version of DP83848C "Andrew F. Davis" <afd@ti.com> - 2016-02-07 18:50 +0100
Re: [PATCH v2 0/5] net: phy: dp83848: Add support for TI TLK10x Ethernet PHYs Florian Fainelli <f.fainelli@gmail.com> - 2016-02-07 23:40 +0100
csiph-web