[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200511103937.GC8216@sirena.org.uk>
Date: Mon, 11 May 2020 11:39:37 +0100
From: Mark Brown <broonie@...nel.org>
To: Sumit Semwal <sumit.semwal@...aro.org>
Cc: agross@...nel.org, bjorn.andersson@...aro.org, lgirdwood@...il.com,
robh+dt@...nel.org, nishakumari@...eaurora.org,
linux-arm-msm@...r.kernel.org, linux-kernel@...r.kernel.org,
devicetree@...r.kernel.org, kgunda@...eaurora.org,
rnayak@...eaurora.org
Subject: Re: [v2 3/4] regulator: qcom: Add labibb driver
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.
Download attachment "signature.asc" of type "application/pgp-signature" (489 bytes)
Powered by blists - more mailing lists