Re: [PATCH 5/6] pinctrl: sprd: Increase the range of register values

Andy Shevchenko
2023-08-25T10:21:01Z

On Fri, Aug 25, 2023 at 11:18:25AM +0800, Linhua Xu wrote:
> From: Linhua Xu <Linhua.Xu@unisoc.com>
>
> As the UNISOC pin controller version iterates, more registers are required
> to meet new functional requirements. Thus modify them.

...

+ bits.h and...

> +#define NUM_OFFSET (22)
> +#define TYPE_OFFSET (18)
> +#define BIT_OFFSET (10)
> +#define WIDTH_OFFSET (6)

Why do you need parentheses? Also what do these represent
(since they are decimal numbers)?

...

> #define SPRD_PIN_INFO(num, type, offset, width, reg) \
> (((num) & 0xFFF) << NUM_OFFSET | \
> ((type) & 0xF) << TYPE_OFFSET | \
> ((offset) & 0xFF) << BIT_OFFSET | \
> ((width) & 0xF) << WIDTH_OFFSET | \
> - ((reg) & 0xF))
> + ((reg) & 0x1F))

...use GENMASK() everywhere above.

...

> .type = (((a) >> TYPE_OFFSET) & 0xf), \
> .bit_offset = (((a) >> BIT_OFFSET) & 0xff), \
> .bit_width = ((a) >> WIDTH_OFFSET & 0xf), \
> - .reg = ((a) & 0xf) \
> + .reg = ((a) & 0x1f) \

Ditto.

--
With Best Regards,
Andy Shevchenko