Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp2924665img; Sun, 24 Mar 2019 23:26:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqyBueZPnHZTJD+wEIFk9HI3c/fEsZsO7ZdhPUqJSqhwqcCewGmW/igVFtqY3cqk749PrZLD X-Received: by 2002:a17:902:56a:: with SMTP id 97mr23320909plf.320.1553495197616; Sun, 24 Mar 2019 23:26:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553495197; cv=none; d=google.com; s=arc-20160816; b=h5YwTNSqgR1wJ5AGKSY+pXCLlC4ngPHD1+vDXUrkqpL0pTeJbnA4uoqwbAiQmHY1CQ e0Iqun08//MCULKVYF3IUpmxxitQ/gGG6GQOD1hJjR8Ck0tOHtql3XBZ8b2iWLg/Bo5b AOfAC/L9cqMSWCch9aj8WwVBcceUZQsVDEWuUX/52ZZdjd0Aw5RYFb6y6s9GDopXASvO EtIdngM3372xm+k1IeCnPlB/p6V38vtlIjMnXeahbM4qb5W17tJz8a3ek7tN5clKqko9 VdXgD1BmW6hbQa0Ch5690gVYTQqrdkKc0yPZhHUuB+cVzGQwe372EfbdRE104W7FNvnB pR6w== 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=p6jZFM4uKZmmd8N/chkful+ZD8FsiAd/9uwJICIJ0zk=; b=bfSDqyGth30JvBnlpcdlueBSYcOnINCIfzQfzBmYTSf4Tvd/AcJLudK5jhXKnX30de 8Z935MKWLSxMZvotFFMsYiw05FKNmDxQPlzQmZls3WY41ggo0cZPqjnjUaSZt0GCItJn 2kvOGRZNYgmnIZ+FRCB5npbAZCKM6tu/577WwiabBm+X5iQQhY7UuN4RXwa2dmMNk30u zDeMgLwL2a6ejba6XAevBGIYvNWBwGRJKsTYueHX+JyuNQFGxCXJq85O/IkTjZDTVJY/ Uef+3dHDUZJhIucYv4P68MoLGMuXavJ/9KoejJRKWdKka+wSl+FxfO1s43Qy0FKR0I08 3KBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=tniDY5Ew; 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 a4si12510496pgq.471.2019.03.24.23.26.23; Sun, 24 Mar 2019 23:26:37 -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=tniDY5Ew; 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 S1729845AbfCYGZZ (ORCPT + 99 others); Mon, 25 Mar 2019 02:25:25 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:40154 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729604AbfCYGZY (ORCPT ); Mon, 25 Mar 2019 02:25:24 -0400 Received: by mail-pf1-f193.google.com with SMTP id c207so5639667pfc.7; Sun, 24 Mar 2019 23:25:24 -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=p6jZFM4uKZmmd8N/chkful+ZD8FsiAd/9uwJICIJ0zk=; b=tniDY5EwLN11L7eu43+i1s1Bf9E9i7HV2YfeauI/peDqWD8tGU2R5dqkOGctVVJfui i/MvRy8sQhgXUU+mbgvuG+h4RWexOCRA+Veg33w1T1wS27K5s9bZtVaPqvz5lYHzvNWZ 0nEhRXKCrs3I5AZHdYyf7DvHyGOu4dMOG1Olkpxka0j9vHxPRafIAqNBziUcT42FpZLf a+mcGGU3PqcYQYVW6iV6tlfBd8ofNO/IroRs1xEsBNyX0laAYfFqpWceLJ9gAx4RXGOs YFnFUMbb3/gt2wVY/Y1nQBUWI+yd5fM13fOzVrkYsBUsi42cqUKJm5mNXXmxe7bLiDUo em5g== 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=p6jZFM4uKZmmd8N/chkful+ZD8FsiAd/9uwJICIJ0zk=; b=rukyfBeqc0Ns+0kmpKKDWDffADSm+ZhT7tcVkAPMiiVMjeK95hlJ9mX7/f1nt05Gif 25yKjtMc9RV1gdfJFCdbdLg1hHwpq3Ue3uhud8u2Z9iKQHK55fyQHAlOR5cFuwSe5/oh nTuQN7k54yYmWI5/anGwCXNi3qPM84QF35libT3dH275yuN1Vlh8zgdc6jjnhnxKhXvx wjg1e3E1cno67/HIbe7bGdfROdrdYPUm8V328mv198ZMz5R+JWRG9pYQFa18Xu06FEDo oQBGLLkqFDin2nv/DXnUlJvuJR3SUgAvLluQAdb5MJN/8uTlSM2dZLkj/kNMX3pcbHe0 tZrQ== X-Gm-Message-State: APjAAAUZsc93FISDueojh7j96Yo/sOzBadyBnR5BHT/qnDz+RT155hx4 fcI1FR6TGgFXLFZkslfoYwE= X-Received: by 2002:a63:470a:: with SMTP id u10mr22217094pga.17.1553495124097; Sun, 24 Mar 2019 23:25:24 -0700 (PDT) Received: from localhost.localdomain ([2001:268:c0a5:e068:c70:4af9:86e2:2]) by smtp.gmail.com with ESMTPSA id a65sm19978589pgc.72.2019.03.24.23.25.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 24 Mar 2019 23:25:23 -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-arch@vger.kernel.org, linux-kernel@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, William Breathitt Gray , Geert Uytterhoeven Subject: [PATCH v12 11/11] gpio: 74x164: Utilize the for_each_set_clump8 macro Date: Mon, 25 Mar 2019 15:26:18 +0900 Message-Id: X-Mailer: git-send-email 2.21.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 | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/gpio/gpio-74x164.c b/drivers/gpio/gpio-74x164.c index fb7b620763a2..e43a6de3b6eb 100644 --- a/drivers/gpio/gpio-74x164.c +++ b/drivers/gpio/gpio-74x164.c @@ -9,6 +9,7 @@ * published by the Free Software Foundation. */ +#include #include #include #include @@ -75,20 +76,19 @@ 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 int offset; + unsigned long bankmask; + const unsigned int ngpio = chip->registers * 8; + size_t bank; + unsigned int 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, ngpio) { + bank = (chip->registers - 1) - (offset / 8); + bitmask = bitmap_get_value8(bits, ngpio, 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.21.0