mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mark Brown <broonie@kernel.org>
To: Pi-Hsun Shih <pihsun@chromium.org>
Cc: Nicolas Boichat <drinkcat@chromium.org>,
	Liam Girdwood <lgirdwood@gmail.com>,
	Benson Leung <bleung@chromium.org>,
	Enric Balletbo i Serra <enric.balletbo@collabora.com>,
	Guenter Roeck <groeck@chromium.org>,
	Gwendal Grignou <gwendal@chromium.org>,
	Lee Jones <lee.jones@linaro.org>,
	Fabien Lahoudere <fabien.lahoudere@collabora.com>,
	Tzung-Bi Shih <tzungbi@google.com>,
	open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 2/2] regulator: Add driver for cros-ec-regulator
Date: Tue, 9 Jun 2020 12:19:19 +0100	[thread overview]
Message-ID: <20200609111919.GB4583@sirena.org.uk> (raw)
In-Reply-To: <20200609080001.121499-3-pihsun@chromium.org>

[-- Attachment #1: Type: text/plain, Size: 1746 bytes --]

On Tue, Jun 09, 2020 at 03:59:55PM +0800, Pi-Hsun Shih wrote:

> +static int cros_ec_regulator_set_state(struct regulator_dev *dev, bool enable)
> +{
> +	struct cros_ec_regulator_data *data = rdev_get_drvdata(dev);
> +	struct ec_params_regulator_enable cmd = {
> +		.index = data->index,
> +		.enable = enable ? 1 : 0,

The ternery operator is totally redundant here.

> +static int cros_ec_regulator_enable(struct regulator_dev *dev)
> +{
> +	return cros_ec_regulator_set_state(dev, true);
> +}

> +static int cros_ec_regulator_disable(struct regulator_dev *dev)
> +{
> +	return cros_ec_regulator_set_state(dev, false);
> +}

I'm not sure that the shared function is really worthwhile though,
there's not really enough in it and certainly not anything complicated.

> +static int cros_ec_regulator_set_voltage(struct regulator_dev *dev, int min_uV,
> +					 int max_uV, unsigned int *selector)
> +{
> +	struct cros_ec_regulator_data *data = rdev_get_drvdata(dev);
> +	int min_mV = DIV_ROUND_UP(min_uV, 1000);
> +	int max_mV = max_uV / 1000;
> +	struct ec_params_regulator_set_voltage cmd = {
> +		.index = data->index,
> +		.min_mv = min_mV,
> +		.max_mv = max_mV,
> +	};
> +
> +	if (min_mV > max_mV)
> +		return -EINVAL;

The core will do this for you.

> +	ret = of_property_read_u32(np, "google,remote-regulator",
> +				   &drvdata->index);
> +	if (ret < 0)
> +		return ret;

This remote-regulator property is a bit weird, it feels like it should
be a reg property on a bus.

> +#if defined(CONFIG_OF)
> +static const struct of_device_id regulator_cros_ec_of_match[] = {
> +	{ .compatible = "regulator-cros-ec", },
> +	{},
> +};
> +MODULE_DEVICE_TABLE(of, regulator_cros_ec_of_match);
> +#endif

Your compatible is google,regulator-cros-ec.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  reply	other threads:[~2020-06-09 11:19 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-09  7:59 [PATCH 0/2] Add support for voltage regulator on ChromeOS EC Pi-Hsun Shih
2020-06-09  7:59 ` [PATCH 1/2] dt-bindings: regulator: Add DT binding for cros-ec-regulator Pi-Hsun Shih
2020-06-09 11:21   ` Mark Brown
2020-06-09  7:59 ` [PATCH 2/2] regulator: Add driver " Pi-Hsun Shih
2020-06-09 11:19   ` Mark Brown [this message]
2020-06-10  4:31     ` Pi-Hsun Shih
2020-06-10 10:01       ` Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200609111919.GB4583@sirena.org.uk \
    --to=broonie@kernel.org \
    --cc=bleung@chromium.org \
    --cc=drinkcat@chromium.org \
    --cc=enric.balletbo@collabora.com \
    --cc=fabien.lahoudere@collabora.com \
    --cc=groeck@chromium.org \
    --cc=gwendal@chromium.org \
    --cc=lee.jones@linaro.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pihsun@chromium.org \
    --cc=tzungbi@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®