Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp732059imm; Mon, 1 Oct 2018 18:14:06 -0700 (PDT) X-Google-Smtp-Source: ACcGV61I7vmnMi/p3kH+F4VgTh1GjCAxTl9s4b7+ljC1n7LTs32bR/9eh5WJMmJQytAXeYr3Fy3Q X-Received: by 2002:a62:9586:: with SMTP id c6-v6mr13963103pfk.234.1538442846199; Mon, 01 Oct 2018 18:14:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538442846; cv=none; d=google.com; s=arc-20160816; b=KcwcaBsBWE2BRc+8aBFY+l2PUhFKnSXVnFcEMZB0yjyNvdfa2Z/QOwtDmVEK6yJMAC 3d+QIp1ZFgWuYx1KWB5aVuqkfVUlg3VekVWITJ8MCIJtpfHQIJak6uHAEQBgwWWCYZSA LbyPbEKYjFgg9JMcEYSe0lhMKf7N3M1tuJMNACJ03FitDNbS4DtOJHOIbzSLQ1JPZ/jM 8llH4NqGS3k6qkNez4wh5BNumou2nC4q0uKpsouy02FvczwMtKlE3GLRIeUEQh+/ZnKd cWFSHKzwbKAv2kjk+nTNPiDZJIJ0Q8T1+YzzgMKiEMqNSgD8KKqqOLxyA2pjoQDjzsUE Tcyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=kxoVlUB0gxo40vXl38z0GrK1GeDonW7N5dpqkna0AGU=; b=ssNBIKZYt2ew4A9NJjvbpCSnJGmK7k8Vr83Dvf6e4BoqOKywPSRx6P2JDGYtbT0ZL3 Gw/o3ugWZnhpTQOMWCcWORNXItYjPQkUHMFjZb0pxWIrDcBAbVoi7WSsyyJPR94B4g9+ CT/JHFQ4YsQqWy2ZGqKXIUEat3JNwc2zSFciIupFKYO1tFt8dtsGBy3z7sZas7tSpjWt dpgaUVU7FHfvc7N5lJBxMthWtIvdO4FoNkWCoyoHDjcLlTtAL6Gv2T6FaS4UQNIZqIz6 vu1k1PLMnZTJUNIMMh9qKq9unbP8hew3vF0WVg1FTN9n6E6KEWH09xROSv6oidDztgzU YbPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="Z06/SIKK"; 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 8-v6si13437928pgu.519.2018.10.01.18.13.51; Mon, 01 Oct 2018 18:14:06 -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="Z06/SIKK"; 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 S1726958AbeJBHxs (ORCPT + 99 others); Tue, 2 Oct 2018 03:53:48 -0400 Received: from mail-io1-f68.google.com ([209.85.166.68]:35479 "EHLO mail-io1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726027AbeJBHxs (ORCPT ); Tue, 2 Oct 2018 03:53:48 -0400 Received: by mail-io1-f68.google.com with SMTP id w11-v6so324822iob.2; Mon, 01 Oct 2018 18:13:14 -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:mime-version :content-transfer-encoding; bh=kxoVlUB0gxo40vXl38z0GrK1GeDonW7N5dpqkna0AGU=; b=Z06/SIKK9Yudnda3tee2EpNyqRfT+9aIfNdbj+IBRYcY2A64ukWRQwpq2zSITifwU+ QGdEQVVn1T9Q6wSr5EMc19vWxWdNlgccz8/xhg7nyeyznZ75CWpbTChdfUpXLhKiTVRw TqJGQlT1eV5x4g9I/qyoXwlj3fixzPA678qTl1SXzZI7dWhrcuICbqbmkYTJB2YbXm87 6oNJWiVrQaWBSZyu0Gm64bQo0D6oYotyCmMQWUZN1jexDqfPIAm/s82UnudY7tXteyH0 12DQsF7jOye37JIC679AZHw+V0gb4P/TMh8r4cEM2wwH05siSIisXfknKdSw4AWu07gk fqjQ== 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:mime-version :content-transfer-encoding; bh=kxoVlUB0gxo40vXl38z0GrK1GeDonW7N5dpqkna0AGU=; b=FCUMb7rFSVF+3YX0DecX+/KT94rj6FuUOfTPO/6b18zzuQrfU2a8t+lI2VtsGU4lTg ucqVCIxFoLiVXUJU8QHwDTfVym8AHj92pG8ZVLpI6Elt3ypxY0egc2v9t/7WY2Mxf9Ot brYADWCaigQQfkOp9PWn9gRvxn9xTG0ZIqvfJCgM+2RVfn0nuavacVmilGRGh9liDoSP ks/iQGdXbEVTjJ8teYTN1sYWt5OqQ8K7h/tRnIByVf8JyVgrhDsUuJvNJPNhNr1tc+3s NfzoxHQ7yRbj/G3BBaqwJqL2eS3QpFTitytMJvXKQuf0g/c/PPE6MopXLwFEgcYLGvH/ 2SJQ== X-Gm-Message-State: ABuFfogcLvTpFWX8A6pIeS/Uwo0OCjmTKH5cNXScsV6xHAVBDRfpZIkc B9sMllifEZpodjkbOY97Iv4= X-Received: by 2002:a17:902:64c1:: with SMTP id y1-v6mr13801912pli.301.1538442793915; Mon, 01 Oct 2018 18:13:13 -0700 (PDT) Received: from localhost.localdomain (122-223-50-245.fukuoka.fdn.vectant.ne.jp. [122.223.50.245]) by smtp.gmail.com with ESMTPSA id e190-v6sm23709696pfc.81.2018.10.01.18.13.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 01 Oct 2018 18:13:13 -0700 (PDT) From: William Breathitt Gray To: linus.walleij@linaro.org, akpm@linux-foundation.org Cc: linux-gpio@vger.kernel.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, andriy.shevchenko@linux.intel.com, linux@rasmusvillemoes.dk, William Breathitt Gray Subject: [RESEND PATCH v4 0/8] Introduce the for_each_set_clump macro Date: Tue, 2 Oct 2018 10:12:39 +0900 Message-Id: X-Mailer: git-send-email 2.19.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This is a resend of v4 in hopes of getting some more ACKS and a few more eyes on this patchset. 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.19.0