From: Chi-Wen Weng <cwweng.linux@gmail.com>
To: Andy Shevchenko <andriy.shevchenko@intel.com>
Cc: jic23@kernel.org, robh@kernel.org, krzk+dt@kernel.org,
conor+dt@kernel.org, dlechner@baylibre.com, nuno.sa@analog.com,
andy@kernel.org, linux-arm-kernel@lists.infradead.org,
linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org, cwweng@nuvoton.com
Subject: Re: [PATCH v2 2/2] iio: adc: Add Nuvoton MA35D1 EADC driver
Date: Mon, 13 Jul 2026 20:06:42 +0800 [thread overview]
Message-ID: <cd0aa9c5-6e24-4b8b-92d1-630cf47b066b@gmail.com> (raw)
In-Reply-To: <alTJPExu9b3lRtx_@ashevche-desk.local>
Hi Andy,
Thank you for the detailed review.
> bitmap.h implies bitops.h...
>
>> +#include <linux/bitops.h>
>
> ...so you may drop this one.
Will do. I will drop linux/bitops.h. I will also drop
linux/mod_devicetable.h since platform_device.h is enough here.
> Please, make all register offsets fixed width, exempli gratia
>
> define MA35D1_EADC_STATUS2 0x0f8
Will fix all register offsets to use fixed-width hex values.
>> +#define MA35D1_EADC_INTSRC0_SPLIEN(n) BIT(n)
>
> Useless? Can't BIT() be used directly?
The field selects which sample module raises ADINT0. This initial driver
only uses sample module 0, so I will replace this helper with a fixed
named bit for SPLIEN0.
>> +#define MA35D1_EADC_INTERNAL_VREF_MV 1600
>
> _mV (yes, as per SI).
Will rename the macro and field to use _mV.
>> +#define MA35D1_EADC_REF_STABLE_US 1000
>
> (1 * USEC_PER_MSEC) ?
> If go this way, include time.h for the multiplier definition.
Will change this to use USEC_PER_MSEC and include linux/time.h.
>> +static const struct regmap_config ma35d1_adc_regmap_config = {
>> + .reg_bits = 32,
>> + .val_bits = 32,
>> + .reg_stride = 4,
>> + .max_register = MA35D1_EADC_REFADJCTL,
>
> No cache?
No register cache is intended for this MMIO ADC block. I will make that
explicit by setting .cache_type = REGCACHE_NONE.
>> +static bool ma35d1_adc_valid_diff_pair(unsigned int vinp, unsigned
int vinn)
>
> Wondering if this is just
>
> return (vinp >= 0 && vinp < 4 && (vinn == vinp + 4));
Yes, the valid differential pairs are 0-4, 1-5, 2-6 and 3-7. Since vinp
is unsigned, I will simplify this to:
return vinp < 4 && vinn == vinp + 4;
>> +static int ma35d1_adc_set_bits(...)
>> +static int ma35d1_adc_clear_bits(...)
>
> What's the point in these wrappers?
There is no strong reason to keep them. I will remove the wrappers and
use regmap_set_bits() / regmap_clear_bits() directly.
>> +static int ma35d1_adc_setup_reference(struct ma35d1_adc *adc)
>
> Add a short comment with reference to a datasheet table/section/et
cetera.
Will add a short comment describing the REFADJCTL/PDREF and VREFSEL
settings according to the MA35D1 EADC reference control description.
> With
>
> static regmap *map = adc->regmap;
>
> this becomes ...
Will use a local regmap pointer in functions that access several
registers. That should make the code shorter and easier to read.
>> + ret = regmap_update_bits(adc->regmap, MA35D1_EADC_CTL,
>> + MA35D1_EADC_CTL_DIFFEN |
>> + MA35D1_EADC_CTL_DMOF, ctl);
>
> regmap_assign_bits()
Will use regmap_assign_bits() for the differential mode bits.
>> +static int ma35d1_adc_update_scan_mode(...)
>
> This is interesting check...
I will rework this to explicitly accept exactly one IIO_VOLTAGE scan
channel. This avoids depending on the last bit found in the scan mask.
>> + guard(mutex)(&adc->lock);
>> + if (adc->suspended || !adc->scan_chan)
>> + goto done;
>
> This is usually leads to a mess in the compiler...
Will fix this by removing the goto from the trigger handler and using a
scoped_guard() block instead.
>> + chan->info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
>> + BIT(IIO_CHAN_INFO_SCALE);
>
> Broken indentation...
Will fix the indentation.
>> +static struct iio_chan_spec
>> +ma35d1_adc_timestamp_channel(unsigned int scan_index)
>
> Useless wrapper. Just put _SOFT_TIMESTAMP() in place.
Will remove the helper and assign the timestamp channel directly using a
compound literal.
>> + if (!num_channels)
>> + return dev_err_probe(dev, -ENODATA,
>> + "no ADC channels configured\n");
>
> I would return -ENOENT...
Will change this to -ENOENT.
>> + channels = devm_kcalloc(dev, num_channels + 1,
sizeof(*channels), GFP_KERNEL);
>
> size_add() ?
Will use size_add(num_channels, 1).
>> + differential = false;
>> + vinn = 0;
>
> Make it an 'else' branch.
Will do.
>> + adc->vref = devm_regulator_get_optional(dev, "vref");
>
> It can be unnested:
Will unnest the optional regulator handling in v3.
>> + adc->vref_mv = ret / 1000;
>
> (MICRO / MILLI)
>
> instead of plain 1000.
Will fix this as well. The regulator API returns the voltage in
microvolts, while the driver stores the reference in millivolts for
IIO scale reporting. I will rename the field to vref_mV and use:
adc->vref_mV = ret / (MICRO / MILLI);
with linux/units.h included, instead of using the plain 1000 constant.
Thanks again for the review. I will address these comments in the next
revision.
Best regards,
Chi-Wen
prev parent reply other threads:[~2026-07-13 12:06 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-13 8:11 [PATCH v2 0/2] iio: adc: Add Nuvoton MA35D1 EADC support Chi-Wen Weng
2026-07-13 8:11 ` [PATCH v2 1/2] dt-bindings: iio: adc: Add Nuvoton MA35D1 EADC Chi-Wen Weng
2026-07-13 9:35 ` Rob Herring (Arm)
2026-07-13 8:11 ` [PATCH v2 2/2] iio: adc: Add Nuvoton MA35D1 EADC driver Chi-Wen Weng
2026-07-13 8:30 ` sashiko-bot
2026-07-13 11:17 ` Andy Shevchenko
2026-07-13 12:06 ` Chi-Wen Weng [this message]
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=cd0aa9c5-6e24-4b8b-92d1-630cf47b066b@gmail.com \
--to=cwweng.linux@gmail.com \
--cc=andriy.shevchenko@intel.com \
--cc=andy@kernel.org \
--cc=conor+dt@kernel.org \
--cc=cwweng@nuvoton.com \
--cc=devicetree@vger.kernel.org \
--cc=dlechner@baylibre.com \
--cc=jic23@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nuno.sa@analog.com \
--cc=robh@kernel.org \
/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