[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <643a0d80-3d99-420e-9e77-acc67728fbe7@gmail.com>
Date: Mon, 22 Apr 2024 12:10:39 +0800
From: Jacky Huang <ychuang570808@...il.com>
To: Andy Shevchenko <andy.shevchenko@...il.com>
Cc: linus.walleij@...aro.org, robh+dt@...nel.org,
krzysztof.kozlowski+dt@...aro.org, conor+dt@...nel.org,
p.zabel@...gutronix.de, j.neuschaefer@....net,
linux-arm-kernel@...ts.infradead.org, linux-gpio@...r.kernel.org,
devicetree@...r.kernel.org, linux-kernel@...r.kernel.org,
ychuang3@...oton.com, schung@...oton.com
Subject: Re: [PATCH v7 3/3] pinctrl: nuvoton: Add ma35d1 pinctrl and GPIO
driver
Dear Andy,
On 2024/4/10 下午 04:54, Andy Shevchenko wrote:
>> +#define MA35_GP_MODE_MASK_WIDTH 2
>> +
>> +#define MA35_GP_SLEWCTL_MASK_WIDTH 2
> I looked at the code how you use these... Oh, please switch to FIELD_GET() /
> FIELD_PREP() (don't forget to include bitfield.h)
>
> ...
>
> ...
>> + regval &= ~GENMASK(setting->shift + MA35_MFP_BITS_PER_PORT - 1,
>> + setting->shift);
> This will generate an awful code. Use respective FIELD_*() macros.
>
> ...
>
>> + regval &= ~GENMASK(gpio * MA35_GP_MODE_MASK_WIDTH - 1,
>> + gpio * MA35_GP_MODE_MASK_WIDTH);
>> + regval |= mode << gpio * MA35_GP_MODE_MASK_WIDTH;
> Ditto.
>
> ...
>
>> + regval &= GENMASK(gpio * MA35_GP_MODE_MASK_WIDTH - 1,
>> + gpio * MA35_GP_MODE_MASK_WIDTH);
>> +
>> + return regval >> gpio * MA35_GP_MODE_MASK_WIDTH;
> Ditto.
>
> ...
>
>
Allow me to remove irrelevant parts.
I attempted to follow your advice and use FIELD_GET() and FIELD_PREP(),
but found
it impractical. The reason is that these two macros require their 'mask'
argument
to be a constant, otherwise compilation errors occur, which is the issue
I encountered.
Since the mask here is calculated and not a constant, compilation errors
occur.
Taking MA35_GP_REG_MODE as an example, within 32 bits, every 2 bits
represent
the mode of a GPIO pin, and the mask is obtained by GENMASK(gpio * 2 -1,
gpio * 2),
where the 'gpio' argument is a variable, not a constant, leading to
compilation
errors.
Due to this reason, I will leave this part unchanged, or do you have any
other suggestions?
Best Regards,
Jacky Huang
Powered by blists - more mailing lists