From nobody Mon Apr 6 23:35:58 2026 Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) (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 C02783EAC7D for ; Tue, 17 Mar 2026 15:04:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773759857; cv=none; b=H4VkBJe2js53NQgHKmgBRDWXB+YFxQEkAVNIA0YusxQiYwPbnCCI8fREaASlqaTHnerkHAZ69ZTq9KIggKR/QdBoQHCq1kzu/YuPFX2vq4Vq6F8SWQdZdd9LieZZboSx7bxNE/MQGuVNN6PXV9oTuwYmtlzHWACcB7PzJumN5lo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773759857; c=relaxed/simple; bh=nJstDZ/QxoZ2lCZSTohbFx88cUeNPJ2aHRDezpiEztg=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=CYdtNWzbDdOEQDGEfBZJcZT6Ah7dxz+hyyOUIORNUZMaRBP909ix+y+79s3bNphpg47kxEpesf1X8wN3siydsLex+pymrGUTVF/dqN3jGdlxMFFRijxfsAhmhiw54546CXZZfavlv9nxjqeauPWok+Ix3M6Jh831HTFZN/9ueJE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=vzGd9q3P; arc=none smtp.client-ip=209.85.128.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="vzGd9q3P" Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-4852e09e23dso50191085e9.0 for ; Tue, 17 Mar 2026 08:04:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1773759854; x=1774364654; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=oof/EJX4ZjAg7qi0LTv1JyI3DSw6kCFAbKLxi0V35OE=; b=vzGd9q3P1man3wgFU8Ae/2FmCphz/ZIQYr9NxR3KvklRncYhwydgq2Fi5/OV745q1h 1TVoWQ+G6hijXFGIvsCfNs3lE6xjFjHWwJys92XSwhQCBA30Kb/d/8abvK71UT/3/aYf FOHSScxLgqy+f6Clb/9qawXV08KHpTDuPhAhfLExztvvBAPX28ezB0M16lvBi0UN9HeU /j0C6qSm7fs/ogV1F7VUdMLzmhMqaB35YjVMs2MCCWCX07dQzRjI4TEbqWLFVhBVDhaE HdLKOSRVPyuICJy1ffHgr0j+bCIgjnGQjufpYtPyfguK6TNgNPkG0EAj/4cnffuYW998 f+pg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773759854; x=1774364654; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=oof/EJX4ZjAg7qi0LTv1JyI3DSw6kCFAbKLxi0V35OE=; b=o9yyUdOh9dkVdMW+CezlGMWPuXsu2sq9a/tOg6qWgMquQZRvnzSBEoDm8cibZ3qOsM 0WaP77Y4h6QI+6GmfHNUadXE4iOQAYWNbc3MiJN7N97eg6OHB8nR/NfC9urH4pu8vl8B Grq/GYqueV2lk/uWUPJ93f2DniHCwZX7N17myzTmK+GYsHGUGMBXK3Nwjb0SmwUNUNs1 uEVfNe/gABtiq9CIIXLF5AwfPKRGCaiRDQVe9/ChGWGXlQOzooy/W4AnGyZ6POPLBzLS 8zZWXY4L1t37p3ZmiJDKuyx81Kk/1GimDo+IUhI2FeT0G5T+ZPcRwdgbLkO6/LjsAEm4 YeDA== X-Forwarded-Encrypted: i=1; AJvYcCU9g/KJCG+MYaCcoQ2gaU0gHZ7XYcgJn16mLx7GP6ofIh4/zXgrxnAvR1CyL9gKhcrV43f/CGDqwi5PX9Y=@vger.kernel.org X-Gm-Message-State: AOJu0YxfZ8RliqxRBM84RDjHq5Lz6gbwRhsAfV4A304wmShFgZEHckBo L0eEmFS4v9C/rPD1AEFT5dsMI1k7CZAm925xeWITXqI5R4bu8oQJYyNbR7kNzsoiXEI= X-Gm-Gg: ATEYQzynuAneDq6J0oVr+T9lPcG+N0G5pfzOTfyl/rvG3AWu+LlnpenQ4IoTMZ0j8Xj JtwEMYVDhohyYZEaBO4+mw8Ee02Vpp7WU5C0RP8oRxqXks2VnCKhSwXNsNZu5JoC1mJIGWUkzir 7ik+aBrCC2TzrmnSVqbl5lDLYmRiNtJ3tlOzsOYCLoAi5SZeMshNpF1IBSnIrxFhctFBuJ+k6Zc I6XZfyPdXJ1J7ZGVfwHguFsHtMHO6Xued2MaAWAQSwdRlgZ8sSM/pAwG+v2xvF95KpxAi44jVqe +9y2DgqQzZb3jzeUL76LXoUkGXE4ZiPQ+MnV3LN8girKpVi/kMCFK6tn3UB+XWX333WjdVQ+uh7 VeaYcVNYdPLz857PmpXHic1UDLhwPxEtdORErY2l9m3P3CQZrHZvU/L+T3yvH9dXfikKKxLFfxK +8sRCuF9wu1dLzDA== X-Received: by 2002:a05:600c:1388:b0:483:badb:618f with SMTP id 5b1f17b1804b1-485567050dcmr289431605e9.25.1773759854008; Tue, 17 Mar 2026 08:04:14 -0700 (PDT) Received: from localhost ([151.37.101.237]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4856eaeca12sm131699815e9.12.2026.03.17.08.04.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Mar 2026 08:04:13 -0700 (PDT) From: Francesco Lavra To: Jonathan Cameron , David Lechner , =?UTF-8?q?Nuno=20S=C3=A1?= , Andy Shevchenko , Jonathan Corbet , Shuah Khan , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org Subject: [PATCH v8 4/6] iio: ABI: Add support for floating-point numbers in buffer scan elements Date: Tue, 17 Mar 2026 16:04:13 +0100 Message-Id: <20260317150413.3878365-1-flavra@baylibre.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20260317150316.3878107-1-flavra@baylibre.com> References: <20260317150316.3878107-1-flavra@baylibre.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=5769; i=flavra@baylibre.com; h=from:subject; bh=nJstDZ/QxoZ2lCZSTohbFx88cUeNPJ2aHRDezpiEztg=; b=owEB7QES/pANAwAKAe3xO3POlDZfAcsmYgBpuW1t8z8jlx35g+4GGQ9DFdnRdXczS088/vY6/ 7I230SyTA+JAbMEAAEKAB0WIQSGV4VPlTvcox7DFObt8TtzzpQ2XwUCabltbQAKCRDt8TtzzpQ2 X77VC/4qIu1oMFG1fT+Ujce45VvyVrqPCWBtWmoJuSCMcE84ii/nMOAI8amjPmTrut/ZeSF3RMA tRQWc1HXiyrN9TXlLGFAI2I60729IxamVGmO2WN0qE/Xv1NcHsn2Vd/O1wZb+XhvD2ZKw3gcaTv 4Pr+X8uaNwof5k4AoCbIsXvuEyOxTU8bhQyDlsuPvTiQHqaYlC6p8SQv+agknLOP2lL4cg2AtTc o5/U248wVWXY7iTdCwL4h3QNY4ze7XLTs+eky4ZxO6a0+c2/gy8IcalxghC4LgB/5Im5BcpXvhL MhujgxqoGzmUBLB1bKMxMNPLDillRTPfcSBJkkuezC2Vs3M8iVcNQJh68teEBcsabsYGFi4fw5s 8g3TJ2rT4DIPWjiZa4MrZg8GtQiK0BR+7V2daqkH5HL5AUxsY5SXipYjcXY1JYxw3qj5shHK00O JGHJ+8hBqaWkz3aN9+YILQa++ryvU84lLiZinXyTbs8k4yEo0rk/OwYf4vmKA3XYt4/nU= X-Developer-Key: i=flavra@baylibre.com; a=openpgp; fpr=8657854F953BDCA31EC314E6EDF13B73CE94365F Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" In the data storage description of a scan element, the first character after the colon can have the values 's' and 'u' to specify signed and unsigned integers, respectively. Add 'f' as an allowed value to specify floating-point numbers formatted according to the IEEE 754 standard. Signed-off-by: Francesco Lavra --- Documentation/ABI/testing/sysfs-bus-iio | 33 +++++++++++++----------- Documentation/driver-api/iio/buffers.rst | 3 ++- Documentation/iio/iio_devbuf.rst | 3 ++- include/linux/iio/iio.h | 2 ++ 4 files changed, 24 insertions(+), 17 deletions(-) diff --git a/Documentation/ABI/testing/sysfs-bus-iio b/Documentation/ABI/te= sting/sysfs-bus-iio index 5f87dcee78f7..bd6c3305dd2b 100644 --- a/Documentation/ABI/testing/sysfs-bus-iio +++ b/Documentation/ABI/testing/sysfs-bus-iio @@ -1510,21 +1510,24 @@ Contact: linux-iio@vger.kernel.org Description: Description of the scan element data storage within the buffer and hence the form in which it is read from user-space. - Form is [be|le]:[s|u]bits/storagebits[>>shift]. - be or le specifies big or little endian. s or u specifies if - signed (2's complement) or unsigned. bits is the number of bits - of data and storagebits is the space (after padding) that it - occupies in the buffer. shift if specified, is the shift that - needs to be applied prior to masking out unused bits. Some - devices put their data in the middle of the transferred elements - with additional information on both sides. Note that some - devices will have additional information in the unused bits - so to get a clean value, the bits value must be used to mask - the buffer output value appropriately. The storagebits value - also specifies the data alignment. So s48/64>>2 will be a - signed 48 bit integer stored in a 64 bit location aligned to - a 64 bit boundary. To obtain the clean value, shift right 2 - and apply a mask to zero the top 16 bits of the result. + Form is [be|le]:[f|s|u]bits/storagebits[>>shift]. + be or le specifies big or little endian. f means floating-point + (IEEE 754 binary format), s means signed (2's complement), u means + unsigned. bits is the number of bits of data and storagebits is the + space (after padding) that it occupies in the buffer; when using a + floating-point format, bits must be one of the width values defined + in the IEEE 754 standard for binary interchange formats (e.g. 16 + indicates the binary16 format for half-precision numbers). shift, + if specified, is the shift that needs to be applied prior to + masking out unused bits. Some devices put their data in the middle + of the transferred elements with additional information on both + sides. Note that some devices will have additional information in + the unused bits, so to get a clean value the bits value must be + used to mask the buffer output value appropriately. The storagebits + value also specifies the data alignment. So s48/64>>2 will be a + signed 48 bit integer stored in a 64 bit location aligned to a 64 + bit boundary. To obtain the clean value, shift right 2 and apply a + mask to zero the top 16 bits of the result. For other storage combinations this attribute will be extended appropriately. =20 diff --git a/Documentation/driver-api/iio/buffers.rst b/Documentation/drive= r-api/iio/buffers.rst index e16abaf826fe..8779022e3da5 100644 --- a/Documentation/driver-api/iio/buffers.rst +++ b/Documentation/driver-api/iio/buffers.rst @@ -37,9 +37,10 @@ directory contains attributes of the following form: * :file:`index`, the scan_index of the channel. * :file:`type`, description of the scan element data storage within the bu= ffer and hence the form in which it is read from user space. - Format is [be|le]:[s|u]bits/storagebits[Xrepeat][>>shift] . + Format is [be|le]:[f|s|u]bits/storagebits[Xrepeat][>>shift] . =20 * *be* or *le*, specifies big or little endian. + * *f*, specifies if floating-point. * *s* or *u*, specifies if signed (2's complement) or unsigned. * *bits*, is the number of valid data bits. * *storagebits*, is the number of bits (after padding) that it occupies = in the diff --git a/Documentation/iio/iio_devbuf.rst b/Documentation/iio/iio_devbu= f.rst index dca1f0200b0d..e91730fa3cea 100644 --- a/Documentation/iio/iio_devbuf.rst +++ b/Documentation/iio/iio_devbuf.rst @@ -83,9 +83,10 @@ and the relevant _type attributes to establish the data = storage format. =20 Read-only attribute containing the description of the scan element data st= orage within the buffer and hence the form in which it is read from userspace. F= ormat -is [be|le]:[s|u]bits/storagebits[Xrepeat][>>shift], where: +is [be|le]:[f|s|u]bits/storagebits[Xrepeat][>>shift], where: =20 - **be** or **le** specifies big or little-endian. +- **f** specifies if floating-point. - **s** or **u** specifies if signed (2's complement) or unsigned. - **bits** is the number of valid data bits. - **storagebits** is the number of bits (after padding) that it occupies i= n the diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h index d48a0ab01b8d..1f2c1cb03394 100644 --- a/include/linux/iio/iio.h +++ b/include/linux/iio/iio.h @@ -180,9 +180,11 @@ struct iio_event_spec { * Format values in scan type * @IIO_SCAN_FORMAT_SIGNED_INT: Signed integer (two's complement). * @IIO_SCAN_FORMAT_UNSIGNED_INT: Unsigned integer. + * @IIO_SCAN_FORMAT_FLOAT: Floating point. */ #define IIO_SCAN_FORMAT_SIGNED_INT 's' #define IIO_SCAN_FORMAT_UNSIGNED_INT 'u' +#define IIO_SCAN_FORMAT_FLOAT 'f' =20 /** * struct iio_scan_type - specification for channel data format in buffer --=20 2.39.5