From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.51]) (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 E23843890FA for ; Wed, 4 Mar 2026 08:07:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.51 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772611622; cv=none; b=cEfU08F+sbAnonG0+lfPr493DzHVPR81JazcpwF4l2aa7+TD2oBEP+Xzrq152J8NlwGHaFhsPvywwkkgAAVB1pjSpmQJN6/T336hpKG8tyFqt1yZAl1glXT+BkAib1IC96xBgPASyHgr1L6q8ebL7hr6Me+j4yAhSZ+YtfCoFCM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772611622; c=relaxed/simple; bh=+5kKHgCbfIr6HZ3Ur8u9/0KCgquM6MW/BxUYCxIK5I8=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Uq03lbxPHcwSkzsPEUSgsxqzjDt+Y8J9pea9L4XO9idABTM6RlEFNCuchrdM9IxnfAQVv1lbJGngv0GV7Gg1w9axBhacrp8HLexb32mbK3eRPQFg7hSMqPnsXmACzdx1OuFXBdCROFswsHr0JfuGe/3D4HL6tYcVtPW8pDoPgPQ= 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=W6L+jXLz; arc=none smtp.client-ip=209.85.221.51 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="W6L+jXLz" Received: by mail-wr1-f51.google.com with SMTP id ffacd0b85a97d-439b97a8a8cso2908889f8f.1 for ; Wed, 04 Mar 2026 00:07:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1772611619; x=1773216419; 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=tZaP3R+BOklF7RhKo03SxE9I1TxjdRO6hcgS5F2nTkQ=; b=W6L+jXLzrfAxTdt9qJK2kS95KWTgMwPeNVXelnWQZ7vfPf5oEKhEuM1WbMDrt1fHK3 OVlSD5lWKuNkpZOzSJnzG0EoUDggKiWLGCsOxcn+aN3GH9wGruLma3n4HV4+b0hyj79r R28U0IDqJ0RkrC3HT/5/Gr2xM7klq1/l9ejwmtppB/1mDWVfeudlHVdV4VaD67PfefGg UH6NRM+ppS1YqnHcC7xWHYcmPfqbJzdSnIRco2GRJ6EV0wIkd3Ns2fATq2fnxVcHy83g GS2b3UqaCPEri3G0641v38t2NkH//D3fiVybckUOwPg1yNL5ZhUTTQwSeX0bLdxmmQQp CL2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772611619; x=1773216419; 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=tZaP3R+BOklF7RhKo03SxE9I1TxjdRO6hcgS5F2nTkQ=; b=T/3uqVyOc9B6VLi6l4ad7M2yogQeIKoJv1g5ltWzzQwttvBceHN2pxgxe2wQrKQ6ZC Rv3OnjuB49IGXG/1xsHJ7P3cBC0TsSvTtMVSAen1rhIyl0yi25s/KQ85pKGsUkcIdNmL YVoCZ8MTz0BOw3K2WfoL8f4fezh3hGEz6kDqaRZ/pR+m399Rvh0Zx9RjzEZ4Db5oquaz +mWHt+puZdmsqMyOIFIAwX3iz/Hem5ZCJKSh+GWu5h2qydqv3lCmwpjOQW8Z7JJFcutr sFjaxg7Wmy6MtVbauJaQYDdBa9N28xgj/bFPOUWJ7aup1EYZUTBGPH++XYyfnEGDoKIl my7w== X-Forwarded-Encrypted: i=1; AJvYcCVPlZ7risNMFMxChle7DryFCwWMcGi13QUeyvuVxsNY1vZs4NodTHVJxzFcz8TmuOSHD9TKniFOd+0=@vger.kernel.org X-Gm-Message-State: AOJu0YzwK9y0FOiJDLsjt7Y0kOa/cmePDhuxD1FXkWRBhaqMK0X9k72u uVWCvVyNVolNWyYWR3VJPpqhib6y3PgKJjEbWlFH9EcLo/ajVAiGEvW/J+TpieHTBVo= X-Gm-Gg: ATEYQzxXve+ixqRpsak7mMaxwYqVqgG/y1eD4L29AR8mZdlvk80wy3wJLji6mO8JBvh KDPeD3Z2i4FnPbah7pI4Prb4OmWA7bjxk/jtYfXHU2epaL/3uqWidX1no400Z4Em9cCSolSQfn9 gOfCb0k973ILtHG0nMQO/rMqhNb83NQLhp3SljJ2X2E8irRuRXb0iDQXTs91PSUy408M5FU6vkM N+R1BzwUvpVDXOouPm0K66uw/svJOOylGD3KGfQ9zYapnXnyfACgYl48MxNDo4ZaioA1Tk9H4zw p8n85rlC6Vjdh6ok9MHbmeLFfaLOJTqrvje6dZk6i7HCLGYbZl9ErgD2j70d6WQmr7RC6tKGX0K i9jEgqafsND6lnIV76c4HoylFIufo/or53MwdyBwNaZT8oJEYDS+JYB2Z3+8djYa1OGNG X-Received: by 2002:a05:6000:1842:b0:439:b7c9:2efd with SMTP id ffacd0b85a97d-439c7fd3e2emr1972255f8f.37.1772611619243; Wed, 04 Mar 2026 00:06:59 -0800 (PST) Received: from localhost ([151.19.177.89]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-439b485a0b6sm24871128f8f.39.2026.03.04.00.06.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Mar 2026 00:06:59 -0800 (PST) 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 v7 4/6] iio: ABI: Add support for floating-point numbers in buffer scan elements Date: Wed, 4 Mar 2026 09:06:57 +0100 Message-Id: <20260304080658.2844434-1-flavra@baylibre.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20260304080519.2844101-1-flavra@baylibre.com> References: <20260304080519.2844101-1-flavra@baylibre.com> Precedence: bulk X-Mailing-List: linux-doc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=5093; i=flavra@baylibre.com; h=from:subject; bh=+5kKHgCbfIr6HZ3Ur8u9/0KCgquM6MW/BxUYCxIK5I8=; b=owEB7QES/pANAwAKAe3xO3POlDZfAcsmYgBpp+ghK4q2jVvRC8PObm6sJmhgdvHZvM9gDB29A M83+5Wz02WJAbMEAAEKAB0WIQSGV4VPlTvcox7DFObt8TtzzpQ2XwUCaafoIQAKCRDt8TtzzpQ2 X6slC/0XZSNizAK3tm1OWubsiLQa5nXOJpvHb8jg/m4uuPzciIyRHz5Q6VL81bbV6rXDqwveI9V JMMwKIvxIqz3HHM6MpUb7MDs+684wwHXFPm7gEXnyGIDDZxAGKEo8n74oFNoNNIzjCbV6xbrxhx hkFnKjc9GTZ5lTafjFxmosZvRG7oy+CKZroTMpeISDq42O3oVO4GshAOE9oE3BsvNrqQafX/xMi 6XhmhSYWRSWohKrgrihmLluiSVYrdBKnC/7gRBKNne9afD9ZAax4kYIl/zXLqWGr6NVZt2kNLIn x7UPPY1bBu94mymOlJRbd5BqSszVUF8FBXRMttMPW5nSv6+nVZ2mLgLqo0RGW2Iimvxj0qLzK2l L4cl4SCvS3XGIjrsmRdbUMgIqLLgFyUlVjM2Mm9x8EbnpnE4ALxSJ++OYoW5L05gqZjtPdhtnjr 97mpjcraJwlz9FsJV0JVhRM02yG7UiPQD2Ag+CH6Zk8kadHcpnbpI/tWFQXtygssqsEnE= 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 | 3 ++- Documentation/iio/iio_devbuf.rst | 3 ++- 3 files changed, 22 insertions(+), 17 deletions(-) diff --git a/Documentation/ABI/testing/sysfs-bus-iio b/Documentation/ABI/testing/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. diff --git a/Documentation/driver-api/iio/buffers.rst b/Documentation/driver-api/iio/buffers.rst index f36e6d00173f..2fc9c2951a9d 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 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]:[f|s|u]bits/storagebits[Xrepeat][>>shift] . * *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_devbuf.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. Read-only attribute containing the description of the scan element data storage 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: +is [be|le]:[f|s|u]bits/storagebits[Xrepeat][>>shift], where: - **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 -- 2.39.5