[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAO_48GFGpHeu_xb9XT9CFMOSUOJgRrb-z_KZ3-r3X78s-2ddjw@mail.gmail.com>
Date: Thu, 14 May 2020 16:57:43 +0530
From: Sumit Semwal <sumit.semwal@...aro.org>
To: Mark Brown <broonie@...nel.org>
Cc: agross@...nel.org, Bjorn Andersson <bjorn.andersson@...aro.org>,
lgirdwood@...il.com, robh+dt@...nel.org,
Nisha Kumari <nishakumari@...eaurora.org>,
linux-arm-msm@...r.kernel.org, LKML <linux-kernel@...r.kernel.org>,
devicetree@...r.kernel.org, kgunda@...eaurora.org,
Rajendra Nayak <rnayak@...eaurora.org>
Subject: Re: [v2 3/4] regulator: qcom: Add labibb driver
Hello Mark,
Thank you for your review comments!
On Mon, 11 May 2020 at 16:09, Mark Brown <broonie@...nel.org> 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.
Powered by blists - more mailing lists