Re: [PATCH 1/6] pinctrl: sprd: Modify the probe function parameters

From: Andy Shevchenko
Date: Fri Aug 25 2023 - 06:09:48 EST


On Fri, Aug 25, 2023 at 11:18:21AM +0800, Linhua Xu wrote:
> From: Linhua Xu <Linhua.Xu@xxxxxxxxxx>
>
> For UNISOC pin controller, the offset values of the common register and
> misc register will be different. Thus put these in the probe function
> parameters.

...

> +#define PINCTRL_REG_OFFSET 0x20

0x0020

> +#define PINCTRL_REG_MISC_OFFSET 0x4020

...

> if (pin->type == GLOBAL_CTRL_PIN) {
> - pin->reg = (unsigned long)sprd_pctl->base +
> - PINCTRL_REG_LEN * reg;
> + pin->reg = (unsigned long)(sprd_pctl->base +
> + (unsigned long)(PINCTRL_REG_LEN * reg));

Please, make sure you get rid of castings completely. They are weird
for the start and may lead to bugs.

> pin->bit_offset = sprd_soc_pin_info[i].bit_offset;
> pin->bit_width = sprd_soc_pin_info[i].bit_width;
> ctrl_pin++;
> } else if (pin->type == COMMON_PIN) {
> pin->reg = (unsigned long)sprd_pctl->base +
> - PINCTRL_REG_OFFSET + PINCTRL_REG_LEN *
> + sprd_pctl->common_pin_offset + PINCTRL_REG_LEN *
> (i - ctrl_pin);
> com_pin++;
> } else if (pin->type == MISC_PIN) {
> pin->reg = (unsigned long)sprd_pctl->base +
> - PINCTRL_REG_MISC_OFFSET + PINCTRL_REG_LEN *
> + sprd_pctl->misc_pin_offset + PINCTRL_REG_LEN *
> (i - ctrl_pin - com_pin);
> }

Ditto.

--
With Best Regards,
Andy Shevchenko