Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp2450395lqo; Mon, 13 May 2024 21:12:40 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWZSpj/vPclqfnG817nrYzf7nuo7Dy8M2PhyBvTmRUbETuNCpaYbg80uw6pJfWi539p1aXFtGGwdXclWbZPnMa4Rx4LrQA5I3TMwp/r/g== X-Google-Smtp-Source: AGHT+IGqEcyb6kr7Lmj2UjESw0htgc9NMpqpr20xRe1xVDe6BC734ukhnthMCJtCqf1JmUeRzm1G X-Received: by 2002:a50:c311:0:b0:573:1ebe:3ebd with SMTP id 4fb4d7f45d1cf-5734d59751amr8283763a12.5.1715659960220; Mon, 13 May 2024 21:12:40 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715659960; cv=pass; d=google.com; s=arc-20160816; b=CLzx/TkLhEvK1WovgrDZ9YN5LWeF+jzC0bl586CUtsXhl7BeGbe9rcAcJvvQyvIYeg 0U7h5f8P9VdleosL4msK9PMpSP/e4QjvUarfPmnTH6bdhVZ+ITxujH4uDo9FijhhvpzH zP05IUP9iVZR3FLOY/c9gjWIhp0A1hOzlxm01kKeqNh+a2t4lv7z8ZuihoKv6gwoCNm2 ybaj8rfXTWDs9qwe8WNZRxSzU+yD6iPiJXMa7sEgnAZcfdMYATHbpQFvgSKzQXPwtZIm wvE5iOyAW1Ly1ESVfAj7RMh2z4NGd6O5Qb4YmrxKVWCppdWVDR2d0k3HDmNf0ssX01qi VQrA== ARC-Message-Signature: i=2; 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=ZRPEnu/ON9I5NtOR1yelgmcp8gSLZwJcxlTGStCRKXM=; fh=Juh44qOJiGg3392vaOW1yjg3XNcllp2Ke6Acvszf684=; b=kg8OCNJAvaBnTKVofR+oUamSQZWQpAoNTwvLU90F1RHYNKFw7N7Qadi7jrdSYpzc4T yKSud7Ff93WqYoq53bvChR0K3Ef75gty1yiVScFse5LGhFWj548RVTwqNp2BqEpV8o3d I7mOAi0f4eTYqxvhkhqa4F3elAyZUoE4FrBWVmATwoiKpLchxMMsfgnYEcfac9RYnrYt moA/gmzyiJJgu/thmEH0VkQMzoXpYVhZ3ZDNHxlDn/olW1lgsamX/9WCO7/Cw0iwABJR wkm2a5TyL0DdSIz4t2CcIOAie4Y+Iba9jpWiu7ky04ImL61PqsKVIFUTjC1UFaob1uRC mx9Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=kVLkeYMb; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-178299-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-178299-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-5733c2d5d31si5640634a12.269.2024.05.13.21.12.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 May 2024 21:12:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-178299-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=kVLkeYMb; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-178299-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-178299-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 am.mirrors.kernel.org (Postfix) with ESMTPS id EDF531F22AD7 for ; Tue, 14 May 2024 04:12:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1F21311712; Tue, 14 May 2024 04:12:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="kVLkeYMb" Received: from mail-oa1-f44.google.com (mail-oa1-f44.google.com [209.85.160.44]) (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 D2D7D1879; Tue, 14 May 2024 04:12:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.44 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715659951; cv=none; b=VNnxIynTeSxbySG1/iURtKdGdOGFcoShODKh64QSmLLvDNFV7vnFcnkC3ooTVlAH8Dgcy4jbMMMJJowpaTORd/v9XTsSUHlHQY9zQtRHHR7epBZb3WKMGDRdHTRr9L1VdIKoba4XuliCv+VOqACjOTz67iLD75jgXyITMfTeA90= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715659951; c=relaxed/simple; bh=BSNSHZATQNEiFHEX3bIx9iNu5D407arnYgHWBJhIj60=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=TknwuW5c4vWSa45eXxsR4d/2hyfWmAyP5rhXZVn7nUWCQ+ifJ0ynRLdnjZIrjZAzPM+FmbuGXPABb6fpx1Mtll3xnAYpGL58gzDOMitu9zTc4bPFy9GvPvKHw6sXrS3tOfUV7QTCFaRXV1xkvFUka5zKNnY0zGd8AzvJ9ww9Zq4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=kVLkeYMb; arc=none smtp.client-ip=209.85.160.44 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-f44.google.com with SMTP id 586e51a60fabf-23f0d4353abso3347151fac.3; Mon, 13 May 2024 21:12:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715659949; x=1716264749; 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=ZRPEnu/ON9I5NtOR1yelgmcp8gSLZwJcxlTGStCRKXM=; b=kVLkeYMbsYmGoft1R4gmmwVW9J6kfhnSe0JqcjEAHfrzwsHYXBMjeSKq8xHCMPUHkH /4uEsdB+vbbeRmgctURFJFGSW2s4jbh9cl279TkZca8y/vu+02t+mbYXzX8WGllCQHwB +JI3AjfRWVF6j2VU+uPx94vWDiYesRuUXSgo6Ll72B8GOsV5yEmbW0w0oNtPo4KGTazN kvK5P1vdkiLe2PzqNcAUuVnPF0sNMXgCwAdCgvRorilAOqcVwunfGcd2FGTYAqcI576g KnlTSbsCVD621NnNH2WRA3iXBjgtGkkxCiT0qTuB7ufAUbuqMhSvOXgBO9AiFOd/m4yI qp2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715659949; x=1716264749; 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=ZRPEnu/ON9I5NtOR1yelgmcp8gSLZwJcxlTGStCRKXM=; b=vdpzzItOhCNasZwKGWupgpWCBndknoQGFDWUF4wlc54cisth7RsxseE7vu+X0HKxEU E98iMBaWFKiQsAZ0JqjKd1moxzgLDHEjL2kUkDFP16L+DAC9enqRdCQAD5f6dEtoo8k2 /YggYweEH/4xj0QfvRnEdTn533x9F8TV/jJXnzu5NgR9xDGot/tZ5ooqBJdug5OABtqg pa0os4JUXhDS36m43lJPboCofsHxJU1OG2zdfSJkykHXqjELgdnyNCQ/PRCs25HHhapt ttr6RssJzgbs61244GVpAaEAoVYMElo2Ah561xPYOP47LnP6ClrSuGqJH6Uikdp/otsZ FRxQ== X-Forwarded-Encrypted: i=1; AJvYcCXlLL+/03avgiEJXmO1572RsrNbxHYtTELzj6mct70Me2ifVYaFxOe70WzHscB+wtGeipY0b0vsmjdmmCuxnhTxH20wds+n2F955rfhoEU5JOMq6R6p8v9ww3mFP5ZhwXMP1b2byud/d8F84/YfLAH/9UY1HLCEH5b5+g4TC+2ZhMrKzg== X-Gm-Message-State: AOJu0YyNepug+yWYP15WkUeXSqLpAAnOhnVcE3XOXaVTrjbz1G7L84Vl zpA9eYVhFQmb5AVKC0Q2uvGvBSfc1w0mVlyZIu3D5xizpJIq+eqt X-Received: by 2002:a05:6871:e70b:b0:240:851c:e6f1 with SMTP id 586e51a60fabf-24172f87de2mr14243879fac.59.1715659948858; Mon, 13 May 2024 21:12:28 -0700 (PDT) Received: from Kuiu.. ([140.110.223.222]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-6f4d2ae0f1csm8383633b3a.99.2024.05.13.21.12.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 May 2024 21:12:28 -0700 (PDT) From: Huichun Feng To: Linus Walleij , Bartosz Golaszewski , Jonathan Corbet , Kent Gibson , linux-gpio@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Cc: foxhoundsk.tw@gmail.com Subject: [PATCH] docs: gpio: prefer pread(2) for interrupt reading Date: Tue, 14 May 2024 12:12:23 +0800 Message-Id: <20240514041223.800811-1-foxhoundsk.tw@gmail.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit In legacy sysfs GPIO, when using poll(2) on the sysfs GPIO value for state change awaiting, a subsequent read(2) is required for consuming the event, which the doc recommends the use of lseek(2) or close-and-reopen to reset the file offset afterwards. The recommendations however, require at least 2 syscalls to consume the event. Gladly, use of pread(2) require only 1 syscall for the consumption. Let's advertise this usage by prioritizing its placement. Signed-off-by: Huichun Feng --- Documentation/driver-api/gpio/legacy.rst | 6 ++++-- Documentation/userspace-api/gpio/sysfs.rst | 7 ++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Documentation/driver-api/gpio/legacy.rst b/Documentation/driver-api/gpio/legacy.rst index b6505914791c..c1a083444b0c 100644 --- a/Documentation/driver-api/gpio/legacy.rst +++ b/Documentation/driver-api/gpio/legacy.rst @@ -648,8 +648,10 @@ and have the following read/write attributes: poll(2) will return whenever the interrupt was triggered. If you use poll(2), set the events POLLPRI. If you use select(2), set the file descriptor in exceptfds. After poll(2) returns, - either lseek(2) to the beginning of the sysfs file and read the - new value or close the file and re-open it to read the value. + use pread(2) to read the value at offset zero. Alternatively, + either lseek(2) to the beginning of the sysfs file and read + the new value or close the file and re-open it to read the + value. "edge" ... reads as either "none", "rising", "falling", or "both". Write these strings to select the signal edge(s) diff --git a/Documentation/userspace-api/gpio/sysfs.rst b/Documentation/userspace-api/gpio/sysfs.rst index 116921048b18..bd64896de91a 100644 --- a/Documentation/userspace-api/gpio/sysfs.rst +++ b/Documentation/userspace-api/gpio/sysfs.rst @@ -97,9 +97,10 @@ and have the following read/write attributes: poll(2) will return whenever the interrupt was triggered. If you use poll(2), set the events POLLPRI and POLLERR. If you use select(2), set the file descriptor in exceptfds. After - poll(2) returns, either lseek(2) to the beginning of the sysfs - file and read the new value or close the file and re-open it - to read the value. + poll(2) returns, use pread(2) to read the value at offset + zero. Alternatively, either lseek(2) to the beginning of the + sysfs file and read the new value or close the file and + re-open it to read the value. "edge" ... reads as either "none", "rising", "falling", or -- 2.34.1