Received: by 2002:a05:7412:8598:b0:f9:33c2:5753 with SMTP id n24csp198635rdh; Mon, 18 Dec 2023 16:42:27 -0800 (PST) X-Google-Smtp-Source: AGHT+IF+MIRL55Hi41nTJcDnT+D3SDeb3MdWqnTJLfal0mZneFWHdCXSo+BrrMjAbXBxh/V9JgJ2 X-Received: by 2002:a37:ef09:0:b0:77f:8bfa:c157 with SMTP id j9-20020a37ef09000000b0077f8bfac157mr12497073qkk.100.1702946546972; Mon, 18 Dec 2023 16:42:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702946546; cv=none; d=google.com; s=arc-20160816; b=wCJxwyAx3VfNOB9RzaGVdYFAbDNgH/mbeeHrkpym3MR5HYCdUky7+YjUREPQhBMVX+ vxLAmlZnWFjNw5TBWNpESg4SFMZ1yAHnpKrWpOKRnfAjmRf+HBZbvsp8I/KoblHdgZ+U iUirCUvXXsjqFZ1xVomTqDfIiXil38iWfByStBSxW1ehz0tLXU78Pt7OaF9bFKdoiNY0 L7VxQNO7W+0GToDUWWXHpFKHwnxfiNotdVw4pEcS77+4M7aaP33g0FZrSPhEAVIbXtlk ehWcLPib1n5+PVAjuTZe23vuqWgjX6UMAeJ5uDsu8on9Pe92UFMjYn6EKngLhimhn5QH h3yg== 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=otPd7l+Z7prrbMamvFTywA1HhQfFLfdVkZWrd8gdbx8=; fh=GNOA1jdeAuH+tfAEzFx15vIukVGFZnqrW9xHApUHjl0=; b=mqsPHuY7uYTXWAbYMkD7Usz4uOfmwb5BSQG84KFo2pxDCo8u2+xe2GePj4MZzRRdff SLxHrOb41yR7jEuGA+bmwBVkBU0271yQv7pa92Ovluxyztr7fqRxnAA6WbQjGO515qDL 7JOejY5brth08Ti0Uzdnn0RS+lpCONbhFBg6aJHYje24/jNj+6NBqH9UvpG1PsYux/rJ sU8x5svCnuGJSj5SOxfDWM564cW8H6Ua0VOFmik37IevxJUhaYTL7/uX3C5u0l6JnS2m P8CPc4waHSi/StpvvxqeLAxY8uiLJSdoIcohjAJ85HAVcoEbXetVmbyJQWNwGVFZ2RQD WZGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=EFu9mAeE; spf=pass (google.com: domain of linux-kernel+bounces-4529-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-4529-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id m22-20020a05620a291600b00767185b2dfasi26086077qkp.622.2023.12.18.16.42.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 16:42:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-4529-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=EFu9mAeE; spf=pass (google.com: domain of linux-kernel+bounces-4529-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-4529-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id A2A081C219E7 for ; Tue, 19 Dec 2023 00:42:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0B0F915A0; Tue, 19 Dec 2023 00:42:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="EFu9mAeE" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-oo1-f52.google.com (mail-oo1-f52.google.com [209.85.161.52]) (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 B232915B1; Tue, 19 Dec 2023 00:42:16 +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-oo1-f52.google.com with SMTP id 006d021491bc7-59148c1ad35so2827263eaf.2; Mon, 18 Dec 2023 16:42:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702946535; x=1703551335; 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=otPd7l+Z7prrbMamvFTywA1HhQfFLfdVkZWrd8gdbx8=; b=EFu9mAeEguZ4yoHC79AGKcuGW+haDJre3Rc7D/YDA/XYtOvkg0ZOO7msXr5frgDdmP Lic03qX8O+PRcNBZ0LaH2jndqNGjc2hkFJ+2BK14WrqlKeRk7sjvYna49+N1YlhuHGJ4 p6Rr+SWUZUTXyW5z+sl5o8ImUuovxXtti/55tj30zuFo81t2ypnCpnaDzvB1pu8z+YmA Yh42wyXhwdYj380ksAWBGX6j9P5Xx6mOv2joYtZ8lO64xiMUCG0uKnEfgnF6b/Ozzo1h Lo5BK7ow4UC6BqFPJPmjP2ygx0F/GxRixt0mue3vApoVtxXIxh+FP0AeAcHAi2mouRZh +bqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702946535; x=1703551335; 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=otPd7l+Z7prrbMamvFTywA1HhQfFLfdVkZWrd8gdbx8=; b=TNujlkBCQEevTe+xD9LnsN3KWIoZ0Dd0ce2YD+UqnujHFLOBv7VitabSsnCbNWnwvQ 2LJK6nOQLx6wKj4WF3WS2KIARDDllvglolTk4JEfRxqsmzxE+R09KQ95emVsqLOcTeVO V/dduywFvKGQq0CsSINXWpZbhqdS0PDNwFP3Idc0rNU+YXAOISIEybE3KjHwnGcQZ8Qt Vu3K420Vm0pskKgNyzEKkJvauNjW/l8TMxRWxIipazkEhrrA1u/FRVeiZmJxzTYuGhf0 5Yw7F3alAIY4rzv5PZizmqcant0Dksam2ncNSeoVJNnRulZOkTbAqX5cyTW9EzWTTjGk ZX2A== X-Gm-Message-State: AOJu0Yyo8rYHbrNZT5kJR6dsEUBnK5rEA/6SKGykmiyEQy23SVYa9y6M 74G2vvGboWQuGU76DR/F+7kFommNo40= X-Received: by 2002:a05:6358:4320:b0:172:f644:647f with SMTP id r32-20020a056358432000b00172f644647fmr102467rwc.53.1702946535379; Mon, 18 Dec 2023 16:42:15 -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 l9-20020a17090a3f0900b0028ae3b5dde9sm173484pjc.12.2023.12.18.16.42.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 16:42:14 -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 v5 0/5] gpiolib: cdev: relocate debounce_period_us Date: Tue, 19 Dec 2023 08:41:53 +0800 Message-Id: <20231219004158.12405-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 v4 -> v5: (all changes are to patch 1) - rename line_is_supplemental() to line_has_supinfo(). - document line_set_debounce_period(). 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 | 402 +++++++++++++++++++++++------------- drivers/gpio/gpiolib.c | 3 - drivers/gpio/gpiolib.h | 5 - 3 files changed, 256 insertions(+), 154 deletions(-) -- 2.39.2