Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2317980pxa; Mon, 3 Aug 2020 13:03:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwjzLvRT1+OauA9wZvI4V8sAZGjYUKbmflvFePjgmD5rlA28S/WVKsLJe7c3ndkSRzy0WaD X-Received: by 2002:a05:6402:22c2:: with SMTP id dm2mr16834830edb.182.1596485018165; Mon, 03 Aug 2020 13:03:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596485018; cv=none; d=google.com; s=arc-20160816; b=EF2nUbydSaMWxl/0i//PHm2IVKu10mL78GIJeFlBDaWqXKy3phuCO2srMC2KFbNjzr GDR0ditueNJ46LrgH2WBV+n/tlcsTjh9nHIPQaDsZhqvWvyhG3VhF8YJOQcKBAk1z5pB VsTFBGPswJsqg3AVocZwbMOLjS0dhYtXuCTCsZwcPhAvY+lsAoFvYTE71fMrcPSHVzCs BVlskLA1ZEKWJuuGxoC4LLrshPTqYIq0zWzgC9X0g62G7G0xk6Q0vFFHYQcvGQkP0jVg 7ovQclcVtxNYF6ED5zmi+MEgpcZDkhrfZjrBZN39IiKjfIR5yqOgXX3CpGUfwmtbaFK7 GIDw== 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 :in-reply-to:references:mime-version:dkim-signature; bh=6A/5RoJHIBxD93DNQBku4nNngBquUzm6++SOMVJrgBM=; b=ynZl1q1GNl1wJkRM3BZynVouKjAO+sQEI/RPD+JnHJ6EjHNUBhV77BQpMfuTX5esmU I+Y2bwG8tCHUQCXdj8EOK2yJ0s10hlDVCt1e8qM8wtqjQ3LxVq4e+62S1lcx78FKvG5a Trt1YUCffrSQB+EDw97eO/SAv6Pb7jg+aAX4zjgMV8218t+R179irjks0Ffi8rgPlnL1 KGsN1V8cHzORgoj41FmVrOIGorVWAf3SJFAtzzcLUvZjsykCo459uFFOvnIBOzqFq49i mqdj1CG2+icFFj0WxbKTQXOI1zN7eBmIyR6zLHbHWg5AFYzlZsWVCQivxCO2wFhltjLC xxmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b="lcZFQ/uh"; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l23si10970891ejq.620.2020.08.03.13.03.16; Mon, 03 Aug 2020 13:03:38 -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=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b="lcZFQ/uh"; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728771AbgHCUDC (ORCPT + 99 others); Mon, 3 Aug 2020 16:03:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56394 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728229AbgHCUDC (ORCPT ); Mon, 3 Aug 2020 16:03:02 -0400 Received: from mail-qt1-x844.google.com (mail-qt1-x844.google.com [IPv6:2607:f8b0:4864:20::844]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 49A59C06174A for ; Mon, 3 Aug 2020 13:03:02 -0700 (PDT) Received: by mail-qt1-x844.google.com with SMTP id w9so29201897qts.6 for ; Mon, 03 Aug 2020 13:03:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=6A/5RoJHIBxD93DNQBku4nNngBquUzm6++SOMVJrgBM=; b=lcZFQ/uh69bDfLnH4QjtClbnbC9Wijo0Q/P/gHCCdM3fj9wpEmEMnvAE65yi9VW36F Upac67ajq0iLvIlPQV1bA+0c7RRbr0o7974MNCj33dgPmZU9xomPvDXh0o5BdQYZchym bh+Nkava4V15mqFrjGstx+Ng4+z5bn7clLb0TZWA6a2m1lyGh2Z1ERwlzUZKFHj66WDn ZTg6CxoLfSXuTPNX/zP00UjPcthMGxNyReR0JHcFuqWD7H06I8IjWpyD6zZfJG1JOZ8g w/KoBLdSkQMvrAP6FtcfqzUsyMO27/6msa3/aHctO8Gud+P6Km5Pbg+1aKUCcaiSPCVo xtJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=6A/5RoJHIBxD93DNQBku4nNngBquUzm6++SOMVJrgBM=; b=fwYMWC2CE9yQWpaf4ghOpay5jqhyxc5lX6KyND5K1Egmcd7vATpfgxtXx2xryf4z9m wjtBDjV8HFRF8qzKBQd7QVscF28eTiWZ2I77VnKv5UqUGeBmK+XIgPvwri9knjh+4DoK T3sVMsbf1/ffIdJJSBQ3cZVuQFWVyAKQWYx6+cJGjJl18pg+37pl1sv4v2e4RmeMrqSB Hltkw3xCljHPu+NGLQSsHZfQ60sc+5B5ben185zQeIZbPLo2hbIKhFeSeKLNnJAXNxZV 3YzQ1t217q9ksGPN5TAhvpWKjZFzxZUuly7PmRTz0ku6tKYFYyh74+5KAgYUUpoOsPMQ v7Ig== X-Gm-Message-State: AOAM532hTjp6QhrqLXQ5JSg80G/QMsbE325fTVHwmKT42dOlu3yZkl1T 1/36fI/03dL5l68vACY5txWSKDehR8H1rWy+qVlrmw== X-Received: by 2002:ac8:72cc:: with SMTP id o12mr17792007qtp.27.1596484981465; Mon, 03 Aug 2020 13:03:01 -0700 (PDT) MIME-Version: 1.0 References: <20200725041955.9985-1-warthog618@gmail.com> <20200725041955.9985-6-warthog618@gmail.com> <20200726011244.GA6587@sol> <20200802033158.GA13174@sol> In-Reply-To: <20200802033158.GA13174@sol> From: Bartosz Golaszewski Date: Mon, 3 Aug 2020 22:02:50 +0200 Message-ID: Subject: Re: [PATCH v2 05/18] gpiolib: cdev: support GPIO_GET_LINE_IOCTL and GPIOLINE_GET_VALUES_IOCTL To: Kent Gibson Cc: Andy Shevchenko , Linux Kernel Mailing List , "open list:GPIO SUBSYSTEM" , Linus Walleij 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 Sun, Aug 2, 2020 at 5:32 AM Kent Gibson wrote: > > On Fri, Jul 31, 2020 at 06:05:10PM +0200, Bartosz Golaszewski wrote: > > On Sun, Jul 26, 2020 at 3:12 AM Kent Gibson wrote: [snip!] > > > > > > > > > +static u64 gpioline_config_flags(struct gpioline_config *lc, int line_idx) > > > > > +{ > > > > > + int i; > > > > > + > > > > > + for (i = lc->num_attrs - 1; i >= 0; i--) { > > > > > > > > Much better to read is > > > > > > > > unsigned int i = lc->num_attrs; > > > > > > > > while (i--) { > > > > ... > > > > } > > > > > > > > > > Really? I find that the post-decrement in the while makes determining the > > > bounds of the loop more confusing. > > > > > > > Agreed, Andy: this is too much nit-picking. :) > > > > I was actually hoping for some feedback on the direction of that loop, > as it relates to the handling of multiple instances of the same > attribute associated with a given line. > > The reverse loop here implements a last in wins policy, but I'm now > thinking the kernel should be encouraging userspace to only associate a > given attribute with a line once, and that a first in wins would help do > that - as additional associations would be ignored. > > Alternatively, the kernel should enforce that an attribute can only be > associated once, but that would require adding more request validation. > I guess this would result in a lot of churn to do validation which is largely unnecessary? To me the first in wins sounds more consistent. Also: I just started going through the patches - nice idea with the GPIO attributes, I really like it. Although I need to give it a longer thought tomorrow - I'm wondering if we can maybe unify them and the flags. [snip] Bartosz