2024-01-28 15:50:08

by Linus Walleij

[permalink] [raw]
Subject: Re: [PATCH v3 4/4] pinctrl: nuvoton: Add ma35d1 pinctrl and GPIO driver

Hi Jacky,

thanks for your patch!

this caught my eye:

On Tue, Jan 23, 2024 at 9:06 AM Jacky Huang <[email protected]> wrote:

> From: Jacky Huang <[email protected]>
>
> Add common pinctrl and GPIO driver for Nuvoton MA35 series SoC, and
> add support for ma35d1 pinctrl.
>
> Signed-off-by: Jacky Huang <[email protected]>
(...)

> + if (ma35_pinconf_get_power_source(npctl, pin) == MVOLT_1800) {
> + for (i = 0; i < sizeof(ds_1800mv_tbl) / sizeof(u32); i++) {

Isn't this equivalent to:

for (i = 0; i < ARRAY_SIZE(ds_1800mv_tbl; i++) {

> + if (ds_1800mv_tbl[i] == strength)
> + ds_val = i;
> + }
> + } else {
> + for (i = 0; i < sizeof(ds_3300mv_tbl) / sizeof(u32); i++) {

Dito

Perhaps more cases, pls check!

Yours,
Linus Walleij


2024-01-29 02:10:15

by Jacky Huang

[permalink] [raw]
Subject: Re: [PATCH v3 4/4] pinctrl: nuvoton: Add ma35d1 pinctrl and GPIO driver

Dear Linus,

Thanks for your review.


On 2024/1/28 下午 11:49, Linus Walleij wrote:
> Hi Jacky,
>
> thanks for your patch!
>
> this caught my eye:
>
> On Tue, Jan 23, 2024 at 9:06 AM Jacky Huang <[email protected]> wrote:
>
>> From: Jacky Huang <[email protected]>
>>
>> Add common pinctrl and GPIO driver for Nuvoton MA35 series SoC, and
>> add support for ma35d1 pinctrl.
>>
>> Signed-off-by: Jacky Huang <[email protected]>
> (...)
>
>> + if (ma35_pinconf_get_power_source(npctl, pin) == MVOLT_1800) {
>> + for (i = 0; i < sizeof(ds_1800mv_tbl) / sizeof(u32); i++) {
> Isn't this equivalent to:
>
> for (i = 0; i < ARRAY_SIZE(ds_1800mv_tbl; i++) {
>
>> + if (ds_1800mv_tbl[i] == strength)
>> + ds_val = i;
>> + }
>> + } else {
>> + for (i = 0; i < sizeof(ds_3300mv_tbl) / sizeof(u32); i++) {
> Dito
>
> Perhaps more cases, pls check!
>
> Yours,
> Linus Walleij


Yes, I will use ARRAY_SIZE instead.


Best Regards,
Jacky Huang