From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) (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 716F521FF47 for ; Wed, 25 Feb 2026 10:06:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.41 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772013988; cv=none; b=iz7K3Q4tmBa5FJlpV6ANO/UMp6E8D9Ph9tmvSc5sHvMYRECjuexA/n7ajuh39PJ1iXVkwgDSUVdnC40TauLANPnM4kIWepw9PHZRKHoqLXlI2bmk16Epp5hAg5SC8sUL9c6vr2tLmEPwrV1ExfCXO6VzAuglXbtAwg5Ddf7+fpU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772013988; c=relaxed/simple; bh=OUTw+IZ7nvZ0bRHe3v+kMpcU/KJZUTpiBhUnfw/Y2E4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=FBFgY9aWdHlP9Ywk8USIyiHtAqgDFHc+TB0HbjxoVEL054RXp2AOeosk71uoBrKIby2TWyMXrr4pppzOI0fS4uWgJzbEoesy2odNRfZHIvc+hn8imVgXrikIKcqU3Lt9hg80iPIh0ZZs8iJoKIU4riO1wugVgepBaAcbRdwjDyM= 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=mTf7hy3p; arc=none smtp.client-ip=209.85.128.41 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="mTf7hy3p" Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-4807068eacbso50683255e9.2 for ; Wed, 25 Feb 2026 02:06:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1772013986; x=1772618786; 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=Bfequrh/RHjbP4wgWQJnqugNFeY3tpsmLATDEKfrZHg=; b=mTf7hy3pzBmfMGWrv0Un6kHMortWwndoeDZAO7IbtSEl+bNCxCOM6PRzdQWIRGy0Bi JuaXZn66PR2ZW/8N7EaGY6IsCwUzzhTFootjA+OtFZt1W3Jc+lFFOWR2FfXSh7WLd2xP CPn34OnXvk+IRPcylKI3de1N4sFE3GmRVVUOe/y7fXxfD+zb4ialbXCniJna5NtN0oI8 fTDCOoGCkW0ecFgDWLBrAlpjYbFZtLqmMD3yp5gNpy+Kmv2CkNFAPZs2kveX//pvk7hV 3UtkO5QgkEJDhqTZ3MiGBMltVtam2eVNgkXq35J80UaSqEAZFJPydu7JyoEYXb6UEr7E rD5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772013986; x=1772618786; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=Bfequrh/RHjbP4wgWQJnqugNFeY3tpsmLATDEKfrZHg=; b=gPinX33QnPk5lMqiqgusbaN75xQtXWa0QsoMqA5/UE2COxqtvjjjG2+9icwIFLWKk5 ohcdGtVabkRdLcGcn3kjr1AfOcRrCNQZ1zSe5OxnxUN6j80ce4h0wqrcm3YvbQPnQq2/ y6CB70XjKAtvAgHKfCuVE4sYMZEVMJh6v14pEBchQo/rWM2FOtRvGmGeZvyP7rnY0N05 Q5UWnp/YUcUXwbxTd7X6wW4G/MAnpymeeJ/258S05+Snw1QPXqCALBTTUBno0nYGqJE5 1HjE39lQ4trHJ5EAYRn9/H0BtFb0thODxWNts1+feusRF7a/rxk2XgZtHEax+Ecr47/+ 0n2Q== X-Gm-Message-State: AOJu0YxKMnaEBAKIQBezfiLTj9hsT19UhdLxsOIyfT4ECI+EtRvPiXee F/Q6sUO31FMESBVgLoSojRl1t3Cu2H27WBlTsGbukiSAc0AVGUpY1HEVYEiA4zVM0YjnhOz0FTF QI2ILyEc= X-Gm-Gg: ATEYQzzuM16Nx6a7HQAs5Jg7a8599EYgVzXDBOVu+FWXxlheWflRSScVf74K8J/LBff qF0gODZwa9b+d2zZ40wwlINsPdoVnvsX/Vib3AzHC25KA2cfRV16kdy9vr3a4blA1sMm11P3T/n x9LZyyUbvNB4c9bqCaZfo/Zt70I7P3yztmQ8zbLsb+YCBV/zo7Wm17F5eJAzrfmkWZiQnhTSSii p+xiuOhFyrQjXnRF0psbvAEpbu2/gipEDMCz8+Erxn5c+E9LrNc8rHpRrst/4ouWYif9q3ZMbfn /kdRjhnwHJOJpeuxx/bnvWbANf/5fEu0G+hJlj8KiJFHMcCckzyevzFsNsUU8bWz6DGeAVrTfGx rn5j+aTYEj+DRbx+nGvgedwCGoKjkc7Agiq0azzMRTlBj9kd2dRAtfmILp19rITD0XKQkArkDPA wxq0Re X-Received: by 2002:a05:600c:8b66:b0:483:6f7c:19f4 with SMTP id 5b1f17b1804b1-483a95ed6f3mr232970065e9.30.1772013985716; Wed, 25 Feb 2026 02:06:25 -0800 (PST) Received: from localhost ([151.35.220.155]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-483bd7162b8sm51105845e9.8.2026.02.25.02.06.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Feb 2026 02:06:25 -0800 (PST) From: Francesco Lavra To: Cc: linux-kernel@vger.kernel.org Subject: [PATCH v6 5/7] iio: ABI: Add support for floating-point numbers in buffer scan elements Date: Wed, 25 Feb 2026 11:06:04 +0100 Message-Id: <20260225100608.2367061-5-flavra@baylibre.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20260225100608.2367061-1-flavra@baylibre.com> References: <20260225100421.2366864-1-flavra@baylibre.com> <20260225100608.2367061-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=5020; i=flavra@baylibre.com; h=from:subject; bh=OUTw+IZ7nvZ0bRHe3v+kMpcU/KJZUTpiBhUnfw/Y2E4=; b=owEB7QES/pANAwAKAe3xO3POlDZfAcsmYgBpnsmN2KWraQGWFT7ps0G1BE/xWgXMxvGyYbf+w 0nHZei/3imJAbMEAAEKAB0WIQSGV4VPlTvcox7DFObt8TtzzpQ2XwUCaZ7JjQAKCRDt8TtzzpQ2 X5pIC/9s2DZeC9Wv7LY5+R+8dd87EvOdGZGsVFBO9vfc63W6/V/iEMOXltGBgkROjZCzJPkib5f +RdMldKATepipyRKuD7WLZbhv2W4ZLj1l/Am7H0MaWWMRjTsJpUWB/7jGuPhJFCG65WJV8+h+Nh lXvK+EVTEu1IWj1if08+lx8Pm/fnekIjNeTQ7NKGFHWJwe+dTE1whHNFb+vpFbr4nKxi63WdT4o 5XvfH5E3fGIQHPdynE7gdP8IeQvRd5fgYShbAM8PLSC2z/6WJ97mVkVp5sgXra3Rtv9Y2zEO5wb h+qyJO7F0X2QxyF56w04NHB+Vv3pJZDP6+BwpSTLgz8q0Kd/iBJWDpRvw4gsFMgJCa8NOkUBm7+ xnaO/yZU+c/SZzO2O/tkDFchm7SZB1krFazcIWX/uB3BRgq+VG8Q7dXW4PUHw/+vBOuW476TFaz quiD8cDmtkAJyHMMCEJc4peEJukYX2b9wgQ+v2GVR+vH5Oc96zoMUUe3XTecNFv5TvCns= X-Developer-Key: i=flavra@baylibre.com; a=openpgp; fpr=8657854F953BDCA31EC314E6EDF13B73CE94365F Content-Transfer-Encoding: 8bit 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 | 5 ++-- Documentation/iio/iio_devbuf.rst | 3 ++- 3 files changed, 23 insertions(+), 18 deletions(-) diff --git a/Documentation/ABI/testing/sysfs-bus-iio b/Documentation/ABI/testing/sysfs-bus-iio index 5f87dcee78f7..61961bca4dce 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]:[s|u|f]bits/storagebits[>>shift]. + be or le specifies big or little endian. s means signed (two's + complement), u means unsigned, f means floating-point (IEEE 754 + binary format). 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. diff --git a/Documentation/driver-api/iio/buffers.rst b/Documentation/driver-api/iio/buffers.rst index 00398472ce59..43410b5053d2 100644 --- a/Documentation/driver-api/iio/buffers.rst +++ b/Documentation/driver-api/iio/buffers.rst @@ -37,10 +37,11 @@ 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 buffer 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]:[s|u|f]bits/storagebits[Xrepeat][>>shift] . * *be* or *le*, specifies big or little endian. - * *s* or *u*, specifies if signed (2's complement) or unsigned. + * *s* or *u* or *f*, specifies if signed (2's complement) or unsigned or + floating-point. * *bits*, is the number of valid data bits. * *storagebits*, is the number of bits (after padding) that it occupies in the buffer. diff --git a/Documentation/iio/iio_devbuf.rst b/Documentation/iio/iio_devbuf.rst index dca1f0200b0d..6d7e7dcc2d80 100644 --- a/Documentation/iio/iio_devbuf.rst +++ b/Documentation/iio/iio_devbuf.rst @@ -86,7 +86,8 @@ within the buffer and hence the form in which it is read from userspace. Format is [be|le]:[s|u]bits/storagebits[Xrepeat][>>shift], where: - **be** or **le** specifies big or little-endian. -- **s** or **u** specifies if signed (2's complement) or unsigned. +- **s** or **u** or **f** specifies if signed (2's complement) or unsigned or + floating-point. - **bits** is the number of valid data bits. - **storagebits** is the number of bits (after padding) that it occupies in the buffer. -- 2.39.5