From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by ash.osuosl.org (Postfix) with ESMTP id 356E41C11AD for ; Fri, 1 Jun 2018 09:31:05 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 3339189C96 for ; Fri, 1 Jun 2018 09:31:05 +0000 (UTC) Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id qP4w+bVlzVUQ for ; Fri, 1 Jun 2018 09:31:04 +0000 (UTC) Received: from mail-wr0-f196.google.com (mail-wr0-f196.google.com [209.85.128.196]) by hemlock.osuosl.org (Postfix) with ESMTPS id 661E989C91 for ; Fri, 1 Jun 2018 09:31:04 +0000 (UTC) Received: by mail-wr0-f196.google.com with SMTP id w10-v6so35665189wrk.9 for ; Fri, 01 Jun 2018 02:31:04 -0700 (PDT) From: Sergio Paracuellos Subject: [RESEND PATCH 5/6] staging: mt7621-gpio: change gc_map to don't use pointers Date: Fri, 1 Jun 2018 11:30:55 +0200 Message-Id: <1527845456-1221-5-git-send-email-sergio.paracuellos@gmail.com> In-Reply-To: <1527845456-1221-1-git-send-email-sergio.paracuellos@gmail.com> References: <20180601091807.GA9257@kroah.com> <1527845456-1221-1-git-send-email-sergio.paracuellos@gmail.com> List-Id: Linux Driver Project Developer List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: driverdev-devel-bounces@linuxdriverproject.org Sender: "devel" To: gregkh@linuxfoundation.org Cc: neil@brown.name, driverdev-devel@linuxdriverproject.org 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 Reviewed-by: NeilBrown --- drivers/staging/mt7621-gpio/gpio-mt7621.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/drivers/staging/mt7621-gpio/gpio-mt7621.c b/drivers/staging/mt7621-gpio/gpio-mt7621.c index 390cc56..3192fc8 100644 --- a/drivers/staging/mt7621-gpio/gpio-mt7621.c +++ b/drivers/staging/mt7621-gpio/gpio-mt7621.c @@ -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) -- 2.7.4 _______________________________________________ devel mailing list devel@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel