From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-oi1-f170.google.com (mail-oi1-f170.google.com [209.85.167.170]) (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 AE707384243 for ; Wed, 4 Mar 2026 22:53:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.170 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772664835; cv=none; b=oPxoj5Kfk+DVp4JeDP4YKsE6Dm8jAamt60nKzf1v21paqAO0TI3cmogNHgEKZPgAMn/H/iW5nOKGh2U9vLuejep8+v/Yy4uAkH3G5BkHkA731Y7WTHvuYcT/SjF8rV/9mZt201IT/TTvZuV9ZeWVpYn0A6K7StSpvyZIje21XDA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772664835; c=relaxed/simple; bh=KgsH7RL+/t75qBFgpOtWwlUS/7lvJy57STviAsEdSrs=; h=Message-ID:Date:MIME-Version:Subject:To:References:From: In-Reply-To:Content-Type; b=hRZ6ut9cUgewEGb+A806RoMwo+aMeRY4zBavovGns0D2g2otqKaMrwS3p434MqURqBuqT9/8Xp6T7Gi52AyutiWKDJ3yxJrG4RJfOua6KY2R77xVNR4aUr5Gd8JG959r1npSUjVCqGkBIVW1wqUI0LSWWivKw2/OSsTCh2ITxPg= 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=UdxJDJmY; arc=none smtp.client-ip=209.85.167.170 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="UdxJDJmY" Received: by mail-oi1-f170.google.com with SMTP id 5614622812f47-45f194e9a98so2809967b6e.3 for ; Wed, 04 Mar 2026 14:53:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1772664832; x=1773269632; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id:from :to:cc:subject:date:message-id:reply-to; bh=d7hoUPZ6OJpBxH+RHqUIwk6AIGVllMPyf3oZmRm458Q=; b=UdxJDJmY1P5MjkDvO8GcZ59xJCblhqfGf/Q+43DxnlvyXJgAFsL9bn9hbMm8kMNiQh 6kXDY+xRDXOAzr/PnifLZAWfkOFk8Zu7GfHUUVMxHY+qZ6lpmbGbVk2EhomGCdpT6e/5 KvcNGlOcDk4Au2suRx1NWY/bzLsM2BC59zUqZHIfo6qfnAhj9F/AYcsI73tTHu2EqRA1 m73EOjDckuoSFMWBHH8rUhChvTIqTqXMH5WwBiFAMPEWdhSdtZBii0MCyXgvdaeJ9jV3 m18o69mDjklMkXmGzEu8W3X8xjLStK3zGEEK+ksqCS+9LkYlvDsgYpl7KmE82AzpRnpO GnYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772664832; x=1773269632; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=d7hoUPZ6OJpBxH+RHqUIwk6AIGVllMPyf3oZmRm458Q=; b=kieiLsvnF4W8CZfl0nPZKNXkMdZzfsU4kAnqD9XYuJhbVYznHCfoeGmwOiKrZASb44 BE8M8F49e+dWsWY4ZXBREJa6juqBFmCahry3FByRfLjESPrk0lYDHsPLOxn/fK60mF+H rviKGEzcWu17UkSLu2e8GCyvWsQLKHtFMgQTUt10irkIkmI1YltXT2vavSJUYteItmEv IRrwrajHnP1H7QumgC81TRcoPzrM9XPaf4fowl7L3c30/3TU3jp+SXGsaLGLi/UHJJDd K+9KkpZ0NMudyY03N8ECQDHxOGEclb1d3GIbEux2MBHDnAnW2es82Knncg2k4SurwhNC Kd5A== X-Forwarded-Encrypted: i=1; AJvYcCWhU6EMtZn5ub7kHmixWCYHkHixrk3bDX1V8NkjkYNXfxV4vgavnOhclr7aIptTEp1Gce2+JNZQP4H3KWM=@vger.kernel.org X-Gm-Message-State: AOJu0YzbPc5GMFeMN7V/hQuq2lq3PUxX714Guu9DiPtpTcP/PqNNRCvM gim09JUz4uVLtqo++HQE9cgyfXIWT77h9GqM6LE4wXYBuoZxFPqe0/K0xiw6smNi5nA= X-Gm-Gg: ATEYQzzluQ4W9+vRuiOQpZkVXxYLo2HahXRVNePYxRFkRU3NFuk8Wavici/YJ4dLfjn 7u3PsQg5yVxuRTQ6Scinsm8T7qVYacs1/N9n8cOc/ArRHjtvWFbCB2HZsbkRPMpaepGqpZxSBUU s8q1MIOrWGglUn8jpvaru9PFbHG/MyOzc7gO5CVKHb6jLNh5OZqgf8iLm72iYFqte/hdMB3zX/p P1CEAIHvLUv+gZtMg7gpT1Fa7mnnDA/Im7E3/9F4XXF72yz79/Rrm9zeqwE5TYRyteX1A+mxakO R/QdFTjflpx4DQSNHrs3fI0K1R/MT+cUOh6yDH6SebijF3jVqachC6LF3a8Ylx2BcXLMYsTdcyt oOnV9gOAfbyUoq9AQ6p/5PkQdd36eQvzXyxEvc7CGi4uaxeVJUC21pvs+26CKqjzeGbGhqeLXo5 +E+Y9OKh/YqLv6Me91ATT5SMY5tCl0OBBPBVY2kmLvQr9gyC+lq0654yhuTi9Lyr7ep5CtlXnYi A== X-Received: by 2002:a05:6808:1391:b0:44d:b72e:ec1a with SMTP id 5614622812f47-4651ace7519mr1948954b6e.45.1772664831633; Wed, 04 Mar 2026 14:53:51 -0800 (PST) Received: from ?IPV6:2600:8803:e7e4:500:d719:8353:352f:b2e0? ([2600:8803:e7e4:500:d719:8353:352f:b2e0]) by smtp.gmail.com with ESMTPSA id 5614622812f47-464bb59b656sm12059893b6e.12.2026.03.04.14.53.50 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 04 Mar 2026 14:53:51 -0800 (PST) Message-ID: Date: Wed, 4 Mar 2026 16:53:50 -0600 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v7 3/6] iio: tools: Add support for floating-point numbers in buffer scan elements To: Francesco Lavra , Jonathan Cameron , =?UTF-8?Q?Nuno_S=C3=A1?= , Andy Shevchenko , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org References: <20260304080519.2844101-1-flavra@baylibre.com> <20260304080650.2844401-1-flavra@baylibre.com> Content-Language: en-US From: David Lechner In-Reply-To: <20260304080650.2844401-1-flavra@baylibre.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 3/4/26 2:06 AM, Francesco Lavra wrote: > A subsequent commit will add floating-point support to the ABI; enhance > the iio_generic_buffer tool to be able to parse this new data format. > > Signed-off-by: Francesco Lavra > --- > tools/iio/iio_generic_buffer.c | 56 +++++++++++++++++++++++++++++----- > tools/iio/iio_utils.c | 8 ++--- > tools/iio/iio_utils.h | 4 +-- > 3 files changed, 55 insertions(+), 13 deletions(-) > > diff --git a/tools/iio/iio_generic_buffer.c b/tools/iio/iio_generic_buffer.c > index bc82bb6a7a2a..39c13b9ad20b 100644 > --- a/tools/iio/iio_generic_buffer.c > +++ b/tools/iio/iio_generic_buffer.c > @@ -89,7 +89,7 @@ static void print1byte(uint8_t input, struct iio_channel_info *info) > */ > input >>= info->shift; > input &= info->mask; > - if (info->is_signed) { > + if (info->format == 's') { > int8_t val = (int8_t)(input << (8 - info->bits_used)) >> > (8 - info->bits_used); > printf("%05f ", ((float)val + info->offset) * info->scale); > @@ -112,12 +112,26 @@ static void print2byte(uint16_t input, struct iio_channel_info *info) > */ > input >>= info->shift; > input &= info->mask; > - if (info->is_signed) { > + switch (info->format) { > + case 's': { > int16_t val = (int16_t)(input << (16 - info->bits_used)) >> > (16 - info->bits_used); > printf("%05f ", ((float)val + info->offset) * info->scale); > - } else { > + break; > + } > + case 'u': > printf("%05f ", ((float)input + info->offset) * info->scale); > + break; > + case 'f': { > + union { > + uint16_t u; > + __fp16 f; Do we need to check for compiler support here since this data type might not be supported on all targets? Also wondering if _Float16 would be better than __fp16. > + } converter; > + > + converter.u = input; > + printf("%05f ", ((float)converter.f + info->offset) * info->scale); > + break; > + } > } > } > ... > @@ -46,7 +46,7 @@ struct iio_channel_info { > unsigned shift; > uint64_t mask; > unsigned be; > - unsigned is_signed; > + unsigned format; char would be more natural. > unsigned location; > }; >