From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754069AbcBGSOC (ORCPT ); Sun, 7 Feb 2016 13:14:02 -0500 Received: from mail-lf0-f45.google.com ([209.85.215.45]:36137 "EHLO mail-lf0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753354AbcBGSOA (ORCPT ); Sun, 7 Feb 2016 13:14:00 -0500 Subject: Re: [PATCH v2 3/5] net: phy: dp83848: Reorganize code for readability and safety To: "Andrew F. Davis" , Florian Fainelli , "David S . Miller" References: <1454867241-20928-1-git-send-email-afd@ti.com> <1454867241-20928-4-git-send-email-afd@ti.com> Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org From: Sergei Shtylyov Organization: Cogent Embedded Message-ID: <56B78964.4030606@cogentembedded.com> Date: Sun, 7 Feb 2016 21:13:56 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.0 MIME-Version: 1.0 In-Reply-To: <1454867241-20928-4-git-send-email-afd@ti.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > --- > 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