Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp982598pxk; Fri, 25 Sep 2020 03:08:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzsPfu3qOXHs+BPmIAcK0esUVwybYWq1j+sw7uUz4Bx9wOC53N1oltVYxmHEojYl06tn4bI X-Received: by 2002:a17:906:934e:: with SMTP id p14mr1862375ejw.348.1601028495644; Fri, 25 Sep 2020 03:08:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601028495; cv=none; d=google.com; s=arc-20160816; b=QTJeyU1Puc7ErBephchuzQ0+C8Uzzkp+fufrgukiPK7wmo7GQvwascq6JcjcgtJf68 5hhiUp5BlUwqEIYYbjArBtGxdTkYB99BtIVHYPslbuM30nBGPxoGRQdt+xvJcaOd5ZYn UD7zMnWbmChCiWEB0DqZ8Z8sJ1MQxYCJY3nMqWpyiO3STkZB5iU/fqsOofn1W25AFHQT If/uenLGN+ass2lVd4yugE+7k6jEZ4JWYlTicPWNx9COgDiC7zZcVnwcyHZ1Ka+1Gf8v I/59ole12EKPdFQw9Rw88eQ8bn9GAa8Ip02isEx9lTwSGZ1mBpft1WxpYdjZ07oPLhyv R3rw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=lj9oeRjf3zqHOI1lrAhS50c7ExJjW+ZIVM2Q3CpvRlc=; b=vTcPW6robwuxFuj7ufR4xqkbZIjR5TkNIaiPzzfSQVYA5BKgjy8NPdQsDvrSfoUUjh Je/sESTxCo7IR4VHu8DNsq9yQJlUqkg4PgxEM08HnEDUnpjE6El0+VZeurOo3OtMH0jF ZEsFy1tgh1JeEHX132aQySsW6TccyN2YTfIJldMNSJ/d1chxxkKL/Z6lhEj6PDg0r44L qkpjmZFyjSaHPOB/rTmu64AoLwKD1KPt7BRyDXFnBKVX7fTBmoj5AOep3tpfNK60/owV /5NKb6hLFg5MAjEoPTThWU+alZGfLhXD8BlqMLLSqSupSlw+dyNm/dt6BZHlCDoO3KwX kV/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=iL13dvMM; 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 df4si1363340edb.378.2020.09.25.03.07.52; Fri, 25 Sep 2020 03:08:15 -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=iL13dvMM; 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 S1727904AbgIYKGV (ORCPT + 99 others); Fri, 25 Sep 2020 06:06:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727044AbgIYKGV (ORCPT ); Fri, 25 Sep 2020 06:06:21 -0400 Received: from mail-pg1-x541.google.com (mail-pg1-x541.google.com [IPv6:2607:f8b0:4864:20::541]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 11B27C0613CE; Fri, 25 Sep 2020 03:06:21 -0700 (PDT) Received: by mail-pg1-x541.google.com with SMTP id y14so2117135pgf.12; Fri, 25 Sep 2020 03:06:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=lj9oeRjf3zqHOI1lrAhS50c7ExJjW+ZIVM2Q3CpvRlc=; b=iL13dvMMELfX/+oazQ9ItLSLB5TFGSR4kWK+CASxfk9BH9kj4f3GA1+7/lLGdW1zQH 6Zv/AjUGCHZALk6DgQ8cr4p3q2bOed1x0/P6kyR0sQdX7VROkDeiyT0FUosGRJ0RkRrf W906uBqoX2VeY3UKo+MsSSEnXAGHlL3o1xKJsI+kJre4wqa/mW6YmuFUIW+bUIrrEPyo 6Tqv32Sx5oyqaIFGxutkBEgtSKHnLPc5p7zAzKMonWNdgpEdtQ4HzXRXH4DswvvpRbme XLQbAmWis0yWJbOVl05C1dmajpqvQ10oCx+GV09luFKin+FSEdA5/TBgfTJSjMIYrxYF kOhA== 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=lj9oeRjf3zqHOI1lrAhS50c7ExJjW+ZIVM2Q3CpvRlc=; b=QNAgT1vZIChqbiQwjKkosDC+4URhSbcqMuD/rCO5ZsyY5QGkbywU+30vgA8mZjjNXD S9qP7bkefTQRi2XELRmhfikUspFVycHvHFbNzRbmqkZZj7Cg00XtwwYfVjh/uiZn9sUK l52b1wRapEj90priimiGK9HThWnJLtX9Z+pzWd1+ZWhsWabnLgrHKR2TFfuPz0GaCrVh gjW7GBEZtCMZfHVBL20hTp+wtDasbV8n9PWTaJAh4nu5nIFWnKe+UlNf+XdXtPlvTpsv VjAgNmNuueV5TYlSO6tUEw9rCdBpI9BTfG0ltO8O9S6ErSGeLW2Uuu9OhLR4WlB6KJA+ +GEA== X-Gm-Message-State: AOAM531xivCyN/mMJethhOdp/0Z+PeGLiRZFx4nChpJ3eWRaZzTXx+Jt pXcv/c+dPG3v/hC6lMQRZn3LLYsuXVYRCIxUUIs= X-Received: by 2002:aa7:81d5:0:b029:142:2501:39fa with SMTP id c21-20020aa781d50000b0290142250139famr3435059pfn.73.1601028380525; Fri, 25 Sep 2020 03:06:20 -0700 (PDT) MIME-Version: 1.0 References: <20200922023151.387447-1-warthog618@gmail.com> <20200922023151.387447-8-warthog618@gmail.com> <20200924080921.GE17562@sol> In-Reply-To: <20200924080921.GE17562@sol> From: Andy Shevchenko Date: Fri, 25 Sep 2020 13:06:02 +0300 Message-ID: Subject: Re: [PATCH v9 07/20] gpiolib: cdev: support GPIO_V2_GET_LINE_IOCTL and GPIO_V2_LINE_GET_VALUES_IOCTL To: Kent Gibson Cc: Linux Kernel Mailing List , "open list:GPIO SUBSYSTEM" , Bartosz Golaszewski , Linus Walleij , Arnd Bergmann Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 24, 2020 at 11:09 AM Kent Gibson wrote: > On Wed, Sep 23, 2020 at 02:11:54PM +0300, Andy Shevchenko wrote: > > On Tue, Sep 22, 2020 at 5:35 AM Kent Gibson wrote: ... > > > + assign_bit(FLAG_ACTIVE_LOW, flagsp, > > > + flags & GPIO_V2_LINE_FLAG_ACTIVE_LOW); > > > > What I meant is to attach also this to the other assign_bit():s below. > > And just in case a question: why not __asign_bit() do we really need atomicity? > > > > These are initialized as per their order in the flags so it is easier to > tell if any are missing. > > The atomicity is not required here, but it is elsewhere so you are > oblidged to use it for all accesses, no? I'm not sure. I think if you are using non-atomic in one place, it means that all automatically drop the atomicity guarantee. So, it's all or none for atomicity, for non-atomicity it's rather none or at least one. That said, code should be carefully checked before doing such. > > > + if (flags & GPIO_V2_LINE_FLAG_OUTPUT) > > > + set_bit(FLAG_IS_OUT, flagsp); > > > + else if (flags & GPIO_V2_LINE_FLAG_INPUT) > > > + clear_bit(FLAG_IS_OUT, flagsp); > > > + > > > + assign_bit(FLAG_OPEN_DRAIN, flagsp, > > > + flags & GPIO_V2_LINE_FLAG_OPEN_DRAIN); > > > + assign_bit(FLAG_OPEN_SOURCE, flagsp, > > > + flags & GPIO_V2_LINE_FLAG_OPEN_SOURCE); > > > + assign_bit(FLAG_PULL_UP, flagsp, > > > + flags & GPIO_V2_LINE_FLAG_BIAS_PULL_UP); > > > + assign_bit(FLAG_PULL_DOWN, flagsp, > > > + flags & GPIO_V2_LINE_FLAG_BIAS_PULL_DOWN); > > > + assign_bit(FLAG_BIAS_DISABLE, flagsp, > > > + flags & GPIO_V2_LINE_FLAG_BIAS_DISABLED); ... > > > + /* Make sure this is terminated */ > > > + ulr.consumer[sizeof(ulr.consumer)-1] = '\0'; > > > + if (strlen(ulr.consumer)) { > > > + lr->label = kstrdup(ulr.consumer, GFP_KERNEL); > > > + if (!lr->label) { > > > + ret = -ENOMEM; > > > + goto out_free_linereq; > > > + } > > > + } > > > > Still don't get why we can\t use kstrndup() here... > > > > I know ;-). > > Another one directly from v1, and the behaviour there is to leave > lr->label nulled if consumer is empty. > It just avoids a pointless malloc for the null terminator. Again, similar as for bitmap API usage, if it makes code cleaner and increases readability, I will go for it. Also don't forget the army of janitors that won't understand the case and simply convert everything that can be converted. -- With Best Regards, Andy Shevchenko