[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <2E89032DDAA8B9408CB92943514A0337014C1E28A3@SW-EX-MBX01.diasemi.com>
Date: Thu, 22 Mar 2018 10:40:01 +0000
From: Adam Thomson <Adam.Thomson.Opensource@...semi.com>
To: Guenter Roeck <linux@...ck-us.net>,
Adam Thomson <Adam.Thomson.Opensource@...semi.com>,
Heikki Krogerus <heikki.krogerus@...ux.intel.com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Sebastian Reichel <sre@...nel.org>,
"Hans de Goede" <hdegoede@...hat.com>, Jun Li <jun.li@....com>
CC: "linux-usb@...r.kernel.org" <linux-usb@...r.kernel.org>,
"linux-pm@...r.kernel.org" <linux-pm@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"Support Opensource" <Support.Opensource@...semi.com>
Subject: RE: [PATCH v5 4/5] typec: tcpm: Represent source supply through
power_supply
On 22 March 2018 04:09, Guenter Roeck wrote:
> > +static int tcpm_psy_set_prop(struct power_supply *psy,
> > + enum power_supply_property psp,
> > + const union power_supply_propval *val)
> > +{
> > + struct tcpm_port *port = power_supply_get_drvdata(psy);
> > + int ret = 0;
> > +
> > + switch (psp) {
> > + case POWER_SUPPLY_PROP_ONLINE:
> > + ret = tcpm_psy_set_online(port, val);
> > + break;
> > + case POWER_SUPPLY_PROP_VOLTAGE_NOW:
> > + if ((val->intval < (port->pps_data.min_volt * 1000)) ||
> > + (val->intval > (port->pps_data.max_volt * 1000)))
> > + ret = -EINVAL;
> > + else
> > + ret = tcpm_pps_set_out_volt(port, (val->intval / 1000));
> > + break;
> > + case POWER_SUPPLY_PROP_CURRENT_NOW:
> > + if (val->intval > (port->pps_data.max_curr * 1000))
> > + ret = -EINVAL;
> > + else
> > + ret = tcpm_pps_set_op_curr(port, (val->intval / 1000));
>
> I am really not a friend of excessive ( ).
Yes, I got that. :) I am of the opinion that they should be used to enforce
precedence. This to me is good coding practice and makes it unambiguous for the
reader. That's why I use them as above. Do you think the above uses make it
harder to understand or more difficult to maintain?
Powered by blists - more mailing lists