Received: by 2002:a05:6359:6284:b0:131:369:b2a3 with SMTP id se4csp347809rwb; Fri, 4 Aug 2023 13:51:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGDNh4VtYmfLB5JOuk5p09C/MitjLS0LOAoq2Cp+XM1pIzX5pXlc4/EwWUAurlF3nAZlGbW X-Received: by 2002:a17:903:124f:b0:1b8:a74e:56ae with SMTP id u15-20020a170903124f00b001b8a74e56aemr3107860plh.40.1691182301098; Fri, 04 Aug 2023 13:51:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691182301; cv=none; d=google.com; s=arc-20160816; b=F23NOG5YUkQbYxeZVBoXnM3iWbRhZ5fX+pzywgSm2mvAP15d0MjbSe4ioDdjxtMZlP nWL0j6dkEYE+8aBc0BBjsO3wXhTgRZfAacj1HTkxRu4euKub8+THw6dkTwpRY9qJeODQ pExQuOIOb8s+V6cTgFoGq3SBWTI0Q4+d1CPWL5Z/idBWp4jefSTIlud9h9qojnBcz9aF 2d3gpN2OZBZus25KbzSwPTciBQIDIcHFGhVShrGrZHoT+zvuxVVQBolxYZuaCWqaYWb5 5q5rGrDhITF0QOpiqho43pYg53NveHLoAZJyvMQpmBJPZcueszDQR4IAyKc3yGgnkMgY f4Yw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:organization:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=aNYriiMcNvTWTJgANnSie1CRiZwlJ4SlLyy4Pfm+1Hg=; fh=gqPwQ16NXCJcUG8cqIGsT/05IFk85XLXLyWYeH+gcWk=; b=oWRMy58B6n4kRulborJxFOTMhCVMepELtOVA+OtpEUd8IjA2xInN+ohgitzQ/o8/FU y4IPPm8bz4aHNkVEjLXnGe1Y8zpAIk1zGB96tb31Ic95GY+x71ix1I7M0xI+4Rbty3/B C+Ja7trREpdgkXiqtKTJbwRznvjAHxfuwFdUp+fN2G3+voPDeUOomz3P/rnnXTEP1WnY s4bLhqJTDJpMUw9O2LR5qO3+544RM4RQw0z7kclb9+XFXOxD8EpIpnC1xPEEqFpx7zXb Df4gWhRGAPNuBmztbsRuxrT7+18zG1eosPs54szY33d29fkYsOVvhzSPueJhJX7mXquk HhoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=adEzplsu; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lf15-20020a170902fb4f00b001bb053dc947si2202675plb.177.2023.08.04.13.51.28; Fri, 04 Aug 2023 13:51:41 -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=@intel.com header.s=Intel header.b=adEzplsu; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229706AbjHDT61 (ORCPT + 99 others); Fri, 4 Aug 2023 15:58:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60596 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229551AbjHDT6Z (ORCPT ); Fri, 4 Aug 2023 15:58:25 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D9BCE6E; Fri, 4 Aug 2023 12:58:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1691179104; x=1722715104; h=date:from:to:cc:subject:message-id:references: mime-version:content-transfer-encoding:in-reply-to; bh=+UFLJexDEQ254y7YqmIGhFkuKiS0FmKIYPvZmypYM0w=; b=adEzplsubNNXdTuiWk6yecFRQW7lFHWFlzDuH0XnQ7KVusLeHBgkZxha q/UejMLIPR++l2Doqnc9PYApRQxBctsQ3ArGo8WdSHtKqcYin7sPiXFi5 /Pg0U3Ga7DGHZ1e4N1eiXNlCXT4uAJyDtpAO367P/KD/6xfppnXuYsi1V zX2JXfZNF3k56kEDYe6xRevm1rQAap9CcbvyORftd40MGJO+rcpI9/7x0 WrDnNZIEORiDD2Ry48y3q1DZRKJw7mFamR4Jy4zXo8HCkY/O0plyaAxaZ BPk3K44jDKxHG0r27eX+g4+eU3G6aS8v/zGl5aDd/I6MAiQwnZND6u7UL A==; X-IronPort-AV: E=McAfee;i="6600,9927,10792"; a="350546967" X-IronPort-AV: E=Sophos;i="6.01,255,1684825200"; d="scan'208";a="350546967" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Aug 2023 12:58:23 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10792"; a="730179139" X-IronPort-AV: E=Sophos;i="6.01,255,1684825200"; d="scan'208";a="730179139" Received: from smile.fi.intel.com ([10.237.72.54]) by orsmga002.jf.intel.com with ESMTP; 04 Aug 2023 12:58:21 -0700 Received: from andy by smile.fi.intel.com with local (Exim 4.96) (envelope-from ) id 1qS0wF-005nGB-2T; Fri, 04 Aug 2023 22:58:19 +0300 Date: Fri, 4 Aug 2023 22:58:19 +0300 From: Andy Shevchenko To: Bartosz Golaszewski Cc: Linus Walleij , Kent Gibson , Viresh Kumar , Geert Uytterhoeven , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: Re: [RFC PATCH] gpio: consumer: new virtual driver Message-ID: References: <20230802152808.33037-1-brgl@bgdev.pl> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_NONE,URIBL_BLOCKED autolearn=ham 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 04, 2023 at 06:03:47PM +0200, Bartosz Golaszewski wrote: > On Thu, Aug 3, 2023 at 1:39 PM 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 checks by calling list_count_nodes() and return -ENODATA in case it's 0. > > > + swnode = 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 == gpio_consumer_device_is_live_unlocked(dev)) -- With Best Regards, Andy Shevchenko