Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp7038527rdb; Fri, 15 Dec 2023 16:17:22 -0800 (PST) X-Google-Smtp-Source: AGHT+IH6AwtHT/lNhtvF6d0r7PvJ3AxV5Bi5Wavif1UvpADHsUzboJ4k76PTvqoMdgpW+Jxjjr2h X-Received: by 2002:a17:902:e54e:b0:1cf:e880:cb8f with SMTP id n14-20020a170902e54e00b001cfe880cb8fmr7703392plf.55.1702685842278; Fri, 15 Dec 2023 16:17:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702685842; cv=none; d=google.com; s=arc-20160816; b=QMMrjIPLO9MTDQJCszArfc9rxIMUNBsJJipOIAZKknLD1+skqxrk7vTzHq1fCCx6OH XtlncQpTRhd3GvzN5xbQwcWm1IG36efGARYwTbHheF+XUL8cQqphsKd5yc98idzjZYz4 VEcqt9ZFMgoCfbUcnwGrs65L4c2XaWkJwNFvjXhZlgYpgpTN+p8ByOOdI6jgUjJ5U6zj 3W1m8kKK+29cuDGJ1H+xNELBV9wxAzmz6KfJYTbJ/iLh+/pV5bpEcJi28nhV5W5a2+k8 zOouxUjQCtACCN4Olhu13n1UvuVZlQ6a6/JhVepiLUCxp/Dfco4HjkQaz++jS+pAg+/w r3vQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=flXnXhNzYj5bQT+Vtb1f16zrrFTB81Pqcpw5aYSnuoc=; fh=GNOA1jdeAuH+tfAEzFx15vIukVGFZnqrW9xHApUHjl0=; b=MZqli5SkfUxWxQemjZPQSxeVz/ppeOWmAJeEQNYF/E/E1IVf0WBVurJUlTlwOmUUcP pM9HFczjKHgXTDnKXuZawjUYi0e1o/qF/4zv8FusKXHPO8TSShGvCWS3PjwBZWyDoD/6 oTYKVnUPlzv+lZagtHab5NIx1Xabk+kGp6ioqNyF+UIBysTnXYiOaZjvfIKhsuosGUXy PWndSB+rGZ7Hav/KYRFMqH3T3sBnZjy0rM+MTroEV+RbL0Olk2oE0MSxvgvtv4V1l8Vd q9N3BcMpxf9MvF5FJf8kbv4mIfFqp98Y07FKRTxAadoBlRX5QsMxXGjJu7leD78v8n5W ShIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=hCTlkieo; spf=pass (google.com: domain of linux-kernel+bounces-1859-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-1859-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id w6-20020a170902a70600b001cfc4215864si13551496plq.588.2023.12.15.16.17.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Dec 2023 16:17:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-1859-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=hCTlkieo; spf=pass (google.com: domain of linux-kernel+bounces-1859-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-1859-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 6D78EB229A8 for ; Sat, 16 Dec 2023 00:17:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 667FF62D; Sat, 16 Dec 2023 00:17:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="hCTlkieo" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-oa1-f50.google.com (mail-oa1-f50.google.com [209.85.160.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3B22B7E; Sat, 16 Dec 2023 00:17:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-oa1-f50.google.com with SMTP id 586e51a60fabf-2031b9c8389so813565fac.1; Fri, 15 Dec 2023 16:17:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702685825; x=1703290625; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=flXnXhNzYj5bQT+Vtb1f16zrrFTB81Pqcpw5aYSnuoc=; b=hCTlkieoc41uSpFVZzNEWmhZJRYuAqCSBdTRw8o6kboINv/58KGL00vcdQIS7GWwvV zc4buU6WQcY64r6wEVfahQl6BLhjn6j9O40e6/JmoTd/anRjHtMfMH0yrri/4WcK179N ykMNS/WFo1lQjYsSfGUwHcSzQlaCIpSBiUUzd+NriWo28m63Sg22mMKqwVqNlFBn6Z2x EkHJIMQy3nQlv+QUf4HpE41wKM2msNiPiymt7WhBvXI4N5IzZoV165/c83iEP7Cfnw0v 1RrtrWE/80irVg1kdHkJSY8NiYiG/tmEl3AosROpfT/eYr1KYmomtZzcPep0srJtdUlY WsxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702685825; x=1703290625; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=flXnXhNzYj5bQT+Vtb1f16zrrFTB81Pqcpw5aYSnuoc=; b=eJzfJqjPEknwtIpcAtcw0M2QQ65SioSo1oTcupJkuf5rr9qMWufvdRoGQTA0L2xCtG O11jxPig28EHtBRUT43kRo/md2kf710rHsDdwXA0MFQix/R/UJDJRvZhZJnhj/f1vUzR m1bIIP7cA/qIRy/lqp+rDv2FZn6UHhH3nXBpJ6KYy/QZmMjwTQvg24iNsyaCfEvkzuNO rd5wIlrdzpApw1Yee2WnfjOYESk3kgUsAolLtMiY0q8Cig07dykRu0jXiDBAlGQ2zSin BA59MgmtrbV9QfwByzB9KMpUQ79OburxlIFGlLMvolkOf8yFQkW23KANeNFftNzC3WjW z8Fw== X-Gm-Message-State: AOJu0YyHCXC6jlFuEQNYtq1spwF4LUTdKz7ZOlDk6SG1AGdlEUohOHwV E1IKhn94EhNM1CniIOGeX8BvCXz3j4E= X-Received: by 2002:a05:6870:8926:b0:203:521f:7611 with SMTP id i38-20020a056870892600b00203521f7611mr3944369oao.4.1702685824405; Fri, 15 Dec 2023 16:17:04 -0800 (PST) Received: from rigel.home.arpa (60-241-235-125.tpgi.com.au. [60.241.235.125]) by smtp.gmail.com with ESMTPSA id ei39-20020a056a0080e700b006cbef269712sm14176124pfb.9.2023.12.15.16.17.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Dec 2023 16:17:04 -0800 (PST) From: Kent Gibson To: linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, brgl@bgdev.pl, linus.walleij@linaro.org, andy@kernel.org Cc: Kent Gibson Subject: [PATCH v4 0/5] gpiolib: cdev: relocate debounce_period_us Date: Sat, 16 Dec 2023 08:16:47 +0800 Message-Id: <20231216001652.56276-1-warthog618@gmail.com> X-Mailer: git-send-email 2.39.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit This series contains minor improvements to gpiolib-cdev. The banner change is relocating the debounce_period_us from gpiolib's struct gpio_desc to cdev's struct line. Patch 1 stores the field locally in cdev. Patch 2 removes the now unused field from gpiolib. Patch 3 is somewhat related and removes a FIXME from gpio_desc_to_lineinfo(). The FIXME relates to a race condition in the calculation of the used flag, but I would assert that from the userspace perspective the read operation itself is inherently racy. The line being reported as unused in the info provides no guarantee - it just an indicator that requesting the line is likely to succeed - assuming the line is not otherwise requested in the meantime. Given the overall operation is racy, trying to stamp out an unlikely race within the operation is pointless. Accept it as a possibility that has negligible side-effects and reduce the number of locks held simultaneously and the duration that the gpio_lock is held. Patches 1 and 3 introduce usage of guard() and scoped_guard() to cdev. Patch 4 replaces any remaining discrete lock/unlock calls around critical sections with guard() or scoped_guard(). Patch 5 is unrelated to debounce or info, but addresses Andy's recent lamentation that the linereq get/set values functions are confusing and under documented. Figured I may as well add that while I was in there. Changes v3 -> v4: (changes other than using --histogram are to patch 1) - use --histogram to generate patches. - include cleanup.h. - make supinfo_lock static. - immediately return from supinfo_to_lineinfo() if line not found. Changes v2 -> v3: - reorder patches to move full adoption of guard()/scoped_guard() to patch 4. - use guard() rather than scoped_guard() where the scope extends to the end of the function. - split supinfo into supinfo_tree and supinfo_lock (patch 1). - rename flags to dflags in gpio_desc_to_lineinfo() (patch 3). Changes v1 -> v2: (changes are to patch 2 unless otherwise noted) - adopt scoped_guard() for critical sections, inserting patch 1 and updating patch 2 and 4. - move rb_node field to beginning of struct line. - merge struct supinfo into supinfo var declaration. - move rb_tree field to beginning of struct supinfo. - replace pr_warn() with WARN(). - drop explicit int to bool conversion in line_is_supplemental(). - use continue to bypass cleanup in linereq_free(). - fix typo in commit message (patch 4) Kent Gibson (5): gpiolib: cdev: relocate debounce_period_us from struct gpio_desc gpiolib: remove debounce_period_us from struct gpio_desc gpiolib: cdev: reduce locking in gpio_desc_to_lineinfo() gpiolib: cdev: fully adopt guard() and scoped_guard() gpiolib: cdev: improve documentation of get/set values drivers/gpio/gpiolib-cdev.c | 391 +++++++++++++++++++++++------------- drivers/gpio/gpiolib.c | 3 - drivers/gpio/gpiolib.h | 5 - 3 files changed, 246 insertions(+), 153 deletions(-) -- 2.39.2