From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D943DC43332 for ; Tue, 9 Feb 2021 13:32:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B4B7164ED3 for ; Tue, 9 Feb 2021 13:32:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231452AbhBINcL (ORCPT ); Tue, 9 Feb 2021 08:32:11 -0500 Received: from forward104o.mail.yandex.net ([37.140.190.179]:38428 "EHLO forward104o.mail.yandex.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231327AbhBINcJ (ORCPT ); Tue, 9 Feb 2021 08:32:09 -0500 Received: from iva4-66d7931d4d60.qloud-c.yandex.net (iva4-66d7931d4d60.qloud-c.yandex.net [IPv6:2a02:6b8:c0c:78a3:0:640:66d7:931d]) by forward104o.mail.yandex.net (Yandex) with ESMTP id B987F940876; Tue, 9 Feb 2021 16:31:24 +0300 (MSK) Received: from iva1-bc1861525829.qloud-c.yandex.net (iva1-bc1861525829.qloud-c.yandex.net [2a02:6b8:c0c:a0e:0:640:bc18:6152]) by iva4-66d7931d4d60.qloud-c.yandex.net (mxback/Yandex) with ESMTP id tQU3zPfplQ-VOIaxjde; Tue, 09 Feb 2021 16:31:24 +0300 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=maquefel.me; s=mail; t=1612877484; bh=aJvzXXLz8Fe5HdokcQEWZcrpg+/kk5XCdinRvVVSvP4=; h=In-Reply-To:References:Date:Subject:To:From:Message-Id:Cc; b=thjhnJg1IOd+MXkVZ5VQNHZZWD57de2StTVnntOMKdMyDWbrB1V2DakCJs1zs5xTk yHJvldOB4EMB70QK3I1+JE7585iUvNbgAnDXl0xxkJCecOOQyT/nC3F2/uhMSrz9Ri KLDysrLBbSWSw/OhsItKwAaU2LHnlj0BfMMtbrXI= Authentication-Results: iva4-66d7931d4d60.qloud-c.yandex.net; dkim=pass header.i=@maquefel.me Received: by iva1-bc1861525829.qloud-c.yandex.net (smtp/Yandex) with ESMTPSA id aJNFhJtpP6-VNoaSKwt; Tue, 09 Feb 2021 16:31:24 +0300 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (Client certificate not present) From: Nikita Shubin Cc: Andy Shevchenko , Nikita Shubin , Linus Walleij , Alexander Sverdlin , Bartosz Golaszewski , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 6/7] gpio: ep93xx: refactor ep93xx_gpio_add_bank Date: Tue, 9 Feb 2021 16:31:09 +0300 Message-Id: <20210209133110.7383-7-nikita.shubin@maquefel.me> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210209133110.7383-1-nikita.shubin@maquefel.me> References: <20210209133110.7383-1-nikita.shubin@maquefel.me> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org - replace plain numbers with girq->num_parents in devm_kcalloc - replace plain numbers with girq->num_parents for port F - refactor i - 1 to i + 1 to make loop more readable - combine getting IRQ's loop and setting handler's into single loop Reviewed-by: Linus Walleij Acked-by: Alexander Sverdlin Signed-off-by: Nikita Shubin --- drivers/gpio/gpio-ep93xx.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/gpio/gpio-ep93xx.c b/drivers/gpio/gpio-ep93xx.c index 9760df7d1172..56ddf6b9baba 100644 --- a/drivers/gpio/gpio-ep93xx.c +++ b/drivers/gpio/gpio-ep93xx.c @@ -370,7 +370,7 @@ static int ep93xx_gpio_add_bank(struct ep93xx_gpio_chip *egc, girq->parent_handler = ep93xx_gpio_ab_irq_handler; girq->num_parents = 1; - girq->parents = devm_kcalloc(dev, 1, + girq->parents = devm_kcalloc(dev, girq->num_parents, sizeof(*girq->parents), GFP_KERNEL); if (!girq->parents) @@ -392,15 +392,14 @@ static int ep93xx_gpio_add_bank(struct ep93xx_gpio_chip *egc, */ girq->parent_handler = ep93xx_gpio_f_irq_handler; girq->num_parents = 8; - girq->parents = devm_kcalloc(dev, 8, + girq->parents = devm_kcalloc(dev, girq->num_parents, sizeof(*girq->parents), GFP_KERNEL); if (!girq->parents) return -ENOMEM; /* Pick resources 1..8 for these IRQs */ - for (i = 1; i <= 8; i++) - girq->parents[i - 1] = platform_get_irq(pdev, i); - for (i = 0; i < 8; i++) { + for (i = 0; i < girq->num_parents; i++) { + girq->parents[i] = platform_get_irq(pdev, i + 1); gpio_irq = EP93XX_GPIO_F_IRQ_BASE + i; irq_set_chip_data(gpio_irq, &epg->gc[5]); irq_set_chip_and_handler(gpio_irq, -- 2.26.2