Re: [v2 3/4] regulator: qcom: Add labibb driver

From: Sumit Semwal
Date: Thu May 14 2020 - 07:27:59 EST


Hello Mark,

Thank you for your review comments!
On Mon, 11 May 2020 at 16:09, Mark Brown <broonie@xxxxxxxxxx> wrote:
>
> 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?
Right, will change.
>
> > +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.
Yes, will update accordingly.

>
> > +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.
>
Makes sense; I am not terribly familiar with the regulator core and
helpers, so let me look and refactor accordingly.

> > + 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).
Will try to simplify.
>
> > + ret = regulator_disable_regmap(rdev);
> > +
> > + if (ret < 0) {
>
> You have lots of blank lines between operations and checking their
> return codes?
>
will correct that.
> > + 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?
Got it. Let me look deeper.
>
> > + 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.
I can change over to switch, though in the current set of downstream
code I've seen, it doesn't look that it would get extended. But I
guess there isn't any harm in moving over to switch. Will do.

Best,
Sumit.