gpio: Add CNS3XXX mmio gpio support
Subsystems (3)
PATCH 1/2 gpio: Add CNS3XXX mmio gpio support
Add CNS3XXX generic memory mapped GPIO controller support. Also implement cascaded GPIO interrupts for all 64 GPIOs.
--- arch/arm/Kconfig | 3 + arch/arm/configs/cns3420vb_defconfig | 1 + arch/arm/mach-cns3xxx/cns3420vb.c | 120 ++++++ arch/arm/mach-cns3xxx/core.c | 10 - arch/arm/mach-cns3xxx/include/mach/cns3xxx.h | 8 +- arch/arm/mach-cns3xxx/include/mach/gpio.h | 64 ++++ drivers/gpio/Kconfig | 6 + drivers/gpio/Makefile | 1 + drivers/gpio/gpio-cns3xxx.c | 516 ++++++++++++++++++++++++++ 9 files changed, 717 insertions(+), 12 deletions(-) create mode 100644 arch/arm/mach-cns3xxx/include/mach/gpio.h create mode 100644 drivers/gpio/gpio-cns3xxx.c
arch/arm/Kconfig +3 -0
@@ -333,6 +333,9 @@ config ARCH_CNS3XXX select ARM_GIC select MIGHT_HAVE_PCI select PCI_DOMAINS if PCI + select ARCH_REQUIRE_GPIOLIB + select GPIO_GENERIC_PLATFORM + select GENERIC_IRQ_CHIP help Support for Cavium Networks CNS3XXX platform.
arch/arm/configs/cns3420vb_defconfig +1 -0
@@ -52,6 +52,7 @@ CONFIG_SERIAL_8250_CONSOLE=y CONFIG_LEGACY_PTY_COUNT=16 # CONFIG_HW_RANDOM is not set # CONFIG_HWMON is not set +CONFIG_GPIO_SYSFS=y # CONFIG_VGA_CONSOLE is not set # CONFIG_HID_SUPPORT is not set # CONFIG_USB_SUPPORT is not set
arch/arm/mach-cns3xxx/cns3420vb.c +120 -0
136 lines not on this page · raw message
arch/arm/mach-cns3xxx/core.c +0 -10
@@ -42,16 +42,6 @@ static struct map_desc cns3xxx_io_desc[] __initdata = { .length = SZ_4K, .type = MT_DEVICE, }, { - .virtual = CNS3XXX_GPIOA_BASE_VIRT, - .pfn = __phys_to_pfn(CNS3XXX_GPIOA_BASE), - .length = SZ_4K, - .type = MT_DEVICE, - }, { - .virtual = CNS3XXX_GPIOB_BASE_VIRT, - .pfn = __phys_to_pfn(CNS3XXX_GPIOB_BASE), - .length = SZ_4K, - .type = MT_DEVICE, - }, { .virtual = CNS3XXX_MISC_BASE_VIRT, .pfn = __phys_to_pfn(CNS3XXX_MISC_BASE), .length = SZ_4K,
arch/arm/mach-cns3xxx/include/mach/cns3xxx.h +6 -2
@@ -624,9 +624,13 @@ int cns3xxx_cpu_clock(void);#define NR_IRQS_CNS3XXX (IRQ_TC11MP_GIC_START + 64) -#if !defined(NR_IRQS ) || (NR_IRQS <NR_IRQS_CNS3XXX ) +#define MAX_GPIOA_NO 32 +#define MAX_GPIOB_NO 32 +#define MAX_GPIO_NO (MAX_GPIOA_NO + MAX_GPIOB_NO) + +#if !defined(NR_IRQS ) || (NR_IRQS < (NR_IRQS_CNS3XXX +MAX_GPIO_NO ))#undef NR_IRQS -#define NR_IRQS NR_IRQS_CNS3XXX +#define NR_IRQS (NR_IRQS_CNS3XXX + MAX_GPIO_NO)#endif #endif /* __MACH_BOARD_CNS3XXX_H */
arch/arm/mach-cns3xxx/include/mach/gpio.h new file +64 -0
64 lines not on this page · raw message
drivers/gpio/Kconfig +6 -0
@@ -90,6 +90,12 @@ config GPIO_IT8761E help Say yes here to support GPIO functionality of IT8761E super I/O chip. +config GPIO_CNS3XXX + bool "CNS3XXX GPIO" + depends on ARCH_CNS3XXX + help + Say yes here to support the Cavium CNS3XXX GPIO interrupts. + config GPIO_EP93XX def_bool y depends on ARCH_EP93XX
drivers/gpio/Makefile +1 -0
@@ -12,6 +12,7 @@ obj-$(CONFIG_GPIO_AB8500) += gpio-ab8500.o obj-$(CONFIG_GPIO_ADP5520) += gpio-adp5520.o obj-$(CONFIG_GPIO_ADP5588) += gpio-adp5588.o obj-$(CONFIG_GPIO_BT8XX) += gpio-bt8xx.o +obj-$(CONFIG_GPIO_CNS3XXX) += gpio-cns3xxx.o obj-$(CONFIG_GPIO_CS5535) += gpio-cs5535.o obj-$(CONFIG_GPIO_DA9052) += gpio-da9052.o obj-$(CONFIG_GPIO_EP93XX) += gpio-ep93xx.o
drivers/gpio/gpio-cns3xxx.c new file +516 -0
516 lines not on this page · raw message
Signature · 1 line
1.7.6
PATCH 1/2 gpio: Add CNS3XXX mmio gpio support
arch/arm/mach-cns3xxx/include/mach/gpio.h line 6
Quoted 12 lines · Tommy Lin
arch/arm/mach-cns3xxx/include/mach/gpio.h new file +6
-0@@ -0,0 +1,64 @@ +#ifndef _CNS3XXX_GPIO_H_ +#define _CNS3XXX_GPIO_H_ + +#include <mach/cns3xxx.h> + +#define ARCH_NR_GPIOS MAX_GPIO_NO
Ok.
arch/arm/mach-cns3xxx/include/mach/gpio.h line 8
Quoted 2 lines
arch/arm/mach-cns3xxx/include/mach/gpio.h new file +2
-0+ +#include <asm-generic/gpio.h>
Please see linux-next's arch/arm/include/asm/gpio.h
Quoted 6 lines
arch/arm/mach-cns3xxx/include/mach/gpio.h new file +6
-0+ +#define GPIO_OUTPUT_OFFSET 0x00 +#define GPIO_INPUT_OFFSET 0x04 +#define GPIO_DIR_OFFSET 0x08 +#define GPIO_BIT_SET_OFFSET 0x10 +#define GPIO_BIT_CLEAR_OFFSET 0x14
arch/arm/mach-cns3xxx/include/mach/gpio.h line 47
Quoted 10 lines
arch/arm/mach-cns3xxx/include/mach/gpio.h new file +10
-0+#define GPIO_INTR_ENABLE_OFFSET 0x20 +#define GPIO_INTR_RAW_STATUS_OFFSET 0x24 +#define GPIO_INTR_MASKED_STATUS_OFFSET 0x28 +#define GPIO_INTR_MASK_OFFSET 0x2C +#define GPIO_INTR_CLEAR_OFFSET 0x30 +#define GPIO_INTR_TRIGGER_METHOD_OFFSET 0x34 +#define GPIO_INTR_TRIGGER_BOTH_EDGES_OFFSET 0x38 +#define GPIO_INTR_TRIGGER_POL_OFFSET 0x3C +#define GPIO_BOUNCE_ENABLE_OFFSET 0x40 +#define GPIO_BOUNCE_PRESCALE_OFFSET 0x44
Do you really need to put these here? Can they go in a private header file maybe in arch/arm/mach-xxx/ ?
arch/arm/mach-cns3xxx/include/mach/gpio.h line 53
Quoted 6 lines
arch/arm/mach-cns3xxx/include/mach/gpio.h new file +6
-0+ + +#define gpio_get_value __gpio_get_value +#define gpio_set_value __gpio_set_value +#define gpio_cansleep __gpio_cansleep +#define gpio_to_irq cns3xxx_gpio_to_irq
Again, please see linux-next.
arch/arm/mach-cns3xxx/include/mach/gpio.h line 32
Quoted 2 lines
arch/arm/mach-cns3xxx/include/mach/gpio.h new file +2
-0+struct chog_gpio_chip { +char *name;
const?
Quoted 7 lines
arch/arm/mach-cns3xxx/include/mach/gpio.h new file +7
-0+int base; +u16 ngpio; +int irq; +struct irq_chip_generic *gc; +void __iomem *reg_base; +void __iomem *reg_gpio_dis; +};
...
arch/arm/mach-cns3xxx/include/mach/gpio.h
Quoted 2 lines
arch/arm/mach-cns3xxx/include/mach/gpio.h new file +2
-0+struct cns3xxx_regs { +char *name;
const?
Quoted 3 lines
arch/arm/mach-cns3xxx/include/mach/gpio.h new file +3
-0+void __iomem *addr; +u32 offset; +};
...
arch/arm/mach-cns3xxx/include/mach/gpio.h
Quoted 5 lines
arch/arm/mach-cns3xxx/include/mach/gpio.h new file +5
-0+inline int cns3xxx_gpio_to_irq (unsigned gpio) +{ +return NR_IRQS_CNS3XXX + gpio; +} +EXPORT_SYMBOL (gpio_to_irq);
No. Three issues:
1. You are exporting a function you're not defining here.
2. The function is marked inline yet nothing in this file uses it, so the inline provides no useful purpose.
3. Please use the standard gpiolib gpio_to_irq() and hook the translation into the gpiolib .to_irq method.
...
Quoted 110 lines
arch/arm/mach-cns3xxx/include/mach/gpio.h new file +110
-0+static void __iomem *gpio_map (struct platform_device *pdev, +const char *name,int *err) +{ +struct device *dev = &pdev->dev; +struct resource *r; +resource_size_t start; +resource_size_t sz; +void __iomem *ret; + + *err =0 ; + + r =platform_get_resource_byname (pdev,IORESOURCE_MEM , name); +if (!r) +return NULL ; + + sz =resource_size (r); + start = r->start; + +if (!devm_request_mem_region (dev, start, sz, r->name)) { + *err = -EBUSY ; +return NULL ; + } + + ret =devm_ioremap (dev, start, sz); +if (!ret) { + *err = -ENOMEM ; +return NULL ; + } + +return ret; +} + +static int __devinit gpio_probe (struct platform_device *pdev) +{ +int i, nr_gpios =0 , err =0 ; +struct device *dev = &pdev->dev; +struct resource *res; +void __iomem *misc_reg; +struct irq_chip_type *ct; + +/* TODO Once the clk framework (clk_get() + clk_enable()) is +* implemented. Use clok framework APIs instead of these APIs. +*/ +cns3xxx_pwr_clk_en (0x1 <<PM_CLK_GATE_REG_OFFSET_GPIO ); +cns3xxx_pwr_soft_rst (0x1 <<PM_CLK_GATE_REG_OFFSET_GPIO ); + + + misc_reg =gpio_map (pdev,"MISC" , &err); +if (!misc_reg) { +dev_dbg (dev,"%s gpio_map \"MISC\" failure! err=%d\n" , + __func__, err); +return err; + } + +/* Scan and match GPIO resources */ +for (i =0 ; i < nr_banks; i++) { +/* Fetech GPIO interrupt control register base address */ + gc_info[i].reg_base =gpio_map (pdev, gc_info[i].name, &err); +if (!gc_info[i].reg_base) { +dev_dbg (dev,"%s gpio_map %s failure! err=%d\n" , + __func__, gc_info[i].name, err); + goto err1; + } + +/* Fetech GPIO interrupt ID number */ + res =platform_get_resource_byname (pdev,IORESOURCE_IRQ , + gc_info[i].name); +if (!res) { +dev_dbg (dev,"%s platform_get_resource_byname (%s)" +"failed!\n" , gc_info[i].name, __func__); + err = -ENODEV ; + goto err2; + } + gc_info[i].irq = res->start; + gc_info[i].reg_gpio_dis = misc_reg +0x14 + i *4 ; + + gc_info[i].gc =irq_alloc_generic_chip ("GPIO" ,1 , +NR_IRQS_CNS3XXX + gc_info[i].base, + gc_info[i].reg_base, handle_level_irq); +if (!gc_info[i].gc) { +dev_dbg (dev,"%s irq_alloc_generic_chip failed!\n" , + __func__); + err = -ENOMEM ; + goto err2; + } + gc_info[i].gc->private = &gc_info[i]; + + ct = gc_info[i].gc->chip_types; + ct->regs.mask =get_offset (GPIO_INTR_ENABLE_OFFSET ); + ct->regs.ack =get_offset (GPIO_INTR_CLEAR_OFFSET ); + ct->regs.type =get_offset (GPIO_INTR_TRIGGER_METHOD_OFFSET ); + ct->regs.polarity =get_offset (GPIO_INTR_TRIGGER_POL_OFFSET ); + ct->type =IRQ_TYPE_LEVEL_HIGH |IRQ_TYPE_LEVEL_LOW ; + ct->chip.irq_ack = irq_gc_ack_set_bit; + ct->chip.irq_mask = irq_gc_mask_clr_bit; + ct->chip.irq_unmask = irq_gc_mask_set_bit; + ct->chip.irq_set_type = cns3xxx_gpio_set_irq_type; + +irq_setup_generic_chip (gc_info[i].gc,IRQ_MSK (gc_info[i].ngpio), +IRQ_GC_INIT_MASK_CACHE |IRQ_GC_INIT_NESTED_LOCK , +IRQ_NOREQUEST ,IRQ_LEVEL |IRQ_NOPROBE ); + +irq_set_chained_handler (gc_info[i].irq, gpio_irq_handler); + err =irq_set_handler_data (gc_info[i].irq, &gc_info[i]); +if (err) { +dev_dbg (dev,"%s irq_set_handler_data fail!\n" , + __func__); + goto err2; + } +
arch/arm/mach-cns3xxx/include/mach/gpio.h
Quoted 10 lines
arch/arm/mach-cns3xxx/include/mach/gpio.h new file +10
-0+ nr_gpios += gc_info[i].ngpio; +if (nr_gpios >=MAX_GPIO_NO ) +break ; + } + +return 0 ; + +err2: +if (gc_info[1 ].reg_base) +devm_iounmap (dev, gc_info[0 ].reg_base);
This looks buggy. You're unmapping the wrong reg_base.
arch/arm/mach-cns3xxx/include/mach/gpio.h
Quoted 6 lines
arch/arm/mach-cns3xxx/include/mach/gpio.h new file +6
-0+ +err1: +if (gc_info[0 ].reg_base) +devm_iounmap (dev, gc_info[0 ].reg_base); + +devm_iounmap (dev, misc_reg);
This is also rather inconsistent. While you iounmap, you're not releasing the region which you claimed in gpio_map().
It's also rather unnecessary. One of the reasons for devm_* is that drivers shouldn't need to care about cleaning up the managed resources. The driver model will take care of that when a probe fails, or upon remove. It avoids people making mistakes like the above.
However, I don't see where you're cleaning up the generic irqchip which was allocated (which is an unmanaged resource).
PATCH 1/2 gpio: Add CNS3XXX mmio gpio support
Quoted 3 lines
Quoted 1 line
+#include <
asm-generic/gpio.h>Please see linux-next's
arch/arm/include/asm/gpio.h
That means I have to submit to linux-next, if I following linux-next gpio.h header file.
Quoted 10 lines
Review
Quoted 7 lines
(quoted diff) +7
-0+#define GPIO_INTR_MASK_OFFSET ? ? ? ? ? ? ? ? ? ? ? ?0x2C +#define GPIO_INTR_CLEAR_OFFSET ? ? ? ? ? ? ? ? ? ? ? 0x30 +#define GPIO_INTR_TRIGGER_METHOD_OFFSET ? ? ? ? ? ? ?0x34 +#define GPIO_INTR_TRIGGER_BOTH_EDGES_OFFSET ?0x38 +#define GPIO_INTR_TRIGGER_POL_OFFSET ? ? ? ? 0x3C +#define GPIO_BOUNCE_ENABLE_OFFSET ? ? ? ? ? ?0x40 +#define GPIO_BOUNCE_PRESCALE_OFFSET ? ? ? ? ?0x44Do you really need to put these here? ?Can they go in a private header file maybe in
arch/arm/mach-xxx/?
I will move these register offset macros to arch/arm/mach-cns3xxx/gpio-regs.h
Quoted 17 lines
Review
Quoted 6 lines
(quoted diff) +6
-0+ + +#define gpio_get_value ? ? ? ? ? ? ? ? ? ? ? __gpio_get_value +#define gpio_set_value ? ? ? ? ? ? ? ? ? ? ? __gpio_set_value +#define gpio_cansleep ? ? ? ? ? ? ? ? ? ? ? ?__gpio_cansleep +#define gpio_to_irq ? ? ? ? ? ? ? ? ?cns3xxx_gpio_to_irqAgain, please see linux-next.
drivers/gpio/gpio-cns3xxx.c line 178
Quoted 5 lines
drivers/gpio/gpio-cns3xxx.c new file +5
-0+inline int cns3xxx_gpio_to_irq (unsigned gpio) +{ + ? ? return NR_IRQS_CNS3XXX + gpio; +} +EXPORT_SYMBOL (gpio_to_irq);No. ?Three issues:
Quoted 5 lines
1. You are exporting a function you're not defining here.
2. The function is marked inline yet nothing in this file uses it, so ? the inline provides no useful purpose.
3. Please use the standard gpiolibgpio_to_irq()and hook the translation ? into the gpiolib .to_irq method.
I leverage the generic driver for memory mapped GPIO, which is not define gpio_to_irq(). So I use the lazy way here. I should change the way to use bgpio_chip and hook gpio_to_irq().
Quoted 133 lines
Quoted 110 lines
(quoted diff) +110
-0+static void __iomem *gpio_map(struct platform_device *pdev, + ? ? ? ? ? ? const char *name, int *err) +{ + ? ? struct device *dev = &pdev->dev; + ? ? struct resource *r; + ? ? resource_size_t start; + ? ? resource_size_t sz; + ? ? void __iomem *ret; + + ? ? *err = 0; + + ? ? r = platform_get_resource_byname(pdev, IORESOURCE_MEM, name); + ? ? if (!r) + ? ? ? ? ? ? return NULL; + + ? ? sz = resource_size(r); + ? ? start = r->start; + + ? ? if (!devm_request_mem_region(dev, start, sz, r->name)) { + ? ? ? ? ? ? *err = -EBUSY; + ? ? ? ? ? ? return NULL; + ? ? } + + ? ? ret = devm_ioremap(dev, start, sz); + ? ? if (!ret) { + ? ? ? ? ? ? *err = -ENOMEM; + ? ? ? ? ? ? return NULL; + ? ? } + + ? ? return ret; +} + +static int __devinit gpio_probe(struct platform_device *pdev) +{ + ? ? int i, nr_gpios = 0, err = 0; + ? ? struct device *dev = &pdev->dev; + ? ? struct resource *res; + ? ? void __iomem *misc_reg; + ? ? struct irq_chip_type *ct; + + ? ? /* TODO Once the clk framework (clk_get() + clk_enable()) is + ? ? ?* implemented. Use clok framework APIs instead of these APIs. + ? ? ?*/ + ? ? cns3xxx_pwr_clk_en(0x1 << PM_CLK_GATE_REG_OFFSET_GPIO); + ? ? cns3xxx_pwr_soft_rst(0x1 << PM_CLK_GATE_REG_OFFSET_GPIO); + + + ? ? misc_reg = gpio_map(pdev, "MISC", &err); + ? ? if (!misc_reg) { + ? ? ? ? ? ? dev_dbg(dev, "%s gpio_map \"MISC\" failure! err=%d\n", + ? ? ? ? ? ? ? ? ? ? ? ? ? ? __func__, err); + ? ? ? ? ? ? return err; + ? ? } + + ? ? /* Scan and match GPIO resources */ + ? ? for (i = 0; i < nr_banks; i++) { + ? ? ? ? ? ? /* Fetech GPIO interrupt control register base address */ + ? ? ? ? ? ? gc_info[i].reg_base = gpio_map(pdev, gc_info[i].name, &err); + ? ? ? ? ? ? if (!gc_info[i].reg_base) { + ? ? ? ? ? ? ? ? ? ? dev_dbg(dev, "%s gpio_map %s failure! err=%d\n", + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? __func__, gc_info[i].name, err); + ? ? ? ? ? ? ? ? ? ? goto err1; + ? ? ? ? ? ? } + + ? ? ? ? ? ? /* Fetech GPIO interrupt ID number */ + ? ? ? ? ? ? res = platform_get_resource_byname(pdev, IORESOURCE_IRQ, + ? ? ? ? ? ? ? ? ? ? ? ? ? ? gc_info[i].name); + ? ? ? ? ? ? if (!res) { + ? ? ? ? ? ? ? ? ? ? dev_dbg(dev, "%s platform_get_resource_byname (%s)" + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? "failed!\n", gc_info[i].name, __func__); + ? ? ? ? ? ? ? ? ? ? err = -ENODEV; + ? ? ? ? ? ? ? ? ? ? goto err2; + ? ? ? ? ? ? } + ? ? ? ? ? ? gc_info[i].irq = res->start; + ? ? ? ? ? ? gc_info[i].reg_gpio_dis = misc_reg + 0x14 + i * 4; + + ? ? ? ? ? ? gc_info[i].gc = irq_alloc_generic_chip("GPIO", 1, + ? ? ? ? ? ? ? ? ? ? ? ? ? ? NR_IRQS_CNS3XXX + gc_info[i].base, + ? ? ? ? ? ? ? ? ? ? ? ? ? ? gc_info[i].reg_base, handle_level_irq); + ? ? ? ? ? ? if (!gc_info[i].gc) { + ? ? ? ? ? ? ? ? ? ? dev_dbg(dev, "%s irq_alloc_generic_chip failed!\n", + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? __func__); + ? ? ? ? ? ? ? ? ? ? err = -ENOMEM; + ? ? ? ? ? ? ? ? ? ? goto err2; + ? ? ? ? ? ? } + ? ? ? ? ? ? gc_info[i].gc->private = &gc_info[i]; + + ? ? ? ? ? ? ct = gc_info[i].gc->chip_types; + ? ? ? ? ? ? ct->regs.mask = get_offset(GPIO_INTR_ENABLE_OFFSET); + ? ? ? ? ? ? ct->regs.ack = get_offset(GPIO_INTR_CLEAR_OFFSET); + ? ? ? ? ? ? ct->regs.type = get_offset(GPIO_INTR_TRIGGER_METHOD_OFFSET); + ? ? ? ? ? ? ct->regs.polarity = get_offset(GPIO_INTR_TRIGGER_POL_OFFSET); + ? ? ? ? ? ? ct->type = IRQ_TYPE_LEVEL_HIGH | IRQ_TYPE_LEVEL_LOW; + ? ? ? ? ? ? ct->chip.irq_ack = irq_gc_ack_set_bit; + ? ? ? ? ? ? ct->chip.irq_mask = irq_gc_mask_clr_bit; + ? ? ? ? ? ? ct->chip.irq_unmask = irq_gc_mask_set_bit; + ? ? ? ? ? ? ct->chip.irq_set_type = cns3xxx_gpio_set_irq_type; + + ? ? ? ? ? ? irq_setup_generic_chip(gc_info[i].gc, IRQ_MSK(gc_info[i].ngpio), + ? ? ? ? ? ? ? ? ? ? IRQ_GC_INIT_MASK_CACHE | IRQ_GC_INIT_NESTED_LOCK, + ? ? ? ? ? ? ? ? ? ? IRQ_NOREQUEST, IRQ_LEVEL | IRQ_NOPROBE); + + ? ? ? ? ? ? irq_set_chained_handler(gc_info[i].irq, gpio_irq_handler); + ? ? ? ? ? ? err = irq_set_handler_data(gc_info[i].irq, &gc_info[i]); + ? ? ? ? ? ? if (err) { + ? ? ? ? ? ? ? ? ? ? dev_dbg(dev, "%s irq_set_handler_data fail!\n", + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? __func__); + ? ? ? ? ? ? ? ? ? ? goto err2; + ? ? ? ? ? ? } +Review
Quoted 10 lines
(quoted diff) +10
-0+ ? ? ? ? ? ? nr_gpios += gc_info[i].ngpio; + ? ? ? ? ? ? if (nr_gpios >= MAX_GPIO_NO) + ? ? ? ? ? ? ? ? ? ? break; + ? ? } + + ? ? return 0; + +err2: + ? ? if (gc_info[1].reg_base) + ? ? ? ? ? ? devm_iounmap(dev, gc_info[0].reg_base);This looks buggy. ?You're unmapping the wrong
reg_base.drivers/gpio/gpio-cns3xxx.c
Quoted 6 lines
drivers/gpio/gpio-cns3xxx.c new file +6
-0+ +err1: + ? ? if (gc_info[0].reg_base) + ? ? ? ? ? ? devm_iounmap(dev, gc_info[0].reg_base); + + ? ? devm_iounmap(dev, misc_reg);This is also rather inconsistent. ?While you iounmap, you're not releasing the region which you claimed in
gpio_map().
Quoted 4 lines
It's also rather unnecessary. ?One of the reasons for devm_* is that drivers shouldn't need to care about cleaning up the managed resources. The driver model will take care of that when a probe fails, or upon remove. ?It avoids people making mistakes like the above.
I got the idea. There is no need to do any devm_iounmap here. So I can just remove these devm_iounmap.
Quoted 2 lines
However, I don't see where you're cleaning up the generic irqchip which was allocated (which is an unmanaged resource).
irq_remove_generic_chip didn't release the memory allocated by irq_alloc_generic_chip,
I should release memory myself.
Signature · 2 lines
Best Regards, Tommy