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: 685506 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4922AC77B73 for ; Mon, 22 May 2023 04:58:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230513AbjEVE6u (ORCPT ); Mon, 22 May 2023 00:58:50 -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 Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org 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;