linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] gpio: brcmstb: Use dynamic GPIO base numbers
@ 2024-04-23 18:46 Doug Berger
  2024-04-23 18:54 ` Florian Fainelli
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Doug Berger @ 2024-04-23 18:46 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, Florian Fainelli
  Cc: bcm-kernel-feedback-list, linux-gpio, linux-arm-kernel,
	linux-kernel, Doug Berger, Phil Elwell

Forcing a gpiochip to have a fixed base number now leads to a warning
message. Remove the need to do so by using the offset value of the
gpiochip.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
Signed-off-by: Doug Berger <opendmb@gmail.com>
---
change in v2:
  gc->base is already initialized to -1 by bgpio_init() so the
  redundant initialization in this driver was removed.

 drivers/gpio/gpio-brcmstb.c | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)

diff --git a/drivers/gpio/gpio-brcmstb.c b/drivers/gpio/gpio-brcmstb.c
index a789af4a5c85..790cb278b72a 100644
--- a/drivers/gpio/gpio-brcmstb.c
+++ b/drivers/gpio/gpio-brcmstb.c
@@ -50,7 +50,6 @@ struct brcmstb_gpio_priv {
 	struct irq_domain *irq_domain;
 	struct irq_chip irq_chip;
 	int parent_irq;
-	int gpio_base;
 	int num_gpios;
 	int parent_wake_irq;
 };
@@ -92,7 +91,7 @@ brcmstb_gpio_get_active_irqs(struct brcmstb_gpio_bank *bank)
 static int brcmstb_gpio_hwirq_to_offset(irq_hw_number_t hwirq,
 					struct brcmstb_gpio_bank *bank)
 {
-	return hwirq - (bank->gc.base - bank->parent_priv->gpio_base);
+	return hwirq - bank->gc.offset;
 }
 
 static void brcmstb_gpio_set_imask(struct brcmstb_gpio_bank *bank,
@@ -118,7 +117,7 @@ static int brcmstb_gpio_to_irq(struct gpio_chip *gc, unsigned offset)
 {
 	struct brcmstb_gpio_priv *priv = brcmstb_gpio_gc_to_priv(gc);
 	/* gc_offset is relative to this gpio_chip; want real offset */
-	int hwirq = offset + (gc->base - priv->gpio_base);
+	int hwirq = offset + gc->offset;
 
 	if (hwirq >= priv->num_gpios)
 		return -ENXIO;
@@ -263,7 +262,7 @@ static void brcmstb_gpio_irq_bank_handler(struct brcmstb_gpio_bank *bank)
 {
 	struct brcmstb_gpio_priv *priv = bank->parent_priv;
 	struct irq_domain *domain = priv->irq_domain;
-	int hwbase = bank->gc.base - priv->gpio_base;
+	int hwbase = bank->gc.offset;
 	unsigned long status;
 
 	while ((status = brcmstb_gpio_get_active_irqs(bank))) {
@@ -412,7 +411,7 @@ static int brcmstb_gpio_of_xlate(struct gpio_chip *gc,
 	if (WARN_ON(gpiospec->args_count < gc->of_gpio_n_cells))
 		return -EINVAL;
 
-	offset = gpiospec->args[0] - (gc->base - priv->gpio_base);
+	offset = gpiospec->args[0] - bank->gc.offset;
 	if (offset >= gc->ngpio || offset < 0)
 		return -EINVAL;
 
@@ -596,8 +595,8 @@ static int brcmstb_gpio_probe(struct platform_device *pdev)
 	const __be32 *p;
 	u32 bank_width;
 	int num_banks = 0;
+	int num_gpios = 0;
 	int err;
-	static int gpio_base;
 	unsigned long flags = 0;
 	bool need_wakeup_event = false;
 
@@ -611,7 +610,6 @@ static int brcmstb_gpio_probe(struct platform_device *pdev)
 	if (IS_ERR(reg_base))
 		return PTR_ERR(reg_base);
 
-	priv->gpio_base = gpio_base;
 	priv->reg_base = reg_base;
 	priv->pdev = pdev;
 
@@ -651,7 +649,7 @@ static int brcmstb_gpio_probe(struct platform_device *pdev)
 			dev_dbg(dev, "Width 0 found: Empty bank @ %d\n",
 				num_banks);
 			num_banks++;
-			gpio_base += MAX_GPIO_PER_BANK;
+			num_gpios += MAX_GPIO_PER_BANK;
 			continue;
 		}
 
@@ -691,7 +689,6 @@ static int brcmstb_gpio_probe(struct platform_device *pdev)
 			err = -ENOMEM;
 			goto fail;
 		}
-		gc->base = gpio_base;
 		gc->of_gpio_n_cells = 2;
 		gc->of_xlate = brcmstb_gpio_of_xlate;
 		/* not all ngpio lines are valid, will use bank width later */
@@ -713,7 +710,7 @@ static int brcmstb_gpio_probe(struct platform_device *pdev)
 					bank->id);
 			goto fail;
 		}
-		gpio_base += gc->ngpio;
+		num_gpios += gc->ngpio;
 
 		dev_dbg(dev, "bank=%d, base=%d, ngpio=%d, width=%d\n", bank->id,
 			gc->base, gc->ngpio, bank->width);
@@ -724,7 +721,7 @@ static int brcmstb_gpio_probe(struct platform_device *pdev)
 		num_banks++;
 	}
 
-	priv->num_gpios = gpio_base - priv->gpio_base;
+	priv->num_gpios = num_gpios;
 	if (priv->parent_irq > 0) {
 		err = brcmstb_gpio_irq_setup(pdev, priv);
 		if (err)
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] gpio: brcmstb: Use dynamic GPIO base numbers
  2024-04-23 18:46 [PATCH v2] gpio: brcmstb: Use dynamic GPIO base numbers Doug Berger
@ 2024-04-23 18:54 ` Florian Fainelli
  2024-04-23 20:22 ` Linus Walleij
  2024-04-24  8:32 ` Bartosz Golaszewski
  2 siblings, 0 replies; 4+ messages in thread
From: Florian Fainelli @ 2024-04-23 18:54 UTC (permalink / raw)
  To: Doug Berger, Linus Walleij, Bartosz Golaszewski
  Cc: bcm-kernel-feedback-list, linux-gpio, linux-arm-kernel,
	linux-kernel, Phil Elwell

[-- Attachment #1: Type: text/plain, Size: 430 bytes --]

On 4/23/24 11:46, Doug Berger wrote:
> Forcing a gpiochip to have a fixed base number now leads to a warning
> message. Remove the need to do so by using the offset value of the
> gpiochip.
> 
> Signed-off-by: Phil Elwell <phil@raspberrypi.com>
> Signed-off-by: Doug Berger <opendmb@gmail.com>

Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Tested-by: Florian Fainelli <florian.fainelli@broadcom.com>
-- 
Florian


[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4221 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] gpio: brcmstb: Use dynamic GPIO base numbers
  2024-04-23 18:46 [PATCH v2] gpio: brcmstb: Use dynamic GPIO base numbers Doug Berger
  2024-04-23 18:54 ` Florian Fainelli
@ 2024-04-23 20:22 ` Linus Walleij
  2024-04-24  8:32 ` Bartosz Golaszewski
  2 siblings, 0 replies; 4+ messages in thread
From: Linus Walleij @ 2024-04-23 20:22 UTC (permalink / raw)
  To: Doug Berger
  Cc: Bartosz Golaszewski, Florian Fainelli, bcm-kernel-feedback-list,
	linux-gpio, linux-arm-kernel, linux-kernel, Phil Elwell

On Tue, Apr 23, 2024 at 8:46 PM Doug Berger <opendmb@gmail.com> wrote:

> Forcing a gpiochip to have a fixed base number now leads to a warning
> message. Remove the need to do so by using the offset value of the
> gpiochip.
>
> Signed-off-by: Phil Elwell <phil@raspberrypi.com>
> Signed-off-by: Doug Berger <opendmb@gmail.com>

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] gpio: brcmstb: Use dynamic GPIO base numbers
  2024-04-23 18:46 [PATCH v2] gpio: brcmstb: Use dynamic GPIO base numbers Doug Berger
  2024-04-23 18:54 ` Florian Fainelli
  2024-04-23 20:22 ` Linus Walleij
@ 2024-04-24  8:32 ` Bartosz Golaszewski
  2 siblings, 0 replies; 4+ messages in thread
From: Bartosz Golaszewski @ 2024-04-24  8:32 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, Florian Fainelli, Doug Berger
  Cc: Bartosz Golaszewski, bcm-kernel-feedback-list, linux-gpio,
	linux-arm-kernel, linux-kernel, Phil Elwell

From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>


On Tue, 23 Apr 2024 11:46:05 -0700, Doug Berger wrote:
> Forcing a gpiochip to have a fixed base number now leads to a warning
> message. Remove the need to do so by using the offset value of the
> gpiochip.
> 
> 

Applied, thanks!

[1/1] gpio: brcmstb: Use dynamic GPIO base numbers
      commit: ec37529e544c59bb8ba35fd950c7bec28e5d54ee

Best regards,
-- 
Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-04-24  8:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-23 18:46 [PATCH v2] gpio: brcmstb: Use dynamic GPIO base numbers Doug Berger
2024-04-23 18:54 ` Florian Fainelli
2024-04-23 20:22 ` Linus Walleij
2024-04-24  8:32 ` Bartosz Golaszewski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).