devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: skakit@codeaurora.org
To: Mark Brown <broonie@kernel.org>
Cc: Andy Gross <agross@kernel.org>,
	Bjorn Andersson <bjorn.andersson@linaro.org>,
	Rob Herring <robh+dt@kernel.org>,
	Lee Jones <lee.jones@linaro.org>,
	Liam Girdwood <lgirdwood@gmail.com>,
	mka@chromium.org, swboyd@chromium.org,
	Das Srinagesh <gurus@codeaurora.org>,
	David Collins <collinsd@codeaurora.org>,
	kgunda@codeaurora.org,
	Subbaraman Narayanamurthy <subbaram@codeaurora.org>,
	linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/4] regulator: Add a regulator driver for the PM8008 PMIC
Date: Tue, 28 Sep 2021 17:46:54 +0530	[thread overview]
Message-ID: <fbd80685df0a86b30868187e2556d67f@codeaurora.org> (raw)
In-Reply-To: <20210917153837.GB4700@sirena.org.uk>

Hi Mark,

Thanks for reviewing the changes!

On 2021-09-17 21:08, Mark Brown wrote:
> On Fri, Sep 17, 2021 at 04:15:37PM +0530, Satya Priya wrote:
> 
>> +static int pm8008_regulator_is_enabled(struct regulator_dev *rdev)
>> +{
>> +	struct pm8008_regulator *pm8008_reg = rdev_get_drvdata(rdev);
>> +	int rc;
>> +	u8 reg;
>> +
>> +	rc = pm8008_read(pm8008_reg->regmap,
>> +			LDO_ENABLE_REG(pm8008_reg->base), &reg, 1);
>> +	if (rc < 0) {
>> +		pr_err("failed to read enable reg rc=%d\n", rc);
>> +		return rc;
>> +	}
>> +
>> +	return !!(reg & ENABLE_BIT);
>> +}
> 
> This could just be regulator_is_enabled_regmap().  There's also a lot 
> of
> instances in the driver where it's using pr_err() not dev_err() (and
> similarly for the debug prints).
> 

Okay, I'll use the helper regulator_is_enabled_regmap() here and remove 
this completely.

>> +
>> +static int pm8008_regulator_enable(struct regulator_dev *rdev)
>> +{
>> +	struct pm8008_regulator *pm8008_reg = rdev_get_drvdata(rdev);
>> +	int rc, current_uv, delay_us, delay_ms, retry_count = 10;
>> +	u8 reg;
> 
> This is the regmap helper.
> 

Okay, I'll use regulator_enable_regmap().

>> +	/*
>> +	 * Wait for the VREG_READY status bit to be set using a timeout 
>> delay
>> +	 * calculated from the current commanded voltage.
>> +	 */
>> +	delay_us = STARTUP_DELAY_USEC
>> +			+ DIV_ROUND_UP(current_uv, pm8008_reg->step_rate);
>> +	delay_ms = DIV_ROUND_UP(delay_us, 1000);
> 
> Set poll_enable_time and implement get_status() then this will be
> handled by the core.
> 

Anyway I will be removing this API.

>> +static int pm8008_regulator_disable(struct regulator_dev *rdev)
>> +{
> 
> Use the regmap helper.
> 

Ok, I'll use regulator_disable_regmap.

>> +	rc = pm8008_write_voltage(pm8008_reg, min_uv, max_uv);
>> +	if (rc < 0)
>> +		return rc;
> 
> This is the only place where write_voltage() is called, may as well 
> just
> inline it.
> 

Okay.

>> +	init_voltage = -EINVAL;
>> +	of_property_read_u32(reg_node, "qcom,init-voltage", &init_voltage);
> 
> Why does this property exist and if it's needed why is it specific to
> this device?  It looks like the device allows you to read the voltage 
> on
> startup from the regmap.
> 

I think it is not necessary, will remove it.

>> +	init_data = of_get_regulator_init_data(dev, reg_node,
>> +						&pm8008_reg->rdesc);
>> +	if (init_data == NULL) {
>> +		dev_err(dev, "%s: failed to get regulator data\n", name);
>> +		return -ENODATA;
>> +	}
>> +	if (!init_data->constraints.name) {
>> +		dev_err(dev, "%s: regulator name missing\n", name);
>> +		return -EINVAL;
>> +	}
> 
> Just let the core find the init data for you, there is no reason to
> insist on a system provided name - that is an entirely optional 
> property
> for systems to use, there is no reason for a regulator driver to care.
> 

OK, I will remove this if check.

>> +	init_data->constraints.input_uV = init_data->constraints.max_uV;
>> +	init_data->constraints.valid_ops_mask |= REGULATOR_CHANGE_STATUS
>> +						| REGULATOR_CHANGE_VOLTAGE;
> 
> This is absolutely not something that a regulator driver should be
> doing, the whole point with constraints is that they come from the
> machine.
> 

Okay I will remove this.

>> +static int pm8008_parse_regulator(struct regmap *regmap, struct 
>> device *dev)
>> +{
>> +	int rc = 0;
>> +	const char *name;
>> +	struct device_node *child;
>> +	struct pm8008_regulator *pm8008_reg;
>> +
>> +	/* parse each subnode and register regulator for regulator child */
>> +	for_each_available_child_of_node(dev->of_node, child) {
>> +		pm8008_reg = devm_kzalloc(dev, sizeof(*pm8008_reg), GFP_KERNEL);
>> +		if (!pm8008_reg)
> 
> You shouldn't be doing this, just unconditionally register all the
> regulators supported by the chip.  If they don't appear in the DT 
> that's
> totally fine - it gives read only access which can be useful for
> diagnostics.

Okay will remove this check as well.

-Satya Priya.

  reply	other threads:[~2021-09-28 12:17 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-17 10:45 [PATCH 0/4] Add Qualcomm Technologies, Inc. PM8008 regulator driver Satya Priya
2021-09-17 10:45 ` [PATCH 1/4] dt-bindings: mfd: pm8008: Add pm8008 regulator node Satya Priya
2021-09-17 19:48   ` Rob Herring
2021-09-20 19:32   ` Stephen Boyd
2021-09-28 12:31     ` skakit
2021-09-20 20:40   ` Rob Herring
2021-09-28 12:43     ` skakit
2021-09-17 10:45 ` [PATCH 2/4] regulator: dt-bindings: Add pm8008 regulator bindings Satya Priya
2021-09-17 15:48   ` Mark Brown
2021-09-28 12:44     ` skakit
2021-09-17 10:45 ` [PATCH 3/4] regulator: Add a regulator driver for the PM8008 PMIC Satya Priya
2021-09-17 15:38   ` Mark Brown
2021-09-28 12:16     ` skakit [this message]
2021-09-17 10:45 ` [PATCH 4/4] arm64: dts: qcom: sc7280: Add pm8008 regulators support for sc7280-idp Satya Priya
2021-09-20 19:37   ` Stephen Boyd
2021-09-28 12:42     ` skakit
2021-09-17 11:01 ` [PATCH 0/4] Add Qualcomm Technologies, Inc. PM8008 regulator driver skakit

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=fbd80685df0a86b30868187e2556d67f@codeaurora.org \
    --to=skakit@codeaurora.org \
    --cc=agross@kernel.org \
    --cc=bjorn.andersson@linaro.org \
    --cc=broonie@kernel.org \
    --cc=collinsd@codeaurora.org \
    --cc=devicetree@vger.kernel.org \
    --cc=gurus@codeaurora.org \
    --cc=kgunda@codeaurora.org \
    --cc=lee.jones@linaro.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mka@chromium.org \
    --cc=robh+dt@kernel.org \
    --cc=subbaram@codeaurora.org \
    --cc=swboyd@chromium.org \
    /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;
as well as URLs for NNTP newsgroup(s).