Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp804089imm; Tue, 15 May 2018 09:23:41 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoTOZnF0QWF9RuG0Z/Ftm/3ZyeOiqD2gOfpStVD5Cf7nkCHnz2h69jyHAyEVB53Cu8q62yY X-Received: by 2002:a62:c103:: with SMTP id i3-v6mr15798230pfg.148.1526401421819; Tue, 15 May 2018 09:23:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526401421; cv=none; d=google.com; s=arc-20160816; b=xeXT8gWdxP7+CgV/DyBGqbVu+qITIzKM1HbERQg1ShGBl9R7Se6TBE0tcIN3vMxha2 D/GcqTiaPma7GUYR6nTP8laPsDGjXcN2JB15uGNKQ8t2pPRzbrxbx8oNGP8DjfHkhVYN lWsqmRyaubB5utO4YS0qtLbBsXIUWtNZjcFL9tl8pPArocvPLuIDYnUviXiq7a1lkft1 qjYXEwCS2F+6x3I7nJSpLDvbRubUFmU8xj8XBZh9M4z6cL5MRJvP81L8S7fuKnIF0Dkh 9qul075Yvew2K27V8Cvxc1bFjNCOW4cqC0O+KrRJ8AR02FGKUNWo78GLUcI/0N4F4Q+L A5Nw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=kmr8409u/SN83iMwhd6yn9R2Dod/QiCS/GDYE56T4fI=; b=hAMi4JgBm9VJVgkQ/vZunvRPHl52swvh6FPPHs8ObrvJaJoS/yij9YB+PyFyKv75TY HtI4nyTFvHdcliJ8nXWrNVbF5iTt+a8e1d15uzYnxQYFu6UI0n07qhoaqJ60IRl5J7Hq TZShhGzXrDmep8716ECiZ5iMHclDsk2naPOycaCMe+jB+Bnbh3AVmfCHPY+jpoD/Z95S Sqh9mqYsdzopxPgjcLoPESv+gIJFIhQj65canAP0TFdTk7Fkd0I0r5mmkdTbPRJBSEj7 JOEGsJrznRfWDHJJavvlAD4TJFMguiCBhrkJv7Q/pfWuFHdUGG8KQt8ZsDTA3vjJyVxK GMBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=cvNGmoCA; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g11-v6si385860pfk.187.2018.05.15.09.23.08; Tue, 15 May 2018 09:23:41 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=cvNGmoCA; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753095AbeEOQWZ (ORCPT + 99 others); Tue, 15 May 2018 12:22:25 -0400 Received: from mail-yw0-f195.google.com ([209.85.161.195]:36843 "EHLO mail-yw0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751847AbeEOQWX (ORCPT ); Tue, 15 May 2018 12:22:23 -0400 Received: by mail-yw0-f195.google.com with SMTP id l15-v6so242003ywk.3; Tue, 15 May 2018 09:22:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=kmr8409u/SN83iMwhd6yn9R2Dod/QiCS/GDYE56T4fI=; b=cvNGmoCAUsNEUpuOPcsC3hgfrMhN13PbOZu0GQQMvCUuJfwEJk2HkgNdFBqel/iTz8 5C7UDoNSEhstIzMbhRWbGZF6ORnQxDZMMnCJLFqffES8cq5h2FEAwi8AcWFA2Hw17/BJ Z0PIEK7uftcp3vQdVsXWca04cZnkZTBOE4lUiE5Mj4t6ANnsWRYR6Ptv/4pKgBVkreM+ COBzUU0e5kGhK2OFwENOBgjWkEM3Jju8oo00qVYaAsYxRjajbPhmhHwZK6MzyGZqfpKy JO6PwAm07B/joBlAoYKAhl+jcxXjhwy3FAhqaoAuqixcFPzgb8hmJtRZMSCyWxG5xbJ2 7uEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=kmr8409u/SN83iMwhd6yn9R2Dod/QiCS/GDYE56T4fI=; b=ZfMf1Nj5y/4+KpCiezXTMiccyicv7Z1AV708Y9FQ5GSUCzZSBs6fTt2e4D6mfL/iIt y1b7bHqkdvmSfD3B4iC+bKiJ1QoGx4pCXTmr2GJ+C++Y8+hFmuCLzk14IKJSkbSyjzAL tll/WYnmkFclfq88clTMG/PXAvX7Vf32BvmTJQfO40K9qAUmJYimzgtWFFoxvEt6K2pa +mV4nU8cezVlXVkNX6lpbyfK8JgcKzkIsFstxwpiyAly1mVuL31Z4eThsMi6qcZ2UeIQ rewx+MEuFH7dg0PYhYQLS6BOuifTyvC0dT1t6A+xrQebJ7OiHcBbvyYMpsdfDMCgTMLT q6fA== X-Gm-Message-State: ALKqPwdjOaKbp43MuxuRnoVpN+RwKKqoB7zs+PVWlKF6PO7fV4D415aW o8uJeGy2NrfqkAmm8qrCK44= X-Received: by 2002:a81:ac0d:: with SMTP id k13-v6mr6944668ywh.106.1526401343034; Tue, 15 May 2018 09:22:23 -0700 (PDT) Received: from localhost ([72.188.97.40]) by smtp.gmail.com with ESMTPSA id s20-v6sm155278ywg.83.2018.05.15.09.22.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 15 May 2018 09:22:22 -0700 (PDT) From: William Breathitt Gray To: linus.walleij@linaro.org Cc: linux-gpio@vger.kernel.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, William Breathitt Gray Subject: [PATCH v4 0/8] Introduce the for_each_set_clump macro Date: Tue, 15 May 2018 12:22:13 -0400 Message-Id: X-Mailer: git-send-email 2.17.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Changes in v4: - Fix bitmap_set arguments (last parameter is nbits not endbit) While adding GPIO get_multiple/set_multiple callback support for various drivers, I noticed a pattern of looping manifesting that would be useful standardized as a macro. This patchset introduces the for_each_set_clump macro and utilizes it in several GPIO drivers. The for_each_set_clump macro facilitates a for-loop syntax that iterates over entire groups of set bits at a time. For example, suppose you would like to iterate over a 16-bit integer 4 bits at a time, skipping over 4-bit groups with no set bit, where XXXX represents the current 4-bit group: Example: 1011 1110 0000 1111 First loop: 1011 1110 0000 XXXX Second loop: 1011 XXXX 0000 1111 Third loop: XXXX 1110 0000 1111 Each iteration of the loop returns the next 4-bit group that has at least one set bit. The for_each_set_clump macro has six parameters: * clump: set to current clump index for the iteration * index: set to current bitmap word index for the iteration * offset: bits offset of the found clump in the bitmap word * bits: bitmap to search within * size: bitmap size in number of clumps * clump_size: clump size in number of bits The clump_size argument can be an arbitrary number of bits and is not required to be a multiple of 2. This patchset was rebased on top of the following three commits: * commit aaf96e51de11 ("gpio: pci-idio-16: Fix port memory offset for get_multiple callback") * commit 304440aa96c6 ("gpio: pcie-idio-24: Fix port memory offset for get_multiple/set_multiple callbacks") * commit e026646c178d ("gpio: pcie-idio-24: Fix off-by-one error in get_multiple loop") When I implemented the test_for_each_set_clump function, I used bitmap_set to set the expected bitmap for the test. This method of setting bits only segments at a time was rather tedious and error-prone; is there a better way to accomplish what I did (set a bitmap after a DECLARE_BITMAP)? William Breathitt Gray William Breathitt Gray (8): bitops: Introduce the for_each_set_clump macro lib/test_bitmap.c: Add for_each_set_clump test cases gpio: 104-dio-48e: Utilize for_each_set_clump macro gpio: 104-idi-48: Utilize for_each_set_clump macro gpio: gpio-mm: Utilize for_each_set_clump macro gpio: ws16c48: Utilize for_each_set_clump macro gpio: pci-idio-16: Utilize for_each_set_clump macro gpio: pcie-idio-24: Utilize for_each_set_clump macro drivers/gpio/gpio-104-dio-48e.c | 67 +++++--------------- drivers/gpio/gpio-104-idi-48.c | 32 ++-------- drivers/gpio/gpio-gpio-mm.c | 67 +++++--------------- drivers/gpio/gpio-pci-idio-16.c | 67 ++++++-------------- drivers/gpio/gpio-pcie-idio-24.c | 102 +++++++++++------------------- drivers/gpio/gpio-ws16c48.c | 66 +++++-------------- include/asm-generic/bitops/find.h | 9 +++ include/linux/bitops.h | 7 ++ lib/find_bit.c | 40 ++++++++++++ lib/test_bitmap.c | 71 +++++++++++++++++++++ 10 files changed, 236 insertions(+), 292 deletions(-) -- 2.17.0