* [PATCH 1/2] gpio: davinci: Remove redundant members davinci_gpio_controller stuct @ 2017-01-04 8:26 ` Keerthy 0 siblings, 0 replies; 10+ messages in thread From: Keerthy @ 2017-01-04 8:26 UTC (permalink / raw) To: linus.walleij; +Cc: linux-kernel, j-keerthy, linux-gpio, gnurou, t-kristo davinci_gpio_controller struct has set_data, in_data, clr_data members that are assigned and never used. Signed-off-by: Keerthy <j-keerthy@ti.com> --- drivers/gpio/gpio-davinci.c | 3 --- include/linux/platform_data/gpio-davinci.h | 3 --- 2 files changed, 6 deletions(-) diff --git a/drivers/gpio/gpio-davinci.c b/drivers/gpio/gpio-davinci.c index 9191056..163f81e 100644 --- a/drivers/gpio/gpio-davinci.c +++ b/drivers/gpio/gpio-davinci.c @@ -266,9 +266,6 @@ static int davinci_gpio_probe(struct platform_device *pdev) if (!regs) return -ENXIO; chips[i].regs = regs; - chips[i].set_data = ®s->set_data; - chips[i].clr_data = ®s->clr_data; - chips[i].in_data = ®s->in_data; gpiochip_add_data(&chips[i].chip, &chips[i]); } diff --git a/include/linux/platform_data/gpio-davinci.h b/include/linux/platform_data/gpio-davinci.h index 6ace3fd..44ca530 100644 --- a/include/linux/platform_data/gpio-davinci.h +++ b/include/linux/platform_data/gpio-davinci.h @@ -33,9 +33,6 @@ struct davinci_gpio_controller { /* Serialize access to GPIO registers */ spinlock_t lock; void __iomem *regs; - void __iomem *set_data; - void __iomem *clr_data; - void __iomem *in_data; int gpio_unbanked; unsigned gpio_irq; }; -- 1.9.1 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 1/2] gpio: davinci: Remove redundant members davinci_gpio_controller stuct @ 2017-01-04 8:26 ` Keerthy 0 siblings, 0 replies; 10+ messages in thread From: Keerthy @ 2017-01-04 8:26 UTC (permalink / raw) To: linus.walleij; +Cc: linux-kernel, j-keerthy, linux-gpio, gnurou, t-kristo davinci_gpio_controller struct has set_data, in_data, clr_data members that are assigned and never used. Signed-off-by: Keerthy <j-keerthy@ti.com> --- drivers/gpio/gpio-davinci.c | 3 --- include/linux/platform_data/gpio-davinci.h | 3 --- 2 files changed, 6 deletions(-) diff --git a/drivers/gpio/gpio-davinci.c b/drivers/gpio/gpio-davinci.c index 9191056..163f81e 100644 --- a/drivers/gpio/gpio-davinci.c +++ b/drivers/gpio/gpio-davinci.c @@ -266,9 +266,6 @@ static int davinci_gpio_probe(struct platform_device *pdev) if (!regs) return -ENXIO; chips[i].regs = regs; - chips[i].set_data = ®s->set_data; - chips[i].clr_data = ®s->clr_data; - chips[i].in_data = ®s->in_data; gpiochip_add_data(&chips[i].chip, &chips[i]); } diff --git a/include/linux/platform_data/gpio-davinci.h b/include/linux/platform_data/gpio-davinci.h index 6ace3fd..44ca530 100644 --- a/include/linux/platform_data/gpio-davinci.h +++ b/include/linux/platform_data/gpio-davinci.h @@ -33,9 +33,6 @@ struct davinci_gpio_controller { /* Serialize access to GPIO registers */ spinlock_t lock; void __iomem *regs; - void __iomem *set_data; - void __iomem *clr_data; - void __iomem *in_data; int gpio_unbanked; unsigned gpio_irq; }; -- 1.9.1 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 2/2] gpio: davinci: Remove gpio2regs function to accommodate multi instances 2017-01-04 8:26 ` Keerthy @ 2017-01-04 8:26 ` Keerthy -1 siblings, 0 replies; 10+ messages in thread From: Keerthy @ 2017-01-04 8:26 UTC (permalink / raw) To: linus.walleij; +Cc: linux-kernel, j-keerthy, linux-gpio, gnurou, t-kristo gpio2regs is written making an assumption that driver supports only one instance of gpio controller. Removing this and adding a generic array so as to support multiple instances of gpio controllers. Signed-off-by: Keerthy <j-keerthy@ti.com> --- drivers/gpio/gpio-davinci.c | 30 +++++++----------------------- 1 file changed, 7 insertions(+), 23 deletions(-) diff --git a/drivers/gpio/gpio-davinci.c b/drivers/gpio/gpio-davinci.c index 163f81e..26b874a 100644 --- a/drivers/gpio/gpio-davinci.c +++ b/drivers/gpio/gpio-davinci.c @@ -43,25 +43,7 @@ struct davinci_gpio_regs { #define MAX_LABEL_SIZE 20 static void __iomem *gpio_base; - -static struct davinci_gpio_regs __iomem *gpio2regs(unsigned gpio) -{ - void __iomem *ptr; - - if (gpio < 32 * 1) - ptr = gpio_base + 0x10; - else if (gpio < 32 * 2) - ptr = gpio_base + 0x38; - else if (gpio < 32 * 3) - ptr = gpio_base + 0x60; - else if (gpio < 32 * 4) - ptr = gpio_base + 0x88; - else if (gpio < 32 * 5) - ptr = gpio_base + 0xb0; - else - ptr = NULL; - return ptr; -} +static unsigned int offset_array[5] = {0x10, 0x38, 0x60, 0x88, 0xb0}; static inline struct davinci_gpio_regs __iomem *irq2regs(struct irq_data *d) { @@ -262,7 +244,7 @@ static int davinci_gpio_probe(struct platform_device *pdev) #endif spin_lock_init(&chips[i].lock); - regs = gpio2regs(base); + regs = gpio_base + offset_array[i]; if (!regs) return -ENXIO; chips[i].regs = regs; @@ -417,7 +399,9 @@ static int gpio_irq_type_unbanked(struct irq_data *data, unsigned trigger) davinci_gpio_irq_map(struct irq_domain *d, unsigned int irq, irq_hw_number_t hw) { - struct davinci_gpio_regs __iomem *g = gpio2regs(hw); + struct davinci_gpio_controller *chips = + (struct davinci_gpio_controller *)d->host_data; + struct davinci_gpio_regs __iomem *g = chips[hw / 32].regs; irq_set_chip_and_handler_name(irq, &gpio_irqchip, handle_simple_irq, "davinci_gpio"); @@ -554,7 +538,7 @@ static int davinci_gpio_irq_setup(struct platform_device *pdev) irq_chip->irq_set_type = gpio_irq_type_unbanked; /* default trigger: both edges */ - g = gpio2regs(0); + g = chips[0].regs; writel_relaxed(~0, &g->set_falling); writel_relaxed(~0, &g->set_rising); @@ -574,7 +558,7 @@ static int davinci_gpio_irq_setup(struct platform_device *pdev) */ for (gpio = 0, bank = 0; gpio < ngpio; bank++, bank_irq++, gpio += 16) { /* disabled by default, enabled only as needed */ - g = gpio2regs(gpio); + g = chips[bank / 2].regs; writel_relaxed(~0, &g->clr_falling); writel_relaxed(~0, &g->clr_rising); -- 1.9.1 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 2/2] gpio: davinci: Remove gpio2regs function to accommodate multi instances @ 2017-01-04 8:26 ` Keerthy 0 siblings, 0 replies; 10+ messages in thread From: Keerthy @ 2017-01-04 8:26 UTC (permalink / raw) To: linus.walleij; +Cc: linux-kernel, j-keerthy, linux-gpio, gnurou, t-kristo gpio2regs is written making an assumption that driver supports only one instance of gpio controller. Removing this and adding a generic array so as to support multiple instances of gpio controllers. Signed-off-by: Keerthy <j-keerthy@ti.com> --- drivers/gpio/gpio-davinci.c | 30 +++++++----------------------- 1 file changed, 7 insertions(+), 23 deletions(-) diff --git a/drivers/gpio/gpio-davinci.c b/drivers/gpio/gpio-davinci.c index 163f81e..26b874a 100644 --- a/drivers/gpio/gpio-davinci.c +++ b/drivers/gpio/gpio-davinci.c @@ -43,25 +43,7 @@ struct davinci_gpio_regs { #define MAX_LABEL_SIZE 20 static void __iomem *gpio_base; - -static struct davinci_gpio_regs __iomem *gpio2regs(unsigned gpio) -{ - void __iomem *ptr; - - if (gpio < 32 * 1) - ptr = gpio_base + 0x10; - else if (gpio < 32 * 2) - ptr = gpio_base + 0x38; - else if (gpio < 32 * 3) - ptr = gpio_base + 0x60; - else if (gpio < 32 * 4) - ptr = gpio_base + 0x88; - else if (gpio < 32 * 5) - ptr = gpio_base + 0xb0; - else - ptr = NULL; - return ptr; -} +static unsigned int offset_array[5] = {0x10, 0x38, 0x60, 0x88, 0xb0}; static inline struct davinci_gpio_regs __iomem *irq2regs(struct irq_data *d) { @@ -262,7 +244,7 @@ static int davinci_gpio_probe(struct platform_device *pdev) #endif spin_lock_init(&chips[i].lock); - regs = gpio2regs(base); + regs = gpio_base + offset_array[i]; if (!regs) return -ENXIO; chips[i].regs = regs; @@ -417,7 +399,9 @@ static int gpio_irq_type_unbanked(struct irq_data *data, unsigned trigger) davinci_gpio_irq_map(struct irq_domain *d, unsigned int irq, irq_hw_number_t hw) { - struct davinci_gpio_regs __iomem *g = gpio2regs(hw); + struct davinci_gpio_controller *chips = + (struct davinci_gpio_controller *)d->host_data; + struct davinci_gpio_regs __iomem *g = chips[hw / 32].regs; irq_set_chip_and_handler_name(irq, &gpio_irqchip, handle_simple_irq, "davinci_gpio"); @@ -554,7 +538,7 @@ static int davinci_gpio_irq_setup(struct platform_device *pdev) irq_chip->irq_set_type = gpio_irq_type_unbanked; /* default trigger: both edges */ - g = gpio2regs(0); + g = chips[0].regs; writel_relaxed(~0, &g->set_falling); writel_relaxed(~0, &g->set_rising); @@ -574,7 +558,7 @@ static int davinci_gpio_irq_setup(struct platform_device *pdev) */ for (gpio = 0, bank = 0; gpio < ngpio; bank++, bank_irq++, gpio += 16) { /* disabled by default, enabled only as needed */ - g = gpio2regs(gpio); + g = chips[bank / 2].regs; writel_relaxed(~0, &g->clr_falling); writel_relaxed(~0, &g->clr_rising); -- 1.9.1 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH 2/2] gpio: davinci: Remove gpio2regs function to accommodate multi instances 2017-01-04 8:26 ` Keerthy (?) @ 2017-01-11 11:04 ` Linus Walleij 2017-01-11 12:40 ` Keerthy -1 siblings, 1 reply; 10+ messages in thread From: Linus Walleij @ 2017-01-11 11:04 UTC (permalink / raw) To: Keerthy Cc: linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, Alexandre Courbot, Tero Kristo On Wed, Jan 4, 2017 at 9:26 AM, Keerthy <j-keerthy@ti.com> wrote: > gpio2regs is written making an assumption that driver supports only > one instance of gpio controller. Removing this and adding a generic > array so as to support multiple instances of gpio controllers. > > Signed-off-by: Keerthy <j-keerthy@ti.com> > - regs = gpio2regs(base); > + regs = gpio_base + offset_array[i]; I understand this. > - struct davinci_gpio_regs __iomem *g = gpio2regs(hw); > + struct davinci_gpio_controller *chips = > + (struct davinci_gpio_controller *)d->host_data; > + struct davinci_gpio_regs __iomem *g = chips[hw / 32].regs; And this, if each instans has 32 GPIOs. > - g = gpio2regs(0); > + g = chips[0].regs; Also makes sense. > - g = gpio2regs(gpio); > + g = chips[bank / 2].regs; But what is this? I don't understand that /2 at all. Please insert a comment explaining it so I can figure it out. Are there two banks per instance? Yours, Linus Walleij ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 2/2] gpio: davinci: Remove gpio2regs function to accommodate multi instances 2017-01-11 11:04 ` Linus Walleij @ 2017-01-11 12:40 ` Keerthy 2017-01-11 15:53 ` Linus Walleij 0 siblings, 1 reply; 10+ messages in thread From: Keerthy @ 2017-01-11 12:40 UTC (permalink / raw) To: Linus Walleij Cc: linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, Alexandre Courbot, Tero Kristo On Wednesday 11 January 2017 04:34 PM, Linus Walleij wrote: > On Wed, Jan 4, 2017 at 9:26 AM, Keerthy <j-keerthy@ti.com> wrote: > >> gpio2regs is written making an assumption that driver supports only >> one instance of gpio controller. Removing this and adding a generic >> array so as to support multiple instances of gpio controllers. >> >> Signed-off-by: Keerthy <j-keerthy@ti.com> > >> - regs = gpio2regs(base); >> + regs = gpio_base + offset_array[i]; > > I understand this. > >> - struct davinci_gpio_regs __iomem *g = gpio2regs(hw); >> + struct davinci_gpio_controller *chips = >> + (struct davinci_gpio_controller *)d->host_data; >> + struct davinci_gpio_regs __iomem *g = chips[hw / 32].regs; > > And this, if each instans has 32 GPIOs. > >> - g = gpio2regs(0); >> + g = chips[0].regs; > > Also makes sense. > >> - g = gpio2regs(gpio); >> + g = chips[bank / 2].regs; > > But what is this? I don't understand that /2 at all. Please insert a > comment explaining it so I can figure it out. Are there two banks > per instance? Yes! There are register sets for 32 GPIOs. 2 banks of 16 GPIOs are covered by each set of registers hence /2. Shall i add a comment and send this patch alone separately? > > Yours, > Linus Walleij > ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 2/2] gpio: davinci: Remove gpio2regs function to accommodate multi instances 2017-01-11 12:40 ` Keerthy @ 2017-01-11 15:53 ` Linus Walleij 2017-01-12 1:52 ` Keerthy 2017-01-13 3:54 ` Keerthy 0 siblings, 2 replies; 10+ messages in thread From: Linus Walleij @ 2017-01-11 15:53 UTC (permalink / raw) To: Keerthy Cc: linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, Alexandre Courbot, Tero Kristo On Wed, Jan 11, 2017 at 1:40 PM, Keerthy <j-keerthy@ti.com> wrote: > On Wednesday 11 January 2017 04:34 PM, Linus Walleij wrote: >> On Wed, Jan 4, 2017 at 9:26 AM, Keerthy <j-keerthy@ti.com> wrote: >> >>> gpio2regs is written making an assumption that driver supports only >>> one instance of gpio controller. Removing this and adding a generic >>> array so as to support multiple instances of gpio controllers. >>> >>> Signed-off-by: Keerthy <j-keerthy@ti.com> >> >> >>> - regs = gpio2regs(base); >>> + regs = gpio_base + offset_array[i]; >> >> >> I understand this. >> >>> - struct davinci_gpio_regs __iomem *g = gpio2regs(hw); >>> + struct davinci_gpio_controller *chips = >>> + (struct davinci_gpio_controller >>> *)d->host_data; >>> + struct davinci_gpio_regs __iomem *g = chips[hw / 32].regs; >> >> >> And this, if each instans has 32 GPIOs. >> >>> - g = gpio2regs(0); >>> + g = chips[0].regs; >> >> >> Also makes sense. >> >>> - g = gpio2regs(gpio); >>> + g = chips[bank / 2].regs; >> >> >> But what is this? I don't understand that /2 at all. Please insert a >> comment explaining it so I can figure it out. Are there two banks >> per instance? > > > Yes! There are register sets for 32 GPIOs. 2 banks of 16 GPIOs are covered > by each set of registers hence /2. Shall i add a comment and send this patch > alone separately? Yeah. I am currently confused by several patch sets for davinci in my inbox, can you rebase on my devel branch when I push it and resend *all* you have cooking for DaVinci? Yours, Linus Walleij ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 2/2] gpio: davinci: Remove gpio2regs function to accommodate multi instances 2017-01-11 15:53 ` Linus Walleij @ 2017-01-12 1:52 ` Keerthy 2017-01-13 3:54 ` Keerthy 1 sibling, 0 replies; 10+ messages in thread From: Keerthy @ 2017-01-12 1:52 UTC (permalink / raw) To: Linus Walleij Cc: linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, Alexandre Courbot, Tero Kristo On Wednesday 11 January 2017 09:23 PM, Linus Walleij wrote: > On Wed, Jan 11, 2017 at 1:40 PM, Keerthy <j-keerthy@ti.com> wrote: >> On Wednesday 11 January 2017 04:34 PM, Linus Walleij wrote: >>> On Wed, Jan 4, 2017 at 9:26 AM, Keerthy <j-keerthy@ti.com> wrote: >>> >>>> gpio2regs is written making an assumption that driver supports only >>>> one instance of gpio controller. Removing this and adding a generic >>>> array so as to support multiple instances of gpio controllers. >>>> >>>> Signed-off-by: Keerthy <j-keerthy@ti.com> >>> >>> >>>> - regs = gpio2regs(base); >>>> + regs = gpio_base + offset_array[i]; >>> >>> >>> I understand this. >>> >>>> - struct davinci_gpio_regs __iomem *g = gpio2regs(hw); >>>> + struct davinci_gpio_controller *chips = >>>> + (struct davinci_gpio_controller >>>> *)d->host_data; >>>> + struct davinci_gpio_regs __iomem *g = chips[hw / 32].regs; >>> >>> >>> And this, if each instans has 32 GPIOs. >>> >>>> - g = gpio2regs(0); >>>> + g = chips[0].regs; >>> >>> >>> Also makes sense. >>> >>>> - g = gpio2regs(gpio); >>>> + g = chips[bank / 2].regs; >>> >>> >>> But what is this? I don't understand that /2 at all. Please insert a >>> comment explaining it so I can figure it out. Are there two banks >>> per instance? >> >> >> Yes! There are register sets for 32 GPIOs. 2 banks of 16 GPIOs are covered >> by each set of registers hence /2. Shall i add a comment and send this patch >> alone separately? > > Yeah. > > I am currently confused by several patch sets for davinci in my inbox, > can you rebase on my devel branch when I push it and resend > *all* you have cooking for DaVinci? Sure Linus i will do that. Thanks, Keerthy > > Yours, > Linus Walleij > ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 2/2] gpio: davinci: Remove gpio2regs function to accommodate multi instances 2017-01-11 15:53 ` Linus Walleij 2017-01-12 1:52 ` Keerthy @ 2017-01-13 3:54 ` Keerthy 1 sibling, 0 replies; 10+ messages in thread From: Keerthy @ 2017-01-13 3:54 UTC (permalink / raw) To: Linus Walleij Cc: linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, Alexandre Courbot, Tero Kristo On Wednesday 11 January 2017 09:23 PM, Linus Walleij wrote: > On Wed, Jan 11, 2017 at 1:40 PM, Keerthy <j-keerthy@ti.com> wrote: >> On Wednesday 11 January 2017 04:34 PM, Linus Walleij wrote: >>> On Wed, Jan 4, 2017 at 9:26 AM, Keerthy <j-keerthy@ti.com> wrote: >>> >>>> gpio2regs is written making an assumption that driver supports only >>>> one instance of gpio controller. Removing this and adding a generic >>>> array so as to support multiple instances of gpio controllers. >>>> >>>> Signed-off-by: Keerthy <j-keerthy@ti.com> >>> >>> >>>> - regs = gpio2regs(base); >>>> + regs = gpio_base + offset_array[i]; >>> >>> >>> I understand this. >>> >>>> - struct davinci_gpio_regs __iomem *g = gpio2regs(hw); >>>> + struct davinci_gpio_controller *chips = >>>> + (struct davinci_gpio_controller >>>> *)d->host_data; >>>> + struct davinci_gpio_regs __iomem *g = chips[hw / 32].regs; >>> >>> >>> And this, if each instans has 32 GPIOs. >>> >>>> - g = gpio2regs(0); >>>> + g = chips[0].regs; >>> >>> >>> Also makes sense. >>> >>>> - g = gpio2regs(gpio); >>>> + g = chips[bank / 2].regs; >>> >>> >>> But what is this? I don't understand that /2 at all. Please insert a >>> comment explaining it so I can figure it out. Are there two banks >>> per instance? >> >> >> Yes! There are register sets for 32 GPIOs. 2 banks of 16 GPIOs are covered >> by each set of registers hence /2. Shall i add a comment and send this patch >> alone separately? > > Yeah. > > I am currently confused by several patch sets for davinci in my inbox, > can you rebase on my devel branch when I push it and resend > *all* you have cooking for DaVinci? I am assuming that Patch 1 from this is applied. I will club this one along with my latest series and send a new v2 series so that all are in one place. Thanks, Keerthy > > Yours, > Linus Walleij > ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 1/2] gpio: davinci: Remove redundant members davinci_gpio_controller stuct 2017-01-04 8:26 ` Keerthy (?) (?) @ 2017-01-11 11:00 ` Linus Walleij -1 siblings, 0 replies; 10+ messages in thread From: Linus Walleij @ 2017-01-11 11:00 UTC (permalink / raw) To: Keerthy Cc: linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, Alexandre Courbot, Tero Kristo On Wed, Jan 4, 2017 at 9:26 AM, Keerthy <j-keerthy@ti.com> wrote: > davinci_gpio_controller struct has set_data, in_data, clr_data > members that are assigned and never used. > > Signed-off-by: Keerthy <j-keerthy@ti.com> Nice catch! Patch applied. Yours, Linus Walleij ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2017-01-13 3:55 UTC | newest] Thread overview: 10+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2017-01-04 8:26 [PATCH 1/2] gpio: davinci: Remove redundant members davinci_gpio_controller stuct Keerthy 2017-01-04 8:26 ` Keerthy 2017-01-04 8:26 ` [PATCH 2/2] gpio: davinci: Remove gpio2regs function to accommodate multi instances Keerthy 2017-01-04 8:26 ` Keerthy 2017-01-11 11:04 ` Linus Walleij 2017-01-11 12:40 ` Keerthy 2017-01-11 15:53 ` Linus Walleij 2017-01-12 1:52 ` Keerthy 2017-01-13 3:54 ` Keerthy 2017-01-11 11:00 ` [PATCH 1/2] gpio: davinci: Remove redundant members davinci_gpio_controller stuct Linus Walleij
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.