Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp67428pxa; Mon, 10 Aug 2020 18:58:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzVogzf8x+zYqYigXPoN5uZAirQOGDgKjf6l7oeB6f0jZ/qo0YYvUNy4eIXjqVPhqNkxzhr X-Received: by 2002:aa7:cf06:: with SMTP id a6mr24801245edy.293.1597111081033; Mon, 10 Aug 2020 18:58:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597111081; cv=none; d=google.com; s=arc-20160816; b=ilGKr1OUjrka7Rdxf5ZgASMS56YOG46PwZn/Os1jEbG2UwB5agsU5oh/WS0CeuBBZK s5JXqYjWTba05ICDb6fOxaeYC5nbOvgyHswlLWw78AYjbLRQA2ak5a8jV+aIrVgfxoQ1 f59pR8I9++o/3Ky5NPbLaDjY/V1dM1Ab7O9Cv87UOHso92a9Ywwl6tZw8nkvqf+NQLCL lxEWjYH65VRC6Ij7Cs6mcPsiCw8TJQ9ZFvA9X3zxOC6ZvU8c4uJF3B8H1DggFnap+oCF hoh2EBgcz/ajFSK3YGtG98zFex3WYIO9/VMFsHyFAIxo2j14JcPohm739geeWLW+cZuY clBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:to:from:date :dkim-signature; bh=8TNdl+C8uye8Ja5jd+YiNm9s++KEtit0cbi0OQRWSFY=; b=agTV68Aj/hnfM4/6iN69Susst29h1HRLcK+WO4XgsKa9O9KXbPNnHawNn7q3RmCkPO Ep+7KGN+vwc4q5t0gPX/oKnE9yo/lCZ4fsy2S0uGpOqt9TA9rmmyAA9lkAfbOIp3XdwU KdiHzta5ZtnGwoBd3aR6bNAWcz4aSaeu4Im7I/qAUh399t4o+gr7dOd6qUCUduuzYYDZ Rt7qTj0s7rK+BZMvcVoRB0v7hQecd8wlPSFFdiYkeoqSCcvpsjKS0stixRTTJAknj/6J a5tl53DnJ5i7xPI92D0oed633soWDYfva2gs1K0mADvhqK3BXzSN/yZi//gVeeEU9Obs njuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=PijYJW8U; 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 g15si11243990edy.601.2020.08.10.18.57.37; Mon, 10 Aug 2020 18:58:01 -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=PijYJW8U; 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 S1728019AbgHKB5G (ORCPT + 99 others); Mon, 10 Aug 2020 21:57:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48022 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727985AbgHKB5F (ORCPT ); Mon, 10 Aug 2020 21:57:05 -0400 Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B893C06174A; Mon, 10 Aug 2020 18:57:05 -0700 (PDT) Received: by mail-pg1-x544.google.com with SMTP id t6so5955075pgq.1; Mon, 10 Aug 2020 18:57:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=8TNdl+C8uye8Ja5jd+YiNm9s++KEtit0cbi0OQRWSFY=; b=PijYJW8UUZ4ppYLApZYvd5T3IzVvKdIZrU/doMYicvI2K1gt96P+DHyvD0/PT3zT9g 7ECqjPg/Y6nAmxapa4QURVDrnERrKz80gO6ghlrjgEAzcqRimMTvnw1XR38ajO0ih8CY BRKQUF6f3ou95MP8jW78OvNhE1rsDVqqcYvkS6Os4afu5Q6+7lH+U2hsniG8VlzXKMbJ ul/wplryuiyNWkDHYss8NOlVGmowDyHCVxtkrS2yKQjVqmxCV6ux53pD/6tvyyFmxVAJ 10zsmaV7zObAE4M+MJy0NJfGSJOuIMf8ZD0gl+Ejbc6/o8UfjWhXAQcRWWHqHLPeZmjN LWdw== 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:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=8TNdl+C8uye8Ja5jd+YiNm9s++KEtit0cbi0OQRWSFY=; b=ksJTxLDGbfT1ZD63XTnOEeHtZYZywMkqSt/lDri3UQKL3XpZlRTMkaEAxi7EGhWqPo 9QeWcZjiNyvEuMLjghZvM39Yz/WW4UWG0SdcvYePGHSBTMjkfbXAoJvm4i70irF5Z7RY LUc4CkQB7XW0pO1gCNH9G6KWBgyssIB8iG2dCN4YsdhX6MHAX1swRgfWPILaPOxZ9TaL CffCdbKdtznboEsd1aWBPC0iSq5h5CCx00EgjNjWNs0UFBUj0cUvHl/8rWc6bKnkcchs MYGx9yF+PLJwx8y+ClC55d0NY6IrkvnBEIZNfJzUmJbh29ds2LczbUGX4p+PTL7+2Pw0 yr9w== X-Gm-Message-State: AOAM5301G2EaQR2T20f7dTLm/QqQcz2cRuDSANBHKGlpumZ4E8dE946y LFQ+ngNVS4Na21aGEye2XVf0auy0 X-Received: by 2002:a63:5213:: with SMTP id g19mr12981742pgb.44.1597111024494; Mon, 10 Aug 2020 18:57:04 -0700 (PDT) Received: from sol (106-69-161-64.dyn.iinet.net.au. [106.69.161.64]) by smtp.gmail.com with ESMTPSA id b15sm19781452pgk.14.2020.08.10.18.57.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Aug 2020 18:57:03 -0700 (PDT) Date: Tue, 11 Aug 2020 09:56:59 +0800 From: Kent Gibson To: linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, bgolaszewski@baylibre.com, linus.walleij@linaro.org Subject: Re: [PATCH v3 05/18] gpiolib: cdev: support GPIO_V2_GET_LINE_IOCTL and GPIO_V2_LINE_GET_VALUES_IOCTL Message-ID: <20200811015659.GB25507@sol> References: <20200809132529.264312-1-warthog618@gmail.com> <20200809132529.264312-6-warthog618@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200809132529.264312-6-warthog618@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Aug 09, 2020 at 09:25:16PM +0800, Kent Gibson wrote: > Add support for requesting lines using the GPIO_V2_GET_LINE_IOCTL, and > returning their current values using GPIO_V2_LINE_GET_VALUES_IOCTL. > > Signed-off-by: Kent Gibson > --- > [snip] > +static long line_get_values(struct line *line, void __user *ip) > +{ > + struct gpio_v2_line_values lv; > + DECLARE_BITMAP(vals, GPIO_V2_LINES_MAX); > + DECLARE_BITMAP(mask, GPIO_V2_LINES_MAX); > + struct gpio_desc **descs; > + int ret, i, didx, num_get = 0; > + > + /* NOTE: It's ok to read values of output lines. */ > + if (copy_from_user(&lv, ip, sizeof(lv))) > + return -EFAULT; > + > + if (lv.mask == 0) > + return -EINVAL; > + > + bitmap_from_u64(mask, lv.mask); > + num_get = bitmap_weight(mask, line->num_descs); Nuts, that doesn't do what I intend, and is part of a failed experiment that I thought I had reverted. Assume that in the next version the mask handling will be similar to line_set_values_locked in patch 09. i.e. for (i = 0; i < line->num_descs; i++) if (lv.mask & BIT_ULL(i)) num_get++; and the subsequent mask tests will be against lv.mask instead of the mask bitmap declared above (which will be gone). I won't do a v4 just yet though - there is sure to be other things to go in there. Cheers, Kent.