Received: by 10.213.65.68 with SMTP id h4csp440131imn; Tue, 13 Mar 2018 09:06:56 -0700 (PDT) X-Google-Smtp-Source: AG47ELtEnn7WKFoPq00BV2eMB1Z2DG2RaL7x0lOKVInWaKBiDMRsAAbchCaTejc0qP6CurV0K+hi X-Received: by 10.101.93.15 with SMTP id e15mr884361pgr.175.1520957216327; Tue, 13 Mar 2018 09:06:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520957216; cv=none; d=google.com; s=arc-20160816; b=Jub5sdAnPyCN5En2pCgq1813NJsDo9jByEBbDaMJXRwt4s0aXo0yRpT5CiEiS/WqgQ U6rjEBFDu1oxC+jWRN1IllbfQkDbkY0WPI2t9R+vZuS9Sa34YL5KLhjMgPnW3p81gC3W OosdPVoCDi51AmAvx2YfpSIerMhCmn5fUUn1Nj0PyA4LlQxi82zLBez0A9h+qFN+ZKD/ pRpoB9eRHouzugXatwUEVsShLdRotgYab8IF8ci9vnAAyaGbfTUU2g00kNXU9/mJoo2Q YENO3aV515deDyO50KwTeYzJ8DSV+Hmbdgz8uT8nC+UuNKt9xPA0eIN/GuBihTRX3xsB y6RQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=FLQCAScMaOXmI1c3f2PVXojVEJDSztLRzVOx9JEMgqw=; b=i2zBgFcejaY5AjIU5A04XBMaolzQ8fqtgZbyaP+rixXi1I5VThEezFABc1+XJISAVp JIBRgmbhbqeThPrF5RCxxfEFOUcR1ASCArYPzqGmW6Ztqzt3/wiCvsua6DYPvg+Ea3TF to5aN5bcbVoc5h0ufhvmwd4NMBroJYJMugk4AFV5nWnU+D+fyLYcmhRU0SN6eVVw1X7P l/JYPBxopvgogY6HZTFOc2coSw+G/d3Ib31k1OJc7izPGCPL7f+WfKnvRHkffAdNOVH1 EtBpWqA6wbOew2KJy/75XA1PijLyBcgtVX/ceLUXJx1iuK8q7W1oOPGVfuueFkh+wyjW ViBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=gKMcLlYK; 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 c7si285753pfi.323.2018.03.13.09.06.41; Tue, 13 Mar 2018 09:06:56 -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=gKMcLlYK; 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 S934604AbeCMQEj (ORCPT + 99 others); Tue, 13 Mar 2018 12:04:39 -0400 Received: from mail-qt0-f180.google.com ([209.85.216.180]:46214 "EHLO mail-qt0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934047AbeCMQEe (ORCPT ); Tue, 13 Mar 2018 12:04:34 -0400 Received: by mail-qt0-f180.google.com with SMTP id m13so108070qtg.13; Tue, 13 Mar 2018 09:04:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=FLQCAScMaOXmI1c3f2PVXojVEJDSztLRzVOx9JEMgqw=; b=gKMcLlYKaRQaEKHZ5htKXO9nzzqcj5GunIHX8hYvXwqFiBxreVbSZfsgBM4G92Pebr pcYued1+ASbvVWwpCWzbqSGNT0rzEmIqnDrusL+mtGnztH61UUxvqQ6AoCLXK4ugUxAK qWgqn1x+2ZjhQhtg7LFfz5czeUuEXBwff2DQ7DGkTmOMCYhjBaj0a6Qed2buZQUAxFnp KZS/n/rXpmvfzSr7Lliys5+34+wd4b7STqAKPYl/eKk3TznK2OVx2vh8w+55pisTrITc B1D/zbD1jdjqgnt3jP/VSOVM0jFddDVfzYMklOZPoJcRFYYN8Y496f7OOev+EK0BqoaV E9gw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=FLQCAScMaOXmI1c3f2PVXojVEJDSztLRzVOx9JEMgqw=; b=TZzQwfQaLT7q/a0nLoMA0TQ6E136bHCCI+4fDMMN8m3IsmQd4/qUSccZZOrYWzakkH H8wt4BlMQT4xp+7Wj3Krzlympsrim7pUbfrZmNpJnA996daJWaseQVfLah7wWd6ogH5E feCaua+cgJGnhlIP7FarRHmm8EJynFTW0pAPp6knIqUvFg+znpKocVYNR9Sf9L2Kn0oF CCG2E2/2vlS9M4Sr+7YMgfuwQ3vE8Tx8bRvuwKRrc7RYMSbZyIpLhYhfx5abhP3V+KBQ HWlErBi3oqKInc3PRUwqeLQFqR5leZhfmTv/uz7/tiqf5gkVqSNx5UG9/f3VHgKl7mHH qlBg== X-Gm-Message-State: AElRT7ENMbBjTnTZA5M+/HXvrhg3OwYPR7zlKFF1kWQasOpG1Gf4e7S+ rBNNcQE/3Thotf2ZAPUGyuU6GWTCLGtf8W7hmUA= X-Received: by 10.237.61.145 with SMTP id i17mr1695884qtf.293.1520957073575; Tue, 13 Mar 2018 09:04:33 -0700 (PDT) MIME-Version: 1.0 Received: by 10.12.195.80 with HTTP; Tue, 13 Mar 2018 09:04:33 -0700 (PDT) In-Reply-To: References: From: Andy Shevchenko Date: Tue, 13 Mar 2018 18:04:33 +0200 Message-ID: Subject: Re: [PATCH 3/8] gpio: pci-idio-16: Implement get_multiple callback To: William Breathitt Gray Cc: Linus Walleij , "open list:GPIO SUBSYSTEM" , Linux Kernel Mailing List , linux-iio@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Mar 12, 2018 at 10:49 PM, William Breathitt Gray wrote: > +static int idio_16_gpio_get_multiple(struct gpio_chip *chip, > + unsigned long *mask, unsigned long *bits) > +{ > + /* clear bits array to a clean slate */ > + for (i = 0; i < chip->ngpio; i += BITS_PER_LONG) > + bits[i / BITS_PER_LONG] = 0; bitmap_clear() or bitmap_zero() > + /* get bits are evaluated a gpio register size at a time */ > + for (i = 0; i < chip->ngpio; i += gpio_reg_size) { > + bit_word_offset = i % BITS_PER_LONG; > + bits_mask = mask[BIT_WORD(i)] & (reg_mask << bit_word_offset); > + if (!bits_mask) { > + /* no get bits in this register so skip to next one */ > + continue; > + } for_each_set_bit() ? > + /* store acquired bits */ > + bits[BIT_WORD(i)] |= port_state << bit_word_offset; __set_bit() __clear_bit() We have bitmap API for *ages*. Is it too hard to check? -- With Best Regards, Andy Shevchenko