Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp1603698imb; Sat, 2 Mar 2019 23:45:20 -0800 (PST) X-Google-Smtp-Source: AHgI3Ib2g2i3158337CfgNsDcj7CuW7oKohybV24GzDqCdf4IqjtDTdo6ieHSvZukJqzU6jh3lPw X-Received: by 2002:aa7:9259:: with SMTP id 25mr13968562pfp.221.1551599120847; Sat, 02 Mar 2019 23:45:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551599120; cv=none; d=google.com; s=arc-20160816; b=GzzIYc1dLThMeLYXtyTiz/YAbNpmKzpz9+eTxTXGoPnpCToD3ytWovYxb72/Tza6TR Z2yRgH5rUfWVF0cHJcf59FTWZiga2ED8Ubf3griY48+e//3On2Qwqdkpj0aZEM5PE0MI d8Sr6d1emWC18yEBpoO5nV2POXUopRxcTJp7BZF9nFkjYNGRj/WWglE+H1Vm8ipv0mji HhhupGsjn1ZOtQmCezPCAtkfUYyWhSPTKcykJvvsQahbCD59LWurTTXppM6rx15VNPqt vczHUv3GxHdW82ukaDp3zLEONNQBLWNoad8AwaQP4/Q1knQqArCJHyGP/S4vIElKMTTJ vywQ== 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=FTGLQuMzA6NXFSyBaP9yP3iqhOjyb5SMy1QH7j0ioDk=; b=PJfPBCFW6Y50G5LUMv5GKQLwBMV1JWEHDj5fp/ufY9R37PSxvY2ahQ6DLHTxFRh0sZ s60wbCZJwwWGZxk3i+LwTGjgq9FrWY5hfoIr3Owxmk5zT3/Po5piT4UrpSG086hRFKuc CJp+3+jk4eU7E0Dpgh/UjkecM9JrvPrhzuSZ0kyxFdOx5g2mBWoA6vNjtEYFHzwxrJLa sBlBhHkh3AUtFPP95ApGdml/gWWpIEonKmXl5kcagwSyvwd+UoiQjIrTR5Ge5ZjI70wk Y1LmPSamyoJPh8DKeGSZ3T4hwROXZ1i8Sh8E8KT2xQh0iKyauAXjDOl825qLuY82/zV8 tfWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=nPEjXNC8; 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 y5si2476006pge.192.2019.03.02.23.44.53; Sat, 02 Mar 2019 23:45:20 -0800 (PST) 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=nPEjXNC8; 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 S1726037AbfCCHoZ (ORCPT + 99 others); Sun, 3 Mar 2019 02:44:25 -0500 Received: from mail-pg1-f194.google.com ([209.85.215.194]:36245 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725998AbfCCHoZ (ORCPT ); Sun, 3 Mar 2019 02:44:25 -0500 Received: by mail-pg1-f194.google.com with SMTP id r124so1028161pgr.3; Sat, 02 Mar 2019 23:44:24 -0800 (PST) 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=FTGLQuMzA6NXFSyBaP9yP3iqhOjyb5SMy1QH7j0ioDk=; b=nPEjXNC8eHDuVCCKg0hFBeTWLkXIf9gug1s8tDZkRAH4veV1F6D0HNzqgyWB5OXOvF VhnhkAxOpVeWFdWrklMSbvHgs66ptkg5mlf8xjj2ESbwi2ktE0F8KISHLct2AEyeWSn+ /0NNxL5lRThwY+qOfPjXvNLIzsCOplg0rb2zcVSRD4XF1MFCyKJn//a1QMepNwUNQ5fJ QzQOe1jW9eaVBEwFicONRSh33lJGqSyPYRrDgciTA4GFfSt6Zgd3CJnBTZPMRr3YVhR8 Fy6LHKqcir6trUMbU3gX7y89Ea22XKOXCP1Mp8PKrA6KYpcr2ZJXk7s07KiYrLOzJ5Nz qZgA== 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=FTGLQuMzA6NXFSyBaP9yP3iqhOjyb5SMy1QH7j0ioDk=; b=Tw6N2qSulNb0HTye5qZbB47sgZmR1qnQqhvwH83SacCMgC73ZelIusNx8SatDiLVGB bs7Q0RmsRzZyAADtHg9VUF6nlLmbh0Dw4pw2SgF8+mWmtDYHtwUnrUhC7dx2r2vRGt4o C2T9rdoPBLpOAUwDQpeo1X2aE+S73+Kcpnp42JijP1h2H9M/V63XLZDwo0IfkONLJrF8 St9my3D9cbqUWuxMXeoenPZM3JZT2N0fWIOMllvtQtrvC9u7pYlfUTpR0HKEDLxIbmqx RUfOXSOORNPLOo4Z5pssjr7SHWQUfkvqVDMjM73Bs3XM7b8nYkGQSncY7V33FmPbTG7L 45Mg== X-Gm-Message-State: APjAAAWYEVODciSPRIZNg0Ap7QHmDRFHqa0U81BTyWtfJerlBp/7gqXj ENpe7p7P3DbNfRl/+gQ7+eE= X-Received: by 2002:a63:de48:: with SMTP id y8mr3745654pgi.253.1551599063897; Sat, 02 Mar 2019 23:44:23 -0800 (PST) Received: from localhost.localdomain ([2001:268:c0a5:3b5c:c70:4af9:86e2:2]) by smtp.gmail.com with ESMTPSA id f8sm3453113pgs.77.2019.03.02.23.44.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 02 Mar 2019 23:44:22 -0800 (PST) From: William Breathitt Gray To: linus.walleij@linaro.org Cc: akpm@linux-foundation.org, linux-gpio@vger.kernel.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, andriy.shevchenko@linux.intel.com, linux@rasmusvillemoes.dk, yamada.masahiro@socionext.com, bgolaszewski@baylibre.com, linux-arm-kernel@lists.infradead.org, William Breathitt Gray Subject: [PATCH v9 0/9] Introduce the for_each_set_clump8 macro Date: Sun, 3 Mar 2019 16:44:39 +0900 Message-Id: X-Mailer: git-send-email 2.21.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 Changes in v9: - Return unsigned long for bitmap_get_value8 for consistency 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_clump8 macro and utilizes it in several GPIO drivers. The for_each_set_clump macro8 facilitates a for-loop syntax that iterates over a memory region entire groups of set bits at a time. For example, suppose you would like to iterate over a 32-bit integer 8 bits at a time, skipping over 8-bit groups with no set bit, where XXXXXXXX represents the current 8-bit group: Example: 10111110 00000000 11111111 00110011 First loop: 10111110 00000000 11111111 XXXXXXXX Second loop: 10111110 00000000 XXXXXXXX 00110011 Third loop: XXXXXXXX 00000000 11111111 00110011 Each iteration of the loop returns the next 8-bit group that has at least one set bit. The for_each_set_clump8 macro has four parameters: * start: set to the bit offset of the current clump * clump: set to the current clump value * bits: bitmap to search within * size: bitmap size in number of bits In this version of the patchset, the for_each_set_clump macro has been reimplemented and simplified based on the suggestions provided by Rasmus Villemoes and Andy Shevchenko in the version 4 submission. In particular, the function of the for_each_set_clump macro has been restricted to handle only 8-bit clumps; the drivers that use the for_each_set_clump macro only handle 8-bit ports so a generic for_each_set_clump implementation is not necessary. Thus, a solution for large clumps (i.e. those larger than the width of a bitmap word) can be postponed until a driver appears that actually requires such a generic for_each_set_clump implementation. For what it's worth, a semi-generic for_each_set_clump (i.e. for clumps smaller than the width of a bitmap word) can be implemented by simply replacing the hardcoded '8' and '0xFF' instances with respective variables. I have not yet had a need for such an implementation, and since it falls short of a true generic for_each_set_clump function, I have decided to forgo such an implementation for now. In addition, the bitmap_get_value8 and bitmap_set_value8 functions are introduced to get and set 8-bit values respectively. Their use is based on the behavior suggested in the patchset version 4 review. William Breathitt Gray (9): bitops: Introduce the for_each_set_clump8 macro lib/test_bitmap.c: Add for_each_set_clump8 test cases gpio: 104-dio-48e: Utilize for_each_set_clump8 macro gpio: 104-idi-48: Utilize for_each_set_clump8 macro gpio: gpio-mm: Utilize for_each_set_clump8 macro gpio: ws16c48: Utilize for_each_set_clump8 macro gpio: pci-idio-16: Utilize for_each_set_clump8 macro gpio: pcie-idio-24: Utilize for_each_set_clump8 macro gpio: uniphier: Utilize for_each_set_clump8 macro drivers/gpio/gpio-104-dio-48e.c | 73 ++++++-------------- drivers/gpio/gpio-104-idi-48.c | 37 +++------- drivers/gpio/gpio-gpio-mm.c | 73 ++++++-------------- drivers/gpio/gpio-pci-idio-16.c | 75 ++++++++------------ drivers/gpio/gpio-pcie-idio-24.c | 111 +++++++++++------------------- drivers/gpio/gpio-uniphier.c | 16 ++--- drivers/gpio/gpio-ws16c48.c | 72 ++++++------------- include/asm-generic/bitops/find.h | 14 ++++ include/linux/bitops.h | 5 ++ lib/find_bit.c | 81 ++++++++++++++++++++++ lib/test_bitmap.c | 65 +++++++++++++++++ 11 files changed, 313 insertions(+), 309 deletions(-) -- 2.21.0