Re: [PATCH] net: dsa: bcm_sf2: Propagate error value from mdio_write

From: Heiner Kallweit
Date: Wed Dec 26 2018 - 14:42:40 EST


On 26.12.2018 20:32, Kangjie Lu wrote:
>
>
> On Wed, Dec 26, 2018 at 1:13 PM Heiner Kallweit <hkallweit1@xxxxxxxxx <mailto:hkallweit1@xxxxxxxxx>> wrote:
>
> On 26.12.2018 19:21, Kangjie Lu wrote:
> > Both bcm_sf2_sw_indir_rw and mdiobus_write_nested could fail, so let's
> > return their error codes upstream.
> >
> > Signed-off-by: Kangjie Lu <kjlu@xxxxxxx <mailto:kjlu@xxxxxxx>>
> > ---
> >Â drivers/net/dsa/bcm_sf2.c | 7 +++----
> >Â 1 file changed, 3 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/net/dsa/bcm_sf2.c b/drivers/net/dsa/bcm_sf2.c
> > index 2eb68769562c..236815700fba 100644
> > --- a/drivers/net/dsa/bcm_sf2.c
> > +++ b/drivers/net/dsa/bcm_sf2.c
> > @@ -303,11 +303,10 @@ static int bcm_sf2_sw_mdio_write(struct mii_bus *bus, int addr, int regnum,
> >Â Â Â Â * send them to our master MDIO bus controller
> >Â Â Â Â */
> >Â Â Â Âif (addr == BRCM_PSEUDO_PHY_ADDR && priv->indir_phy_mask & BIT(addr))
> > -Â Â Â Â Â Â Âbcm_sf2_sw_indir_rw(priv, 0, addr, regnum, val);
> > +Â Â Â Â Â Â Âreturn bcm_sf2_sw_indir_rw(priv, 0, addr, regnum, val);
> This is wrong. Please get familiar with what the function does.
> And test changes before submitting them!
>
> Â
> bcm_sf2_sw_indir_rw() doesn't return an error code, so we don't propagate its return value but return 0 after it.
>
> ForÂmdiobus_write_nested(), since it does return an error code, we propagate its error code upstream.Â
>
> Does this sound right to you?
> Â
Better. You should test a change before submitting (and better not only compile-test).
And please no HTML mails. Get familiar with the basics of kernel development
before submitting. Read document "SubmittingPatches" and the following for netdev:
https://www.kernel.org/doc/Documentation/networking/netdev-FAQ.txt
By the way: net-next is closed currently.

>
>
> >Â Â Â Âelse
> > -Â Â Â Â Â Â Âmdiobus_write_nested(priv->master_mii_bus, addr, regnum, val);
> > -
> > -Â Â Âreturn 0;
> > +Â Â Â Â Â Â Âreturn mdiobus_write_nested(priv->master_mii_bus,
> > +Â Â Â Â Â Â Â Â Â Â Â Â Â Â Âaddr, regnum, val);
> >Â }
>
> >Â static irqreturn_t bcm_sf2_switch_0_isr(int irq, void *dev_id)
> >
>
>
>
> --
> Kangjie Lu
> Assistant Professor
> Department of Computer Science and Engineering
> University of Minnesota
> Personal homepage <https://www-users.cs.umn.edu/~kjlu>