[PATCH RFC] gpio: brcmstb: Properly account for empty banks

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Justin Chen <justinpopo6@xxxxxxxxx>

On some chips we have empty banks or a hole in the register space.
The driver assumes all banks are consecutive and the same size.
To work around this, we create a fake bank where there is a hole
and keep it out of the linked list so it won't be called or initialized

Signed-off-by: Justin Chen <justinpopo6@xxxxxxxxx>
---
 drivers/gpio/gpio-brcmstb.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/drivers/gpio/gpio-brcmstb.c b/drivers/gpio/gpio-brcmstb.c
index 99247f6..9daeda7 100644
--- a/drivers/gpio/gpio-brcmstb.c
+++ b/drivers/gpio/gpio-brcmstb.c
@@ -603,6 +603,18 @@ static int brcmstb_gpio_probe(struct platform_device *pdev)
 		struct brcmstb_gpio_bank *bank;
 		struct gpio_chip *gc;
 
+		/*
+		 * If bank_width is 0, then there is an empty bank in the
+		 * register block. Special handling for this case.
+		 */
+		if (bank_width == 0) {
+			dev_dbg(dev, "Fake bank %d (GPIO(s): %d-%d)\n",
+			  num_banks, gpio_base, gpio_base + MAX_GPIO_PER_BANK);
+			num_banks++;
+			gpio_base += MAX_GPIO_PER_BANK;
+			continue;
+		}
+
 		bank = devm_kzalloc(dev, sizeof(*bank), GFP_KERNEL);
 		if (!bank) {
 			err = -ENOMEM;
@@ -611,7 +623,7 @@ static int brcmstb_gpio_probe(struct platform_device *pdev)
 
 		bank->parent_priv = priv;
 		bank->id = num_banks;
-		if (bank_width <= 0 || bank_width > MAX_GPIO_PER_BANK) {
+		if (bank_width < 0 || bank_width > MAX_GPIO_PER_BANK) {
 			dev_err(dev, "Invalid bank width %d\n", bank_width);
 			err = -EINVAL;
 			goto fail;
-- 
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux