Re: [PATCH V3 2/6] pinctrl: sprd: Fix the incorrect mask and shift definition

From: Andy Shevchenko
Date: Fri Oct 27 2023 - 07:33:03 EST


On Fri, Oct 27, 2023 at 03:14:22PM +0800, Linhua Xu wrote:
> From: Linhua Xu <Linhua.Xu@xxxxxxxxxx>
>
> Pull-up and pull-down are mutually exclusive. When setting one of them,
> the bit of the other needs to be clear. Now, there are cases where pull-up
> and pull-down are set at the same time in the code, thus fix them.

...

> Fixes:<1fb4b907e808> ("pinctrl: sprd: Add Spreadtrum pin control driver")
>
> Signed-off-by: Linhua Xu <Linhua.Xu@xxxxxxxxxx>

Same comment about the Fixes: tag.

...

> -#define SLEEP_PULL_DOWN_MASK 0x1
> +#define SLEEP_PULL_DOWN_MASK GENMASK(1, 0)
> #define SLEEP_PULL_DOWN_SHIFT 2

No, this is an incorrect (prone to errors and confusion) change.
You need to introduce new mask for both of them and use in the code.

#define SLEEP_PULL_UP_DOWN_MASK GENMASK(1, 0)
#define SLEEP_PULL_UP_DOWN_SHIFT 2

...

> -#define PULL_DOWN_MASK 0x1
> +#define PULL_DOWN_MASK (GENMASK(1, 0) | BIT(6))
> #define PULL_DOWN_SHIFT 6

Ditto.

#define PULL_UP_DOWN_MASK (GENMASK(1, 0) | BIT(6))
#define PULL_UP_DOWN_SHIFT 6

--
With Best Regards,
Andy Shevchenko