From nobody Fri Dec 19 14:34:01 2025 Received: from mail-pf1-f181.google.com (mail-pf1-f181.google.com [209.85.210.181]) (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 6A283283FD3; Mon, 19 May 2025 14:26:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747664775; cv=none; b=qIdDDJgqZIN4593DRKt5jMjDnlVbTEiEiftmStaim9AmVepQ0x8qHcT6QjEGgs2uMw5hvPOlDrRI0HR1UQ4y/yHTM5GQSvJ9zGs2VojQWX2g8qY6QuOzHWNP69UqXQT/3HgfX314rncneumee+oZGlrFWsMMCJbmqKGneMlBf5o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747664775; c=relaxed/simple; bh=pIsXkfwmbJwpyIPN7p01NdbcZXCT8CBrk099Zl10eFI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ABXRqMoVnMnAx/GjOX8hTTerCYTwANYhGwWs0nIj0R2ivOKThw2YN+6+HH2ACr7G866YDtERL2rU0Bs+nzgV+jofpIqYFsscnrqe74pt4/YFC2XIMTeex3CKk2F3VDT8D1YSelX5SzEPiOjjQdffgfA9xwl+eSZdIxCh3PQgOxc= 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=VFJA9TlZ; arc=none smtp.client-ip=209.85.210.181 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="VFJA9TlZ" Received: by mail-pf1-f181.google.com with SMTP id d2e1a72fcca58-742af848148so2052985b3a.1; Mon, 19 May 2025 07:26:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1747664773; x=1748269573; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Ws6NGUTrhwrUyFzENkHKMEqXVz0k1/x1kYmVqczNDF0=; b=VFJA9TlZyPt4Ojo/hiheBR3MbrA+ED0DUREyQOEfxDpKiSGPJZXufRWwLQX9njv38R jA7YnFmOOd6+4utx1NGkbO+LVp/jEZMdmP5TZHQJZiDpsnX3NgVdmfDwaDvzkTlhOTGD bSA9N/M2HO7caw/qXVFeEsd4FzK1ITk1snbNBBsGjuesC0ifI4H+ggbzat6CWS7CoE5U lrv/+n4PQck+P/jR6PciO5CoM8V9h0eBWS50JYTwr76HdINtJqhdkBnBQ7f9hTmzMq6d VOHJuQSRrfiJJPSz2jI4+LkvQFSkzcJ5J4Dj7YyGlc8nXZ1ioCs9DnTznoTMx9PWcifx 49tw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747664773; x=1748269573; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Ws6NGUTrhwrUyFzENkHKMEqXVz0k1/x1kYmVqczNDF0=; b=ZOmSyll0dfpjrk6nRLTorCnUYGrjEVk7972T7hMhynn9aX05zu1YoGoBrHKSqqhYI7 qH9j7Bm9drrB4tqIrq2Gmf0gXliIDbYDejxuf1xtlfM+et74aDVPLE5d08r1B+mWuaS1 Et3ZbxgBOmzudtBIo+DB4jT6bs37GxWi7zgKGYPSKxPt8Wi9r3osmqoAQBCrsi5nY9ur ZjP+AKtyXx82tLM3M7ISAPpTUTn2DfQ2Q69h0Uco475vdDgwtSqQYBMUl1OkrrvFhSr/ eQhOnje1thCKNrSJ4PDQhOnvKK6ImE4pnkakl4PjXPSVOqOB3oxRZm3Ry3BO+QJyAnQA AJ/A== X-Forwarded-Encrypted: i=1; AJvYcCUiNjX2kVppatVxDktencbXiZXBHwZ8lO2TbH+AI3cebo709h7Wkt0+trcFSPraOzH5AlPCoGJeQXw=@vger.kernel.org, AJvYcCXL9YXhL83o6p9CHQnkRWx/jdq63Aq5Vv/X2GiuAboo7+sRQlRFecrNeVPYkNfT/sQ4NN9cXVcFr38Wkchb@vger.kernel.org X-Gm-Message-State: AOJu0YxsKuKQNNjBmRj+hnKFssRTIc6wb201hKRBv6h4yorPaB199PK4 t2v78tjigEIK8ng8V3Tpjby7ZyH8DYnzdPbDCf3i0txRFjr3MGXJqg2n X-Gm-Gg: ASbGncvJt4LctWZtR6vbZJYDYmJJr0EXxK03dS3D+yHp50+PCw0SQPXG5G5vOs/II5n iEO8eUBazBQFE5rcUmI+SpLRR796+eUGfrHuzixJIh1hrt2llcbJws1BNVtbF9Bkth+0r3u0Gtx /LnMgVPHLJ91qRanB58tYD3vSnFyg6jPV2AfUguCblef/gc8OdSlSa+EyaExgKRdIU8bi80r5i5 7N7xJW4e4AgRWXa7WwPE6xZPN/HxscW4+fqfvdOhBs2TA8XsX27L5ZIIY/r45m3RiVV9LbOj6KJ VVmJjeTXM/SH2lufuKA9TmbVsjIN/tJ5DP70C/CRBIotT0efzxdEnMvKAem8IkBN/NVO X-Google-Smtp-Source: AGHT+IFLB86+GGsQOIbdQ6TWsM7RA3lPV1bojIEbPOR6YJ9mg5Np9dvMCVNczPoT9o9AC34ZtMj7GA== X-Received: by 2002:a05:6a00:a24:b0:742:a91d:b2f6 with SMTP id d2e1a72fcca58-742a97e0b3dmr17911736b3a.13.1747664773431; Mon, 19 May 2025 07:26:13 -0700 (PDT) Received: from gye-ThinkPad-T590.. ([39.120.225.141]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-742a96e211csm6465303b3a.16.2025.05.19.07.26.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 May 2025 07:26:13 -0700 (PDT) From: Gyeyoung Baek To: Jonathan Cameron , David Lechner , =?UTF-8?q?Nuno=20S=C3=A1?= , Andy Shevchenko Cc: Gyeyoung Baek , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH RFC 1/9] iio: buffer: Fix checkpatch.pl warning Date: Mon, 19 May 2025 23:25:53 +0900 Message-ID: <20250519-timestamp-v1-1-fcb4f6c2721c@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250519-timestamp-v1-0-fcb4f6c2721c@gmail.com> References: <20250519-timestamp-v1-0-fcb4f6c2721c@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Remove the following trivial warning: "WARNING: Block comments should align the * on each line" Signed-off-by: Gyeyoung Baek --- drivers/iio/buffer/industrialio-triggered-buffer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/buffer/industrialio-triggered-buffer.c b/drivers/i= io/buffer/industrialio-triggered-buffer.c index c06515987e7a..9bf75dee7ff8 100644 --- a/drivers/iio/buffer/industrialio-triggered-buffer.c +++ b/drivers/iio/buffer/industrialio-triggered-buffer.c @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0-only - /* +/* * Copyright (c) 2012 Analog Devices, Inc. * Author: Lars-Peter Clausen */ --=20 2.43.0 From nobody Fri Dec 19 14:34:01 2025 Received: from mail-pf1-f175.google.com (mail-pf1-f175.google.com [209.85.210.175]) (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 986CA283FF5; Mon, 19 May 2025 14:26:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747664778; cv=none; b=eolr2cHQvBiyBGXRoEukir7t/hxrcBcgiAUKsU0LnnHgYKtPYf43hWeAbxDByydIgMzXRV3/SQXRz31tT9Fx1UnSkgoiY7HSkr/kKRG+PUH/J7yP0pl3mVXXvAV/yUuNM8y+JvRIwYRMi1LEdhCRltU4LDmapI7WyosTe1vbo8Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747664778; c=relaxed/simple; bh=JuLC/Wx7Wg0nAvBCmYwGh7LiLm0cZfVz+AluP+xYrao=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=DHaTlmhktxXBevk6PS6c/gdFl5E3w853A5Y0I747IsONQ+FA2Y2ymNvKaidK7myPc7iuEzt5Ff1mIRqZ3Hh8KUySLG6wSG9c/ODFOoMyLxbutO6zeMK2CEQuZWrEVQRV8qVacZyOwaQFx8yipz575YnIQiKK4puW88lqzo7OWy0= 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=APJ6vmA/; arc=none smtp.client-ip=209.85.210.175 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="APJ6vmA/" Received: by mail-pf1-f175.google.com with SMTP id d2e1a72fcca58-73c17c770a7so4801467b3a.2; Mon, 19 May 2025 07:26:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1747664776; x=1748269576; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2SDkPzy9RH9RATTYbdRqCXVmsGpXFpSAHI7QpsFMICQ=; b=APJ6vmA/faFZZQKW8ui42ZPkb5sFOSPTdqgtTHlHaS6UQ+V7BopVRAjrnIvZQGm/kx vsFzQjPJhBM6cFqRR2Mo8H/LFrBnIZMOb/7FYZRljyyGC/4klS5Kg4CR0IDjB9yAGZQl z78EtgNixTFNGFVXsFAWiIWdQ7s4lRiW48ohQqu69uh2Bfk6UVu5+V7yt0YmuKHYWspP P78+1+LjeO+62qcb3i8NH/zbgDRmi9WhFlIVlcXg/RZwF2eMmQjwbztysY9htaChzYoS 0aupOvkhMxM6i77x4RhgxVDCXzyoBPp8CYvXXssETpH80jMEoWkiErcxLeV72Rkuj/St JUQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747664776; x=1748269576; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2SDkPzy9RH9RATTYbdRqCXVmsGpXFpSAHI7QpsFMICQ=; b=mZUDBKp753v6nqhrnP6sVSkuOdT18VGAKf6v4bi1JA4McNovyc6+K7MmyiVwXeOKUj OQu7mKnG1kQXxmlWvZX0oFRiZMPhgeFeKlkY0zvSDjrQTRGYhh5T2COipCPcTz4U4vCE rNSsp4LRoOrcUvR2bDL4zajLGdhSQToLnszTQTDTQfaphCTNx0v2fhv0LC6AHcxJvrhl Xzkng2kfUg6KkdI/q2OI2NIhAEqmgqqiH6VVaAS9V/RE/l7hCqN3UhxAdDO/Pj3Bc3xM c3K+AWa27Jxrx0U9HUZIhaZEwVPGFPlbEL4zKL3YxpmsKvyC6/HnidYd3H/Zgq0NEfUm IdZg== X-Forwarded-Encrypted: i=1; AJvYcCUgF0U25djwhfEKKrAioPmBZYxUUjsOzEfnAU2lN7mKbiFfxIvjCY/anW/VSFz5K7+s4KQImiI+pSX7TKJP@vger.kernel.org, AJvYcCWb9wezDOWvcj0k0N6TWz72KjmSyCrWLwassxKhCh05oTDUOpXaLhQnfYGBs8Ilfm+mExykfQnofmk=@vger.kernel.org X-Gm-Message-State: AOJu0Yx+ruYweRuGyxX+cRjoA7ejbbjpkAaD1/5zzWNV9IhYfTtJzPZm StAwcviTXsbq/rfLgM9YskDY1L7vjXC+MiPci1Prm3Ta5giowBQnow37 X-Gm-Gg: ASbGncu4it0YrZPT/+xNI9Ola8QXxLFXloO4uyJE72Dvs8dYw/9uyIxWaYMCS5dlL/l 9+oJ5seq0Fxw+WCGXYhbr9kxXOQRZA84EhcPTbgUlgDubQOa2WP8q5A3Rx+qvwFF1oA4H3beJ7J 0HYEUXKeM7AoEZmY6PJPcdLw2+gwRi+uP4LXvBnLfT+cXhUwoaVXONDy0ONzi9JWsfLXdsldTe3 PGvKw4eOymWaIW28Bt0rNRhp1FWzpHi4B9Hk+pAVtJjtOoZMaoXBj33X2Yf+7REyfIRXAzoXJ51 cRrUJAsOvcw2Y0tBwZt/3FHSjRmEfVO1MfuxGjrhVANp5j3dMXye64QqmVLnz+3fSCSs X-Google-Smtp-Source: AGHT+IFVliOgI5KVl6qOEN0qtuBrpDs9j7s/ClZECT9Dvk6mL7nYUkBDU975EZEv9YLaUFDKtyQGWw== X-Received: by 2002:a05:6a00:944e:b0:736:5b85:a911 with SMTP id d2e1a72fcca58-742a97dba4bmr21333271b3a.8.1747664775819; Mon, 19 May 2025 07:26:15 -0700 (PDT) Received: from gye-ThinkPad-T590.. ([39.120.225.141]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-742a96e211csm6465303b3a.16.2025.05.19.07.26.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 May 2025 07:26:15 -0700 (PDT) From: Gyeyoung Baek To: Jonathan Cameron , David Lechner , =?UTF-8?q?Nuno=20S=C3=A1?= , Andy Shevchenko Cc: Gyeyoung Baek , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH RFC 2/9] iio: consumer: Define timestamp-related structures and constants Date: Mon, 19 May 2025 23:25:54 +0900 Message-ID: <20250519-timestamp-v1-2-fcb4f6c2721c@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250519-timestamp-v1-0-fcb4f6c2721c@gmail.com> References: <20250519-timestamp-v1-0-fcb4f6c2721c@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Define the required constants and structures on the consumer side. The `timestamp_enabled` indicates whether a timestamp is grabbed or not. This is passed to `iio_triggered_buffer_setup_new()` as an argument. The `timestamp_type` indicates which handler grabs the timestamp. This value is set by `iio_poll_func_register()`. Signed-off-by: Gyeyoung Baek --- include/linux/iio/trigger_consumer.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/include/linux/iio/trigger_consumer.h b/include/linux/iio/trigg= er_consumer.h index 2c05dfad88d7..5e6ff8738386 100644 --- a/include/linux/iio/trigger_consumer.h +++ b/include/linux/iio/trigger_consumer.h @@ -13,6 +13,13 @@ struct iio_dev; struct iio_trigger; =20 +enum iio_timestamp_type { + IIO_TIMESTAMP_TYPE_NONE, + IIO_TIMESTAMP_TYPE_CONSUMER_TOP_HALF, + IIO_TIMESTAMP_TYPE_CONSUMER_BOTTOM_HALF, + IIO_TIMESTAMP_TYPE_TRIGGER, +}; + /** * struct iio_poll_func - poll function pair * @@ -26,7 +33,10 @@ struct iio_trigger; * @timestamp: some devices need a timestamp grabbed as soon * as possible after the trigger - hence handler * passes it via here. + * @timestamp_type: indicates which handler grabs the timestamp. + * @timestamp_enabled: if true, automatically grabs the timestamp. **/ + struct iio_poll_func { struct iio_dev *indio_dev; irqreturn_t (*h)(int irq, void *p); @@ -35,6 +45,9 @@ struct iio_poll_func { char *name; int irq; s64 timestamp; + + enum iio_timestamp_type timestamp_type; + bool timestamp_enabled; }; =20 =20 --=20 2.43.0 From nobody Fri Dec 19 14:34:01 2025 Received: from mail-pf1-f182.google.com (mail-pf1-f182.google.com [209.85.210.182]) (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 1E5E6284687; Mon, 19 May 2025 14:26:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747664780; cv=none; b=HLNz03Pp6XkaQDPV2ymQKuEAnQ0k+ucUsXyPABclQalF1U7fFGbt82Wbbyd1cwr5guphxZaif0D7McnJf1qWI2BbDTWcKkRZ7q/YLFzV85lzQ25jWIJwQhEfyJ1tK3fjMXA6etChdovZnvz2BPDn+IEy5RQ3BloEXzqd8u3Zjik= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747664780; c=relaxed/simple; bh=6tyw7//S3oDV1Ghtwcm8ZMKZS9mcRgS9Mvb26goqhVs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ma6/lP+lVyA+KMfEtBjoiTX2gbzSVDIMDYmVF0ZuFrzZrcq7s6GwXI+YWFigdIW9csQA1EjG/CTxFQYIgwQj05W9tR3eBigsqrkm3Eg0qGjGX8ZSqI+aoiCCfKeIHiiy5OSthDRRRSBj56eCbYy8B+W/mO+bbSODRvjs/E3w9W8= 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=dj8PTqYY; arc=none smtp.client-ip=209.85.210.182 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="dj8PTqYY" Received: by mail-pf1-f182.google.com with SMTP id d2e1a72fcca58-74068f95d9fso4014066b3a.0; Mon, 19 May 2025 07:26:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1747664778; x=1748269578; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=FUObscyqJyDseU1fD1f5U5y4CmFZFif/DcNZ9LyKzkA=; b=dj8PTqYYoCwLHH40Fs96FsPSYoJ1OrVEGk5RXzYG55kuXhwno1vmFqZDImv8lWzCXN 6ebVtY1GTrTG5ilfX9B9bzi9fnwAyEWI5bG3WUHf5JxJGfRRvN2g47XWhsx/OBFK44FM A+GNroyFIf5rDHJhjl6Cf8KpkncfA1rq6TwEnhKg+Az8vSqPtm473SfuxP3ggA7JBnJS bO/TjRrWuwQTZZo6fuY/nU31g9ujrJFdgI6HdIIDnZB/dudRw9IBZhVmvjrOaYfTeHIQ GzygEGXadXzkeu8/ZfgpyO67b/pSGx625j0WwPglRONOi3P11pRbD1JJbJ057sbKEHA4 d6Rw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747664778; x=1748269578; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FUObscyqJyDseU1fD1f5U5y4CmFZFif/DcNZ9LyKzkA=; b=q118gdiFcOuRiY3pF3dSawKoKlBL4VNRQoMhfnHpxnZZM9pYaps+/zCNs9OlSNdmFO NCwfi34yMsww1xf1nUai0Fu6p5shCRdI6HYHJNPcn0J9ToOYhFxD0W96z9fq7Zb0EPUi RFWlKRZTBZMVHEdLz5JpZQ6u/ne4XjdM7u4OPPLbZQyoZjXTvq2HcrZ2Xkbwd79PhCTi ETzZaJHjs3zefeBDVvbQNJL6Qfv1/OjnmHXzyUAMeldWSB+jUMlpllH6j795lPAihCKh A5enzYFDX1TN31ZrzxDKlEunADbHrn0MGVfdxl37WFDN7DRpwgZK8kP09uso3LNTCfrM ekbw== X-Forwarded-Encrypted: i=1; AJvYcCW0eX3CuSPcSLUrSwEMnsVyfbDXGAdypTz1NMRHk320FT5aFz5jfnejmHlva5y+976vHCADpFSQPMvwjcnE@vger.kernel.org, AJvYcCXcLYkE5n86+vZmUvbZH7y+SgFfyHWi18Kx/bm75qLVM/SSeZm/k6R0of6jt4H3eekvUePp5jlxNWI=@vger.kernel.org X-Gm-Message-State: AOJu0YyeIVGTyKdJKITbvRfLXzxEcrEy9LAV+FTrRMc4Dod/bQYgR26N JBs2lL34TcRLk9XUOaA1g1WOmnt4Z6Ju387r1nDqeH0nrxXi5lHxdxx3 X-Gm-Gg: ASbGncsJcLHaQ2JqT/L4X5it7rhd220zh3R3cN06WwpHbrZsKqnkQ+aKIesaBxg2qGW C4pZLS0U5PtA11zkKXEE8zV4/fkb5Fvi6VQcvwvvRJWQvgvNAwpxiT6245blW5NG6h3Fa1IOx8G yxgUS47jf4eFWfurJbKs7/RPl7t0VaTSjE9FdtI9EWHJ3QhCcD/L45vtk8EqGoPedsbrHXa+gFA NLaOv1tuQrLesrkpWBNWCMJuoyLIMTQRD0X++JYDR0UfKcrZ5Wh6WbMRQuEIbEZdUllVBYXVA78 Up6KKAyN5lElqf9OIs3uDS0h3/cNdJ+KKcUK7Tw3g3lTy1T0FYTgch8jVQ== X-Google-Smtp-Source: AGHT+IFsS0XnWQ0f2eIOvnxtKkwQc1+JFiTGu1N0s36x0OlGwdwYRVGQDl3qXGcSQ44C5fzJHPotKw== X-Received: by 2002:a05:6a00:4642:b0:736:4fe0:2661 with SMTP id d2e1a72fcca58-742acce00ddmr15279541b3a.11.1747664778176; Mon, 19 May 2025 07:26:18 -0700 (PDT) Received: from gye-ThinkPad-T590.. ([39.120.225.141]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-742a96e211csm6465303b3a.16.2025.05.19.07.26.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 May 2025 07:26:17 -0700 (PDT) From: Gyeyoung Baek To: Jonathan Cameron , David Lechner , =?UTF-8?q?Nuno=20S=C3=A1?= , Andy Shevchenko Cc: Gyeyoung Baek , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH RFC 3/9] iio: consumer: Add new APIs of triggered_buffer_setup() family Date: Mon, 19 May 2025 23:25:55 +0900 Message-ID: <20250519-timestamp-v1-3-fcb4f6c2721c@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250519-timestamp-v1-0-fcb4f6c2721c@gmail.com> References: <20250519-timestamp-v1-0-fcb4f6c2721c@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Add new versions of the `iio_triggered_buffer_setup_ext()` APIs. (API names are tentative) iio_triggered_buffer_setup_new iio_triggered_buffer_setup_ext_new devm_iio_triggered_buffer_setup_new devm_iio_triggered_buffer_setup_ext_new iio_alloc_pollfunc_new these APIs take a bool parameter named `timestamp_enabled`. Signed-off-by: Gyeyoung Baek --- drivers/iio/buffer/industrialio-triggered-buffer.c | 82 ++++++++++++++++++= ++++ drivers/iio/industrialio-trigger.c | 33 +++++++++ include/linux/iio/trigger_consumer.h | 7 ++ include/linux/iio/triggered_buffer.h | 25 +++++++ 4 files changed, 147 insertions(+) diff --git a/drivers/iio/buffer/industrialio-triggered-buffer.c b/drivers/i= io/buffer/industrialio-triggered-buffer.c index 9bf75dee7ff8..9b99bf884ccb 100644 --- a/drivers/iio/buffer/industrialio-triggered-buffer.c +++ b/drivers/iio/buffer/industrialio-triggered-buffer.c @@ -14,6 +14,68 @@ #include #include =20 +int iio_triggered_buffer_setup_ext_new(struct iio_dev *indio_dev, + irqreturn_t (*thread)(int irq, void *p), + bool timestamp_enabled, + enum iio_buffer_direction direction, + const struct iio_buffer_setup_ops *setup_ops, + const struct iio_dev_attr **buffer_attrs) +{ + struct iio_buffer *buffer; + int ret; + + /* + * iio_triggered_buffer_cleanup() assumes that the buffer allocated here + * is assigned to indio_dev->buffer but this is only the case if this + * function is the first caller to iio_device_attach_buffer(). If + * indio_dev->buffer is already set then we can't proceed otherwise the + * cleanup function will try to free a buffer that was not allocated here. + */ + if (indio_dev->buffer) + return -EADDRINUSE; + + buffer =3D iio_kfifo_allocate(); + if (!buffer) { + ret =3D -ENOMEM; + goto error_ret; + } + + indio_dev->pollfunc =3D iio_alloc_pollfunc_new(thread, + timestamp_enabled, + IRQF_ONESHOT, + indio_dev, + "%s_consumer%d", + indio_dev->name, + iio_device_id(indio_dev)); + if (indio_dev->pollfunc =3D=3D NULL) { + ret =3D -ENOMEM; + goto error_kfifo_free; + } + + /* Ring buffer functions - here trigger setup related */ + indio_dev->setup_ops =3D setup_ops; + + /* Flag that polled ring buffering is possible */ + indio_dev->modes |=3D INDIO_BUFFER_TRIGGERED; + + buffer->direction =3D direction; + buffer->attrs =3D buffer_attrs; + + ret =3D iio_device_attach_buffer(indio_dev, buffer); + if (ret < 0) + goto error_dealloc_pollfunc; + + return 0; + +error_dealloc_pollfunc: + iio_dealloc_pollfunc(indio_dev->pollfunc); +error_kfifo_free: + iio_kfifo_free(buffer); +error_ret: + return ret; +} +EXPORT_SYMBOL(iio_triggered_buffer_setup_ext_new); + /** * iio_triggered_buffer_setup_ext() - Setup triggered buffer and pollfunc * @indio_dev: IIO device structure @@ -114,6 +176,26 @@ static void devm_iio_triggered_buffer_clean(void *indi= o_dev) iio_triggered_buffer_cleanup(indio_dev); } =20 +int devm_iio_triggered_buffer_setup_ext_new(struct device *dev, + struct iio_dev *indio_dev, + irqreturn_t (*thread)(int irq, void *p), + bool timestamp_enabled, + enum iio_buffer_direction direction, + const struct iio_buffer_setup_ops *ops, + const struct iio_dev_attr **buffer_attrs) +{ + int ret; + + ret =3D iio_triggered_buffer_setup_ext_new(indio_dev, thread, timestamp_e= nabled, direction, + ops, buffer_attrs); + if (ret) + return ret; + + return devm_add_action_or_reset(dev, devm_iio_triggered_buffer_clean, + indio_dev); +} +EXPORT_SYMBOL_GPL(devm_iio_triggered_buffer_setup_ext_new); + int devm_iio_triggered_buffer_setup_ext(struct device *dev, struct iio_dev *indio_dev, irqreturn_t (*h)(int irq, void *p), diff --git a/drivers/iio/industrialio-trigger.c b/drivers/iio/industrialio-= trigger.c index 54416a384232..527c3cf84be0 100644 --- a/drivers/iio/industrialio-trigger.c +++ b/drivers/iio/industrialio-trigger.c @@ -361,6 +361,39 @@ irqreturn_t iio_pollfunc_store_time(int irq, void *p) } EXPORT_SYMBOL(iio_pollfunc_store_time); =20 +struct iio_poll_func +*iio_alloc_pollfunc_new(irqreturn_t (*thread)(int irq, void *p), + bool timestamp_enabled, + int type, + struct iio_dev *indio_dev, + const char *fmt, + ...) +{ + va_list vargs; + struct iio_poll_func *pf; + + pf =3D kmalloc(sizeof(*pf), GFP_KERNEL); + if (!pf) + return NULL; + va_start(vargs, fmt); + pf->name =3D kvasprintf(GFP_KERNEL, fmt, vargs); + va_end(vargs); + if (pf->name =3D=3D NULL) { + kfree(pf); + return NULL; + } + pf->timestamp_enabled =3D timestamp_enabled; + pf->h =3D NULL; + pf->thread =3D thread; + pf->type =3D type; + pf->indio_dev =3D indio_dev; + + pf->timestamp =3D 0; + pf->timestamp_type =3D 0; + return pf; +} +EXPORT_SYMBOL_GPL(iio_alloc_pollfunc_new); + struct iio_poll_func *iio_alloc_pollfunc(irqreturn_t (*h)(int irq, void *p), irqreturn_t (*thread)(int irq, void *p), diff --git a/include/linux/iio/trigger_consumer.h b/include/linux/iio/trigg= er_consumer.h index 5e6ff8738386..213cd8560518 100644 --- a/include/linux/iio/trigger_consumer.h +++ b/include/linux/iio/trigger_consumer.h @@ -50,6 +50,13 @@ struct iio_poll_func { bool timestamp_enabled; }; =20 +__printf(5, 6) struct iio_poll_func +*iio_alloc_pollfunc_new(irqreturn_t (*thread)(int irq, void *p), + bool timestamp_enabled, + int type, + struct iio_dev *indio_dev, + const char *fmt, + ...); =20 __printf(5, 6) struct iio_poll_func *iio_alloc_pollfunc(irqreturn_t (*h)(int irq, void *p), diff --git a/include/linux/iio/triggered_buffer.h b/include/linux/iio/trigg= ered_buffer.h index 29e1fe146879..5648c382a506 100644 --- a/include/linux/iio/triggered_buffer.h +++ b/include/linux/iio/triggered_buffer.h @@ -9,6 +9,13 @@ struct iio_dev; struct iio_dev_attr; struct iio_buffer_setup_ops; =20 +int iio_triggered_buffer_setup_ext_new(struct iio_dev *indio_dev, + irqreturn_t (*thread)(int irq, void *p), + bool timestamp_enabled, + enum iio_buffer_direction direction, + const struct iio_buffer_setup_ops *setup_ops, + const struct iio_dev_attr **buffer_attrs); + int iio_triggered_buffer_setup_ext(struct iio_dev *indio_dev, irqreturn_t (*h)(int irq, void *p), irqreturn_t (*thread)(int irq, void *p), @@ -17,11 +24,24 @@ int iio_triggered_buffer_setup_ext(struct iio_dev *indi= o_dev, const struct iio_dev_attr **buffer_attrs); void iio_triggered_buffer_cleanup(struct iio_dev *indio_dev); =20 +#define iio_triggered_buffer_setup_new(indio_dev, h, timestamp_enabled, se= tup_ops) \ + iio_triggered_buffer_setup_ext_new((indio_dev), (h), (timestamp_enabled),= \ + IIO_BUFFER_DIRECTION_IN, (setup_ops), \ + NULL) + #define iio_triggered_buffer_setup(indio_dev, h, thread, setup_ops) \ iio_triggered_buffer_setup_ext((indio_dev), (h), (thread), \ IIO_BUFFER_DIRECTION_IN, (setup_ops), \ NULL) =20 +int devm_iio_triggered_buffer_setup_ext_new(struct device *dev, + struct iio_dev *indio_dev, + irqreturn_t (*thread)(int irq, void *p), + bool timestamp_enabled, + enum iio_buffer_direction direction, + const struct iio_buffer_setup_ops *ops, + const struct iio_dev_attr **buffer_attrs); + int devm_iio_triggered_buffer_setup_ext(struct device *dev, struct iio_dev *indio_dev, irqreturn_t (*h)(int irq, void *p), @@ -30,6 +50,11 @@ int devm_iio_triggered_buffer_setup_ext(struct device *d= ev, const struct iio_buffer_setup_ops *ops, const struct iio_dev_attr **buffer_attrs); =20 +#define devm_iio_triggered_buffer_setup_new(dev, indio_dev, thread, timest= amp_enabled, setup_ops) \ + devm_iio_triggered_buffer_setup_ext_new((dev), (indio_dev), (thread), (ti= mestamp_enabled), \ + IIO_BUFFER_DIRECTION_IN, \ + (setup_ops), NULL) + #define devm_iio_triggered_buffer_setup(dev, indio_dev, h, thread, setup_o= ps) \ devm_iio_triggered_buffer_setup_ext((dev), (indio_dev), (h), (thread), \ IIO_BUFFER_DIRECTION_IN, \ --=20 2.43.0 From nobody Fri Dec 19 14:34:01 2025 Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.177]) (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 78DCB284B2E; Mon, 19 May 2025 14:26:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747664782; cv=none; b=q5gxR+O2KkE6BJsmWN9l0ynnvXK/BXu97YVPhAvC11YV2lzFU8ZkFlFE4BDPnS4hNnYPIG8mxOMVqhfHj0YzQFN1mG+v7Iibu0rqaayDWcE6Ut2TA2hzHoWbRUqfpWtkqecAxHXIDkaft73pBE8jiSKZwaUSm6DwBD95PGloDsU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747664782; c=relaxed/simple; bh=9J45HtBubBmey7oBKiVmAPTwwvpT7Y142a0Hwq/B4+o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Z+kT4M28fhUxNfpimJeVcXaqcL5PT5FA6D0YLwzPkz/F96pLheVa/kNAWmvVlDXyMlk6XJWDLYLFX8qfPfJNufpFlaEG3xXd++us4lul2hQVPVUuTrGcjSwc3nAUfiNqCfzPSqo8pvNhlLWe/YFKkmLZCOSnMpNQ0ZIgX0iNQxw= 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=FTFX5W3N; arc=none smtp.client-ip=209.85.210.177 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="FTFX5W3N" Received: by mail-pf1-f177.google.com with SMTP id d2e1a72fcca58-72d3b48d2ffso4316828b3a.2; Mon, 19 May 2025 07:26:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1747664781; x=1748269581; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=72w6sNIQShW9+z7WOR+nkYITWdJqoFUq46toPD7dMQ8=; b=FTFX5W3NiuWbBQwVj4Wml6q9TqyST7nMfWWfc9Bbid4Ftthqr8c28F0rPJttnzvgS1 aQ7cDoxK8NCRTrltO5ZheJ9YfuDUwz+JCl1OhuNXxHglGD+CwrfRk9ETPXPdAJtVm2Nv KywgC1Phftqe6zNbhjIuNMP+JtVwwxD3ZMbj4eGzEybJUe6ME8wJRHSRamzW/nzi05TV Isl30UvsYy44+l+8es+C0eijDI9/XbsxdZIOBbF5VLrYS3ZA9GnKaqqgVfmDVw25ANEc figvKKTcij4wsvm7ocvWNmZb1mCJcKaiDXziTI4JIquOU60z0ywKLge4DhYmNWWZfaa+ NHoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747664781; x=1748269581; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=72w6sNIQShW9+z7WOR+nkYITWdJqoFUq46toPD7dMQ8=; b=iigugAVy+D0Jsgh+zVeQx1bJ6tOsT2mRCtbxLCBBH+DdlTvWK/BAC+5u1PE60qbv9W Zj1YRrl8WeVxFcnFAjQ+gVYOinad50PFvV1Fp12LubeRiBHbeMWFZeL3fPp461tZpPBz oRFBK+A5Tgvwtj9KHu0D1ylS3iXML8057AQCXcxoR3BqPhPYPUXQ7lIQ7ZMf/eirF8BP xu3a/FyLLgyRzp46QvhvOaCqoSiKpzjb9eT7ngYevsSzIxEFV9hvNiGfSGX54vjiVR10 NyjUuf6IQYxtRhIcIkXKJBdBgJTEKFri36E4hueczvSzq8rwk39Z//1J27NSYBjZXkcY 1BTw== X-Forwarded-Encrypted: i=1; AJvYcCURQHe24x0M3xp0LiRe/xP8HC3QoAOyCtEtoDXIqdAv0JFeapKQuWoWER4P9+Cd9k6frUhT68ccowU=@vger.kernel.org, AJvYcCVoD4e/GUiyOtmJTfUslJfxPGpL+Z6gKJDeKoLsHSA6QWyA4kZhCvZ+mqNuSwupx+G7XzqogfNtl+SzBVth@vger.kernel.org X-Gm-Message-State: AOJu0YwxBux8q7UvskbPWbDyfqZXGrsX8GYRNX9CBQJZP2Xl5ddUQoLy 9NflDx5Gx4kCGcFrgXzKNGgXe/airD6URF8pNaBf4K+nG3AV6utv/Dpf X-Gm-Gg: ASbGncvrFdx+rLGbiMCVpI1ulJsSNxGZmPKD/40fjXQXFOXaZFU4Tkw1eTPTYOQO8gA 5Y8y6V2C+hrR65XM2c3DVQc/loqrtXj4o/vQQjaM4IL3zTdCVhbQl5ORtG3mI6N3j1+WB2crNGm WaocBENfUm2JimP4+GEAexqdL3rKTfzrmkJfb+m3PK8cqtDWx3ydN505VYobZjc6coCLooziZnA qYatoV8UMKSjVFsMJ8hFiYFp8WeU1ithrUUyDKDccclnHmOqWTktFaUlYxoA88wdzh1u4ZWTzVn 6QBIADfQ+3IT0sLUSqJI9/EFqRBv3rT1ruIZh+X9ijUVwXFAOD/DISW7Bg== X-Google-Smtp-Source: AGHT+IFoA1qfvEQtDcQsD+Ns9UkG9OyzBjikf6koFx8PXX6r7HAzxGDdeXp5GUGIGcBI9B9HAkjBNA== X-Received: by 2002:a05:6a20:432b:b0:215:cf53:6e6d with SMTP id adf61e73a8af0-2170ce19ec6mr20162279637.27.1747664780557; Mon, 19 May 2025 07:26:20 -0700 (PDT) Received: from gye-ThinkPad-T590.. ([39.120.225.141]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-742a96e211csm6465303b3a.16.2025.05.19.07.26.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 May 2025 07:26:20 -0700 (PDT) From: Gyeyoung Baek To: Jonathan Cameron , David Lechner , =?UTF-8?q?Nuno=20S=C3=A1?= , Andy Shevchenko Cc: Gyeyoung Baek , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH RFC 4/9] iio: consumer: Add new API iio_poll_func_register() Date: Mon, 19 May 2025 23:25:56 +0900 Message-ID: <20250519-timestamp-v1-4-fcb4f6c2721c@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250519-timestamp-v1-0-fcb4f6c2721c@gmail.com> References: <20250519-timestamp-v1-0-fcb4f6c2721c@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable This API wraps either the tophalf or bottomhalf handler to grab a timestamp, based on the consumer's `timestamp_enabled` and the trigger's `trig_type` a= nd `early_timestamp`. Signed-off-by: Gyeyoung Baek --- drivers/iio/industrialio-trigger.c | 58 ++++++++++++++++++++++++++++++++++= +--- 1 file changed, 54 insertions(+), 4 deletions(-) diff --git a/drivers/iio/industrialio-trigger.c b/drivers/iio/industrialio-= trigger.c index 527c3cf84be0..1a7bab2741af 100644 --- a/drivers/iio/industrialio-trigger.c +++ b/drivers/iio/industrialio-trigger.c @@ -65,6 +65,24 @@ ATTRIBUTE_GROUPS(iio_trig_dev); =20 static struct iio_trigger *__iio_trigger_find_by_name(const char *name); =20 +/* Only be invoked in consumer top-half */ +static irqreturn_t iio_pollfunc_top_half_wrapper(int irq, void *p) +{ + struct iio_poll_func *pf =3D p; + + pf->timestamp =3D iio_get_time_ns(pf->indio_dev); + return IRQ_WAKE_THREAD; +} + +/* Only be invoked in consumer botom-half */ +static irqreturn_t iio_pollfunc_bottom_half_wrapper(int irq, void *p) +{ + struct iio_poll_func *pf =3D p; + + pf->timestamp =3D iio_get_time_ns(pf->indio_dev); + return pf->thread(irq, p); +} + int iio_trigger_register(struct iio_trigger *trig_info) { int ret; @@ -270,6 +288,36 @@ static void iio_trigger_put_irq(struct iio_trigger *tr= ig, int irq) clear_bit(irq - trig->subirq_base, trig->pool); } =20 +static int iio_poll_func_register(struct iio_poll_func *pf, + struct iio_trigger *trig) +{ + irq_handler_t tophalf =3D NULL; + irq_handler_t bottomhalf =3D pf->thread; + int ret; + + /* + * The consumer does not need timestamp. + * Just request raw irq handler. + */ + if (!pf->timestamp_enabled) + goto out_request_irq; + + if (trig->trig_type & IIO_TRIG_TYPE_POLL_NESTED) { + bottomhalf =3D iio_pollfunc_bottom_half_wrapper; + pf->timestamp_type =3D IIO_TIMESTAMP_TYPE_CONSUMER_BOTTOM_HALF; + } else if (trig->trig_type & IIO_TRIG_TYPE_POLL) { + tophalf =3D iio_pollfunc_top_half_wrapper; + pf->timestamp_type =3D IIO_TIMESTAMP_TYPE_CONSUMER_TOP_HALF; + } else { + pr_err("Trigger does not set valid trig_type."); + return -EINVAL; + } + +out_request_irq: + return request_threaded_irq(pf->irq, tophalf, bottomhalf, + pf->type, pf->name, pf); +} + /* Complexity in here. With certain triggers (datardy) an acknowledgement * may be needed if the pollfuncs do not include the data read for the * triggering device. @@ -296,10 +344,8 @@ int iio_trigger_attach_poll_func(struct iio_trigger *t= rig, goto out_put_module; } =20 - /* Request irq */ - ret =3D request_threaded_irq(pf->irq, pf->h, pf->thread, - pf->type, pf->name, - pf); + /* Register consumer handlers */ + ret =3D iio_poll_func_register(pf, trig); if (ret < 0) goto out_put_irq; =20 @@ -352,6 +398,10 @@ int iio_trigger_detach_poll_func(struct iio_trigger *t= rig, return ret; } =20 +/* + * Will be deprecated. + * We do not need to set this as a top half manually to grab a timestamp. + */ irqreturn_t iio_pollfunc_store_time(int irq, void *p) { struct iio_poll_func *pf =3D p; --=20 2.43.0 From nobody Fri Dec 19 14:34:01 2025 Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.177]) (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 CD9D2284B4B; Mon, 19 May 2025 14:26:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747664785; cv=none; b=OplUmRJPA9hbU3niZM/mYVlRhlGZGGNrHUHlof4reJcNg3JMTwd3nplihsDk/4Nu8borqlv1qVWxoRu74LpA7kpKruw4vEWYTiIzR3aLXr4URObcHfZcorAezzUSApEByCnAgJP0PmWZx5Q/TOQOSmnG0uarmFFSmz0Ujm4D3fw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747664785; c=relaxed/simple; bh=lS/HUz45oQx+9z2eaRmHfIfkvPWTLAB+/fytA1bUjG4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=jyLvWbhlFFDTqpU/m31XBOQ42lUP6ANK4FvYH8nJVQDhfEwV/5aSp+vM0sqc+dp1sAUCemQtXNz9FsplEf5GshFwLKIzwLma7aiaqyMYg7Im8H/wd5DFz8LtFln5XNLqJeoqHAq0w16TBmkBnq8zjL9J7fQoCBjmMuNQI6SEbfY= 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=PdGpXOaq; arc=none smtp.client-ip=209.85.210.177 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="PdGpXOaq" Received: by mail-pf1-f177.google.com with SMTP id d2e1a72fcca58-74068f95d9fso4014248b3a.0; Mon, 19 May 2025 07:26:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1747664783; x=1748269583; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=EA/lIxRtTaYgwRnB6DUO1QwQzE9WOnzeg19F8rZeoAA=; b=PdGpXOaqJuX6w9gArPED6M0RlKCr2wow9xogZW579uXRvzAkqDUiEIvXeO35Zfr6yv QhzQwdlPCS+1bzs1tNpk0uc23pzRV6nUA2dOZYwG+S8U6Hc6y0e3Tsmvc+ARVw5JbNQC /oOb2TMKzWAX7mqFhZ3Py8jum6KUV21UdT/BiVwREGOJM4L6B0JPM9OKyYexcHcggcTk G4lE40IYoL9jbmWg/d3ASS3dWxN5lYRhk+gBpXdqH3teyoxbk9uD4F+9HEKjmKggl/qG ZWdYq02qUb4ZSDdb1Qjq7IhxwU1d7f95YivcBdhcECpMy20FGPwdf7N9hfy/fr3pWp3d BaKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747664783; x=1748269583; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=EA/lIxRtTaYgwRnB6DUO1QwQzE9WOnzeg19F8rZeoAA=; b=cQc3srDoNhbKX5zPlWi6PqX4HeHZ+JrLqyuoQFKs0cF2bZzCvxtFqntWQ1m74xADiI vL+PVhy1sTKjHZDJmINFg2jH9qCWBogDgQ8BfYJmRGY4EjZZ8AjFGLO64TWgBnJIrEl3 9K4vg58xTT2/sw0m6sbqoBd0SVhEX3cL/4obJNNnbxGm+2yNJ6eV4WRmxep/c1czj+EV bQ0UGr8aiPg1ywIV1iKsxbhsSK0hz7nFKDOQSe3cETL57I1IycrbejD7tUCT/35E70qD VGGvQosBKAygMBXdraNQdyPAl47g7fXCNs48y9lVvEYQXIgHwQ/yI1RaHft0y9rJ1qgC dskQ== X-Forwarded-Encrypted: i=1; AJvYcCVJvPVEdrwuE0tcaQJFuEIYpAJUaS1+sdybZcCJgotcRPsNBa1zmoxFVsdgJY+9edsC3L8n2YFSR/coj6OX@vger.kernel.org, AJvYcCXavhzZSNKdmwz91eeo/iFmR/T+FjB/FboiaAtpbgiyB2aLLJ/M9gTUO31dPY+z8HgqH51tnVXMNJM=@vger.kernel.org X-Gm-Message-State: AOJu0YyYLKVtzb4vnlAX4HlLV0ADYbueDoWH1TfBkTMIJx3Z2JHawUZg BNxWtv9SIn86NuLZ8NwD8NULrWaydWnIuvJYAsf0whK0jnZLFvREreI5 X-Gm-Gg: ASbGncuR+akFhaYsGyxZICi5ThHg2QWCSY/dVYElaW29q1i5jC63Vmt8hhEq8Ysikae HbIkG7FXMwcIp/NcaWYYJOMyKTsoojixp4MaPKfIFSV59iDMpJkEAe8DWTOtIZ7slJ3TOiB6IMY WEhqSmS7N4XQRMceRoJc+9H6Btd4Up/N2vulWLKnRYZCd2oOtdi5YX4FIN8qhgzcVAcsUF+llst RQwumAdV6jgniWqpYVwj7pwXjZeAnDnlFY488Dz6dRo/RGMnFFT+pgWaZWL5zRTQVYwXHrVWxnY 2v5iS7rQkV9Nv2fhNOqyljOMQzhWvWW1MsTjZ9qaep/nI/+KOjc7T0q9Iw== X-Google-Smtp-Source: AGHT+IGkFiDQ5bFXMe7ArKrN+3W0Jtx7TMgPz45kogXhfnRdGYIpduCE80798VLlxvnsMymGc3UhdQ== X-Received: by 2002:a05:6a00:4106:b0:740:9d6f:a73b with SMTP id d2e1a72fcca58-742acd509c3mr15131986b3a.17.1747664783046; Mon, 19 May 2025 07:26:23 -0700 (PDT) Received: from gye-ThinkPad-T590.. ([39.120.225.141]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-742a96e211csm6465303b3a.16.2025.05.19.07.26.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 May 2025 07:26:22 -0700 (PDT) From: Gyeyoung Baek To: Jonathan Cameron , David Lechner , =?UTF-8?q?Nuno=20S=C3=A1?= , Andy Shevchenko Cc: Gyeyoung Baek , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH RFC 5/9] iio: consumer: Add new API iio_pollfunc_get_timestamp() Date: Mon, 19 May 2025 23:25:57 +0900 Message-ID: <20250519-timestamp-v1-5-fcb4f6c2721c@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250519-timestamp-v1-0-fcb4f6c2721c@gmail.com> References: <20250519-timestamp-v1-0-fcb4f6c2721c@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable As the timestamp is automatically grabbed, the consumer can simply read it using this API. Signed-off-by: Gyeyoung Baek --- drivers/iio/industrialio-trigger.c | 6 ++++++ include/linux/iio/trigger_consumer.h | 3 +++ 2 files changed, 9 insertions(+) diff --git a/drivers/iio/industrialio-trigger.c b/drivers/iio/industrialio-= trigger.c index 1a7bab2741af..d6b0e1ec4153 100644 --- a/drivers/iio/industrialio-trigger.c +++ b/drivers/iio/industrialio-trigger.c @@ -398,6 +398,12 @@ int iio_trigger_detach_poll_func(struct iio_trigger *t= rig, return ret; } =20 +s64 iio_pollfunc_get_timestamp(struct iio_poll_func *pf) +{ + return pf->timestamp; +} +EXPORT_SYMBOL(iio_pollfunc_get_timestamp); + /* * Will be deprecated. * We do not need to set this as a top half manually to grab a timestamp. diff --git a/include/linux/iio/trigger_consumer.h b/include/linux/iio/trigg= er_consumer.h index 213cd8560518..279c88cae675 100644 --- a/include/linux/iio/trigger_consumer.h +++ b/include/linux/iio/trigger_consumer.h @@ -65,8 +65,11 @@ __printf(5, 6) struct iio_poll_func struct iio_dev *indio_dev, const char *fmt, ...); + void iio_dealloc_pollfunc(struct iio_poll_func *pf); + irqreturn_t iio_pollfunc_store_time(int irq, void *p); +s64 iio_pollfunc_get_timestamp(struct iio_poll_func *pf); =20 void iio_trigger_notify_done(struct iio_trigger *trig); =20 --=20 2.43.0 From nobody Fri Dec 19 14:34:01 2025 Received: from mail-pf1-f171.google.com (mail-pf1-f171.google.com [209.85.210.171]) (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 326D4285404; Mon, 19 May 2025 14:26:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747664787; cv=none; b=NdceuOC6ho6p2+ffqYfL0tgV8nzkcI9giHBt9XS5GQ2LVOvLELBPjAoC81X93Adbjxc/eJSlM19KPXznCRwLktS0zgcDkLxtzaH6s8+K5tKVMOpU/CNC4VVe0pVSPXx2UTKY+lGYrE91nbU4q6T/5omNoHlTGQOw63lkjsziOKM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747664787; c=relaxed/simple; bh=vZ1t4A51HBNBV0vSdf2YJOMmppC2iughxgxQzwPkvts=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=uUt83+fZJBvYF4pg3SJ5P9JvPlbXo18zSmQRSJb7W4YZ60GnYAKCWNoNpnhbbSkZ4f5VyBMRn8RCFDsgNSgMD7d6A6llKQFLyuLsBFOiKPdEWOTDYEqivqtbJqG0pOT5LK0oIf8YWTF9FAV+cS4kLQy25+S8HcK5p52s4JfI1FU= 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=iuLTBbq5; arc=none smtp.client-ip=209.85.210.171 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="iuLTBbq5" Received: by mail-pf1-f171.google.com with SMTP id d2e1a72fcca58-74264d1832eso5835373b3a.0; Mon, 19 May 2025 07:26:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1747664785; x=1748269585; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=UPZsREccUdFYIK4k967V5KtxVftBRfR0ix29sWoMslc=; b=iuLTBbq5dOgPXbfpvO7MYE0jpVkXIQRvexcXYmqeSUGLyXgQR4CRXmoA2VGYPFPpWs ZOU8ONQO2ihIVwUeJYxoAMA+pQmFlkEY972BYp8ehP5PM1ArKhdSBVsjtOBbqUUmBmbU iVi6eKPOeqMGfAxSUP5lz9UEdUZ2jhLx3id9jTCgy6XlI6T/5trU7QkRg8ZuW28ra7ww /6iesEauCO2CLL8SqJQZDU0PLT8HUPxyrY07AlsCXoFwk6QmthEFt6cQmdwCH3PD4Z5/ WpgZbgO7xQ7vcYzoazQUCDu+2ErxvMMC3i52ns45aaaTb1kcYPisAWpUR9ucDNXhJnzN //gg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747664785; x=1748269585; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UPZsREccUdFYIK4k967V5KtxVftBRfR0ix29sWoMslc=; b=QEuKmDZQmvtOLP8y7njr5mv1vFDkst+ues1XJgjCy2SIdvpQlkKJ1WfrWfF7P64B+z QVtJt/nawGd8sr6Eg8Mtv58y31ooG6U5e+5L+qWkyzXU3nga9W8Kamyzq3wvDekdrYeJ pkFeKTX7evwtIMD5R46ruuU3SLs7nG9Rh189HH9H2Hl1rvzK2l0/2zuvkClHogi+D2Lo AR8yjK0eDy2Zmd9BvGQ615J/9AzA7pgH6ogRc11TrJzSVZhn9COZD2vxe/+GnlsAzGFa DCoZhG300nVmyHIPKChPfuwfs5HwTntHM0v26+r0JC3BZXOcAuVe5v3WvVDjLnBNhVvN Znjw== X-Forwarded-Encrypted: i=1; AJvYcCV1nUYHc8ruxYuvnCuADiCl8MrC0ms4LSx6w3Tqks1htp2agyWmmxtq0pFr0UUAu3yDNvCejb/Os+A=@vger.kernel.org, AJvYcCX8ckFAWmqlWsFeWYM8A5Q8PqT02l2SwtJu5s67Kn+0BM+96bVGc+pOwwQVmL2MDBrMmc9XKJlsb2ltsjJo@vger.kernel.org X-Gm-Message-State: AOJu0YxepjgH+RKm3+zoIDD0racrboYj8fzVumIeYrAYZyHFBJgvtNIX 9AfT9iPe9XEfuP8hSHv90Qv7XgNPvAMYtv6XwV6jzArv87cjCSR048LP X-Gm-Gg: ASbGncs4WmHGjKLBwtwjzS15UXTtYWmWHUnrxJtNk7KbqFcwAactIxkkWKaUYkh179T JWefldnIffwXJFanNbskPNiY7YS8V4cnTP8khsHqxbg4br1XFWwnCrXMqOL8zA/IVCUy5oe6ax5 aOU3S1r3xMX9mHkYOJNBScIAxHLIXhGLz5DfjNACxvCrbErGI1INnTeyMQTfLnC1iBok1wnkzIo IXAKMbc6TddGavSIjJ4Dbi6KVAkx5GwKZi2F1JVKmRCS9Ke14J87dc2qWuel35cVnLTiCYqBF+w HQ7RMRftbBXc5H2jKRj+0mYhmsLJskEddxR0HlOw3t9RXTPF8RM0IQnfhw== X-Google-Smtp-Source: AGHT+IHegutPpp+7Mq2QigLGVv5E6x4Qai4KUmb/XahCPIf3K57/IVQkrVmCbOtx0FZLO6yMB5m9LQ== X-Received: by 2002:a05:6a00:919f:b0:742:a82c:d832 with SMTP id d2e1a72fcca58-742a98e8fdamr20168635b3a.24.1747664785410; Mon, 19 May 2025 07:26:25 -0700 (PDT) Received: from gye-ThinkPad-T590.. ([39.120.225.141]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-742a96e211csm6465303b3a.16.2025.05.19.07.26.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 May 2025 07:26:25 -0700 (PDT) From: Gyeyoung Baek To: Jonathan Cameron , David Lechner , =?UTF-8?q?Nuno=20S=C3=A1?= , Andy Shevchenko Cc: Gyeyoung Baek , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH RFC 6/9] iio: trigger: Define timetamp-related structures and constants Date: Mon, 19 May 2025 23:25:58 +0900 Message-ID: <20250519-timestamp-v1-6-fcb4f6c2721c@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250519-timestamp-v1-0-fcb4f6c2721c@gmail.com> References: <20250519-timestamp-v1-0-fcb4f6c2721c@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The `trig_type` indicates whether the trigger calls poll() or poll_nested(). The `early_timestamp` indicates whether the trigger grabs the timestamp at = the trigger. We need this to prevent the consumer from overwriting the timestamp. To allow the trigger to directly write the timestamp into the consumer's po= ll_func, add poll_func pointer member to the iio_trigger structure. However, I'm not sure if having a poll_func pointer member in iio_trigger is a good approach. Would this approach be acceptable? Signed-off-by: Gyeyoung Baek --- include/linux/iio/trigger.h | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/include/linux/iio/trigger.h b/include/linux/iio/trigger.h index bce3b1788199..f3b89a1e0318 100644 --- a/include/linux/iio/trigger.h +++ b/include/linux/iio/trigger.h @@ -36,6 +36,10 @@ struct iio_trigger_ops { struct iio_dev *indio_dev); }; =20 +#define IIO_TRIG_TYPE_POLL BIT(0) +#define IIO_TRIG_TYPE_POLL_NESTED BIT(1) +#define IIO_TRIG_TYPE_BOTH (IIO_TRIG_TYPE_POLL | \ + IIO_TRIG_TYPE_POLL_NESTED) =20 /** * struct iio_trigger - industrial I/O trigger device @@ -56,7 +60,10 @@ struct iio_trigger_ops { * i.e. if we registered a poll function to the same * device as the one providing the trigger. * @reenable_work: [INTERN] work item used to ensure reenable can sleep. + * @trig_type: [DRIVER] specifies whether the trigger calls poll(), poll_= nested(), or both. + * @early_timestamp: [DRIVER] set to true if the trigger supports grabbing= timestamp. **/ + struct iio_trigger { const struct iio_trigger_ops *ops; struct module *owner; @@ -76,8 +83,13 @@ struct iio_trigger { struct mutex pool_lock; bool attached_own_device; struct work_struct reenable_work; -}; =20 + /* RFC, exists to access the consumer device=E2=80=99s pollfunc. */ + struct iio_poll_func *consumer_pf[CONFIG_IIO_CONSUMERS_PER_TRIGGER]; + + int trig_type; + bool early_timestamp; +}; =20 static inline struct iio_trigger *to_iio_trigger(struct device *d) { --=20 2.43.0 From nobody Fri Dec 19 14:34:01 2025 Received: from mail-pf1-f175.google.com (mail-pf1-f175.google.com [209.85.210.175]) (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 893E42857C9; Mon, 19 May 2025 14:26:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747664789; cv=none; b=B7APpTxWEa3TNXekhVQFssFH6BKBq4+iUXEAoHMV0Kp8RyiC/YDqtNAEyhZVG8PMYW3CuG+DlJvXUCxmVBJuq8c9kwtmEAYDaNES1dP964QtggUD2B2/RKEkpgMz7RWgKsNV7J2JLki4H2UgV4SdtH0EfDKYQ928AvxYJWz/0/0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747664789; c=relaxed/simple; bh=/RPPP+LhZOCwn7VKPxpog19sLuXZfd33R51o4hptkMA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ZcheBf0HHNoun8oT2H7r0xp7z8GapaPoRUamsie0rZ8Uy500LiSh2veJ9aFP6ay6ax7rALPnNx+7tgTD+j7RB4G4ffGhzQlyAaTb4le49VUw7/G2Kv/o4QtvPXAV+wkTLmMVrsybqlZ5/j2nqKWQcKC+zcLwEPKSDYlt5Q/ieB0= 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=PDXJxmtB; arc=none smtp.client-ip=209.85.210.175 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="PDXJxmtB" Received: by mail-pf1-f175.google.com with SMTP id d2e1a72fcca58-742c2ed0fe1so1863966b3a.1; Mon, 19 May 2025 07:26:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1747664788; x=1748269588; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=3OLcPOuf7wIYZebsW+9sYq9tDaVIjAA8Pb1YresFO58=; b=PDXJxmtB8KHcb0gefnnfkOLSW9dpT4vYpvZmyWVEVvQ234G4XnlYoEo3Agcbe4iOfL +yzbYCtK8aAAmRqhYFJw7RAVurVM7yj4Df5YKM7tPJS5FTo2yFTQNU/vGmMbrVeLy3Jt +dKPeC+soopgow9DweVpMBUzx4ttb7jE1JjFGdG1wkjgMyMrfMhiEMFi9BPbWk4+lQy2 W9fDcGL/w2fYOqG3UB4oDqYkimWon4NMjICTmZmvSvrFbyw9pkitkCrfYrkJd6Z8KIXZ wCQ3sgYWgn3GQU3LKdl38srE2Rm2qg+8PDHIbEDQktWh/hs2prnHOOCVXimSgavSA/gM 3XWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747664788; x=1748269588; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3OLcPOuf7wIYZebsW+9sYq9tDaVIjAA8Pb1YresFO58=; b=wLs+reVNkgxmB/uKvLX2aJVGiIYS/HzTjaBhsUxuriwGebiLJb1ld10N6ECafcrISB YUmBuaWxb6QnLi60ZL/3zGuEM4WBSEjAW5V1E98kpj11dTXcE0Gpo8J/UvBt2L+zSXeN 5QPD4npQoGMKMU+JQdTAm9suzC9pAxOJ5Ayuy61vf3pfix+u3XSplh7MrgJ1gofCsXU4 RPH6BtwDExUHV2+OZrN1sAQ2GGjhOCdj+y3kd9qLhliqV87+clCD9oJQNtktclLU3ssx Cz7onMiN1DHmUgFZiHVJbL4CxI1vxdaArnG50b93k+Os/7aERC7l8AWz3nbSmBgXPtnJ A7+A== X-Forwarded-Encrypted: i=1; AJvYcCU2Ba/sxEQgzHaxnyqIqWvjJ6ikKfZxc47xBXtGB3gRuEiNQ8M49AjTXs5JV+0T8ksFnsceLrHa6847lj77@vger.kernel.org, AJvYcCWygF1GGIf0vnMPgmDAc8SJiS3DrmXzJLDyZisyWZFw+N5AJDIYe/cq3mi96hlLL5oYuKjN8n5cshM=@vger.kernel.org X-Gm-Message-State: AOJu0YyOghvCk9zD9fYCXPynwMYQOHGWS1+ZMOoXE9fK6zXHVfWVaMaH 8r5h4Vgg37YSs9QvIYs4oFUuaMfXDI6ST8+/ULVc2+JNsPPP68sDQg3s X-Gm-Gg: ASbGnctxf0LGRA1HD/b1z07KLbKVFDnrrPFaM/7UuCGQIjrteU4BDdpEZQIl63eZpo6 pDXhLKPqmXhKWmi7ind+Gvr2WOgCIN4i6ckPBUcHNqvM/6vBHwxs7eoCM9TL2CY2KYteRk9ugcH crrBDlNkmkDB9nUF9pLS4lD8mXvb1ZZP02/gtf13thfICs89TLtRHo6Oa37C7vbWl1pvkgmL8Cn 0wfXf6bQzMuXHXk7plAMKVIZJKOw9GnKUxAqfCmGeSSPvW7JtxwuL3EhqL7L4PjQ1uWCIxWiWhg RLaPldrPc+nTxAuIkx27qBe0KD2G9o5OfSyOUjVOz1EoiIzz+swHK3U+Ng== X-Google-Smtp-Source: AGHT+IGzUPn/3RyJWEZm6FIIuvUJxbJaW5nf+G1KJHFf37qmTL6hLA8x+1vlGpfzdBfwPsu1dTn3rg== X-Received: by 2002:a05:6a21:3990:b0:1ee:e24d:8fe3 with SMTP id adf61e73a8af0-2162189f499mr18239254637.10.1747664787849; Mon, 19 May 2025 07:26:27 -0700 (PDT) Received: from gye-ThinkPad-T590.. ([39.120.225.141]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-742a96e211csm6465303b3a.16.2025.05.19.07.26.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 May 2025 07:26:27 -0700 (PDT) From: Gyeyoung Baek To: Jonathan Cameron , David Lechner , =?UTF-8?q?Nuno=20S=C3=A1?= , Andy Shevchenko Cc: Gyeyoung Baek , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH RFC 7/9] iio: trigger: Add new API iio_trigger_attach_timestamp() Date: Mon, 19 May 2025 23:25:59 +0900 Message-ID: <20250519-timestamp-v1-7-fcb4f6c2721c@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250519-timestamp-v1-0-fcb4f6c2721c@gmail.com> References: <20250519-timestamp-v1-0-fcb4f6c2721c@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable This new API is used in `iio_poll_func_register()` to handle the case where the trigger writes a timestamp directly into the consumer (i.e. early= _timestamp =3D=3D true). Signed-off-by: Gyeyoung Baek --- drivers/iio/industrialio-trigger.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/drivers/iio/industrialio-trigger.c b/drivers/iio/industrialio-= trigger.c index d6b0e1ec4153..f394933b9d0a 100644 --- a/drivers/iio/industrialio-trigger.c +++ b/drivers/iio/industrialio-trigger.c @@ -288,6 +288,15 @@ static void iio_trigger_put_irq(struct iio_trigger *tr= ig, int irq) clear_bit(irq - trig->subirq_base, trig->pool); } =20 +static int iio_trigger_attach_timestamp(struct iio_trigger *trig, + struct iio_poll_func *pf) +{ + /* RFC */ + trig->consumer_pf[pf->irq - trig->subirq_base] =3D pf; + + return 0; +} + static int iio_poll_func_register(struct iio_poll_func *pf, struct iio_trigger *trig) { @@ -302,6 +311,16 @@ static int iio_poll_func_register(struct iio_poll_func= *pf, if (!pf->timestamp_enabled) goto out_request_irq; =20 + /* + * The trigger supports grabbing timestamp. + * Just request raw irq handler. + */ + if (trig->early_timestamp) { + ret =3D iio_trigger_attach_timestamp(trig, pf); + pf->timestamp_type =3D IIO_TIMESTAMP_TYPE_TRIGGER; + goto out_request_irq; + } + if (trig->trig_type & IIO_TRIG_TYPE_POLL_NESTED) { bottomhalf =3D iio_pollfunc_bottom_half_wrapper; pf->timestamp_type =3D IIO_TIMESTAMP_TYPE_CONSUMER_BOTTOM_HALF; @@ -395,6 +414,9 @@ int iio_trigger_detach_poll_func(struct iio_trigger *tr= ig, module_put(iio_dev_opaque->driver_module); pf->irq =3D 0; =20 + /* RFC */ + trig->consumer_pf[pf->irq - trig->subirq_base] =3D NULL; + return ret; } =20 --=20 2.43.0 From nobody Fri Dec 19 14:34:01 2025 Received: from mail-pf1-f169.google.com (mail-pf1-f169.google.com [209.85.210.169]) (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 D84482857F7; Mon, 19 May 2025 14:26:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747664792; cv=none; b=md7/Z2ebmYG20U6Xaa7ssHshEdk8mM3tGDVZyvNA8uErMqaVFyDEq7JZ4TLMblK4/uPmzlajGFxvl92ffHaBVfoXtIkJcJkbiDvaHOHUiBkAndGBOQ0AQ9f4RD77AkDbOXnjQS+Aw3UTUgp8WTZO3qsvmExlM/tejF23X/Maq/g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747664792; c=relaxed/simple; bh=zjN83KWFIllAO8wzvZzv+RKCQLnKnBP+FKXxjhFv34o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ASHlLsOjYI6A/As7Nphiu+Km7GHw8dq9bFHHd6uCZ9bppE5YuH4Lub+IqYCNM26FrPiZz5pbAwV85CDP0qwh65NGm2zqbWXPDZt5v/7qxFu3VGZF4ccPxDM3ULL64wAvIFWAxobr8WNa9YQS1jFZ93IKY555/VQzPIwBacyukdc= 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=OS2Yl4+q; arc=none smtp.client-ip=209.85.210.169 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="OS2Yl4+q" Received: by mail-pf1-f169.google.com with SMTP id d2e1a72fcca58-74019695377so3483419b3a.3; Mon, 19 May 2025 07:26:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1747664790; x=1748269590; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=zPSK08R64NjDKjVa8ynPBVMp8t7R/JlH6tOj8tW7ci0=; b=OS2Yl4+qU6P9xPK+KTGap22R/23CT7uHB5qbnBquM1vtl/tMzw8pWQwlX7mEVy1cS6 5nuxKPQO/Ku+LGQjkqfan19j0qP/wdU885os3eVCi3ZivzCmeyGQ0S798NUTiibVwJu6 SUCaskGJEnhIykbvT4L4f1iGX9ir+TTisWYbDaik4ZjWZYlVUKhMtv/dstm6IgDe6XH1 CPs7PFb+b4GZwVGMVs4CIZDzAlfI7VFcszxIouABoAwcvH37P0AiH18L4hlirCwWdVlf vtR/1riimlcyZHveafQKkaULxKAWZ9yqLw8US2zQJC3myt+gn0VNDHhpudso9SgQlqT0 8XLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747664790; x=1748269590; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zPSK08R64NjDKjVa8ynPBVMp8t7R/JlH6tOj8tW7ci0=; b=IfjEWqR6QpNV6g146sFzIu4ATlQHLFhqubv911p2LfYVqqnyWjhig8Fn0Do1+x1VG/ 3xLnsy96nwyjwl+ZfO90jUCTo07rMEhGtJYLccoCb6pwGOXW+zCa2Jyt8YTinBEElg0H ote76aOPJCKtU3uAIbTNjIDMz6lktjqIiJYrAR2Y/08i39TdGUw7fIPTXCdgrcb4CTOn EJrzkw4i3zruHcT2rqLTsUZjgBHlcaSxLKQ17aOFcDkUku+oubFUL3JkycVc/WI9offQ Q+z3Bz3188wW5CBScWgmWWgS8SDEv2MUuceaM8+nRrrSrr1sUuHSnwxjf9ssH04/Vg+9 wygA== X-Forwarded-Encrypted: i=1; AJvYcCVBZqGZl2yZkYRizecfXwv++G0lAnoVvcLUO2OCiSl1SA5dWhAHOYxXxsj+xbepEeG1TqdOPHDla+M=@vger.kernel.org, AJvYcCVkDCF1VaMVuajDsmHgk0A2aWA2XUSMqWylNa+XgrNvG1L28Xiz9Ob8HUFJhwpzbfLW2ddaHxqdOpH6nPME@vger.kernel.org X-Gm-Message-State: AOJu0Yzc4R/HQSSKuJEW9tOVj6tcO1XftaP7OnSwPnnRoACkXNTKarkR TFvHvF2QIlqBTUgpIZae7Cn1F6iTEwRlkki8OnWzVGJCrNd+d9D+RLrT X-Gm-Gg: ASbGncvbjNC35NES8p25FXOVGj1qQMC15pcznHF4bG58jJ8StgfnYEFIBeCKSiwL5+T TMLm5bnqFnnemrAFefCfOSfNdgF+S+gkLXgLdG8BHVBjFYfcoL/RNhzFs0o0RthakYLK0HvtuFa DYlUIQWA9NnL5jVDaxRwGe4MrSklarygkxjAruYa2bnJZvuaMp8ydYd0hIWXbMiEiWv/5R0Mqdj B0XENA30RSEFNMradBuB3qCUr3/SxoMy0IsIrS1NlXmdTaJ4tjM5PQTm+P5P5a4WxnFdRF5Npbq mJoTlDHCvkH+i9uJIczrEYT17JXbYQlKWsfMPxj36ipCxwfEpIQOzb9L2w== X-Google-Smtp-Source: AGHT+IHHGm0TdevHKzxfg0NYOhWmxKOpnGpfnjC0W22rUmA3Tlsa1t6XHp8PoVu6uIZaBPZXu4FN7w== X-Received: by 2002:a05:6a00:2288:b0:740:5977:7efd with SMTP id d2e1a72fcca58-742a97eb55fmr18873478b3a.13.1747664790147; Mon, 19 May 2025 07:26:30 -0700 (PDT) Received: from gye-ThinkPad-T590.. ([39.120.225.141]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-742a96e211csm6465303b3a.16.2025.05.19.07.26.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 May 2025 07:26:29 -0700 (PDT) From: Gyeyoung Baek To: Jonathan Cameron , David Lechner , =?UTF-8?q?Nuno=20S=C3=A1?= , Andy Shevchenko Cc: Gyeyoung Baek , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH RFC 8/9] iio: trigger: Add new API iio_trigger_store_time() Date: Mon, 19 May 2025 23:26:00 +0900 Message-ID: <20250519-timestamp-v1-8-fcb4f6c2721c@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250519-timestamp-v1-0-fcb4f6c2721c@gmail.com> References: <20250519-timestamp-v1-0-fcb4f6c2721c@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Now the trigger can simply call `iio_trigger_store_time()` to pass a timestamp to the consumer. Signed-off-by: Gyeyoung Baek --- drivers/iio/industrialio-trigger.c | 16 ++++++++++++++++ include/linux/iio/trigger.h | 2 ++ 2 files changed, 18 insertions(+) diff --git a/drivers/iio/industrialio-trigger.c b/drivers/iio/industrialio-= trigger.c index f394933b9d0a..a961156f0eeb 100644 --- a/drivers/iio/industrialio-trigger.c +++ b/drivers/iio/industrialio-trigger.c @@ -288,6 +288,22 @@ static void iio_trigger_put_irq(struct iio_trigger *tr= ig, int irq) clear_bit(irq - trig->subirq_base, trig->pool); } =20 +void iio_trigger_store_time(struct iio_trigger *trig) +{ + WARN_ON(!trig->early_timestamp); + + for (int i =3D 0; i < CONFIG_IIO_CONSUMERS_PER_TRIGGER; i++) { + struct iio_poll_func *pf =3D trig->consumer_pf[i]; + + if (pf) { + WARN_ON(pf->timestamp_type !=3D IIO_TIMESTAMP_TYPE_TRIGGER); + + pf->timestamp =3D iio_get_time_ns(pf->indio_dev); + } + } +} +EXPORT_SYMBOL(iio_trigger_store_time); + static int iio_trigger_attach_timestamp(struct iio_trigger *trig, struct iio_poll_func *pf) { diff --git a/include/linux/iio/trigger.h b/include/linux/iio/trigger.h index f3b89a1e0318..8048a2c69971 100644 --- a/include/linux/iio/trigger.h +++ b/include/linux/iio/trigger.h @@ -187,6 +187,8 @@ int iio_validate_own_trigger(struct iio_dev *idev, stru= ct iio_trigger *trig); int iio_trigger_validate_own_device(struct iio_trigger *trig, struct iio_dev *indio_dev); =20 +void iio_trigger_store_time(struct iio_trigger *trig); + #else struct iio_trigger; struct iio_trigger_ops; --=20 2.43.0 From nobody Fri Dec 19 14:34:01 2025 Received: from mail-pf1-f174.google.com (mail-pf1-f174.google.com [209.85.210.174]) (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 67F47286418; Mon, 19 May 2025 14:26:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747664794; cv=none; b=kOJ8Uiw526U5zdlzqwoZX2mtvzPfwVKBdyxNe6cROAMHRHyLRN2zEVF5elHLcC4ueWQY4pe1Yv33VZCbbUUfZghqtWEZcbwKkKG0WnaJWRF1ZKBC4nkej6Rl9wGawq7M/kGpMPd21GTpBS9KYrSdmNcR49JyRBp+SrhKch+vBPc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747664794; c=relaxed/simple; bh=pCvjBnapJdnH08Ke1HT2Sckpf25UsBH+CROSCGXOrZk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=SC9Sgg2NmGhJ06xwM+E/iEIhAUwbt7VAvcI3Ox86f5no4fPgWPWODd5ZG/64NqqvXqak9zK3cWqHmoI2EbGFJE9LE0tF9I0zqORIqlDfqas0xddqMDSzryRUnp12lRUcMhvGhdgoAddCIUZ7OXvPD2bwP8wnqNLuEF3zspOs3yI= 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=jujBh54R; arc=none smtp.client-ip=209.85.210.174 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="jujBh54R" Received: by mail-pf1-f174.google.com with SMTP id d2e1a72fcca58-7398d65476eso3546809b3a.1; Mon, 19 May 2025 07:26:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1747664793; x=1748269593; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=osCr06hsylKTSAoTgivd6MavyP7+iemMoVgSaaYvao4=; b=jujBh54RL4ZcZ2sugVNuwMrALvP7snV15eaCe6xaWPOyTSM4NrgXUSafeMRNb01glm 4tgDLm4VxYxdy0qKkUMKDxbINm4nATzzKZWsZ081C/sBXrJmvValrEDX0liHbTRnrLBK PbGx9hOCGxzyCn8sBEiZIplYHjpJbLOrmlTIgiUF1F0kckAdS+jL6sKQ13NCZeP4/zAy 9atI690/6VkVgsWokG1VKrUZAEPLJOURnIl/eqJ6UET1FRXQgXmMvDSH5jKaTs+r+RUD KT3iB1FFbVrlEKxcC3ImTyZlzv1JfFli+bdOpSWTNGoyJ+VLQlHiBuyeGFiPuF76NUvL ycJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747664793; x=1748269593; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=osCr06hsylKTSAoTgivd6MavyP7+iemMoVgSaaYvao4=; b=QJOe7WcS8C0TZ9AnXuFro68UwdghZlat+t0dsviHg5PzegrtkcK+L6aQihXfAPadm3 3nb44fQn/aGll5uEfpO1r74I5sAkjg0LONXqRUhKkVE8ZXbbOMK4WfdjtWVDydb1S3ks WCxtfEFtt+FJtbob7ofzd9xWdaP/WZi4VmxIcmpoHrTweXBgQGfnbTfzbQhyvXPNPx9y iKkIcmn/HGN3mwaWzdGDvFXlNbaymiX2ksVtfdi1wXsYObE7nJgxM8xqUsnjDxq31sz8 xBJp/XucvXUMtoXflmZMAOHO6EiBbdKeVkENAFdAonkyBvQb4fAThBQrecfjnj2QnKW9 c7Gw== X-Forwarded-Encrypted: i=1; AJvYcCUHWkcQmqHMOFj9Nw6aF+Dkp7rFOgYfM5LJAHxuc0r6dYx2pGE9wgg44ms6lgf5ykW1zbJGHrkhU1l4OXwu@vger.kernel.org, AJvYcCVWlNtJW0ZmeWX9JUZNXodZYI9zxdnzUIYe8GhxnwIZZHNfXt4X+PvfXQcWJSn3ESdobaW9K+e4FSs=@vger.kernel.org X-Gm-Message-State: AOJu0YzbcYFu6OT/lPUM6S3A7yuJxr6tXHoGnlVClk5jMRWyFUefCjB5 VDP+cQ8sZWf8O1zQIQAiBRfoleV0jlloGmDMNlcLjB2F5jDwSSUl/ahu X-Gm-Gg: ASbGncsjJPVRHykhf+Ou6wFs50FdxI9wrS920gBBEjrwycVJir7jSK9uVlNGZfcXKo0 JpIQ2tysV/xndGYD/jFkpAiu4XxuN+67Nu8iak06ejxZHHu1dpZ5TKwabm2+1wfdoLyMqQ5/pOS gVWwWwFndiyFMjREZGksYQwynbgwyoLQDUCjBuFH9ht48xsmfdC3NFBtEfOAVbJdU7TTJkc489A rP7KTOLI9lnKp2s9nFD0khoGjxlunxUFt5LIHVIcjGnMdFFtfAO4cNmtAH0IEwR0Rl4dcHUiGDc 3exc9clYJZN6ZPCNT7ABhqHzNUHhBKYIhrUFHRBidZ8i4Zx0zuLCv17+7w== X-Google-Smtp-Source: AGHT+IHlXJapKmWK6jXxCG4EqBwdhv/qvDATVlO2zy3Pd0SLOoU/tuza0cAVvKrefiK7lMbInBl8/A== X-Received: by 2002:a05:6a00:3d01:b0:740:58d3:71a8 with SMTP id d2e1a72fcca58-742a99fabb8mr16216198b3a.1.1747664792613; Mon, 19 May 2025 07:26:32 -0700 (PDT) Received: from gye-ThinkPad-T590.. ([39.120.225.141]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-742a96e211csm6465303b3a.16.2025.05.19.07.26.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 May 2025 07:26:32 -0700 (PDT) From: Gyeyoung Baek To: Jonathan Cameron , David Lechner , =?UTF-8?q?Nuno=20S=C3=A1?= , Andy Shevchenko Cc: Gyeyoung Baek , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH RFC 9/9] iio: rpr0521: Use new timestamp-related APIs Date: Mon, 19 May 2025 23:26:01 +0900 Message-ID: <20250519-timestamp-v1-9-fcb4f6c2721c@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250519-timestamp-v1-0-fcb4f6c2721c@gmail.com> References: <20250519-timestamp-v1-0-fcb4f6c2721c@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable This patch is an example that helps explain the previous series. Now there is no need to handle timestamps differently depending on whether the consumer is attached to its own trigger or to another trigger. And the own trigger of rpr0521 can simply pass a timestamp to consumer, using `iio_trigger_store_time()` Not tested since I don't have the corresponding device. Signed-off-by: Gyeyoung Baek --- drivers/iio/light/rpr0521.c | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/drivers/iio/light/rpr0521.c b/drivers/iio/light/rpr0521.c index 92e7552f3e39..32981db18428 100644 --- a/drivers/iio/light/rpr0521.c +++ b/drivers/iio/light/rpr0521.c @@ -186,7 +186,6 @@ struct rpr0521_data { bool pxs_dev_en; =20 struct iio_trigger *drdy_trigger0; - s64 irq_timestamp; =20 /* optimize runtime pm ops - enable/disable device only if needed */ bool als_ps_need_en; @@ -416,7 +415,7 @@ static irqreturn_t rpr0521_drdy_irq_handler(int irq, vo= id *private) struct iio_dev *indio_dev =3D private; struct rpr0521_data *data =3D iio_priv(indio_dev); =20 - data->irq_timestamp =3D iio_get_time_ns(indio_dev); + iio_trigger_store_time(data->drdy_trigger0); /* * We need to wake the thread to read the interrupt reg. It * is not possible to do that here because regmap_read takes a @@ -446,15 +445,6 @@ static irqreturn_t rpr0521_trigger_consumer_handler(in= t irq, void *p) struct rpr0521_data *data =3D iio_priv(indio_dev); int err; =20 - /* Use irq timestamp when reasonable. */ - if (iio_trigger_using_own(indio_dev) && data->irq_timestamp) { - pf->timestamp =3D data->irq_timestamp; - data->irq_timestamp =3D 0; - } - /* Other chained trigger polls get timestamp only here. */ - if (!pf->timestamp) - pf->timestamp =3D iio_get_time_ns(indio_dev); - err =3D regmap_bulk_read(data->regmap, RPR0521_REG_PXS_DATA, data->scan.channels, (3 * 2) + 1); /* 3 * 16-bit + (discarded) int clear reg. */ @@ -464,7 +454,6 @@ static irqreturn_t rpr0521_trigger_consumer_handler(int= irq, void *p) else dev_err(&data->client->dev, "Trigger consumer can't read from sensor.\n"); - pf->timestamp =3D 0; =20 iio_trigger_notify_done(indio_dev->trig); =20 @@ -867,8 +856,6 @@ static int rpr0521_init(struct rpr0521_data *data) return ret; #endif =20 - data->irq_timestamp =3D 0; - return 0; } =20 @@ -984,6 +971,9 @@ static int rpr0521_probe(struct i2c_client *client) goto err_pm_disable; } data->drdy_trigger0->ops =3D &rpr0521_trigger_ops; + data->drdy_trigger0->early_timestamp =3D true; + data->drdy_trigger0->trig_type =3D IIO_TRIG_TYPE_POLL_NESTED; + indio_dev->available_scan_masks =3D rpr0521_available_scan_masks; iio_trigger_set_drvdata(data->drdy_trigger0, indio_dev); =20 @@ -1011,10 +1001,10 @@ static int rpr0521_probe(struct i2c_client *client) */ =20 /* Trigger consumer setup */ - ret =3D devm_iio_triggered_buffer_setup(indio_dev->dev.parent, + ret =3D devm_iio_triggered_buffer_setup_new(indio_dev->dev.parent, indio_dev, - iio_pollfunc_store_time, rpr0521_trigger_consumer_handler, + true, &rpr0521_buffer_setup_ops); if (ret < 0) { dev_err(&client->dev, "iio triggered buffer setup failed\n"); --=20 2.43.0