[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAHp75VdPjT-wNw0_fNXBEd9ub2Eg_thM2wY9QqrjhwYcz+=ytQ@mail.gmail.com>
Date: Fri, 16 Oct 2020 18:28:29 +0300
From: Andy Shevchenko <andy.shevchenko@...il.com>
To: Gene Chen <gene.chen.richtek@...il.com>
Cc: Jonathan Cameron <jic23@...nel.org>,
Rob Herring <robh+dt@...nel.org>,
Matthias Brugger <matthias.bgg@...il.com>,
Hartmut Knaack <knaack.h@....de>,
Lars-Peter Clausen <lars@...afoo.de>,
Peter Meerwald <pmeerw@...erw.net>,
devicetree <devicetree@...r.kernel.org>,
linux-iio <linux-iio@...r.kernel.org>,
linux-arm Mailing List <linux-arm-kernel@...ts.infradead.org>,
"moderated list:ARM/Mediatek SoC support"
<linux-mediatek@...ts.infradead.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
Gene Chen <gene_chen@...htek.com>, Wilma.Wu@...iatek.com,
shufan_lee@...htek.com, cy_huang@...htek.com,
benjamin.chao@...iatek.com
Subject: Re: [PATCH v6 3/3] iio: adc: mt6360: Add ADC driver for MT6360
On Wed, Sep 30, 2020 at 11:55 AM Gene Chen <gene.chen.richtek@...il.com> wrote:
>
> From: Gene Chen <gene_chen@...htek.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
Powered by blists - more mailing lists