Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp4953298img; Tue, 26 Mar 2019 22:02:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqxzPDIEI2CggDd7mEEBkfQQ4ZcoRn/DwP3QefCwZBqnkiG4hIxvO/OTbwAMZ6QTH0xlm7yP X-Received: by 2002:aa7:818a:: with SMTP id g10mr32994686pfi.178.1553662966978; Tue, 26 Mar 2019 22:02:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553662966; cv=none; d=google.com; s=arc-20160816; b=EGtpjS1C/XKWB833CpImrM73XVyObXyIV3eed8me26whVlc3Zjzys7MnBV8gx2fN3p Yk+NBtREdEgZ2h+0lWEcuPMDVNHoZBYR9mtRZznBOlsN/OZl03FlLRQ4WBPTNjmaxBEQ /1lntOOPOwR5sDTDU8UatyATwJ83zNVpcqShoT/V2OzOCXBKsorvt/AY7sF5uIMj3qUk 7NfcUNzJXEbouawH50h+Iwa55z7nz5wjSFeuIyefu58S8Y2iKpp/Vi2qhjhOCr8qem8z qFGA7fl37jDwLz9sD4SLLLaOBdqsxKfNhBv4/vNHNb2XzQxKIG18QrW57cfjwU6Td9m5 2kng== 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=0I71euHhTT2+JwpcW5o8Nyy8nGlG1C3w/bjF+uE002A=; b=EOYrBM/tCyba5PNjazGCZxq24FnaYIgm+V33tBFSSd6JGaZYILlLFEjQnOXS+EF08j 9V6jVVIhzX+1LLspz4FAXoTAvZEPzXyg3qkARxWqgBdMP6+/z5DOlVifjzpaTwLoca9q m00Nmp6pZUAf64WT3kvN8CNlEAQk9O7t0ULrEFdrlzsgo1Vi14GzuOvr7EBwcNz7LXd9 8l5TE4MhnMmS0UgWkDXs04v7radi7ASClaZtQdU5p7/b38HrPQnRO7WCuyRaXFpbBV1t Id3qgOhordv2SmttZcgfY/6MzNv38GP/ZIn/nyquPNq6MRkV0NjMPypBdNnWO+7kpax+ n3bg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=RxJAI+wr; 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 r13si8581519pgj.413.2019.03.26.22.02.31; Tue, 26 Mar 2019 22:02:46 -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=RxJAI+wr; 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 S1727511AbfC0FBp (ORCPT + 99 others); Wed, 27 Mar 2019 01:01:45 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:41155 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725613AbfC0FBo (ORCPT ); Wed, 27 Mar 2019 01:01:44 -0400 Received: by mail-pg1-f194.google.com with SMTP id f6so5225299pgs.8; Tue, 26 Mar 2019 22:01:44 -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=0I71euHhTT2+JwpcW5o8Nyy8nGlG1C3w/bjF+uE002A=; b=RxJAI+wrrnLYuf5zN1LqQ0NfP/sRXnHsNkAerPKlXipn3hfibBfpYNyEyXZkV27rvv 1LEtXRdFz0qjzjnTAvIiYMA7TjHI+7o38Xb1wpFPFC4MdzacMWClpF8uQ7jJ1UssfKw1 NB/D4Jyx2Uk4Qdb/dFms8L9Jc3b44ezmBnZYRsKGnCl4WvSJ19dj9zQRdArtaD1+95JK 61n7uZiyp4TctN6ocARJffFWWb41MXz6CajEq9rf19Lzpxi26YPHA5faOg5po3ZiRTJ9 fUW2GoFH5cew28D6mPeJepXDvgqNDmDzbkUeJLo1WUSS7T5dZDPknOzeL37S6/XoDpSM s3qg== 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=0I71euHhTT2+JwpcW5o8Nyy8nGlG1C3w/bjF+uE002A=; b=TVsLPGcO7sgKGy8VgUMlYhKg4U9wZso/++x1oyFM5rFiQykr/I7eIbWdONor7KcEI2 lQszT+Q/tNAS9Xt54LexJq+W6AoIMblo6c1XgkBA4S9Go0wru5cFcQ4+fxHGvQI1YsLi XD6B9MecB+59l1qpgyVmiGFn/RtAslWHuzVsh3eKbkZab0F2YoUM+wAhbVXCHEZchvRK gwKjbhw5UyaPPtThzzZvjR589BWwu6dihdHCq+4/Ig1Z3T/uLdtMTG0ufgKEiz3DnpEF eKaaKCYtBzhT90G8f2uqnoieFaNo7L/1vXWZmgSvYHrbaPg4rzcsTtkVOginMl+SB1cn EDOQ== X-Gm-Message-State: APjAAAWSvA8Xer2o2kp/yYKLxMdosmbLBnuyFMgI9vIlgprN9JarFxWz FYEQZNZeDIGvNLDrlmnP5MM= X-Received: by 2002:aa7:82d9:: with SMTP id f25mr33179072pfn.45.1553662904075; Tue, 26 Mar 2019 22:01:44 -0700 (PDT) Received: from localhost.localdomain ([2001:268:c0a5:6014:c70:4af9:86e2:2]) by smtp.gmail.com with ESMTPSA id 143sm2358172pge.50.2019.03.26.22.01.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 26 Mar 2019 22:01:43 -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 v13 10/11] gpio: 74x164: Utilize the for_each_set_clump8 macro Date: Wed, 27 Mar 2019 14:02:39 +0900 Message-Id: <645f16f1d1ad3f215e34a82f457e06725fcf8f56.1553661964.git.vilhelm.gray@gmail.com> 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 | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/drivers/gpio/gpio-74x164.c b/drivers/gpio/gpio-74x164.c index fb7b620763a2..0bbf1162bb31 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,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.21.0