staging: mt7621-gpio: change gc_map to don't use pointers
authorSergio Paracuellos <sergio.paracuellos@gmail.com>
Fri, 1 Jun 2018 09:30:55 +0000 (11:30 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 1 Jun 2018 11:16:24 +0000 (13:16 +0200)
There is no special gain in using pointers for 'gc_map' inside
'mtk_data' structure. We know the number of banks which is fixed
to MTK_BANK_CNT and we can just statically allocate them without
using kernel allocators.

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
Reviewed-by: NeilBrown <neil@brown.name>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/mt7621-gpio/gpio-mt7621.c

index 390cc56..3192fc8 100644 (file)
@@ -45,7 +45,7 @@ struct mtk_data {
        void __iomem *gpio_membase;
        int gpio_irq;
        struct irq_domain *gpio_irq_domain;
-       struct mtk_gc *gc_map[MTK_BANK_CNT];
+       struct mtk_gc gc_map[MTK_BANK_CNT];
 };
 
 static inline struct mtk_gc *
@@ -152,11 +152,8 @@ mediatek_gpio_bank_probe(struct platform_device *pdev, struct device_node *bank)
        if (!id || be32_to_cpu(*id) >= MTK_BANK_CNT)
                return -EINVAL;
 
-       rg = devm_kzalloc(&pdev->dev, sizeof(struct mtk_gc), GFP_KERNEL);
-       if (!rg)
-               return -ENOMEM;
-
-       gpio_data->gc_map[be32_to_cpu(*id)] = rg;
+       rg = &gpio_data->gc_map[be32_to_cpu(*id)];
+       memset(rg, 0, sizeof(*rg));
 
        spin_lock_init(&rg->lock);
 
@@ -196,7 +193,7 @@ mediatek_gpio_irq_handler(struct irq_desc *desc)
        int i;
 
        for (i = 0; i < MTK_BANK_CNT; i++) {
-               struct mtk_gc *rg = gpio_data->gc_map[i];
+               struct mtk_gc *rg = &gpio_data->gc_map[i];
                unsigned long pending;
                int bit;
 
@@ -221,7 +218,7 @@ mediatek_gpio_irq_unmask(struct irq_data *d)
        struct mtk_data *gpio_data = irq_data_get_irq_chip_data(d);
        int pin = d->hwirq;
        int bank = pin / MTK_BANK_WIDTH;
-       struct mtk_gc *rg = gpio_data->gc_map[bank];
+       struct mtk_gc *rg = &gpio_data->gc_map[bank];
        unsigned long flags;
        u32 rise, fall;
 
@@ -242,7 +239,7 @@ mediatek_gpio_irq_mask(struct irq_data *d)
        struct mtk_data *gpio_data = irq_data_get_irq_chip_data(d);
        int pin = d->hwirq;
        int bank = pin / MTK_BANK_WIDTH;
-       struct mtk_gc *rg = gpio_data->gc_map[bank];
+       struct mtk_gc *rg = &gpio_data->gc_map[bank];
        unsigned long flags;
        u32 rise, fall;
 
@@ -263,7 +260,7 @@ mediatek_gpio_irq_type(struct irq_data *d, unsigned int type)
        struct mtk_data *gpio_data = irq_data_get_irq_chip_data(d);
        int pin = d->hwirq;
        int bank = pin / MTK_BANK_WIDTH;
-       struct mtk_gc *rg = gpio_data->gc_map[bank];
+       struct mtk_gc *rg = &gpio_data->gc_map[bank];
        u32 mask = PIN_MASK(pin);
 
        if (!rg)