[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20241112015408.3139996-3-ye.zhang@rock-chips.com>
Date: Tue, 12 Nov 2024 09:54:06 +0800
From: Ye Zhang <ye.zhang@...k-chips.com>
To: Ye Zhang <ye.zhang@...k-chips.com>,
linus.walleij@...aro.org,
brgl@...ev.pl,
heiko@...ech.de,
linux-gpio@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org
Cc: linux-rockchip@...ts.infradead.org,
linux-kernel@...r.kernel.org,
mika.westerberg@...ux.intel.com,
andriy.shevchenko@...ux.intel.com,
tao.huang@...k-chips.com,
finley.xiao@...k-chips.com,
tim.chen@...k-chips.com,
elaine.zhang@...k-chips.com,
Sebastian Reichel <sebastian.reichel@...labora.com>
Subject: [PATCH v5 2/4] gpio: rockchip: change the GPIO version judgment logic
Have a list of valid IDs and default to -ENODEV.
Signed-off-by: Ye Zhang <ye.zhang@...k-chips.com>
Reviewed-by: Sebastian Reichel <sebastian.reichel@...labora.com>
---
drivers/gpio/gpio-rockchip.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/drivers/gpio/gpio-rockchip.c b/drivers/gpio/gpio-rockchip.c
index 702e711f9c23..49eaefeed8fa 100644
--- a/drivers/gpio/gpio-rockchip.c
+++ b/drivers/gpio/gpio-rockchip.c
@@ -667,8 +667,9 @@ static int rockchip_get_bank_data(struct rockchip_pin_bank *bank)
clk_prepare_enable(bank->clk);
id = readl(bank->reg_base + gpio_regs_v2.version_id);
- /* If not gpio v2, that is default to v1. */
- if (id == GPIO_TYPE_V2 || id == GPIO_TYPE_V2_1) {
+ switch (id) {
+ case GPIO_TYPE_V2:
+ case GPIO_TYPE_V2_1:
bank->gpio_regs = &gpio_regs_v2;
bank->gpio_type = GPIO_TYPE_V2;
bank->db_clk = of_clk_get(bank->of_node, 1);
@@ -677,9 +678,14 @@ static int rockchip_get_bank_data(struct rockchip_pin_bank *bank)
clk_disable_unprepare(bank->clk);
return -EINVAL;
}
- } else {
+ break;
+ case GPIO_TYPE_V1:
bank->gpio_regs = &gpio_regs_v1;
bank->gpio_type = GPIO_TYPE_V1;
+ break;
+ default:
+ dev_err(bank->dev, "unsupported version ID: 0x%08x\n", id);
+ return -ENODEV;
}
return 0;
--
2.34.1
Powered by blists - more mailing lists