* [cip-dev] [PATCH 4.4.y-cip] gpio: rcar: use gpiochip data pointer
@ 2020-09-03 14:10 Lad Prabhakar
2020-09-03 17:54 ` Pavel Machek
0 siblings, 1 reply; 5+ messages in thread
From: Lad Prabhakar @ 2020-09-03 14:10 UTC (permalink / raw)
To: cip-dev, Nobuhiro Iwamatsu, Pavel Machek; +Cc: Biju Das
[-- Attachment #1: Type: text/plain, Size: 5080 bytes --]
From: Linus Walleij <linus.walleij@linaro.org>
commit c7b6f457cb53bceece484f4c528d1c149995e6c7 upstream.
This makes the driver use the data pointer added to the gpio_chip
to store a pointer to the state container instead of relying on
container_of().
Cc: Ulrich Hecht <ulrich.hecht+renesas@gmail.com>
Cc: Geert Uytterhoeven <geert+renesas@glider.be>
Cc: Hisashi Nakamura <hisashi.nakamura.ak@renesas.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
[PL: Fixes 6e52cced1aa58 ("gpio: rcar: Implement gpiochip.set_multiple()")]
Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
---
drivers/gpio/gpio-rcar.c | 33 ++++++++++++---------------------
1 file changed, 12 insertions(+), 21 deletions(-)
diff --git a/drivers/gpio/gpio-rcar.c b/drivers/gpio/gpio-rcar.c
index e829f11aca8f..cffeebd2ac4d 100644
--- a/drivers/gpio/gpio-rcar.c
+++ b/drivers/gpio/gpio-rcar.c
@@ -84,8 +84,7 @@ static void gpio_rcar_modify_bit(struct gpio_rcar_priv *p, int offs,
static void gpio_rcar_irq_disable(struct irq_data *d)
{
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
- struct gpio_rcar_priv *p = container_of(gc, struct gpio_rcar_priv,
- gpio_chip);
+ struct gpio_rcar_priv *p = gpiochip_get_data(gc);
gpio_rcar_write(p, INTMSK, ~BIT(irqd_to_hwirq(d)));
}
@@ -93,8 +92,7 @@ static void gpio_rcar_irq_disable(struct irq_data *d)
static void gpio_rcar_irq_enable(struct irq_data *d)
{
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
- struct gpio_rcar_priv *p = container_of(gc, struct gpio_rcar_priv,
- gpio_chip);
+ struct gpio_rcar_priv *p = gpiochip_get_data(gc);
gpio_rcar_write(p, MSKCLR, BIT(irqd_to_hwirq(d)));
}
@@ -137,8 +135,7 @@ static void gpio_rcar_config_interrupt_input_mode(struct gpio_rcar_priv *p,
static int gpio_rcar_irq_set_type(struct irq_data *d, unsigned int type)
{
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
- struct gpio_rcar_priv *p = container_of(gc, struct gpio_rcar_priv,
- gpio_chip);
+ struct gpio_rcar_priv *p = gpiochip_get_data(gc);
unsigned int hwirq = irqd_to_hwirq(d);
dev_dbg(&p->pdev->dev, "sense irq = %d, type = %d\n", hwirq, type);
@@ -175,8 +172,7 @@ static int gpio_rcar_irq_set_type(struct irq_data *d, unsigned int type)
static int gpio_rcar_irq_set_wake(struct irq_data *d, unsigned int on)
{
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
- struct gpio_rcar_priv *p = container_of(gc, struct gpio_rcar_priv,
- gpio_chip);
+ struct gpio_rcar_priv *p = gpiochip_get_data(gc);
int error;
if (p->irq_parent) {
@@ -260,16 +256,11 @@ static irqreturn_t gpio_rcar_irq_handler(int irq, void *dev_id)
return irqs_handled ? IRQ_HANDLED : IRQ_NONE;
}
-static inline struct gpio_rcar_priv *gpio_to_priv(struct gpio_chip *chip)
-{
- return container_of(chip, struct gpio_rcar_priv, gpio_chip);
-}
-
static void gpio_rcar_config_general_input_output_mode(struct gpio_chip *chip,
unsigned int gpio,
bool output)
{
- struct gpio_rcar_priv *p = gpio_to_priv(chip);
+ struct gpio_rcar_priv *p = gpiochip_get_data(chip);
unsigned long flags;
/* follow steps in the GPIO documentation for
@@ -293,7 +284,7 @@ static void gpio_rcar_config_general_input_output_mode(struct gpio_chip *chip,
static int gpio_rcar_request(struct gpio_chip *chip, unsigned offset)
{
- struct gpio_rcar_priv *p = gpio_to_priv(chip);
+ struct gpio_rcar_priv *p = gpiochip_get_data(chip);
int error;
error = pm_runtime_get_sync(&p->pdev->dev);
@@ -309,7 +300,7 @@ static int gpio_rcar_request(struct gpio_chip *chip, unsigned offset)
static void gpio_rcar_free(struct gpio_chip *chip, unsigned offset)
{
- struct gpio_rcar_priv *p = gpio_to_priv(chip);
+ struct gpio_rcar_priv *p = gpiochip_get_data(chip);
pinctrl_free_gpio(chip->base + offset);
@@ -333,15 +324,15 @@ static int gpio_rcar_get(struct gpio_chip *chip, unsigned offset)
/* testing on r8a7790 shows that INDT does not show correct pin state
* when configured as output, so use OUTDT in case of output pins */
- if (gpio_rcar_read(gpio_to_priv(chip), INOUTSEL) & bit)
- return !!(gpio_rcar_read(gpio_to_priv(chip), OUTDT) & bit);
+ if (gpio_rcar_read(gpiochip_get_data(chip), INOUTSEL) & bit)
+ return !!(gpio_rcar_read(gpiochip_get_data(chip), OUTDT) & bit);
else
- return !!(gpio_rcar_read(gpio_to_priv(chip), INDT) & bit);
+ return !!(gpio_rcar_read(gpiochip_get_data(chip), INDT) & bit);
}
static void gpio_rcar_set(struct gpio_chip *chip, unsigned offset, int value)
{
- struct gpio_rcar_priv *p = gpio_to_priv(chip);
+ struct gpio_rcar_priv *p = gpiochip_get_data(chip);
unsigned long flags;
spin_lock_irqsave(&p->lock, flags);
@@ -541,7 +532,7 @@ static int gpio_rcar_probe(struct platform_device *pdev)
irq_chip->irq_release_resources = gpio_rcar_irq_release_resources;
irq_chip->flags = IRQCHIP_SET_TYPE_MASKED | IRQCHIP_MASK_ON_SUSPEND;
- ret = gpiochip_add(gpio_chip);
+ ret = gpiochip_add_data(gpio_chip, p);
if (ret) {
dev_err(dev, "failed to add GPIO controller\n");
goto err0;
--
2.17.1
[-- Attachment #2: Type: text/plain, Size: 419 bytes --]
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#5389): https://lists.cip-project.org/g/cip-dev/message/5389
Mute This Topic: https://lists.cip-project.org/mt/76607574/4520388
Group Owner: cip-dev+owner@lists.cip-project.org
Unsubscribe: https://lists.cip-project.org/g/cip-dev/leave/8129055/727948398/xyzzy [cip-dev@archiver.kernel.org]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [cip-dev] [PATCH 4.4.y-cip] gpio: rcar: use gpiochip data pointer
2020-09-03 14:10 [cip-dev] [PATCH 4.4.y-cip] gpio: rcar: use gpiochip data pointer Lad Prabhakar
@ 2020-09-03 17:54 ` Pavel Machek
2020-09-03 18:01 ` Lad Prabhakar
0 siblings, 1 reply; 5+ messages in thread
From: Pavel Machek @ 2020-09-03 17:54 UTC (permalink / raw)
To: Lad Prabhakar; +Cc: cip-dev, Nobuhiro Iwamatsu, Pavel Machek, Biju Das
[-- Attachment #1.1: Type: text/plain, Size: 1237 bytes --]
Hi!
> This makes the driver use the data pointer added to the gpio_chip
> to store a pointer to the state container instead of relying on
> container_of().
Okay, so this is a cleanup that makes sense for mainline.
> [PL: Fixes 6e52cced1aa58 ("gpio: rcar: Implement gpiochip.set_multiple()")]
Does it fix set_multiple? ... seems so.
Fixing set_multiple is possible with this oneliner, right?
> @@ -541,7 +532,7 @@ static int gpio_rcar_probe(struct platform_device *pdev)
> irq_chip->irq_release_resources = gpio_rcar_irq_release_resources;
> irq_chip->flags = IRQCHIP_SET_TYPE_MASKED | IRQCHIP_MASK_ON_SUSPEND;
>
> - ret = gpiochip_add(gpio_chip);
> + ret = gpiochip_add_data(gpio_chip, p);
> if (ret) {
> dev_err(dev, "failed to add GPIO controller\n");
> goto err0;
The patch is okay and now I understand why you want it. It would have
been nice if changelog told me directly.
Can set_multiple use container_of() too? We get less differences
between 4.4 and 4.4-cip that way, and it is still one-liner.
Best regards,
Pavel
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]
[-- Attachment #2: Type: text/plain, Size: 419 bytes --]
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#5406): https://lists.cip-project.org/g/cip-dev/message/5406
Mute This Topic: https://lists.cip-project.org/mt/76607574/4520388
Group Owner: cip-dev+owner@lists.cip-project.org
Unsubscribe: https://lists.cip-project.org/g/cip-dev/leave/8129055/727948398/xyzzy [cip-dev@archiver.kernel.org]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [cip-dev] [PATCH 4.4.y-cip] gpio: rcar: use gpiochip data pointer
2020-09-03 17:54 ` Pavel Machek
@ 2020-09-03 18:01 ` Lad Prabhakar
2020-09-04 7:45 ` Lad Prabhakar
0 siblings, 1 reply; 5+ messages in thread
From: Lad Prabhakar @ 2020-09-03 18:01 UTC (permalink / raw)
To: Pavel Machek; +Cc: cip-dev, Nobuhiro Iwamatsu, Biju Das
[-- Attachment #1: Type: text/plain, Size: 2090 bytes --]
Hi Pavel,
Thank you for the review.
> -----Original Message-----
> From: Pavel Machek <pavel@denx.de>
> Sent: 03 September 2020 18:55
> To: Prabhakar Mahadev Lad <prabhakar.mahadev-lad.rj@bp.renesas.com>
> Cc: cip-dev@lists.cip-project.org; Nobuhiro Iwamatsu <nobuhiro1.iwamatsu@toshiba.co.jp>; Pavel Machek <pavel@denx.de>; Biju Das
> <biju.das.jz@bp.renesas.com>
> Subject: Re: [PATCH 4.4.y-cip] gpio: rcar: use gpiochip data pointer
>
> Hi!
>
> > This makes the driver use the data pointer added to the gpio_chip
> > to store a pointer to the state container instead of relying on
> > container_of().
>
> Okay, so this is a cleanup that makes sense for mainline.
>
> > [PL: Fixes 6e52cced1aa58 ("gpio: rcar: Implement gpiochip.set_multiple()")]
>
> Does it fix set_multiple? ... seems so.
>
> Fixing set_multiple is possible with this oneliner, right?
>
> > @@ -541,7 +532,7 @@ static int gpio_rcar_probe(struct platform_device *pdev)
> > irq_chip->irq_release_resources = gpio_rcar_irq_release_resources;
> > irq_chip->flags= IRQCHIP_SET_TYPE_MASKED | IRQCHIP_MASK_ON_SUSPEND;
> >
> > -ret = gpiochip_add(gpio_chip);
> > +ret = gpiochip_add_data(gpio_chip, p);
> > if (ret) {
> > dev_err(dev, "failed to add GPIO controller\n");
> > goto err0;
>
> The patch is okay and now I understand why you want it. It would have
> been nice if changelog told me directly.
>
My bad.
> Can set_multiple use container_of() too? We get less differences
> between 4.4 and 4.4-cip that way, and it is still one-liner.
>
It could use gpio_to_priv(), but since there was an commit upstream already I just pulled it in.
Let me know if you if you are OK with the patch or I shall post a one-liner.
Cheers,
Prabhakar
Renesas Electronics Europe GmbH, Geschaeftsfuehrer/President: Carsten Jauch, Sitz der Gesellschaft/Registered office: Duesseldorf, Arcadiastrasse 10, 40472 Duesseldorf, Germany, Handelsregister/Commercial Register: Duesseldorf, HRB 3708 USt-IDNr./Tax identification no.: DE 119353406 WEEE-Reg.-Nr./WEEE reg. no.: DE 14978647
[-- Attachment #2: Type: text/plain, Size: 419 bytes --]
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#5407): https://lists.cip-project.org/g/cip-dev/message/5407
Mute This Topic: https://lists.cip-project.org/mt/76607574/4520388
Group Owner: cip-dev+owner@lists.cip-project.org
Unsubscribe: https://lists.cip-project.org/g/cip-dev/leave/8129055/727948398/xyzzy [cip-dev@archiver.kernel.org]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [cip-dev] [PATCH 4.4.y-cip] gpio: rcar: use gpiochip data pointer
2020-09-03 18:01 ` Lad Prabhakar
@ 2020-09-04 7:45 ` Lad Prabhakar
2020-09-09 6:06 ` Pavel Machek
0 siblings, 1 reply; 5+ messages in thread
From: Lad Prabhakar @ 2020-09-04 7:45 UTC (permalink / raw)
To: Pavel Machek; +Cc: cip-dev, Nobuhiro Iwamatsu, Biju Das
[-- Attachment #1: Type: text/plain, Size: 2647 bytes --]
Hi Pavel,
> -----Original Message-----
> From: Prabhakar Mahadev Lad
> Sent: 03 September 2020 19:01
> To: Pavel Machek <pavel@denx.de>
> Cc: cip-dev@lists.cip-project.org; Nobuhiro Iwamatsu <nobuhiro1.iwamatsu@toshiba.co.jp>; Biju Das <biju.das.jz@bp.renesas.com>
> Subject: RE: [PATCH 4.4.y-cip] gpio: rcar: use gpiochip data pointer
>
> Hi Pavel,
>
> Thank you for the review.
>
> > -----Original Message-----
> > From: Pavel Machek <pavel@denx.de>
> > Sent: 03 September 2020 18:55
> > To: Prabhakar Mahadev Lad <prabhakar.mahadev-lad.rj@bp.renesas.com>
> > Cc: cip-dev@lists.cip-project.org; Nobuhiro Iwamatsu <nobuhiro1.iwamatsu@toshiba.co.jp>; Pavel Machek <pavel@denx.de>; Biju Das
> > <biju.das.jz@bp.renesas.com>
> > Subject: Re: [PATCH 4.4.y-cip] gpio: rcar: use gpiochip data pointer
> >
> > Hi!
> >
> > > This makes the driver use the data pointer added to the gpio_chip
> > > to store a pointer to the state container instead of relying on
> > > container_of().
> >
> > Okay, so this is a cleanup that makes sense for mainline.
> >
> > > [PL: Fixes 6e52cced1aa58 ("gpio: rcar: Implement gpiochip.set_multiple()")]
> >
> > Does it fix set_multiple? ... seems so.
> >
> > Fixing set_multiple is possible with this oneliner, right?
> >
> > > @@ -541,7 +532,7 @@ static int gpio_rcar_probe(struct platform_device *pdev)
> > > irq_chip->irq_release_resources = gpio_rcar_irq_release_resources;
> > > irq_chip->flags= IRQCHIP_SET_TYPE_MASKED | IRQCHIP_MASK_ON_SUSPEND;
> > >
> > > -ret = gpiochip_add(gpio_chip);
> > > +ret = gpiochip_add_data(gpio_chip, p);
> > > if (ret) {
> > > dev_err(dev, "failed to add GPIO controller\n");
> > > goto err0;
> >
> > The patch is okay and now I understand why you want it. It would have
> > been nice if changelog told me directly.
> >
> My bad.
>
> > Can set_multiple use container_of() too? We get less differences
> > between 4.4 and 4.4-cip that way, and it is still one-liner.
> >
> It could use gpio_to_priv(), but since there was an commit upstream already I just pulled it in.
>
I have now posted a oneliner patch (https://patchwork.kernel.org/patch/11756155/)
> Let me know if you if you are OK with the patch or I shall post a one-liner.
>
Please drop the current patch
Cheers,
Prabhakar
Renesas Electronics Europe GmbH, Geschaeftsfuehrer/President: Carsten Jauch, Sitz der Gesellschaft/Registered office: Duesseldorf, Arcadiastrasse 10, 40472 Duesseldorf, Germany, Handelsregister/Commercial Register: Duesseldorf, HRB 3708 USt-IDNr./Tax identification no.: DE 119353406 WEEE-Reg.-Nr./WEEE reg. no.: DE 14978647
[-- Attachment #2: Type: text/plain, Size: 419 bytes --]
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#5416): https://lists.cip-project.org/g/cip-dev/message/5416
Mute This Topic: https://lists.cip-project.org/mt/76607574/4520388
Group Owner: cip-dev+owner@lists.cip-project.org
Unsubscribe: https://lists.cip-project.org/g/cip-dev/leave/8129055/727948398/xyzzy [cip-dev@archiver.kernel.org]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [cip-dev] [PATCH 4.4.y-cip] gpio: rcar: use gpiochip data pointer
2020-09-04 7:45 ` Lad Prabhakar
@ 2020-09-09 6:06 ` Pavel Machek
0 siblings, 0 replies; 5+ messages in thread
From: Pavel Machek @ 2020-09-09 6:06 UTC (permalink / raw)
To: cip-dev; +Cc: Pavel Machek, Nobuhiro Iwamatsu, Biju Das
[-- Attachment #1.1: Type: text/plain, Size: 1363 bytes --]
Hi!
> > > Fixing set_multiple is possible with this oneliner, right?
> > >
> > > > @@ -541,7 +532,7 @@ static int gpio_rcar_probe(struct platform_device *pdev)
> > > > irq_chip->irq_release_resources = gpio_rcar_irq_release_resources;
> > > > irq_chip->flags= IRQCHIP_SET_TYPE_MASKED | IRQCHIP_MASK_ON_SUSPEND;
> > > >
> > > > -ret = gpiochip_add(gpio_chip);
> > > > +ret = gpiochip_add_data(gpio_chip, p);
> > > > if (ret) {
> > > > dev_err(dev, "failed to add GPIO controller\n");
> > > > goto err0;
> > >
> > > The patch is okay and now I understand why you want it. It would have
> > > been nice if changelog told me directly.
> > >
> > My bad.
> >
> > > Can set_multiple use container_of() too? We get less differences
> > > between 4.4 and 4.4-cip that way, and it is still one-liner.
> > >
> > It could use gpio_to_priv(), but since there was an commit upstream already I just pulled it in.
> >
> I have now posted a oneliner patch (https://patchwork.kernel.org/patch/11756155/)
>
> > Let me know if you if you are OK with the patch or I shall post a one-liner.
> >
> Please drop the current patch
Done, thanks... and let me take a look.
Best regards,
Pavel
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]
[-- Attachment #2: Type: text/plain, Size: 419 bytes --]
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#5431): https://lists.cip-project.org/g/cip-dev/message/5431
Mute This Topic: https://lists.cip-project.org/mt/76607574/4520388
Group Owner: cip-dev+owner@lists.cip-project.org
Unsubscribe: https://lists.cip-project.org/g/cip-dev/leave/8129055/727948398/xyzzy [cip-dev@archiver.kernel.org]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-09-09 6:07 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-03 14:10 [cip-dev] [PATCH 4.4.y-cip] gpio: rcar: use gpiochip data pointer Lad Prabhakar
2020-09-03 17:54 ` Pavel Machek
2020-09-03 18:01 ` Lad Prabhakar
2020-09-04 7:45 ` Lad Prabhakar
2020-09-09 6:06 ` Pavel Machek
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).