linux-mediatek.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Andy Shevchenko <andy.shevchenko@gmail.com>
To: Gene Chen <gene.chen.richtek@gmail.com>
Cc: Gene Chen <gene_chen@richtek.com>,
	devicetree <devicetree@vger.kernel.org>,
	Lars-Peter Clausen <lars@metafoo.de>,
	linux-iio <linux-iio@vger.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	cy_huang@richtek.com, benjamin.chao@mediatek.com,
	Rob Herring <robh+dt@kernel.org>,
	"moderated list:ARM/Mediatek SoC support"
	<linux-mediatek@lists.infradead.org>,
	linux-arm Mailing List <linux-arm-kernel@lists.infradead.org>,
	Peter Meerwald <pmeerw@pmeerw.net>,
	Hartmut Knaack <knaack.h@gmx.de>,
	Matthias Brugger <matthias.bgg@gmail.com>,
	Wilma.Wu@mediatek.com, Jonathan Cameron <jic23@kernel.org>,
	shufan_lee@richtek.com
Subject: Re: [PATCH v6 3/3] iio: adc: mt6360: Add ADC driver for MT6360
Date: Fri, 16 Oct 2020 18:28:29 +0300	[thread overview]
Message-ID: <CAHp75VdPjT-wNw0_fNXBEd9ub2Eg_thM2wY9QqrjhwYcz+=ytQ@mail.gmail.com> (raw)
In-Reply-To: <1601542448-7433-4-git-send-email-gene.chen.richtek@gmail.com>

On Wed, Sep 30, 2020 at 11:55 AM Gene Chen <gene.chen.richtek@gmail.com> wrote:
>
> From: Gene Chen <gene_chen@richtek.com>
>
> Add MT6360 ADC driver include Charger Current, Voltage, and

including

> Temperature.

...

> +#define MT6360_AICR_MASK       GENMASK(7, 2)

bits.h is missed.

...

> +#define MT6360_ADCEN_MASK      0x8000

BIT() ?

...

> +static int mt6360_adc_read_channel(struct mt6360_adc_data *mad, int channel, int *val)
> +{

> +       start_t = ktime_get();
> +       predict_end_t = ktime_add_ms(mad->last_off_timestamps[channel], 2 * ADC_WAIT_TIME_MS);
> +
> +       if (ktime_after(start_t, predict_end_t))
> +               pre_wait_time = ADC_WAIT_TIME_MS;
> +       else
> +               pre_wait_time = 3 * ADC_WAIT_TIME_MS;
> +
> +       msleep(pre_wait_time);

This looks like NIH of wait_interruptible() or so.

...

> +       while (true) {

Oh, please avoid infinite loops.

> +               ret = regmap_raw_read(mad->regmap, MT6360_REG_PMUADCRPT1, rpt, sizeof(rpt));
> +               if (ret)
> +                       goto out_adc_conv;
> +
> +               /*
> +                * There are two functions, ZCV and TypeC OTP, running ADC VBAT and TS in
> +                * background, and ADC samples are taken on a fixed frequency no matter read the
> +                * previous one or not.
> +                * To avoid conflict, We set minimum time threshold after enable ADC and
> +                * check report channel is the same.
> +                * The worst case is run the same ADC twice and background function is also running,
> +                * ADC conversion sequence is desire channel before start ADC, background ADC,
> +                * desire channel after start ADC.
> +                * So the minimum correct data is three times of typical conversion time.
> +                */
> +               if ((rpt[0] & MT6360_RPTCH_MASK) == channel)
> +                       break;
> +
> +               msleep(ADC_WAIT_TIME_MS);
> +       }

So, a new NIH of regmap_read_poll_timeout() ?

...

> +       /* rpt[1]: ADC_HI_BYTE, rpt[2]: ADC_LOW_BYTE */
> +       *val = rpt[1] << 8 | rpt[2];

get_unalined_be16() and hence redundant comment.

...

> +static int mt6360_adc_read_offset(struct mt6360_adc_data *mad, int channel, int *val)
> +{
> +       *val = (channel == MT6360_CHAN_TEMP_JC) ? -80 : 0;
> +       return IIO_VAL_INT;

> +

Misplaced blank line.

> +}

> +static const char *mt6360_channel_labels[MT6360_CHAN_MAX] = {
> +       "usbid", "vbusdiv5", "vbusdiv2", "vsys", "vbat", "ibus", "ibat", "chg_vddp", "temp_jc",
> +       "vref_ts", "ts"

Leave comma.
And split  either by power of two or equally between the lines (seems
like 8 + 3 here).

> +};

...

> +       /* Reset all channel off time to the current one */
> +       all_off_time = ktime_get();
> +       for (i = 0; i < MT6360_CHAN_MAX; i++)
> +               info->last_off_timestamps[i] = all_off_time;

memset32() / memset64() / memset_l()
(Not applicable, but JFYI: memset_p() also present)

-- 
With Best Regards,
Andy Shevchenko

_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

  parent reply	other threads:[~2020-10-22 22:36 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-01  8:54 [PATCH v6 0/3] iio: adc: mt6360: Add ADC driver for MT6360 Gene Chen
2020-10-01  8:54 ` [PATCH v6 1/3] dt-bindings: iio: adc: add bindings doc for MT6360 ADC Gene Chen
2020-10-05 14:38   ` Rob Herring
2020-10-01  8:54 ` [PATCH v6 2/3] Documentation: ABI: testing: mt6360: Add ADC sysfs guideline Gene Chen
2020-10-01  8:54 ` [PATCH v6 3/3] iio: adc: mt6360: Add ADC driver for MT6360 Gene Chen
2020-09-30 11:12   ` kernel test robot
2020-10-16 15:28   ` Andy Shevchenko [this message]
2020-10-10 16:57 ` [PATCH v6 0/3] " Jonathan Cameron

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='CAHp75VdPjT-wNw0_fNXBEd9ub2Eg_thM2wY9QqrjhwYcz+=ytQ@mail.gmail.com' \
    --to=andy.shevchenko@gmail.com \
    --cc=Wilma.Wu@mediatek.com \
    --cc=benjamin.chao@mediatek.com \
    --cc=cy_huang@richtek.com \
    --cc=devicetree@vger.kernel.org \
    --cc=gene.chen.richtek@gmail.com \
    --cc=gene_chen@richtek.com \
    --cc=jic23@kernel.org \
    --cc=knaack.h@gmx.de \
    --cc=lars@metafoo.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=matthias.bgg@gmail.com \
    --cc=pmeerw@pmeerw.net \
    --cc=robh+dt@kernel.org \
    --cc=shufan_lee@richtek.com \
    /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).