From patchwork Thu Apr 8 15:31:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 12191741 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.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,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 73C09C433ED for ; Thu, 8 Apr 2021 15:32:56 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 06E126113C for ; Thu, 8 Apr 2021 15:32:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 06E126113C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=SpDxK5HwSpp8JWsV1zEHTT4cOFP1g03g6zqiHZKd77w=; b=iqk05WHAPu/XI6zanbMdh3IVW k4IFVGu1BhDglWXoUMwhyk7d1F1BycXXU6nJN6LEvAvJ0xbkkZOkfyBzYwZt2N3+5CrPttwgDEV+3 n4zZwTPrVK8PqosUfCo4gmjSxKWBvrodW2h3yDC8w16euuAkDkuz1CllGDliO37Xwxhp3RnYuQoMj P8X0fWw7nkpQpCDuVS1+8oBL/SyX2Vy0SnPN3CqdXg3lImx1GQnqzqS8easFmcA0v+2+wAlHfaWmy 7EmnoLUo/tlXCZLr9ZHoHkKdEy5YxiTER4mrpxPL1O9cde9VdHTFJryBkY+PZVA34GSXkhfnwlNfS jO+lpaNzQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lUWcm-008Q6T-15; Thu, 08 Apr 2021 15:31:16 +0000 Received: from mga01.intel.com ([192.55.52.88]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lUWch-008Q4J-6t for linux-arm-kernel@lists.infradead.org; Thu, 08 Apr 2021 15:31:13 +0000 IronPort-SDR: eg5kqjOrFyY38j0FZYF5ACprPtgjvRvbyMkQqyFt9N4NM3jw9l5fqp4hjijZUxQZcll7fFBod5 nmrNwbDeMs7A== X-IronPort-AV: E=McAfee;i="6000,8403,9948"; a="213976048" X-IronPort-AV: E=Sophos;i="5.82,206,1613462400"; d="scan'208";a="213976048" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Apr 2021 08:31:00 -0700 IronPort-SDR: AMoFeEDi9BjzfvhdZSHH6j8m5Z0sEJmZNKIeFJjDniEURWfLQ0S3WyI+m2gfml+P5TqU9xGpeO 33A7tocTJeug== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.82,206,1613462400"; d="scan'208";a="422295421" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga008.jf.intel.com with ESMTP; 08 Apr 2021 08:30:56 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id ABBCFFC; Thu, 8 Apr 2021 18:31:12 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , linux-gpio@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Shubhrajyoti Datta , Srinivas Neeli , Michal Simek , Linus Walleij , Bartosz Golaszewski , Syed Nayyar Waris , vilhelm.gray@gmail.com Subject: [PATCH 1/1] drivers/gpio/gpio-xilinx.c (updated): bitmap-fix Date: Thu, 8 Apr 2021 18:31:08 +0300 Message-Id: <20210408153108.81738-1-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210408_163112_237636_56DC1A6F X-CRM114-Status: GOOD ( 11.06 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Signed-off-by: Andy Shevchenko --- drivers/gpio/gpio-xilinx.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/drivers/gpio/gpio-xilinx.c b/drivers/gpio/gpio-xilinx.c index d5a08dcdd677..109b32104867 100644 --- a/drivers/gpio/gpio-xilinx.c +++ b/drivers/gpio/gpio-xilinx.c @@ -75,9 +75,14 @@ struct xgpio_instance { struct clk *clk; }; +static inline int xgpio_from_bit(struct xgpio_instance *chip, int bit) +{ + return bitmap_bitremap(bit, chip->hw_map, chip->sw_map, 64); +} + static inline int xgpio_to_bit(struct xgpio_instance *chip, int gpio) { - return bitmap_bitremap(gpio, chip->sw_map, chip->hw_map, chip->gc.ngpio); + return bitmap_bitremap(gpio, chip->sw_map, chip->hw_map, 64); } static inline u32 xgpio_get_value32(const unsigned long *map, int bit) @@ -207,11 +212,11 @@ static void xgpio_set_multiple(struct gpio_chip *gc, unsigned long *mask, spin_lock_irqsave(&chip->gpio_lock, flags); - bitmap_replace(state, chip->state, hw_bits, hw_mask, gc->ngpio); + bitmap_replace(state, chip->state, hw_bits, hw_mask, 64); xgpio_write_ch_all(chip, XGPIO_DATA_OFFSET, state); - bitmap_copy(chip->state, state, gc->ngpio); + bitmap_copy(chip->state, state, 64); spin_unlock_irqrestore(&chip->gpio_lock, flags); } @@ -501,6 +506,7 @@ static void xgpio_irqhandler(struct irq_desc *desc) DECLARE_BITMAP(rising, 64); DECLARE_BITMAP(falling, 64); DECLARE_BITMAP(all, 64); + int irq_offset; u32 status; u32 bit; @@ -530,8 +536,10 @@ static void xgpio_irqhandler(struct irq_desc *desc) dev_dbg(gc->parent, "IRQ rising %*pb falling %*pb\n", 64, rising, 64, falling); - for_each_set_bit(bit, all, 64) - generic_handle_irq(irq_find_mapping(gc->irq.domain, bit)); + for_each_set_bit(bit, all, 64) { + irq_offset = xgpio_from_bit(chip, bit); + generic_handle_irq(irq_find_mapping(gc->irq.domain, irq_offset)); + } chained_irq_exit(irqchip, desc); }