Re: [PATCH v4 2/4] gpio: rockchip: change the GPIO version judgment logic

From: Andy Shevchenko
Date: Mon Nov 11 2024 - 04:48:38 EST


On Mon, Nov 11, 2024 at 10:34:10AM +0800, Ye Zhang wrote:
> Have a list of valid IDs and default to -ENODEV.

...

> - /* If not gpio v2, that is default to v1. */
> - if (id == GPIO_TYPE_V2 || id == GPIO_TYPE_V2_1) {
> + switch (id) {
> + case GPIO_TYPE_V1:

If you leave the V2 case first...

> + bank->gpio_regs = &gpio_regs_v1;
> + bank->gpio_type = GPIO_TYPE_V1;
> + break;
> + case GPIO_TYPE_V2:
> + case GPIO_TYPE_V2_1:

...and the v1 case last, the whole diff will be much more understandable and
reviewable.

> bank->gpio_regs = &gpio_regs_v2;
> bank->gpio_type = GPIO_TYPE_V2;
> bank->db_clk = of_clk_get(bank->of_node, 1);
> @@ -677,9 +682,10 @@ static int rockchip_get_bank_data(struct rockchip_pin_bank *bank)
> clk_disable_unprepare(bank->clk);
> return -EINVAL;
> }
> - } else {
> - bank->gpio_regs = &gpio_regs_v1;
> - bank->gpio_type = GPIO_TYPE_V1;
> + break;
> + default:
> + dev_err(bank->dev, "cannot get the version ID\n");
> + return -ENODEV;
> }

--
With Best Regards,
Andy Shevchenko