[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190617150502.GU5316@sirena.org.uk>
Date: Mon, 17 Jun 2019 16:05:02 +0100
From: Mark Brown <broonie@...nel.org>
To: Jeffrey Hugo <jeffrey.l.hugo@...il.com>
Cc: lgirdwood@...il.com, agross@...nel.org, bjorn.andersson@...aro.org,
robh+dt@...nel.org, mark.rutland@....com,
linux-arm-msm@...r.kernel.org, linux-kernel@...r.kernel.org,
devicetree@...r.kernel.org
Subject: Re: [PATCH v4 4/7] regulator: qcom_spmi: Add support for PM8005
On Thu, Jun 13, 2019 at 02:25:53PM -0700, Jeffrey Hugo wrote:
> +static int spmi_regulator_ftsmps426_set_voltage(struct regulator_dev *rdev,
> + unsigned selector)
> +{
> + struct spmi_regulator *vreg = rdev_get_drvdata(rdev);
> + u8 buf[2];
> + int mV;
> +
> + mV = spmi_regulator_common_list_voltage(rdev, selector) / 1000;
> +
> + buf[0] = mV & 0xff;
> + buf[1] = mV >> 8;
> + return spmi_vreg_write(vreg, SPMI_FTSMPS426_REG_VOLTAGE_LSB, buf, 2);
> +}
This could just be a set_voltage_sel(), no need for it to be a
set_voltage() operation....
> +static int spmi_regulator_ftsmps426_get_voltage(struct regulator_dev *rdev)
> +{
> + struct spmi_regulator *vreg = rdev_get_drvdata(rdev);
> + u8 buf[2];
> +
> + spmi_vreg_read(vreg, SPMI_FTSMPS426_REG_VOLTAGE_LSB, buf, 2);
> +
> + return (((unsigned int)buf[1] << 8) | (unsigned int)buf[0]) * 1000;
> +}
...or if the conversion is this trivial why do the list_voltage() lookup
above?
> +spmi_regulator_ftsmps426_set_mode(struct regulator_dev *rdev, unsigned int mode)
> +{
> + struct spmi_regulator *vreg = rdev_get_drvdata(rdev);
> + u8 mask = SPMI_FTSMPS426_MODE_MASK;
> + u8 val;
> +
> + switch (mode) {
> + case REGULATOR_MODE_NORMAL:
> + val = SPMI_FTSMPS426_MODE_HPM_MASK;
> + break;
> + case REGULATOR_MODE_FAST:
> + val = SPMI_FTSMPS426_MODE_AUTO_MASK;
> + break;
> + default:
> + val = SPMI_FTSMPS426_MODE_LPM_MASK;
> + break;
> + }
This should validate, it shouldn't just translate invalid values into
valid ones.
Download attachment "signature.asc" of type "application/pgp-signature" (489 bytes)
Powered by blists - more mailing lists