RE: [PATCH v2 4/5] gpio: sifive: Add GPIO driver for SiFive SoCs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> -----Original Message-----
> From: Bartosz Golaszewski <bgolaszewski@xxxxxxxxxxxx>
> Sent: 20 November 2019 15:31
> To: Yash Shah <yash.shah@xxxxxxxxxx>
> Cc: linus.walleij@xxxxxxxxxx; robh+dt@xxxxxxxxxx; mark.rutland@xxxxxxx;
> palmer@xxxxxxxxxxx; Paul Walmsley ( Sifive) <paul.walmsley@xxxxxxxxxx>;
> aou@xxxxxxxxxxxxxxxxx; tglx@xxxxxxxxxxxxx; jason@xxxxxxxxxxxxxx;
> maz@xxxxxxxxxx; bmeng.cn@xxxxxxxxx; atish.patra@xxxxxxx; Sagar Kadam
> <sagar.kadam@xxxxxxxxxx>; linux-gpio@xxxxxxxxxxxxxxx;
> devicetree@xxxxxxxxxxxxxxx; linux-riscv@xxxxxxxxxxxxxxxxxxx; linux-
> kernel@xxxxxxxxxxxxxxx; Sachin Ghadi <sachin.ghadi@xxxxxxxxxx>
> 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@xxxxxxxxxx> 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@xxxxxxxxxx>
> > [Atish: Various fixes and code cleanup]
> > Signed-off-by: Atish Patra <atish.patra@xxxxxxx>
> > Signed-off-by: Yash Shah <yash.shah@xxxxxxxxxx>
[...]
> > 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





[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux