[RFC PATCH net-next 03/12] phy: Add lan966x ethernet serdes PHY driver

Horatiu Vultur horatiu.vultur at microchip.com
Wed Sep 22 03:04:29 PDT 2021


The 09/20/2021 14:42, Russell King (Oracle) wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
> 
> On Mon, Sep 20, 2021 at 11:52:09AM +0200, Horatiu Vultur wrote:
> > +static int lan966x_calc_sd6g40_setup_lane(struct lan966x_sd6g40_setup_args config,
> > +                                       struct lan966x_sd6g40_setup *ret_val)
> > +{
> > +     struct lan966x_sd6g40_mode_args sd6g40_mode;
> > +     struct lan966x_sd6g40_mode_args *mode_args = &sd6g40_mode;
> > +
> > +     if (lan966x_sd6g40_get_conf_from_mode(config.mode, config.refclk125M,
> > +                                           mode_args))
> > +             return -1;
> 
> This needs fixing to be a real negative error number.
> lan966x_sd6g40_setup_lane() propagates this functions non-zero
> return value, which is then propagated through lan966x_sd6g40_setup(),
> and then through serdes_set_mode() to the PHY layer.
> 
> In general, I would suggest that _all_ int-returning functions in the
> kernel that return a negative failure value _should_ _always_ return a
> negative error code, so that your reviewers don't have to chase code
> paths to work out whether a mistake such as the above exists.
> 
> To put it another way: never use "return -1" in the kernel.

Hi Russell,

Thanks for the suggestion. I will fix this in the next version.

> 
> --
> RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
> FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!

-- 
/Horatiu



More information about the linux-phy mailing list