From patchwork Tue Sep 26 05:20:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 144724 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp1684921vqu; Mon, 25 Sep 2023 22:30:04 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGYkw8x2YP3vBpX00sOcbqStsKLzPb6HndMqSEEwf02KKpRcdTQ7go/2HWRBHNVIApVYzWF X-Received: by 2002:a05:6a20:9151:b0:15e:b8a1:57b0 with SMTP id x17-20020a056a20915100b0015eb8a157b0mr4550904pzc.39.1695706204267; Mon, 25 Sep 2023 22:30:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695706204; cv=none; d=google.com; s=arc-20160816; b=EafoApdsgcJNwrUB1FoI01C0/dzeJO+8QA1PoKX+A0indUhD1vakb6rT9zdNGDWvps ZZp028PFMmoGqgzgXY5wqcbLrl0nZt2BMUIoQlh+sN88R8XA8EdTsFZ7UA7+LnnqVLl4 eKQDnX9d0NxLgwYK5m7FV4Yo3hMJ6ukt9y8Y5VLSSah6iWpuA7Q6dVqFXQZz7OgWdNrN QVRrOZ+sdYcZnHmO9RDH7bjhZI4FP6NwkpAAj8rxFi0ah9LkSZLDqfg16mmqRfLPoLdN wkSeUTZ1ZVOCbVKUPOHppxyJlZsuDneWtVwQDo5Q0tMV5wClhG6bOZezdSxmFXORJx8m ETmw== 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 2620:137:e000::3:7 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 snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id e8-20020a170902cf4800b001bde9e8a29fsi10639063plg.183.2023.09.25.22.30.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Sep 2023 22:30:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; 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 2620:137:e000::3:7 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 18F7E80A1858; Mon, 25 Sep 2023 22:20:46 -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 S233361AbjIZFUo (ORCPT + 26 others); Tue, 26 Sep 2023 01:20:44 -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_Beh=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 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:46 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778076829115310314 X-GMAIL-MSGID: 1778076829115310314 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]);