[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CH2PR13MB3368A85F74CA82994E8C0D1B8C4E0@CH2PR13MB3368.namprd13.prod.outlook.com>
Date: Thu, 21 Nov 2019 08:32:33 +0000
From: Yash Shah <yash.shah@...ive.com>
To: Bartosz Golaszewski <bgolaszewski@...libre.com>
CC: "linus.walleij@...aro.org" <linus.walleij@...aro.org>,
"robh+dt@...nel.org" <robh+dt@...nel.org>,
"mark.rutland@....com" <mark.rutland@....com>,
"palmer@...belt.com" <palmer@...belt.com>,
"Paul Walmsley ( Sifive)" <paul.walmsley@...ive.com>,
"aou@...s.berkeley.edu" <aou@...s.berkeley.edu>,
"tglx@...utronix.de" <tglx@...utronix.de>,
"jason@...edaemon.net" <jason@...edaemon.net>,
"maz@...nel.org" <maz@...nel.org>,
"bmeng.cn@...il.com" <bmeng.cn@...il.com>,
"atish.patra@....com" <atish.patra@....com>,
Sagar Kadam <sagar.kadam@...ive.com>,
"linux-gpio@...r.kernel.org" <linux-gpio@...r.kernel.org>,
"devicetree@...r.kernel.org" <devicetree@...r.kernel.org>,
"linux-riscv@...ts.infradead.org" <linux-riscv@...ts.infradead.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
Sachin Ghadi <sachin.ghadi@...ive.com>
Subject: RE: [PATCH v2 4/5] gpio: sifive: Add GPIO driver for SiFive SoCs
> -----Original Message-----
> From: Bartosz Golaszewski <bgolaszewski@...libre.com>
> Sent: 20 November 2019 15:31
> To: Yash Shah <yash.shah@...ive.com>
> Cc: linus.walleij@...aro.org; robh+dt@...nel.org; mark.rutland@....com;
> palmer@...belt.com; Paul Walmsley ( Sifive) <paul.walmsley@...ive.com>;
> aou@...s.berkeley.edu; tglx@...utronix.de; jason@...edaemon.net;
> maz@...nel.org; bmeng.cn@...il.com; atish.patra@....com; Sagar Kadam
> <sagar.kadam@...ive.com>; linux-gpio@...r.kernel.org;
> devicetree@...r.kernel.org; linux-riscv@...ts.infradead.org; linux-
> kernel@...r.kernel.org; Sachin Ghadi <sachin.ghadi@...ive.com>
> Subject: Re: [PATCH v2 4/5] gpio: sifive: Add GPIO driver for SiFive SoCs
>
> śr., 20 lis 2019 o 07:59 Yash Shah <yash.shah@...ive.com> napisał(a):
> >
> > Adds the GPIO driver for SiFive RISC-V SoCs.
> >
>
> This looks much better just a couple nits.
>
> > Signed-off-by: Wesley W. Terpstra <wesley@...ive.com>
> > [Atish: Various fixes and code cleanup]
> > Signed-off-by: Atish Patra <atish.patra@....com>
> > Signed-off-by: Yash Shah <yash.shah@...ive.com>
[...]
> > diff --git a/drivers/gpio/gpio-sifive.c b/drivers/gpio/gpio-sifive.c
> > new file mode 100644 index 0000000..02666ae
> > --- /dev/null
> > +++ b/drivers/gpio/gpio-sifive.c
> > @@ -0,0 +1,256 @@
> > +// SPDX-License-Identifier: GPL-2.0
> > +/*
> > + * Copyright (C) 2019 SiFive
> > + */
>
> I prefer to have a newline between the copyright notice and the headers.
Done
>
> > +#include <linux/bitops.h>
> > +#include <linux/device.h>
> > +#include <linux/errno.h>
> > +#include <linux/of_irq.h>
> > +#include <linux/gpio/driver.h>
> > +#include <linux/init.h>
> > +#include <linux/of.h>
>
> Is this really needed? I only see functions defined in of_irq.h.
>
> > +#include <linux/platform_device.h>
> > +#include <linux/pm.h>
>
> Same here - I don't see any functions from this header being called.
>
Yes, you are right. Both the above inclusion of header file is unnecessary. Will remove them.
> > +#include <linux/slab.h>
> > +#include <linux/spinlock.h>
> > +#include <linux/regmap.h>
> > +
> > +#define GPIO_INPUT_VAL 0x00
> > +#define GPIO_INPUT_EN 0x04
> > +#define GPIO_OUTPUT_EN 0x08
> > +#define GPIO_OUTPUT_VAL 0x0C
> > +#define GPIO_RISE_IE 0x18
> > +#define GPIO_RISE_IP 0x1C
> > +#define GPIO_FALL_IE 0x20
> > +#define GPIO_FALL_IP 0x24
> > +#define GPIO_HIGH_IE 0x28
> > +#define GPIO_HIGH_IP 0x2C
> > +#define GPIO_LOW_IE 0x30
> > +#define GPIO_LOW_IP 0x34
> > +#define GPIO_OUTPUT_XOR 0x40
> > +
> > +#define MAX_GPIO 32
> > +#define SIFIVE_GPIO_IRQ_OFFSET 7
>
> Please use a single prefix for all symbols in this driver. Let's stick to sifive_gpio
> and SIFIVE_GPIO for defines.
Sure.
>
> > +
> > +struct sifive_gpio {
> > + void __iomem *base;
> > + struct gpio_chip gc;
> > + struct regmap *regs;
> > + u32 enabled;
>
> The name of this field is a bit confusing - do you mind renaming it to
> something like irq_state? Maybe something else, but simply using 'enabled'
> makes me think this has more to do with the chip being enabled.
>
Sure, will rename it to irq_state.
[...]
> > + spin_lock_irqsave(&chip->gc.bgpio_lock, flags);
> > + /* Disable all GPIO interrupts before enabling parent interrupts */
> > + regmap_write(chip->regs, GPIO_RISE_IE, 0);
> > + regmap_write(chip->regs, GPIO_FALL_IE, 0);
> > + regmap_write(chip->regs, GPIO_HIGH_IE, 0);
> > + regmap_write(chip->regs, GPIO_LOW_IE, 0);
> > + spin_unlock_irqrestore(&chip->gc.bgpio_lock, flags);
>
> No need for locking in probe().
Ok.
Thanks for your comments!
- Yash
Powered by blists - more mailing lists