Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp2503306imm; Sat, 13 Oct 2018 21:20:38 -0700 (PDT) X-Google-Smtp-Source: ACcGV60qP1slNEqQfYnF167FEbDZZnkgSP22ByZFciY5XB2yYxYNlJLsfQzCplt4Esop4VokKVAD X-Received: by 2002:a63:3642:: with SMTP id d63-v6mr11193064pga.404.1539490838872; Sat, 13 Oct 2018 21:20:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539490838; cv=none; d=google.com; s=arc-20160816; b=PrgE+HHwQqt7WQGWDr6ZM0Z9SRNtooNLwZLD6yZVpmLbxVZHmb4JDFHcVD7TtDfohD tTRNFilBK1hcywwCL4g6o3MWD7dIqtgVvplL6tExXoWE0VOo9V9+Ulgf90zqIe9s0HeW eU88jB2zVSIvGtEjKXWDI13DowljfDbgtuztardSum+b0UkGqz66/JQC0BO6bDeD27pw ck3pZWZIV8GovTIjNpxAZB42EwO0qa7ULNAK5jbd1iylxxXmSV+gCJkMh6id6yKh+UnN DNQd1oJzzZm+a9Jcrmrk1a4q5mXcUILHfR8l7YRYGmMkzbgVjeQFRP9v11WDhsfnd5ds y2WQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=ZOgEKp7eMC3ZrigqRh8AbVefXULR1cZWtDm/xPURl2M=; b=kezKjcTpOFeEehJnSCEYMY+Qe4wWK8Zt1ynYqxBqCB0uDQYpDGaix5zXZ90xXbksjJ nDGW3SUctvjG/VOlxNHK0Uo3/Nb7ytCzUfjXTHy9eKPstf0j7OMqhM4VEDdnnp6EI3u+ e9PM4Me43livK+Pcb5+Ahy90MzmxwPSlkOA9fXz+b5o2ZBNs+ctACR73kt+XkvRykVTG BzNLqjylNiL0cR0BNVFNsJKiT6md+hcvqSfu79wtU4kT0SaFUq5uVkr2UBHj/7qoTXJy /QbMItgGM6ycwMWfu8KgUs91lPwSi8ht7LvtBo2ysulz0rQpYWLfHL3SF/WcZWqgqGv0 YBYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=pZDbUk1I; 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 j6-v6si7138405pfj.158.2018.10.13.21.20.10; Sat, 13 Oct 2018 21:20:38 -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=pZDbUk1I; 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 S1726175AbeJNL7N (ORCPT + 99 others); Sun, 14 Oct 2018 07:59:13 -0400 Received: from mail-pl1-f193.google.com ([209.85.214.193]:34098 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725848AbeJNL7N (ORCPT ); Sun, 14 Oct 2018 07:59:13 -0400 Received: by mail-pl1-f193.google.com with SMTP id f18-v6so7702446plr.1; Sat, 13 Oct 2018 21:19:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=ZOgEKp7eMC3ZrigqRh8AbVefXULR1cZWtDm/xPURl2M=; b=pZDbUk1IhM+vGLqAKMAF3d8NOdBNOx30PISkbZdbxfskPp1fUL+NnxmkJwCZYmFxYy II/22Fl11Fg33DBc/nrx/ygc2pDsD8HBfwWo7xflVyoWHJ72vM3RdEGS6r0KeCd90hPR v54HBu1s093Y3weIuUT3RGoOqK0c2Yu2m8OppRS2y5MCbQDieeEqlfL4MhvORwBCOIuM neAZhjUmkBg7xVOhfRyFUuYpK/Q9y8PPiDcMoE6oTrzAm82rqfids/vuTcY8eARFzOAH 6JShd2tiECxjnKFKy9cugUbPqIEn3nqOz4rZ7GXLZOj1szs+TWrBAq9ZCQS3oF7IyfQi Ubdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=ZOgEKp7eMC3ZrigqRh8AbVefXULR1cZWtDm/xPURl2M=; b=NfoMxZOz7QIoPhumdJf1FL2vO1dJconhJP9VyjaM4PPIthpbqwrdiTwpuIDR6TOIBO +DrqFbpgDhPIR3EXXxtTGme3GJmQrdtzFvRVNxY1QEueTVqdZ+zKwfdEtE8WwpIuiu2s wpf+M24hyRrpthLY9aKoF8yxEZmv72OZwXZtKKSQPjgSQxKV7KgtA4xC9wjv1HrYXpGD oyBxVPOyJ2u41hbP2Iumc/Mkv3tITsX54VdMA1squgX02rzsVAUa0o188s4OjJs89gaK ne8NNZyrKml4VdyIBlOR5Lrla2QBhc/mv/NzSolWa85NqLUlYX1VoeTgclFNngHSwwuJ 2GNQ== X-Gm-Message-State: ABuFfojcVASbHTpolIUw+vVhB21qWF8mY36IjxZPIr31kRcUAS8k9O3s 0d4xGfV1MAdrhehLYpff8ynTT2gA X-Received: by 2002:a17:902:9a07:: with SMTP id v7-v6mr11681324plp.14.1539490776474; Sat, 13 Oct 2018 21:19:36 -0700 (PDT) Received: from icarus ([2001:268:c0a3:6768:14f8:df52:b210:ea19]) by smtp.gmail.com with ESMTPSA id f68-v6sm8612776pfe.143.2018.10.13.21.19.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 13 Oct 2018 21:19:35 -0700 (PDT) Date: Sun, 14 Oct 2018 13:19:33 +0900 From: William Breathitt Gray To: Rasmus Villemoes Cc: linus.walleij@linaro.org, akpm@linux-foundation.org, linux-gpio@vger.kernel.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, andriy.shevchenko@linux.intel.com Subject: Re: [RESEND PATCH v4 3/8] gpio: 104-dio-48e: Utilize for_each_set_clump macro Message-ID: <20181014041933.GA7335@icarus> References: <5906381114b14d5b0359510a1d23accbd239eaa5.1538441919.git.vilhelm.gray@gmail.com> <822be05b-092b-41c2-3c31-8981acd5cb9e@rasmusvillemoes.dk> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <822be05b-092b-41c2-3c31-8981acd5cb9e@rasmusvillemoes.dk> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Oct 02, 2018 at 09:00:45AM +0200, Rasmus Villemoes wrote: > 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 I don't think the caller cares in this case. Take a look at the gpiod_get_array_value_complex function: the desired inputs are collected before gpio_chip_get_multiple is called and then looped through after -- unrequested bits are simply ignored. This caller behavior also makes sense because a bit value of 0 in the bits array does not necessarily mean the input was not requested, but may instead mean that the value at the input is 0; therefore, the caller must keep track of the requested inputs rather than try to deduce them from the values in the bits array. William Breathitt Gray