linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mark Brown <broonie@kernel.org>
To: Sumit Semwal <sumit.semwal@linaro.org>
Cc: agross@kernel.org, bjorn.andersson@linaro.org,
	lgirdwood@gmail.com, robh+dt@kernel.org,
	nishakumari@codeaurora.org, linux-arm-msm@vger.kernel.org,
	linux-kernel@vger.kernel.org, devicetree@vger.kernel.org,
	kgunda@codeaurora.org, rnayak@codeaurora.org
Subject: Re: [v2 3/4] regulator: qcom: Add labibb driver
Date: Mon, 11 May 2020 11:39:37 +0100	[thread overview]
Message-ID: <20200511103937.GC8216@sirena.org.uk> (raw)
In-Reply-To: <20200508204200.13481-4-sumit.semwal@linaro.org>

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

On Sat, May 09, 2020 at 02:11:59AM +0530, Sumit Semwal wrote:

> +	ret = regmap_bulk_read(reg->regmap, reg->base +
> +			       REG_LABIBB_STATUS1, &val, 1);
> +	if (ret < 0) {
> +		dev_err(reg->dev, "Read register failed ret = %d\n", ret);
> +		return ret;
> +	}

Why a bulk read of a single register?

> +static int _check_enabled_with_retries(struct regulator_dev *rdev,
> +			int retries, int enabled)
> +{

This is not retrying, this is polling to see if the regulator actually
enabled.

> +static int qcom_labibb_regulator_enable(struct regulator_dev *rdev)
> +{

> +	ret = _check_enabled_with_retries(rdev, retries, 1);
> +	if (ret < 0) {
> +		dev_err(reg->dev, "retries exhausted: enable %s regulator\n",
> +			reg->desc.name);
> +		return ret;
> +	}

If this is useful factor it out into a helper or the core, other devices
also have status bits saying if the regulator is enabled.  It looks like
this may be mainly trying to open code something like enable_time, with
possibly some issues where the time taken to enable varies a lot.

> +	if (ret)
> +		return 0;
> +
> +
> +	dev_err(reg->dev, "Can't enable %s\n", reg->desc.name);
> +	return -EINVAL;

Return the actual error code (the logic here is quite convoluted).

> +	ret = regulator_disable_regmap(rdev);
> +
> +	if (ret < 0) {

You have lots of blank lines between operations and checking their
return codes?

> +	ret = _check_enabled_with_retries(rdev, retries, 0);
> +	if (ret < 0) {
> +		dev_err(reg->dev, "retries exhausted: disable %s regulator\n",
> +			reg->desc.name);
> +		return ret;
> +	}

Similarly to the enable path, but is this one about off_on_delay rather
than enable_time?

> +	if (reg_data->type == QCOM_LAB_TYPE) {
> +		reg = &labibb->lab;
> +		reg->desc.enable_mask = LAB_ENABLE_CTL_MASK;
> +	} else {
> +		reg = &labibb->ibb;
> +		reg->desc.enable_mask = IBB_ENABLE_CTL_MASK;
> +	}

Write a switch statement so this is extensible.

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

  reply	other threads:[~2020-05-11 10:39 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-08 20:41 [v2 0/4] Qualcomm labibb regulator driver Sumit Semwal
2020-05-08 20:41 ` [v2 1/4] dt-bindings: regulator: Add labibb regulator Sumit Semwal
2020-05-12  1:43   ` Bjorn Andersson
2020-05-14 11:50     ` Sumit Semwal
2020-05-08 20:41 ` [v2 2/4] arm64: dts: qcom: pmi8998: Add nodes for LAB and IBB regulators Sumit Semwal
2020-05-08 20:41 ` [v2 3/4] regulator: qcom: Add labibb driver Sumit Semwal
2020-05-11 10:39   ` Mark Brown [this message]
2020-05-14 11:27     ` Sumit Semwal
2020-05-27 16:31       ` Sumit Semwal
2020-05-27 16:39         ` Mark Brown
2020-05-12  2:15   ` Bjorn Andersson
2020-05-12 11:44     ` Mark Brown
2020-05-14 11:47     ` Sumit Semwal
2020-05-08 20:42 ` [v2 4/4] regulator: qcom: labibb: Add SC interrupt handling Sumit Semwal
2020-05-11 10:49   ` Mark Brown
2020-05-14 11:50     ` Sumit Semwal
2020-05-12  5:25   ` Bjorn Andersson
2020-05-14 11:58     ` Sumit Semwal

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=20200511103937.GC8216@sirena.org.uk \
    --to=broonie@kernel.org \
    --cc=agross@kernel.org \
    --cc=bjorn.andersson@linaro.org \
    --cc=devicetree@vger.kernel.org \
    --cc=kgunda@codeaurora.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nishakumari@codeaurora.org \
    --cc=rnayak@codeaurora.org \
    --cc=robh+dt@kernel.org \
    --cc=sumit.semwal@linaro.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).