Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp6408898rdb; Thu, 14 Dec 2023 18:49:11 -0800 (PST) X-Google-Smtp-Source: AGHT+IEAkSSPZMI+1DEGXvTWcMmN3s9UofnBxCFLMETRNpGEfXFcv/5iVaCTsw+YD9Gi12LbRakZ X-Received: by 2002:a17:902:6847:b0:1d3:8108:b5c1 with SMTP id f7-20020a170902684700b001d38108b5c1mr606783pln.69.1702608551121; Thu, 14 Dec 2023 18:49:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702608551; cv=none; d=google.com; s=arc-20160816; b=Ns8FiwS0emnNLkkPJdBHZXpz3hbOMbkEvdqcQK2J4lz2T6JEtXZPflcuyuVTGKgQQn krRp7egSWmkLSG4RaUv4HrZ15H9R2jYCw78x+ybvD4g4LWupp15YQMx4cgedaVjK5MxT QVLPKOoljLQJahHdj2K1PqzkR4GII3Pq3bxV4V4CxTwSTgwPh9DHvKt85B0EmjcSYYfN Njl8sLtfnMLlx5TfYcf5NecfzXCoWBsvyj1LxK+Nz0hTeJL5MHzE9pTiOKUFgbvlN9j7 97fbPiJ0tS2U7xt8UHv47lMrpudhBaJJIdT6mSO6wclWt2Awiz/zmUQ069YtXt0XrFQ5 dhGA== 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=4CZ/cRhlCWB3eQZmrv5D9nr6zmIGzao1x0U408OV93s=; fh=GNOA1jdeAuH+tfAEzFx15vIukVGFZnqrW9xHApUHjl0=; b=ODlgwnAnS+YsIfvcXDyUCHF1SGW0E85o0DKsRnc4xyQqYfOsBmqqLyT5mKGBVjSqW/ cjjBEJcyg+UdJjd/iSC5vfw9GAZG40CRlZdxxQ5l760pQU1fdm4uZBE1+3cn8CjFdms3 Ndv9aQofqayJAObKSbP6IOL7OoiOUa+AXAZwEFsVmYS3hySDcvkxyQQ7vTjRJ0ZTRygq 6mBU16x8xYvT0Y8R3y+WOy3ySCSILdQKvWvYrLESS8uOwn4KVOdlxvP1gDRroO81enUO K+aJo2BLL82ZQOns+MnfTxpFpqxhPWjmzDTVT0UeVdGxX/DFlNFxhtVvTzs1VoXHj/hd NZCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=aHImCsV6; spf=pass (google.com: domain of linux-kernel+bounces-364-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-364-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id a6-20020a1709027d8600b001d08c079196si12053893plm.36.2023.12.14.18.49.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 18:49:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-364-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=aHImCsV6; spf=pass (google.com: domain of linux-kernel+bounces-364-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-364-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 7827928690E for ; Fri, 15 Dec 2023 02:42:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1059020FA; Fri, 15 Dec 2023 02:38:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="aHImCsV6" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-pf1-f170.google.com (mail-pf1-f170.google.com [209.85.210.170]) (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 E6B2A1C16; Fri, 15 Dec 2023 02:38:29 +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-pf1-f170.google.com with SMTP id d2e1a72fcca58-6cebbf51742so113413b3a.1; Thu, 14 Dec 2023 18:38:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702607909; x=1703212709; 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=4CZ/cRhlCWB3eQZmrv5D9nr6zmIGzao1x0U408OV93s=; b=aHImCsV6xopsyHH4kXTdOxKiY3RX/nG86YKrJ4BJqGpL2YMZM7edx1cMMdfj9VJvQi oFM10czIoRH+f32e1dDUKHw1HgVx9I30oZhBpeki1YfBD9vFjqJg+b3wf2bqzWyevus8 VIRi379NnxeluiqM3bsIzf8e4dbik68bG+yQdm4cS/bP5iZ2BuK0NcVNDJakRvnWEyen iTmPLeMXsnj3h7jECQyd9323NNl7P/i6l775H1u3sGRv0KkKZAmWZul0dDAP1x+ffRqg AYI10qS565xzOwVjCr0kk8PEpga6xnrl5WEci17R+QUcMjOIPWrcSKKNPAlIyE32xtuj UZLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702607909; x=1703212709; 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=4CZ/cRhlCWB3eQZmrv5D9nr6zmIGzao1x0U408OV93s=; b=HRSFtlt/CgeG8ukuAUXJ2kCInBAtRi/HNg5xa/k9sRkhgEcbHuMIy5pY56naxeKV5G GiSZ4ds0PUCf0mKw2B6TVofwtOr/3+Hq3fAiBtkiLYigo/MWI5Hbe4kofobSw66uGLj6 67iRLzxiYj5ZTax3JWzX/8u5Sd+kHqXMLQXfsOn7C5bbVI8QcmHuPno0DheTNmCvPpuq 1d4lb5o50+r7aaHJQZrfD2bOLCTm+OHRhFed1zCavIREc0r6KJ/6PInsLSsp17k22mNq VklCVUum03s911SZFBQ8+Dh7tnyNuJ76RU9QsUIR9zdA15XNIELqldF1J2u1OoMQk7tl mj7A== X-Gm-Message-State: AOJu0YxYXWDGMsx3sS2hwiMfhZn4QOIUYVyNJThwT8QxzGz6YNQ5wy8A F5COlFOysaepeJO0zaFQORILNYlt3ds= X-Received: by 2002:a05:6a00:3097:b0:6d0:d43f:1907 with SMTP id bh23-20020a056a00309700b006d0d43f1907mr3476678pfb.21.1702607908765; Thu, 14 Dec 2023 18:38:28 -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 fk16-20020a056a003a9000b006d26920a11dsm1437987pfb.0.2023.12.14.18.38.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 18:38:28 -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 v3 0/5] gpiolib: cdev: relocate debounce_period_us Date: Fri, 15 Dec 2023 10:38:00 +0800 Message-Id: <20231215023805.63289-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 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 | 393 ++++++++++++++++++++++-------------- drivers/gpio/gpiolib.c | 3 - drivers/gpio/gpiolib.h | 5 - 3 files changed, 246 insertions(+), 155 deletions(-) -- 2.39.2