Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp3267427ybp; Sun, 6 Oct 2019 08:15:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqw8RCZYuI3zH1SpdQlRdH9dE3uFHM7hhForks9bCkpum0dzIorviFJZ1ftIQ9DpkWkpPVXQ X-Received: by 2002:a17:906:d792:: with SMTP id pj18mr12520756ejb.327.1570374918794; Sun, 06 Oct 2019 08:15:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570374918; cv=none; d=google.com; s=arc-20160816; b=OwVkT1Q3mzBIUx0sxU3TESr3YCjSTsMUL3+bB4BJkwEe6HIg/c92jtLYFLoplpnFHI EYn4UfV4gYOcuGFMRKgkRZcAbf3iqh12nlDRBMdXzMppRZbc9kNUWMDb8SLrYMNklusg Hk/GSYjxKauMeIzm/BSpThkV+8KBTAd0+Bua89AJZfmlCpkaFhq9qKwzS5KN/0DQOEu/ zL7ORT17vAEbK30R6BwBa/iDI6a/iBSQhP5a/pyUNEP79SlIbplWpEQEwP1itp+dTA0v Y9NQ6sCpvXYWVv/ji+HXrlDG1poHglhTtqsgNEdF7yVX1OpFSFdQc6JImqQ8X/6W9UTq J0Og== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=mBleGApOd9DY5AB30uyK9JEv+41JBB1+F0GtLYOX3MQ=; b=Jy0MvcFwIO6aRFHdepe81LVGvD0vzbqYQLzPkC9jrXun4CNPz4hdp5CxhDeS5vup/E lzeJS+Ho91e3O7gkTb1P9tC72YBke6Xka1WkxBrX+n6otpVTkuXKOnA+cW7rD8LfcUDs BjOCnPy9YOhMkMeiJCaEjuIktVryk0sX5NBA5lLH91sMqxXm6YPl0Tux0UCRbx+N2hjn RHPV9dct8TN03K0BLKH1NrK40elKgxIbuozL9WYj4tYvOuG83tjbk66YDYQKEvrGdRWh /8lElIWtP9L+1TCpqXEyJlNvgCTKX/YJNZq27SHnnid3Vb+GG3tuHqWlRZ4sxSlNwP01 SGzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=gt+dpgEz; 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 k16si5861753ejo.7.2019.10.06.08.14.55; Sun, 06 Oct 2019 08:15:18 -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=gt+dpgEz; 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 S1726988AbfJFPMS (ORCPT + 99 others); Sun, 6 Oct 2019 11:12:18 -0400 Received: from mail-yb1-f193.google.com ([209.85.219.193]:42905 "EHLO mail-yb1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726800AbfJFPLs (ORCPT ); Sun, 6 Oct 2019 11:11:48 -0400 Received: by mail-yb1-f193.google.com with SMTP id 4so140661ybq.9; Sun, 06 Oct 2019 08:11:47 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=mBleGApOd9DY5AB30uyK9JEv+41JBB1+F0GtLYOX3MQ=; b=gt+dpgEzdCZwKJd9QMa5Z8eOLC2T8qGgqQPEDXeJ5+hjFfNU9Bzo1oyXr5FLQacxsB anjs36Ex2uAl8Bvf1X9a5T2FRSJ1WsapBZeDxNxG5mNpyGFAqyQCd/SOQjspGsbjgLtq XyyEruQfjzgKhA9Z0+mjV4dhyRBF36HBeV442cmxACfjrVlakS6t3E3nFncy8FCToC2I O2bKb70qAlk//4C2wpJBPSCG/V+4vxW3eDrSYwDJOPrRFMyMhp6nYl9Q80wzA28pn8Ox 1+xg35Su/lH4vHvw1AmMOQXkGQxaTKDv9SSwWmgSifRSUnwVGO5GOdiyHuhZZEoCUHTJ a+0Q== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=mBleGApOd9DY5AB30uyK9JEv+41JBB1+F0GtLYOX3MQ=; b=KTNK9nnjuakia7XGdiYGM0+DvoEW8D0c7hdQEa/C8FylgFFeivnsjeYhrOGhrPgA+O 6dD0y8N4xhC10NN8xBoZujja1qDtf3inpg6Iz0ZYh7BZ6UORePkBF5eveusk2OpbuwFH ZH95wHza6FTztn2xM6pMal6YWRF2H07K2rSDvLoUoBit9e5eJc1wDmmNloAHG4zE+7y/ LkaS+aqNok+ahxBARiFYZ8cLnFiQasBHX8FRvwMWuFEgw83ATBpathPaUHito4GBmlb7 ZBGG3jzGUpGcmkJvdKG39ks5YhrfAgq8gt/5ySU0nbt+LQfxWLIO+fNS2KC9nO8p4o9t 4ixQ== X-Gm-Message-State: APjAAAUXh2FdQgCUvsI59whX9i0ZdOyqwdJhKCKD5/WNn43UIP51erUj Z+XxreQhMK1x8gjzmPuJ+BE= X-Received: by 2002:a25:c1c7:: with SMTP id r190mr1135831ybf.64.1570374707347; Sun, 06 Oct 2019 08:11:47 -0700 (PDT) Received: from localhost.localdomain (072-189-084-142.res.spectrum.com. [72.189.84.142]) by smtp.gmail.com with ESMTPSA id e82sm2662434ywc.43.2019.10.06.08.11.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 06 Oct 2019 08:11:46 -0700 (PDT) From: William Breathitt Gray To: linus.walleij@linaro.org, bgolaszewski@baylibre.com Cc: akpm@linux-foundation.org, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, andriy.shevchenko@linux.intel.com, linux@rasmusvillemoes.dk, yamada.masahiro@socionext.com, linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org, geert@linux-m68k.org, preid@electromag.com.au, lukas@wunner.de, sean.nyekjaer@prevas.dk, morten.tiljeset@prevas.dk, William Breathitt Gray , Geert Uytterhoeven Subject: [PATCH v16 10/14] gpio: 74x164: Utilize the for_each_set_clump8 macro Date: Sun, 6 Oct 2019 11:11:07 -0400 Message-Id: <13f5d24820e5e3a17a64d025f09efc37eda77739.1570374078.git.vilhelm.gray@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: References: 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 Replace verbose implementation in set_multiple callback with for_each_set_clump8 macro to simplify code and improve clarity. Suggested-by: Andy Shevchenko Cc: Geert Uytterhoeven Cc: Phil Reid Signed-off-by: William Breathitt Gray --- drivers/gpio/gpio-74x164.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/drivers/gpio/gpio-74x164.c b/drivers/gpio/gpio-74x164.c index e81307f9754e..05637d585152 100644 --- a/drivers/gpio/gpio-74x164.c +++ b/drivers/gpio/gpio-74x164.c @@ -6,6 +6,7 @@ * Copyright (C) 2010 Miguel Gaio */ +#include #include #include #include @@ -72,20 +73,18 @@ static void gen_74x164_set_multiple(struct gpio_chip *gc, unsigned long *mask, unsigned long *bits) { struct gen_74x164_chip *chip = gpiochip_get_data(gc); - unsigned int i, idx, shift; - u8 bank, bankmask; + unsigned long offset; + unsigned long bankmask; + size_t bank; + unsigned long bitmask; mutex_lock(&chip->lock); - for (i = 0, bank = chip->registers - 1; i < chip->registers; - i++, bank--) { - idx = i / sizeof(*mask); - shift = i % sizeof(*mask) * BITS_PER_BYTE; - bankmask = mask[idx] >> shift; - if (!bankmask) - continue; + for_each_set_clump8(offset, bankmask, mask, chip->registers * 8) { + bank = chip->registers - 1 - offset / 8; + bitmask = bitmap_get_value8(bits, offset) & bankmask; chip->buffer[bank] &= ~bankmask; - chip->buffer[bank] |= bankmask & (bits[idx] >> shift); + chip->buffer[bank] |= bitmask; } __gen_74x164_write_config(chip); mutex_unlock(&chip->lock); -- 2.23.0