[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YUiPqJjsoBg99VbR@shell.armlinux.org.uk>
Date: Mon, 20 Sep 2021 14:42:00 +0100
From: "Russell King (Oracle)" <linux@...linux.org.uk>
To: Horatiu Vultur <horatiu.vultur@...rochip.com>
Cc: davem@...emloft.net, kuba@...nel.org, robh+dt@...nel.org,
andrew@...n.ch, f.fainelli@...il.com,
alexandre.belloni@...tlin.com, vladimir.oltean@....com,
UNGLinuxDriver@...rochip.com, netdev@...r.kernel.org,
devicetree@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-phy@...ts.infradead.org, linux-pm@...r.kernel.org
Subject: Re: [RFC PATCH net-next 03/12] phy: Add lan966x ethernet serdes PHY
driver
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.
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
Powered by blists - more mailing lists