Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp1706731rdh; Tue, 26 Sep 2023 00:30:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHVrQyy87j0OSu6AqaSehoAu3tAPU4FHw9S1+QuyVyWYr4hoGtMSoj8FLacohm5C1EkGFLB X-Received: by 2002:a17:90b:3b48:b0:262:d661:2963 with SMTP id ot8-20020a17090b3b4800b00262d6612963mr6151588pjb.39.1695713437760; Tue, 26 Sep 2023 00:30:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695713437; cv=none; d=google.com; s=arc-20160816; b=EAdgiKx5wA9Mw6mQ6MbTF95wIGh2mRdUDy+A90/LpND1/B5RKirJTdQg8NySrHZqkV cyKpi0A2GSvnRXpe4PiukMjabTzyAyRxhOxE1dw1srySb6q9ThrAwWyWgNgV9OF504YR tWOe3VcHJz7/JsWoLXy04OMerbM+WwfEcY+Yrlp8oDsX2FNsq6bFqsuzEIEWANK6vCvE HaqXgoXolFL+FXziSp6obXeK5+QnkyV0abCuuD3DtJx5X3ZPPhK1XVjsjyh6Fvoqojni /U+llDZwEy0L0EukynJOro9BwaQZO293yX6XV0Uwpoeo6DsnXkMMdHacn2e4DtNlG77E a8ng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=pBJX8Sz54k15/RBkZi9RYeKLTRV90CVvnRpvGJ+6Ev8=; fh=vW1oNT0lvWbI8AMX2u/BZGKXD0nTZmrv2xM94BgUfog=; b=eRnkuiafTsGpCfecgVnsDU//rANfLX4phJdL+hm3g/nQYFhv5c/2t+R52GEMp1bL14 OFxYMDB46jA3j3FW4IOB06Iza1w9jvOljHcV1DV7U1YlYIbIw+t1iNf8L4UinTsJ7uZA D+QEfUDiUIMIsdo/GbaicwczmsY0WW0YrWZJ870OoX94VmR0Qtlnvmt2pH41raCZL98g SEODO3tONyFSIbnVRJ9bLIoWG15tVflWqNtHcUA2P+nR+OP2SKeT9q10o2pbsxLC7nbV AmI+61FBQPPyEJ6/uB2TZy44KZ98IKGxnidzLI0RZDdWPqtphK6za/YbkSZatX7c1YkQ od1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=GfCkes34; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id mi4-20020a17090b4b4400b00276c2b21697si15865167pjb.72.2023.09.26.00.30.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Sep 2023 00:30:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=GfCkes34; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id EF2E28057E3C; Mon, 25 Sep 2023 22:20:47 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233170AbjIZFUn (ORCPT + 99 others); Tue, 26 Sep 2023 01:20:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46246 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231628AbjIZFUc (ORCPT ); Tue, 26 Sep 2023 01:20:32 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 79821120; Mon, 25 Sep 2023 22:20:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1695705625; x=1727241625; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=nbE19XBFoeQsTwGAJN998UHeoS6jXenyajr7Dybr/A4=; b=GfCkes340mSo6zWeejPwvvdkXhS6tIoMiLioOMVARO0N/t8mrnrXjsMU FWjg7u22teNHMSQDsQJOw4OGilZbUc8IIZM1LtFwo/sAujghyjfPOoN5F NADAiiRjfC9cf+WLYBFQ3h1hEyQ3O0kkW9lI8gL4ZBLj8ShR3BN9H+L+d eJwlfy/a3Hi71+OOaHPAfEL7rGEeFADSAIWO9dY5NKiy97ZySk//BFRAm BtN0UcN2a1tTdi3YDflLBLyh9qDjTGFYwgrcqzsa6MV4cmveIG0/3vmwU GcnXs4rJoO0PhsJydM7J8xsSM8Yf66jAXVmjcGPMUmdG8I+f36BpR9f7f Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10843"; a="371820585" X-IronPort-AV: E=Sophos;i="6.03,177,1694761200"; d="scan'208";a="371820585" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Sep 2023 22:20:24 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10843"; a="783824217" X-IronPort-AV: E=Sophos;i="6.03,177,1694761200"; d="scan'208";a="783824217" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga001.jf.intel.com with ESMTP; 25 Sep 2023 22:20:20 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 06CAD919; Tue, 26 Sep 2023 08:20:19 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , Linus Walleij , Bartosz Golaszewski , Yury Norov , linux-gpio@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Shubhrajyoti Datta , Srinivas Neeli , Michal Simek , Bartosz Golaszewski , Andy Shevchenko , Rasmus Villemoes , =?UTF-8?q?Marek=20Beh=C3=BAn?= Subject: [PATCH v1 4/5] gpio: xilinx: Replace bitmap_bitremap() calls Date: Tue, 26 Sep 2023 08:20:06 +0300 Message-Id: <20230926052007.3917389-5-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b In-Reply-To: <20230926052007.3917389-1-andriy.shevchenko@linux.intel.com> References: <20230926052007.3917389-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE 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-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 25 Sep 2023 22:20:48 -0700 (PDT) We have sparse and dence masks of the line mappings based on the view point (Linux numbering or hardware numbering). Since the Linux side uses sequential bits for the mask, we can simply convert a Linux number to the hardware one and vise versa by counting set bits in the respective mask. Hence replace bitmap_bitremap() calls by simpler equivalents. With this done the dence mask is not needed and thus dropped. Signed-off-by: Andy Shevchenko --- drivers/gpio/gpio-xilinx.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/drivers/gpio/gpio-xilinx.c b/drivers/gpio/gpio-xilinx.c index f103c30cc74f..14ca3097563a 100644 --- a/drivers/gpio/gpio-xilinx.c +++ b/drivers/gpio/gpio-xilinx.c @@ -46,7 +46,6 @@ * @gc: GPIO chip * @regs: register block * @hw_map: GPIO pin mapping on hardware side - * @sw_map: GPIO pin mapping on software side * @state: GPIO write state shadow register * @last_irq_read: GPIO read state register from last interrupt * @dir: GPIO direction shadow register @@ -62,7 +61,6 @@ struct xgpio_instance { struct gpio_chip gc; void __iomem *regs; DECLARE_BITMAP(hw_map, 64); - DECLARE_BITMAP(sw_map, 64); DECLARE_BITMAP(state, 64); DECLARE_BITMAP(last_irq_read, 64); DECLARE_BITMAP(dir, 64); @@ -76,12 +74,12 @@ struct xgpio_instance { static inline int xgpio_from_bit(struct xgpio_instance *chip, int bit) { - return bitmap_bitremap(bit, chip->hw_map, chip->sw_map, 64); + return bitmap_weight(chip->hw_map, bit + 1); } static inline int xgpio_to_bit(struct xgpio_instance *chip, int gpio) { - return bitmap_bitremap(gpio, chip->sw_map, chip->hw_map, 64); + return find_nth_bit(chip->hw_map, 64, gpio); } static inline u32 xgpio_get_value32(const unsigned long *map, int bit) @@ -619,9 +617,6 @@ static int xgpio_probe(struct platform_device *pdev) if (width[1] > 32) return -EINVAL; - /* Setup software pin mapping */ - bitmap_set(chip->sw_map, 0, width[0] + width[1]); - /* Setup hardware pin mapping */ bitmap_set(chip->hw_map, 0, width[0]); bitmap_set(chip->hw_map, 32, width[1]); -- 2.40.0.1.gaa8946217a0b