All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] staging: mt7621-gpio: fix problem using one node in DT
@ 2018-07-05  6:00 Sergio Paracuellos
  2018-07-05  6:00 ` [PATCH 1/4] staging: mt7621-gpio: set irq chip name only once Sergio Paracuellos
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Sergio Paracuellos @ 2018-07-05  6:00 UTC (permalink / raw)
  To: gregkh; +Cc: neil, driverdev-devel

This series fix problem related with the last changes included
to use only one node in the device tree and some gpio banks
naming issues.

Hope this helps.

Best regards,
    Sergio Paracuellos

Sergio Paracuellos (4):
  staging: mt7621-gpio: set irq chip name only once
  staging: mt7621-gpio: use custom xlate function
  staging: mt7621-gpio: assign gpio chip custom changes after bgpio_init
  staging: mt7621-gpio: use devm_kasprintf to set gpio banks labels

 drivers/staging/mt7621-gpio/gpio-mt7621.c | 25 ++++++++++++++++++-------
 1 file changed, 18 insertions(+), 7 deletions(-)

-- 
2.7.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

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

* [PATCH 1/4] staging: mt7621-gpio: set irq chip name only once
  2018-07-05  6:00 [PATCH 0/4] staging: mt7621-gpio: fix problem using one node in DT Sergio Paracuellos
@ 2018-07-05  6:00 ` Sergio Paracuellos
  2018-07-05  6:00 ` [PATCH 2/4] staging: mt7621-gpio: use custom xlate function Sergio Paracuellos
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Sergio Paracuellos @ 2018-07-05  6:00 UTC (permalink / raw)
  To: gregkh; +Cc: neil, driverdev-devel

There is only one irq chip so set its name only once
in driver probe function.

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
Reviewed-by: NeilBrown <neil@brown.name>
---
 drivers/staging/mt7621-gpio/gpio-mt7621.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/mt7621-gpio/gpio-mt7621.c b/drivers/staging/mt7621-gpio/gpio-mt7621.c
index 281e621..06024a3 100644
--- a/drivers/staging/mt7621-gpio/gpio-mt7621.c
+++ b/drivers/staging/mt7621-gpio/gpio-mt7621.c
@@ -257,7 +257,6 @@ mediatek_gpio_bank_probe(struct platform_device *pdev,
 			return ret;
 		}
 
-		mediatek_gpio_irq_chip.name = rg->chip.label;
 		ret = gpiochip_irqchip_add(&rg->chip, &mediatek_gpio_irq_chip,
 					   0, handle_simple_irq, IRQ_TYPE_NONE);
 		if (ret) {
@@ -296,6 +295,7 @@ mediatek_gpio_probe(struct platform_device *pdev)
 	gpio_data->gpio_irq = irq_of_parse_and_map(np, 0);
 	gpio_data->dev = &pdev->dev;
 	platform_set_drvdata(pdev, gpio_data);
+	mediatek_gpio_irq_chip.name = dev_name(&pdev->dev);
 
 	for (i = 0; i < MTK_BANK_CNT; i++)
 		mediatek_gpio_bank_probe(pdev, np, i);
-- 
2.7.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

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

* [PATCH 2/4] staging: mt7621-gpio: use custom xlate function
  2018-07-05  6:00 [PATCH 0/4] staging: mt7621-gpio: fix problem using one node in DT Sergio Paracuellos
  2018-07-05  6:00 ` [PATCH 1/4] staging: mt7621-gpio: set irq chip name only once Sergio Paracuellos
@ 2018-07-05  6:00 ` Sergio Paracuellos
  2018-07-05  6:00 ` [PATCH 3/4] staging: mt7621-gpio: assign gpio chip custom changes after bgpio_init Sergio Paracuellos
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Sergio Paracuellos @ 2018-07-05  6:00 UTC (permalink / raw)
  To: gregkh; +Cc: neil, driverdev-devel

The default gpio.of_xlate function assumes there is one gpio chip
for each devicetree node. Device tree had changed to only use one node,
which corresponds to 3 different gpio chips now. For that approach
to work we need a custom xlate function.

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
Reviewed-by: NeilBrown <neil@brown.name>
---
 drivers/staging/mt7621-gpio/gpio-mt7621.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/drivers/staging/mt7621-gpio/gpio-mt7621.c b/drivers/staging/mt7621-gpio/gpio-mt7621.c
index 06024a3..ccf2aa8 100644
--- a/drivers/staging/mt7621-gpio/gpio-mt7621.c
+++ b/drivers/staging/mt7621-gpio/gpio-mt7621.c
@@ -206,6 +206,22 @@ static inline const char * const mediatek_gpio_bank_name(int bank)
 }
 
 static int
+mediatek_gpio_xlate(struct gpio_chip *chip,
+		    const struct of_phandle_args *spec, u32 *flags)
+{
+	int gpio = spec->args[0];
+	struct mtk_gc *rg = to_mediatek_gpio(chip);
+
+	if (rg->bank != gpio / MTK_BANK_WIDTH)
+		return -EINVAL;
+
+	if (flags)
+		*flags = spec->args[1];
+
+	return gpio % MTK_BANK_WIDTH;
+}
+
+static int
 mediatek_gpio_bank_probe(struct platform_device *pdev,
 			 struct device_node *node, int bank)
 {
@@ -220,6 +236,8 @@ mediatek_gpio_bank_probe(struct platform_device *pdev,
 	spin_lock_init(&rg->lock);
 	rg->chip.of_node = node;
 	rg->bank = bank;
+	rg->chip.of_gpio_n_cells = 2;
+	rg->chip.of_xlate = mediatek_gpio_xlate;
 	rg->chip.label = mediatek_gpio_bank_name(rg->bank);
 
 	dat = gpio->gpio_membase + GPIO_REG_DATA + (rg->bank * GPIO_BANK_WIDE);
-- 
2.7.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

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

* [PATCH 3/4] staging: mt7621-gpio: assign gpio chip custom changes after bgpio_init
  2018-07-05  6:00 [PATCH 0/4] staging: mt7621-gpio: fix problem using one node in DT Sergio Paracuellos
  2018-07-05  6:00 ` [PATCH 1/4] staging: mt7621-gpio: set irq chip name only once Sergio Paracuellos
  2018-07-05  6:00 ` [PATCH 2/4] staging: mt7621-gpio: use custom xlate function Sergio Paracuellos
@ 2018-07-05  6:00 ` Sergio Paracuellos
  2018-07-05  6:00 ` [PATCH 4/4] staging: mt7621-gpio: use devm_kasprintf to set gpio banks labels Sergio Paracuellos
  2018-07-05  6:27 ` [PATCH 0/4] staging: mt7621-gpio: fix problem using one node in DT NeilBrown
  4 siblings, 0 replies; 7+ messages in thread
From: Sergio Paracuellos @ 2018-07-05  6:00 UTC (permalink / raw)
  To: gregkh; +Cc: neil, driverdev-devel

bgpio_init function set different data of the gpio chip, like the name.
We want specific name for each bank so to get that not overwritten
move all custom changes after the bgpio_init function call.

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
Reviewed-by: NeilBrown <neil@brown.name>
---
 drivers/staging/mt7621-gpio/gpio-mt7621.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/mt7621-gpio/gpio-mt7621.c b/drivers/staging/mt7621-gpio/gpio-mt7621.c
index ccf2aa8..1b4588a 100644
--- a/drivers/staging/mt7621-gpio/gpio-mt7621.c
+++ b/drivers/staging/mt7621-gpio/gpio-mt7621.c
@@ -236,9 +236,6 @@ mediatek_gpio_bank_probe(struct platform_device *pdev,
 	spin_lock_init(&rg->lock);
 	rg->chip.of_node = node;
 	rg->bank = bank;
-	rg->chip.of_gpio_n_cells = 2;
-	rg->chip.of_xlate = mediatek_gpio_xlate;
-	rg->chip.label = mediatek_gpio_bank_name(rg->bank);
 
 	dat = gpio->gpio_membase + GPIO_REG_DATA + (rg->bank * GPIO_BANK_WIDE);
 	set = gpio->gpio_membase + GPIO_REG_DSET + (rg->bank * GPIO_BANK_WIDE);
@@ -252,6 +249,10 @@ mediatek_gpio_bank_probe(struct platform_device *pdev,
 		return ret;
 	}
 
+	rg->chip.of_gpio_n_cells = 2;
+	rg->chip.of_xlate = mediatek_gpio_xlate;
+	rg->chip.label = mediatek_gpio_bank_name(rg->bank);
+
 	ret = devm_gpiochip_add_data(&pdev->dev, &rg->chip, gpio);
 	if (ret < 0) {
 		dev_err(&pdev->dev, "Could not register gpio %d, ret=%d\n",
-- 
2.7.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

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

* [PATCH 4/4] staging: mt7621-gpio: use devm_kasprintf to set gpio banks labels
  2018-07-05  6:00 [PATCH 0/4] staging: mt7621-gpio: fix problem using one node in DT Sergio Paracuellos
                   ` (2 preceding siblings ...)
  2018-07-05  6:00 ` [PATCH 3/4] staging: mt7621-gpio: assign gpio chip custom changes after bgpio_init Sergio Paracuellos
@ 2018-07-05  6:00 ` Sergio Paracuellos
  2018-07-05  6:27 ` [PATCH 0/4] staging: mt7621-gpio: fix problem using one node in DT NeilBrown
  4 siblings, 0 replies; 7+ messages in thread
From: Sergio Paracuellos @ 2018-07-05  6:00 UTC (permalink / raw)
  To: gregkh; +Cc: neil, driverdev-devel

Instead of using a custom function to return desired name for gpio
use the default assigned one and concat it '-bankN' suffix using
devm_kasprintf kernel function.

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
Reviewed-by: NeilBrown <neil@brown.name>
---
 drivers/staging/mt7621-gpio/gpio-mt7621.c | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/mt7621-gpio/gpio-mt7621.c b/drivers/staging/mt7621-gpio/gpio-mt7621.c
index 1b4588a..d7256b5 100644
--- a/drivers/staging/mt7621-gpio/gpio-mt7621.c
+++ b/drivers/staging/mt7621-gpio/gpio-mt7621.c
@@ -196,15 +196,6 @@ static struct irq_chip mediatek_gpio_irq_chip = {
 	.irq_set_type		= mediatek_gpio_irq_type,
 };
 
-static inline const char * const mediatek_gpio_bank_name(int bank)
-{
-	static const char * const bank_names[] = {
-		"mt7621-bank0", "mt7621-bank1", "mt7621-bank2",
-	};
-
-	return bank_names[bank];
-}
-
 static int
 mediatek_gpio_xlate(struct gpio_chip *chip,
 		    const struct of_phandle_args *spec, u32 *flags)
@@ -251,7 +242,8 @@ mediatek_gpio_bank_probe(struct platform_device *pdev,
 
 	rg->chip.of_gpio_n_cells = 2;
 	rg->chip.of_xlate = mediatek_gpio_xlate;
-	rg->chip.label = mediatek_gpio_bank_name(rg->bank);
+	rg->chip.label = devm_kasprintf(&pdev->dev, GFP_KERNEL, "%s-bank%d",
+					dev_name(&pdev->dev), bank);
 
 	ret = devm_gpiochip_add_data(&pdev->dev, &rg->chip, gpio);
 	if (ret < 0) {
-- 
2.7.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

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

* Re: [PATCH 0/4] staging: mt7621-gpio: fix problem using one node in DT
  2018-07-05  6:00 [PATCH 0/4] staging: mt7621-gpio: fix problem using one node in DT Sergio Paracuellos
                   ` (3 preceding siblings ...)
  2018-07-05  6:00 ` [PATCH 4/4] staging: mt7621-gpio: use devm_kasprintf to set gpio banks labels Sergio Paracuellos
@ 2018-07-05  6:27 ` NeilBrown
  2018-07-05  6:41   ` Sergio Paracuellos
  4 siblings, 1 reply; 7+ messages in thread
From: NeilBrown @ 2018-07-05  6:27 UTC (permalink / raw)
  To: Sergio Paracuellos, gregkh; +Cc: driverdev-devel


[-- Attachment #1.1: Type: text/plain, Size: 849 bytes --]

On Thu, Jul 05 2018, Sergio Paracuellos wrote:

> This series fix problem related with the last changes included
> to use only one node in the device tree and some gpio banks
> naming issues.
>
> Hope this helps.

It sure does.  Everything looks and works as expected now.
all:
  Reviewed-by: NeilBrown <neil@brown.name>

Thanks a lot!

NeilBrown


>
> Best regards,
>     Sergio Paracuellos
>
> Sergio Paracuellos (4):
>   staging: mt7621-gpio: set irq chip name only once
>   staging: mt7621-gpio: use custom xlate function
>   staging: mt7621-gpio: assign gpio chip custom changes after bgpio_init
>   staging: mt7621-gpio: use devm_kasprintf to set gpio banks labels
>
>  drivers/staging/mt7621-gpio/gpio-mt7621.c | 25 ++++++++++++++++++-------
>  1 file changed, 18 insertions(+), 7 deletions(-)
>
> -- 
> 2.7.4

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

[-- Attachment #2: Type: text/plain, Size: 169 bytes --]

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

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

* Re: [PATCH 0/4] staging: mt7621-gpio: fix problem using one node in DT
  2018-07-05  6:27 ` [PATCH 0/4] staging: mt7621-gpio: fix problem using one node in DT NeilBrown
@ 2018-07-05  6:41   ` Sergio Paracuellos
  0 siblings, 0 replies; 7+ messages in thread
From: Sergio Paracuellos @ 2018-07-05  6:41 UTC (permalink / raw)
  To: NeilBrown; +Cc: gregkh, driverdev-devel

On Thu, Jul 05, 2018 at 04:27:31PM +1000, NeilBrown wrote:
> On Thu, Jul 05 2018, Sergio Paracuellos wrote:
> 
> > This series fix problem related with the last changes included
> > to use only one node in the device tree and some gpio banks
> > naming issues.
> >
> > Hope this helps.
> 
> It sure does.  Everything looks and works as expected now.
> all:
>   Reviewed-by: NeilBrown <neil@brown.name>
> 
> Thanks a lot!

Thanks to you for your effort and support reviewing this.

I think we are ready for a new try to get this mainlined.

I'll try to do that tonight.

Best regards,
    Sergio Paracuellos
> 
> NeilBrown
> 
> 
> >
> > Best regards,
> >     Sergio Paracuellos
> >
> > Sergio Paracuellos (4):
> >   staging: mt7621-gpio: set irq chip name only once
> >   staging: mt7621-gpio: use custom xlate function
> >   staging: mt7621-gpio: assign gpio chip custom changes after bgpio_init
> >   staging: mt7621-gpio: use devm_kasprintf to set gpio banks labels
> >
> >  drivers/staging/mt7621-gpio/gpio-mt7621.c | 25 ++++++++++++++++++-------
> >  1 file changed, 18 insertions(+), 7 deletions(-)
> >
> > -- 
> > 2.7.4


_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

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

end of thread, other threads:[~2018-07-05  6:41 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-05  6:00 [PATCH 0/4] staging: mt7621-gpio: fix problem using one node in DT Sergio Paracuellos
2018-07-05  6:00 ` [PATCH 1/4] staging: mt7621-gpio: set irq chip name only once Sergio Paracuellos
2018-07-05  6:00 ` [PATCH 2/4] staging: mt7621-gpio: use custom xlate function Sergio Paracuellos
2018-07-05  6:00 ` [PATCH 3/4] staging: mt7621-gpio: assign gpio chip custom changes after bgpio_init Sergio Paracuellos
2018-07-05  6:00 ` [PATCH 4/4] staging: mt7621-gpio: use devm_kasprintf to set gpio banks labels Sergio Paracuellos
2018-07-05  6:27 ` [PATCH 0/4] staging: mt7621-gpio: fix problem using one node in DT NeilBrown
2018-07-05  6:41   ` Sergio Paracuellos

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.