From patchwork Mon May 22 04:58:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raag Jadav X-Patchwork-Id: 97049 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1228762vqo; Sun, 21 May 2023 22:54:21 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4RcFbJgPAY7MxMcH1qovbUm0OKev/XSjOTEB4Cz1mlG0UtSUZ5XOp3pHr97+msN+L7tBBI X-Received: by 2002:a17:90a:294e:b0:24e:d06:6912 with SMTP id x14-20020a17090a294e00b0024e0d066912mr10711707pjf.18.1684734861452; Sun, 21 May 2023 22:54:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684734861; cv=none; d=google.com; s=arc-20160816; b=p0+4fdaYWZ43VMW+PxTxkQjEautQeG4RqOa7+jKEPPTPMbcgUstHEM5Dj/f5wd2rwG vtMv2+lt+EYSxl71cwBOKuRS6h+ysuLU6eCG2eWLgX9PkIEEx595WbAjSF1hw34ba47z 80suQ7FrX6f99x8WZ8SY02m1YIvK6M6/u7yIYgMixfs6HorWjeM20iQW63WQ2PH9Bsbx 8+q00bnL1stLNveM3f7+41j+eJ3wJgNRjcIsehNtCsfCGg5dTe6cbU71RBpET9SNuB/d ByW2Bwix+k1UJBb/AuNP+hdC7FmAdBiViSIqdHkx43MFvSi2WBKKWZuK34aTXbsibs7i fetg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from :dkim-signature; bh=Td33G2R9t5Afj9t+vFLpnJuk/6a2jIdjefWmaFWKvGc=; b=CE3taMHc+8O/Ew4cP/YN7CgPpCmfodZqgiQLkN3e+NTkyNh0plqDwOGaOa7JtgXP5R P0SWIwrSULhNcFPc/n2V08ObrI8/HWGe5ATaPg1jfF/AVHOELRvsbp5oXLWR1p+fmnYV +wfOQGFEVJKXgu59hfi3Bv8nsw2fcK+tqnuIotH+X92KINUTYFCIaj9MUUTdH+8f45wI BQEqlUueuvPfOgZSEgaFm+rOm9aXbY0BysxcJWk3G7x2+lMu0dxxIbZRxz0S3fYKk5hT de6wyq3eFfyUo+ZF1nZ1tguU8beC6/fROFrC+AoxmygaXyxJBkvPFdw1KdBQTLVQ2EdR LYdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="TayMt/EJ"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id mm14-20020a17090b358e00b00250c48910bdsi4020936pjb.70.2023.05.21.22.54.07; Sun, 21 May 2023 22:54:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="TayMt/EJ"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231642AbjEVE6x (ORCPT + 99 others); Mon, 22 May 2023 00:58:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45970 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229552AbjEVE6t (ORCPT ); Mon, 22 May 2023 00:58:49 -0400 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4FC91C6; Sun, 21 May 2023 21:58:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1684731528; x=1716267528; h=from:to:cc:subject:date:message-id; bh=sDpsTFZfNibw4zeLjj7zpdDqfRmQ7qPkUjJ2IKMHo2Q=; b=TayMt/EJ2Z/O6rmkHi97hA+QN1MCrgEGnhmLxaOyWWFhYjTjRU04yA1/ qEX14uteZjPejABYIf06L1fG5Ij0EzQ/JCaQGZB9bp3VgNV1jq86WKFRD IjyHzTW4XiJMLTebeJnwoe9MLyugpxhmrJVEt+nk+I7EIqKFF7tyzc1lR oPHsxw+vWSBXWVGzUEK3CQ24Qe+pdCuua/aaM8jLmmzLw8pj3ckLAtyo4 8wEy65GQl/1gV9BsCi9+3/jKOPL4Lv5JS4PZe+uq5CuWUJij0hlaeJJ6i Ba/iFEIp2pDPDSLqeB0ftXup6+OsMme99v42P7xH5po+sIXXnjl/HDGC/ Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10717"; a="418535102" X-IronPort-AV: E=Sophos;i="6.00,183,1681196400"; d="scan'208";a="418535102" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 May 2023 21:58:47 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10717"; a="768374525" X-IronPort-AV: E=Sophos;i="6.00,183,1681196400"; d="scan'208";a="768374525" Received: from inesxmail01.iind.intel.com ([10.223.154.20]) by fmsmga008.fm.intel.com with ESMTP; 21 May 2023 21:58:45 -0700 Received: from inlubt0316.iind.intel.com (inlubt0316.iind.intel.com [10.191.20.213]) by inesxmail01.iind.intel.com (Postfix) with ESMTP id DDF5819746; Mon, 22 May 2023 10:28:44 +0530 (IST) Received: by inlubt0316.iind.intel.com (Postfix, from userid 12101951) id D891415B; Mon, 22 May 2023 10:28:44 +0530 (IST) From: Raag Jadav To: linus.walleij@linaro.org, brgl@bgdev.pl, andriy.shevchenko@linux.intel.com Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, mallikarjunappa.sangannavar@intel.com, pandith.n@intel.com, Raag Jadav Subject: [PATCH v1] gpio: tangier: calculate number of ctx using temporary variable Date: Mon, 22 May 2023 10:28:06 +0530 Message-Id: <20230522045806.3442-1-raag.jadav@intel.com> X-Mailer: git-send-email 2.17.1 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766572542199720213?= X-GMAIL-MSGID: =?utf-8?q?1766572542199720213?= Utilize a temporary variable to calculate number of ctx from ngpio inside ->probe() implementation. While at it, include math.h for using DIV_ROUND_UP(). Signed-off-by: Raag Jadav --- drivers/gpio/gpio-tangier.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/gpio/gpio-tangier.c b/drivers/gpio/gpio-tangier.c index e990781935ba..7ce3eddaed25 100644 --- a/drivers/gpio/gpio-tangier.c +++ b/drivers/gpio/gpio-tangier.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -428,10 +429,11 @@ static int tng_gpio_add_pin_ranges(struct gpio_chip *chip) int devm_tng_gpio_probe(struct device *dev, struct tng_gpio *gpio) { const struct tng_gpio_info *info = &gpio->info; + size_t nctx = DIV_ROUND_UP(info->ngpio, 32); struct gpio_irq_chip *girq; int ret; - gpio->ctx = devm_kcalloc(dev, DIV_ROUND_UP(info->ngpio, 32), sizeof(*gpio->ctx), GFP_KERNEL); + gpio->ctx = devm_kcalloc(dev, nctx, sizeof(*gpio->ctx), GFP_KERNEL); if (!gpio->ctx) return -ENOMEM;