From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-f196.google.com ([209.85.208.196]:45401 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726492AbeJBNmc (ORCPT ); Tue, 2 Oct 2018 09:42:32 -0400 Received: by mail-lj1-f196.google.com with SMTP id x16-v6so730171ljd.12 for ; Tue, 02 Oct 2018 00:00:47 -0700 (PDT) Subject: Re: [RESEND PATCH v4 3/8] gpio: 104-dio-48e: Utilize for_each_set_clump macro References: <5906381114b14d5b0359510a1d23accbd239eaa5.1538441919.git.vilhelm.gray@gmail.com> From: Rasmus Villemoes Message-ID: <822be05b-092b-41c2-3c31-8981acd5cb9e@rasmusvillemoes.dk> Date: Tue, 2 Oct 2018 09:00:45 +0200 MIME-Version: 1.0 In-Reply-To: <5906381114b14d5b0359510a1d23accbd239eaa5.1538441919.git.vilhelm.gray@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-arch-owner@vger.kernel.org List-ID: To: William Breathitt Gray , linus.walleij@linaro.org, akpm@linux-foundation.org Cc: linux-gpio@vger.kernel.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, andriy.shevchenko@linux.intel.com Message-ID: <20181002070045.GUWOVPNERfX64oA9EvSu7B-Wc4IrD7WG3BvbuLDw_Lo@z> On 2018-10-02 03:14, William Breathitt Gray wrote: > /* clear bits array to a clean slate */ > bitmap_zero(bits, chip->ngpio); > > - /* get bits are evaluated a gpio port register at a time */ > - for (i = 0; i < ARRAY_SIZE(ports); i++) { > - /* gpio offset in bits array */ > - bits_offset = i * gpio_reg_size; > - > - /* word index for bits array */ > - word_index = BIT_WORD(bits_offset); > - > - /* gpio offset within current word of bits array */ > - word_offset = bits_offset % BITS_PER_LONG; > - > - /* mask of get bits for current gpio within current word */ > - word_mask = mask[word_index] & (port_mask << word_offset); > - if (!word_mask) { > - /* no get bits in this port so skip to next one */ > - continue; > - } > - > - /* read bits from current gpio port */ > + for_each_set_clump(i, word, offset, mask, ARRAY_SIZE(ports), 8) { > port_state = inb(dio48egpio->base + ports[i]); > - > - /* store acquired bits at respective bits array offset */ > - bits[word_index] |= port_state << word_offset; > + bits[word] |= port_state << offset; Somewhat unrelated to this series, but is the existing code correct? I'd expect the RHS to be masked by word_mask; otherwise we might set bits in bits[] that were not requested? And if one does that, the !word_mask test is merely an optimization to avoid reading the gpios when the result would be ignored anyway. Perhaps no caller cares. Rasmus