aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSergio Paracuellos <sergio.paracuellos@gmail.com>2018-06-01 05:30:55 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-06-01 07:16:24 -0400
commit53364c7ba4b25d6e3f428605254c50d5dfaaa430 (patch)
tree5528ac3f88246b9eb000a39d7539fe016938e059
parent1e2735fe1b49cfa5dd668f61778aaaa46c6fe1c8 (diff)
staging: mt7621-gpio: change gc_map to don't use pointers
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>
-rw-r--r--drivers/staging/mt7621-gpio/gpio-mt7621.c17
1 files changed, 7 insertions, 10 deletions
diff --git a/drivers/staging/mt7621-gpio/gpio-mt7621.c b/drivers/staging/mt7621-gpio/gpio-mt7621.c
index 390cc56b3ac4..3192fc8616b6 100644
--- a/drivers/staging/mt7621-gpio/gpio-mt7621.c
+++ b/drivers/staging/mt7621-gpio/gpio-mt7621.c
@@ -45,7 +45,7 @@ struct mtk_data {
45 void __iomem *gpio_membase; 45 void __iomem *gpio_membase;
46 int gpio_irq; 46 int gpio_irq;
47 struct irq_domain *gpio_irq_domain; 47 struct irq_domain *gpio_irq_domain;
48 struct mtk_gc *gc_map[MTK_BANK_CNT]; 48 struct mtk_gc gc_map[MTK_BANK_CNT];
49}; 49};
50 50
51static inline struct mtk_gc * 51static inline struct mtk_gc *
@@ -152,11 +152,8 @@ mediatek_gpio_bank_probe(struct platform_device *pdev, struct device_node *bank)
152 if (!id || be32_to_cpu(*id) >= MTK_BANK_CNT) 152 if (!id || be32_to_cpu(*id) >= MTK_BANK_CNT)
153 return -EINVAL; 153 return -EINVAL;
154 154
155 rg = devm_kzalloc(&pdev->dev, sizeof(struct mtk_gc), GFP_KERNEL); 155 rg = &gpio_data->gc_map[be32_to_cpu(*id)];
156 if (!rg) 156 memset(rg, 0, sizeof(*rg));
157 return -ENOMEM;
158
159 gpio_data->gc_map[be32_to_cpu(*id)] = rg;
160 157
161 spin_lock_init(&rg->lock); 158 spin_lock_init(&rg->lock);
162 159
@@ -196,7 +193,7 @@ mediatek_gpio_irq_handler(struct irq_desc *desc)
196 int i; 193 int i;
197 194
198 for (i = 0; i < MTK_BANK_CNT; i++) { 195 for (i = 0; i < MTK_BANK_CNT; i++) {
199 struct mtk_gc *rg = gpio_data->gc_map[i]; 196 struct mtk_gc *rg = &gpio_data->gc_map[i];
200 unsigned long pending; 197 unsigned long pending;
201 int bit; 198 int bit;
202 199
@@ -221,7 +218,7 @@ mediatek_gpio_irq_unmask(struct irq_data *d)
221 struct mtk_data *gpio_data = irq_data_get_irq_chip_data(d); 218 struct mtk_data *gpio_data = irq_data_get_irq_chip_data(d);
222 int pin = d->hwirq; 219 int pin = d->hwirq;
223 int bank = pin / MTK_BANK_WIDTH; 220 int bank = pin / MTK_BANK_WIDTH;
224 struct mtk_gc *rg = gpio_data->gc_map[bank]; 221 struct mtk_gc *rg = &gpio_data->gc_map[bank];
225 unsigned long flags; 222 unsigned long flags;
226 u32 rise, fall; 223 u32 rise, fall;
227 224
@@ -242,7 +239,7 @@ mediatek_gpio_irq_mask(struct irq_data *d)
242 struct mtk_data *gpio_data = irq_data_get_irq_chip_data(d); 239 struct mtk_data *gpio_data = irq_data_get_irq_chip_data(d);
243 int pin = d->hwirq; 240 int pin = d->hwirq;
244 int bank = pin / MTK_BANK_WIDTH; 241 int bank = pin / MTK_BANK_WIDTH;
245 struct mtk_gc *rg = gpio_data->gc_map[bank]; 242 struct mtk_gc *rg = &gpio_data->gc_map[bank];
246 unsigned long flags; 243 unsigned long flags;
247 u32 rise, fall; 244 u32 rise, fall;
248 245
@@ -263,7 +260,7 @@ mediatek_gpio_irq_type(struct irq_data *d, unsigned int type)
263 struct mtk_data *gpio_data = irq_data_get_irq_chip_data(d); 260 struct mtk_data *gpio_data = irq_data_get_irq_chip_data(d);
264 int pin = d->hwirq; 261 int pin = d->hwirq;
265 int bank = pin / MTK_BANK_WIDTH; 262 int bank = pin / MTK_BANK_WIDTH;
266 struct mtk_gc *rg = gpio_data->gc_map[bank]; 263 struct mtk_gc *rg = &gpio_data->gc_map[bank];
267 u32 mask = PIN_MASK(pin); 264 u32 mask = PIN_MASK(pin);
268 265
269 if (!rg) 266 if (!rg)