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

From: Andy Shevchenko
Date: Mon Sep 11 2023 - 18:16:47 EST


On Fri, Sep 08, 2023 at 01:51:42PM +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.

...

> #define SLEEP_PULL_DOWN BIT(2)
> -#define SLEEP_PULL_DOWN_MASK 0x1
> +#define SLEEP_PULL_DOWN_MASK GENMASK(1, 0)
> #define SLEEP_PULL_DOWN_SHIFT 2
>
> #define PULL_DOWN BIT(6)
> -#define PULL_DOWN_MASK 0x1
> +#define PULL_DOWN_MASK (GENMASK(1, 0) | BIT(6))
> #define PULL_DOWN_SHIFT 6
>
> #define SLEEP_PULL_UP BIT(3)
> -#define SLEEP_PULL_UP_MASK 0x1
> -#define SLEEP_PULL_UP_SHIFT 3
> +#define SLEEP_PULL_UP_MASK GENMASK(1, 0)
> +#define SLEEP_PULL_UP_SHIFT 2
>
> #define PULL_UP_4_7K (BIT(12) | BIT(7))
> #define PULL_UP_20K BIT(7)
> -#define PULL_UP_MASK 0x21
> -#define PULL_UP_SHIFT 7
> +#define PULL_UP_MASK (GENMASK(1, 0) | BIT(6))
> +#define PULL_UP_SHIFT 6

These look strange now.

So, SLEEP MASK doesn't cover bits 2 and 3.
I believe you should have

#define SLEEP_PULL_UP_DOWN_MASK GENMASK(3, 2)

The other even weirder with this BIT(6) there.

In the similar way:

#define PULL_UP_DOWN_MASK GENMASK(7, 6)


--
With Best Regards,
Andy Shevchenko