Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp157960pxk; Thu, 24 Sep 2020 02:09:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxpScNUnBlamU4mxe/tO5SozAynWv7RXuZMYQrBjcOiw8jIvVwk3XVQQMomq8Oh3fvToK7N X-Received: by 2002:a50:875b:: with SMTP id 27mr3496875edv.117.1600938590520; Thu, 24 Sep 2020 02:09:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600938590; cv=none; d=google.com; s=arc-20160816; b=S4zhoxws54KexF3INljq4KSCw5FJJb5HJyQ44bh7se2IrBRU7RvyMTaJ8TS1W4sXh/ z5ABUP2WYcon/X2WWm9xKcERLrtw6wxEnmBd1WCYZiAUQ58L05aRf7iIjqOeIjK8eDi4 Y01QCenKr+TRNiYlG5dY0biTqHwOydvmpFert3okEGYRaBz9heTDmm9czuRcCNrIigbn TnNWOQ1p7lzDz/m2npwVnIAPmXpJNy64dLaACW2XB+2KNna8BTECIIU0B+7ebSXFdIln kYi3+VjUiCmzmOK7eont6rqfQP4MxBlUpEylULAh0meO5TcklWvL8DiW6DwawqmAPJbv Y9bQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=/uafQO7Db3cLUaQDzRmZMFp1yFX5GHbGqeGmV2t1IAo=; b=nKT775BHA0wTwmCa4HlDY0py0nV0/2pSH3iAHrv33MMkrwpAR4DX+B/V6B+IX7KTP3 YH5/L8Jq242Wj1GbvcUdok+Z6OxVpYKYGrFUbKqzJuXCrUt9l7bAEAmsxCJkHMjtT4AF R928vYYp48mW7uBGFwrSnSJ66fzTMu48v21eQ5SfVbFLi+YV7rJqWI2FV/dkCrwoChlE pDdnJcn3XFkKPolBGlEKlm5g/4EaiuGXhJzPk6QrQBCXvLfacfjvwqYKpdZ7QEueC8o8 vpqg/ubtK4LbSvDcRHFnF2WLxfvOTsuLu3ZRUz+LYFF+khjqLfY89w1IwW5G4USHgx9u AKRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=GaUfL9Wm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id u15si1815859edo.55.2020.09.24.02.09.27; Thu, 24 Sep 2020 02:09:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=GaUfL9Wm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1727300AbgIXJIa (ORCPT + 99 others); Thu, 24 Sep 2020 05:08:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36444 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727211AbgIXJIa (ORCPT ); Thu, 24 Sep 2020 05:08:30 -0400 Received: from mail-pj1-x1041.google.com (mail-pj1-x1041.google.com [IPv6:2607:f8b0:4864:20::1041]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5768BC0613CE; Thu, 24 Sep 2020 02:08:30 -0700 (PDT) Received: by mail-pj1-x1041.google.com with SMTP id s14so4012406pju.1; Thu, 24 Sep 2020 02:08:30 -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; bh=/uafQO7Db3cLUaQDzRmZMFp1yFX5GHbGqeGmV2t1IAo=; b=GaUfL9Wmu8JrDLLQVrZc/ocZRBTG3S988/vz+zIXqhELxAjjsBZ1yEj7zvtoeY8Bn2 wxIC+XbT13Gny9N+fQgcQyznF/eFKbgswYhBiLH53BDTPHbxTevpgs1KKMNl71ZlR57c 0DKU2G+T/xj+AXdyBBT97JNOfC62XcB4szdKxscMnLA5ec2FzRDmi6t6pMcwiCXpwm1p ZOo2QhFIJ0/4BNXkB5J0YlL8RWaN2ZxMcbLSI6BaRAumLcRqAzGADmMpTyzwjvUbI9WA 5EmU8j2Lpw0/6fnH+Y+fWwFrhjhQ0Zp8xMwewwe72LWKNyoxRoSHMsJxA2pqYwFH28BR 7dbQ== 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; bh=/uafQO7Db3cLUaQDzRmZMFp1yFX5GHbGqeGmV2t1IAo=; b=sTnDxBPbBBN3JukOdBs2dfnUilyJnstFV9DFAM2nByMqeTMRysyns52LkEnJc6HBxn I0hj3+7m6PTPioPVqDc2StpZDhseqc7Zyq1Zr0e0PYQ8zGSsFZDDoNH6Af58gn0Z4PHZ Ouu0u4Zz237zXHVlcqCwJ8s4uUxsOHPsFznBRYykavT1h1yRFuWRD9b+VhPoSsyh9383 tqWrUzxi7U20wqh5268gCjGz4qO4pfiepFDgZHIMgLN+rx81mpBmjsApbpz7QrYDHwWt IPOlbObVpUC10EzWT9uUyNLqFiqrA/Rr0GODXOwnbg6oVjobM+7MH3+mEouJdvf2q2WY sioQ== X-Gm-Message-State: AOAM533AQ1P8MzYUO2DbJqniGclyc8rFNuIkGj2GctIrUmVv9jl9v+kW NaT+r1y2dDPOwL0FxEcGIco= X-Received: by 2002:a17:90a:9ed:: with SMTP id 100mr3008129pjo.119.1600938509709; Thu, 24 Sep 2020 02:08:29 -0700 (PDT) Received: from sol (106-69-189-59.dyn.iinet.net.au. [106.69.189.59]) by smtp.gmail.com with ESMTPSA id 84sm2118729pfw.14.2020.09.24.02.08.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Sep 2020 02:08:29 -0700 (PDT) Date: Thu, 24 Sep 2020 17:08:24 +0800 From: Kent Gibson To: Andy Shevchenko Cc: Linux Kernel Mailing List , "open list:GPIO SUBSYSTEM" , Bartosz Golaszewski , Linus Walleij , Arnd Bergmann Subject: Re: [PATCH v9 11/20] gpiolib: cdev: support GPIO_V2_LINE_SET_VALUES_IOCTL Message-ID: <20200924090824.GA20188@sol> References: <20200922023151.387447-1-warthog618@gmail.com> <20200922023151.387447-12-warthog618@gmail.com> <20200924073248.GA17562@sol> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 24, 2020 at 11:21:05AM +0300, Andy Shevchenko wrote: > On Thu, Sep 24, 2020 at 10:32 AM Kent Gibson wrote: > > On Wed, Sep 23, 2020 at 07:18:08PM +0300, Andy Shevchenko wrote: > > > On Tue, Sep 22, 2020 at 5:36 AM Kent Gibson wrote: > > > > > > > > Add support for the GPIO_V2_LINE_SET_VALUES_IOCTL. > > > > > > > +static long linereq_set_values_unlocked(struct linereq *lr, > > > > + struct gpio_v2_line_values *lv) > > > > +{ > > > > + DECLARE_BITMAP(vals, GPIO_V2_LINES_MAX); > > > > + struct gpio_desc **descs; > > > > + unsigned int i, didx, num_set; > > > > + int ret; > > > > + > > > > + bitmap_zero(vals, GPIO_V2_LINES_MAX); > > > > + for (num_set = 0, i = 0; i < lr->num_lines; i++) { > > > > + if (lv->mask & BIT_ULL(i)) { > > > > > > Similar idea > > > > > > DECLARE_BITMAP(mask, 64) = BITMAP_FROM_U64(lv->mask); > > > > > > num_set = bitmap_weight(); > > > > > > > I had played with this option, but bitmap_weight() counts all > > the bits set in the mask - which considers bits >= lr->num_lines. > > Does it mean we have a bug in the code and no test case covered it? > Because from the API I see the parameter nbits which should prevent > this. > Probably me being thick and using nbits as the size of the mask rather than the number of bits of interest. Cheers, Kent. > > So you would need to mask lv->mask before converting it to a bitmap. > > (I'm ok with ignoring those bits in case userspace wants to be lazy and > > use an all 1s mask.) > > Can you confirm a bug in bitmap API? If it's so it's a serious one. > > > But since we're looping over the bitmap anyway we may as well just > > count as we go. > > > > > for_each_set_bit(i, mask, lr->num_lines) > > > > > > > Yeah, that should work. I vaguely recall trying this and finding it > > generated larger object code, but I'll give it another try and if it > > works out then include it in v10. > > > -- > With Best Regards, > Andy Shevchenko