Received: by 2002:a05:6359:6284:b0:131:369:b2a3 with SMTP id se4csp3401508rwb; Mon, 7 Aug 2023 12:58:37 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFekDhy5kgYRqyvYgqQsiau4CmyrJAkSs6671/YszABFI/+1llAoKGO8hIMDaM76MZrlhKq X-Received: by 2002:a2e:9059:0:b0:2b6:9fdf:d8f4 with SMTP id n25-20020a2e9059000000b002b69fdfd8f4mr7222803ljg.29.1691438316974; Mon, 07 Aug 2023 12:58:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691438316; cv=none; d=google.com; s=arc-20160816; b=GvCZvYvXoZfhkJY8nUnSClWrx6BjZYOpQSj65g8ABt98uDFVCDKFWYcmKTricaSpVf khCWULQBiDWk/NmzEvgCpkeC711MYsK10rAv/ydKBkPuAdEAU7P8p17RfaeTv7FipW8V HZ0/Qhl4RmKkPxTqTHMBGDCKaPNiLNZrAL9LNbagL+SDSnq2u5YOBEDUfFMPxDR9lkwS aTgWnXWUW0byDe05QHIEdaf7ePf8UGpieghTyyUZed9e6vtkLiIWT6MImwVA0z2CfckJ Nu9DRXtIg9hbgVplAH85a/9aK54X5rZgc/ferjLbxlFqzydPSTBYL4k8TwDcKMQVctoD 0eSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=pR1XLVuC4FafbCW0W8qRiCSP9MUCg1QW4kAwDb4GxSo=; fh=WdUcsgNC4gEO+ybA5RPhsdyNTItd2DP5blfp7qLQ5+U=; b=O6ISN2zRapZ2XttH4CTZ5PGbkNt3ThURJ2OIAHA0JxIHrEswvFC89otF0QyJbv/sln AQDDA5FYAeTHIYgbiwqO8RgfD6aIYCB+eI/x9zhh9nn4V2p5uiSMpYOVdwovgtI91JWA ciWLIf3T5O1+22Rhoaa4h2PWuuU+k53OW3XyTCDB30MvhAl9eynS8oRNrHN4aEuvDJI6 okk3Y9wK7NKQBuz/ZI0uO0AJ5EguNhLIPkkTKgpagGFX3jjhZufQGA93cxsLD8PHyu8n jNUaeyuoCaA1IPGSdDGH3rMMNFUAVQQPjxyl0gsRN0qe/ltkBroIvSjqPFwLd0mwszN2 NCQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20221208.gappssmtp.com header.s=20221208 header.b=fghvH5Qt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id pg16-20020a170907205000b0099280a7eeeasi5925677ejb.526.2023.08.07.12.58.11; Mon, 07 Aug 2023 12:58:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bgdev-pl.20221208.gappssmtp.com header.s=20221208 header.b=fghvH5Qt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229612AbjHGTri (ORCPT + 99 others); Mon, 7 Aug 2023 15:47:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39032 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229537AbjHGTr1 (ORCPT ); Mon, 7 Aug 2023 15:47:27 -0400 Received: from mail-vs1-xe2b.google.com (mail-vs1-xe2b.google.com [IPv6:2607:f8b0:4864:20::e2b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6508919B0 for ; Mon, 7 Aug 2023 12:46:48 -0700 (PDT) Received: by mail-vs1-xe2b.google.com with SMTP id ada2fe7eead31-44758646388so1732374137.1 for ; Mon, 07 Aug 2023 12:46:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20221208.gappssmtp.com; s=20221208; t=1691437607; x=1692042407; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=pR1XLVuC4FafbCW0W8qRiCSP9MUCg1QW4kAwDb4GxSo=; b=fghvH5QtWy7Zl7Jl0YEwj3DzxNuyG2HC7oHrnVjlZsJYD9zEyF2qebYMCV2Uv7t8NZ sFeJeAH4WaN3Z8SK+OkSTrTowg/b6b+b5erQ/aYGIGYjFRknwG65fGd65ZcEa3+I6C2Z AiF1rLZdBjBQTodstckyybqXYO+jm+iCCSW3Jazipk1GBa9nczn7qrxySL5dNLhg8Evs 1yWL9kybBF6STqC7FB6mizHNX8UwWBEXcqvLu9/FLxnxMEKCWz2y0IHYk4NNHDihpXEA DHFUEPOcyVD6lxnhNoN8WxyhqhSd/FzQl743YbXdXIQXjzWBncw+7Y6MgQ+4+2t1trqB bkzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691437607; x=1692042407; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pR1XLVuC4FafbCW0W8qRiCSP9MUCg1QW4kAwDb4GxSo=; b=GrHb5vrKByubyXKYfEWbUFI17Zczglt2HM8rRBiKuszswmiuwFrsIyhM7ZrWYEteUm dEpBee3vNC5Ljej4TGvh5e3uPNmBFevwgPAjYqNvSSG6nI1Pu+EI4lQXiuinQE62pYuS g/ZzlfAjeMkhw+VcCWVUDLIxig2z67YEaieKzu6WDHum9pq68bsVT96hzc/EQ9Qf5Jto WzEUtoPRWbatmt3IsGvWE+42K1cyLlsTrGfMliVQQWI0Y1m3ielVlA3gXMYTCd9+j7qN FzizsF5Wde2rHsYhBWtgK4SU1g6NSAWsM7rk4cyhzfJJk+O22yym6M+sg+7xQdnQXrBA BZSw== X-Gm-Message-State: AOJu0Yy0EUdLu6A9a4Uyvt6hePRJ+z8L+wEGLIH1zO7wEUfKOPRTnXAh lqVlkb+VF8vXtwsEmTCZ5HHBYTWGafe45yuink/KBA== X-Received: by 2002:a67:d011:0:b0:447:7046:7254 with SMTP id r17-20020a67d011000000b0044770467254mr4484729vsi.35.1691437606891; Mon, 07 Aug 2023 12:46:46 -0700 (PDT) MIME-Version: 1.0 References: <20230802152808.33037-1-brgl@bgdev.pl> In-Reply-To: From: Bartosz Golaszewski Date: Mon, 7 Aug 2023 21:46:35 +0200 Message-ID: Subject: Re: [RFC PATCH] gpio: consumer: new virtual driver To: Andy Shevchenko Cc: Linus Walleij , Kent Gibson , Viresh Kumar , Geert Uytterhoeven , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Aug 4, 2023 at 9:58=E2=80=AFPM Andy Shevchenko wrote: > > On Fri, Aug 04, 2023 at 06:03:47PM +0200, Bartosz Golaszewski wrote: > > On Thu, Aug 3, 2023 at 1:39=E2=80=AFPM Andy Shevchenko > > wrote: > > ... > > > > > + if (list_empty(&dev->lookup_list)) > > > > + return -ENODATA; > > > > > > Instead you may count nodes here and if 0, return an error, otherwise= pass it > > > to the callee. > > > > I'm not following, please rephrase. > > The below call calls list_count_nodes(), you may simply join these two ch= ecks > by calling list_count_nodes() and return -ENODATA in case it's 0. > We don't gain anything by doing that: list_empty() doesn't count nodes, it just checks the head pointer. We would decrease readability (more arguments!) for no reason. Bart > > > > + swnode =3D gpio_consumer_make_device_swnode(dev); > > > > + if (IS_ERR(swnode)) > > > > + return PTR_ERR(swnode); > > ... > > > > > + if ((!live && !gpio_consumer_device_is_live_unlocked(dev)) || > > > > + (live && gpio_consumer_device_is_live_unlocked(dev))) > > > > > > if (live ^ gpio_consumer_device_is_live_unlocked(dev)) > > > > > > ? > > > > Nah, let's not use bitwise operators for boolean logic. > > Then it's even simpler: > > if (live =3D=3D gpio_consumer_device_is_live_unlocked(dev)) > > -- > With Best Regards, > Andy Shevchenko > >