Re: [PATCH net-next v4 4/7] net: pse-pd: Add new power limit get and set c33 features

Kory Maincent
2024-06-26T08:21:50Z

On Tue, 25 Jun 2024 18:49:26 +0000
Sai Krishna Gajula <saikrishnag@marvell.com> wrote:

> > + * Return: 0 on success and failure value on error */ int
> > +pse_ethtool_set_pw_limit(struct pse_control *psec,
> > + struct netlink_ext_ack *extack,
> > + const unsigned int pw_limit)
> > +{
> > + int uV, uA, ret;
> > + s64 tmp_64;
> > +
> > + ret = regulator_get_voltage(psec->ps);
> > + if (!ret) {
> > + NL_SET_ERR_MSG(extack,
> > + "Can't read current voltage");
> > + return ret;
> > + }
> > + if (ret < 0) {
> > + NL_SET_ERR_MSG(extack,
> > + "Error reading current voltage");
> > + return ret;
> > + }
>
> Is there any significance of checking "ret" value against '0' and '< 0'
> separately? Just trying to understand, these checks reflect regulator
> failure etc..?

In fact having ret = 0 is not an error for regulator_get_voltage() but with a 0
value I can't calculate the currrent.
I will update the error message and return value:

NL_SET_ERR_MSG(extack, "Can't calculate the current, PSE voltage read is 0");
return -ERANGE;

> [...]
> Reviewed-by: Sai Krishna <saikrishnag@marvell.com>

Thanks!

Regards,
--
Köry Maincent, Bootlin
Embedded Linux and kernel engineering