Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp5329994rdb; Wed, 13 Dec 2023 05:59:06 -0800 (PST) X-Google-Smtp-Source: AGHT+IGCCM2X9j/zXlcWaXSpZfe53WIhVD8ZiOfxEEe7g/bf700VWMLAbzUVbGy5V0x9eYnlSAEM X-Received: by 2002:a17:903:2309:b0:1d0:6ffd:8346 with SMTP id d9-20020a170903230900b001d06ffd8346mr4294337plh.81.1702475946024; Wed, 13 Dec 2023 05:59:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702475946; cv=none; d=google.com; s=arc-20160816; b=HMtKNicCld5mVH0oWyl4610Sb//SUk7Lz+FepU31yx/T6UTD2F1tFJG3Yw54T/iynT wE0lp5MCyZcAQbxPHRsy1soV5EeIoqWpOzN/keqSy9fgDOoUpqaTiLkOt/OOAHkOF4kp k6GGWbyGRLtYhqtp1zneAN+76+vnVhDLczOa4BSosv1rycN5E2KhcIGP2LfnedAglulu bTKB1QXt35IyzkLBRmkS0zA2oMjx/wOm5yWc9nDydGX5kCN4FZQBIqqige3b905PNZeU ZrIuIDVoe4KbfBOIPIutRcR2pz1SB0SVDbaWgaENQ/HUud0HwbtUQ05Iea6i++PtU7Ln zSqQ== 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-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=Hf9qaITpHxwZhzLUg1AhdQ5nkJg/y5BkTRSdNy8V7EI=; fh=BiTih3HBn05OJvpBeKJCJhFgvirybBPBq65CdTV6sMo=; b=tCNPunX7Z8V1hSqvG73KTebSnukkaYqAGM3wzyBCigrZ5ohqU6T90h7dAkd6kSKL0r N0pn7hB0GZXyUXCoa5S/wGucmEwm0QSJL+6X6mwDmUmjMKCmdqDP2QS/ilnABC+/0Iyr 4LbF6ngG3xIk8xlcJdcQbVKWXtCaavxJoRTy8XAp6xZkiN/F9VPZtRVn/MlnNZNrMCe/ pSNX7WasSJUJ8fNOFSglG4vn1YYib9rODK0AN/jFheQdOvK7juJN0Kg4g/cUkyRU1dp8 IWgPkEqTtyM8osd/sQHgb81YP9ufXaWIm8mNXxlT+84vCVXurdXOQFRJB6mSQfjcV9a3 79IA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id i8-20020a17090332c800b001d3485d9e68si1744774plr.287.2023.12.13.05.59.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 05:59:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 007E980C65C8; Wed, 13 Dec 2023 05:59:04 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379287AbjLMN6w (ORCPT + 99 others); Wed, 13 Dec 2023 08:58:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50392 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235588AbjLMN6W (ORCPT ); Wed, 13 Dec 2023 08:58:22 -0500 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A271E49E2; Wed, 13 Dec 2023 05:55:40 -0800 (PST) X-IronPort-AV: E=McAfee;i="6600,9927,10922"; a="2104255" X-IronPort-AV: E=Sophos;i="6.04,272,1695711600"; d="scan'208";a="2104255" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Dec 2023 05:54:58 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10922"; a="864636987" X-IronPort-AV: E=Sophos;i="6.04,272,1695711600"; d="scan'208";a="864636987" Received: from smile.fi.intel.com ([10.237.72.54]) by FMSMGA003.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Dec 2023 05:54:56 -0800 Received: from andy by smile.fi.intel.com with local (Exim 4.97) (envelope-from ) id 1rDPhO-00000005XYC-0NhR; Wed, 13 Dec 2023 15:54:54 +0200 Date: Wed, 13 Dec 2023 15:54:53 +0200 From: Andy Shevchenko To: Kent Gibson Cc: linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, brgl@bgdev.pl, linus.walleij@linaro.org Subject: Re: [PATCH 1/4] gpiolib: cdev: relocate debounce_period_us from struct gpio_desc Message-ID: References: <20231212054253.50094-1-warthog618@gmail.com> <20231212054253.50094-2-warthog618@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231212054253.50094-2-warthog618@gmail.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 13 Dec 2023 05:59:05 -0800 (PST) On Tue, Dec 12, 2023 at 01:42:50PM +0800, Kent Gibson wrote: > Store the debounce period for a requested line locally, rather than in > the debounce_period_us field in the gpiolib struct gpio_desc. > > Add a global tree of lines containing supplemental line information > to make the debounce period available to be reported by the > GPIO_V2_GET_LINEINFO_IOCTL and the line change notifier. ... > struct line { > struct gpio_desc *desc; > + struct rb_node node; If you swap them, would it benefit in a code generation (bloat-o-meter)? > }; ... > +struct supinfo { > + spinlock_t lock; > + struct rb_root tree; > +}; Same Q. ... > +static struct supinfo supinfo; Why supinfo should be a struct to begin with? Seems to me as an unneeded complication. ... > + pr_warn("%s: duplicate line inserted\n", __func__); I hope at bare minimum we have pr_fmt(), but even though this is poor message that might require some information about exact duplication (GPIO chip label / name, line number, etc). Generally speaking the __func__ in non-debug messages _usually_ is a symptom of poorly written message. ... > +out_unlock: > + spin_unlock(&supinfo.lock); No use of cleanup.h? ... > +static inline bool line_is_supplemental(struct line *line) > +{ > + return READ_ONCE(line->debounce_period_us) != 0; " != 0" is redundant. > +} ... > for (i = 0; i < lr->num_lines; i++) { > - if (lr->lines[i].desc) { > - edge_detector_stop(&lr->lines[i]); > - gpiod_free(lr->lines[i].desc); > + line = &lr->lines[i]; > + if (line->desc) { Perhaps if (!line->desc) continue; ? > + edge_detector_stop(line); > + if (line_is_supplemental(line)) > + supinfo_erase(line); > + gpiod_free(line->desc); > } > } ... > +static int __init gpiolib_cdev_init(void) > +{ > + supinfo_init(); > + return 0; > +} It's a good practice to explain initcalls (different to the default ones), can you add a comment on top to explain the choice of this initcall, please? > +postcore_initcall(gpiolib_cdev_init); -- With Best Regards, Andy Shevchenko