From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-yw1-f179.google.com (mail-yw1-f179.google.com [209.85.128.179]) (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 06C831A6806 for ; Mon, 1 Jun 2026 00:45:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.179 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780274703; cv=none; b=OGQQRt85EFHfwTlH/gi25OIT29jWqP4AVSsO+1uwvuACjP1oF3B2cuyZ23rSpfabuXRln4kkK3Dj0V7PwNtjk4fy0S1j8GileIWfb8LJbcvO8uJL8cRkiHqHHr7xANhquGMTCD1W+85LZAAJuw63nMh5xy3U8YUXMSW12pFwB/M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780274703; c=relaxed/simple; bh=1mtJOHJyw/69DclxGkPrN+gFk5vHFLiAalbGJxuoGdE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Fz0NnyHcgLvPvCli+gN1alHfeUWl32hcNo4r1jz60Ar8qNCwxw22Wm94Xr+8xlLqJsTJoik3LPq8f5dYbvxjmvT06uBeqw+rQtuzgY3Zg12Iu5lJ94dQNThoBvnkkciQhUJijoZfZopY/eF7aiu2ImDFduiPNxFiQ0UMz/3Nt14= 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=jxQlg5OA; arc=none smtp.client-ip=209.85.128.179 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="jxQlg5OA" Received: by mail-yw1-f179.google.com with SMTP id 00721157ae682-7dc18e2498bso47488187b3.3 for ; Sun, 31 May 2026 17:45:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780274701; x=1780879501; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=9sNcx/VAiskm6FYZ+uFUhNLeXBjBzhmJKxvyu7OkeIg=; b=jxQlg5OAtqHM3iHTAqAp6UxfOM6O1gx3zLEHZgW8SvYTx2Qb7JNpJ5CoVijL0mpZ4+ qB5Yc6cHva7Mey7eEAozxYMJGyGvDKybcrUmpxydgF2BzGtNF+ZwtE0rZdXEK001PHfA 90ZOd3Ls15Y//LoA1gtf+Xbjb/AS1DbxJGNxzisj5d2EycTJAXdGjYIcNc76bGcnF46h gpXcYx1W3NpEllN8HyZa339SXuVOl7ba+2epq7LvLuBYnQJHg316FFu6tAbxOnenFsP2 oMOq58jYtGFxvVDqe44fgoZTtnDEk1BHQv7Moq+oeCqejJ/M7T8FVD0PUwiitdHQgfQP fOZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780274701; x=1780879501; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=9sNcx/VAiskm6FYZ+uFUhNLeXBjBzhmJKxvyu7OkeIg=; b=Ny/7tL+T5Bz5T4pmDH464DNT+at99PI37uFfECQnANqyjL3jNqLN8zaXA9mc4w2cdF MoX9sd1jTqMDxaVepTDhO5Zn6CAsRsOPw7l0ctq5VyZ3sDOQwzkoUGNXWW8oFfw3TrrS q9n6RKksdouk7bxZrC+KMDqptnEOUqN2z41w/P89eHA0whcOVv25HwUmTSDOr4HnFARX 5T4807eCZNMnl7Mi3grN3qb67BFBJMbPE0zefc6GXWxe3wZFIxrQUE2sYBW2cWXHQ1u3 RNWJDKHFepV5hnt4gu4Sp7p41SMgGRWHC8gnBbPZLnK6HAsc4Y3XA8dj4oukwi86N9zo yjkA== X-Forwarded-Encrypted: i=1; AFNElJ9Cl7fYyjc3hDnyYDgTzXcWS55lgWBsRyHxtGcu8hvWhjkVMWPunRcStVq/z4buNbFu5H9tA6rs7Hwvpqs=@vger.kernel.org X-Gm-Message-State: AOJu0YyjU9CgnZjDj6ezXiXGrqkhO1xEm4cJQ6SAzOqfajbstWmGNB+j vdT15Kg3+AqYyQvbd2Gb35lO96Ee2VHo55Ha84TEJpdyjgzpNfkQYYB3 X-Gm-Gg: Acq92OErBWK/9JyJzrvbfmgisPLTO1lxVD2jjYdcrbNFY36WJVMrxTdGWafK/RPqJW1 2hca9Ktevy0NmJpWCLlUBl1mmuOVOTAwQumCGr2bkdP64S03jnfcePzbVhdyV5eMtURgFRoU326 UJSLHYPhItjh8pFDhpKH2Z2fyeu/Yn2oXOXYzGh9yzUUuMYhbFFFbAKiB5lOWTCKe88u9OAAf6/ a5LxbPRaxJDuYQ3gzjoo6+r12OycWi1rQpwMkl5r2saYCMNtcb+mkkUt+OQ6+cWE5H8xr/2raW6 SVcV1G43s3+/rDdAZkaL9j7Kb+FQUIzJHIwrxxjLnQSW8jMl2wVmDdLYfauKFSm40/fzVKdQvRT 5Ii5ULFJ150HB5+utU+wTpZSQEspuUlsdTj6wAHi/m/6+137yY9VLjH1GSyoRofaJC4MgPesCeO 5OYxT5wFeUKKlT9DCbHUInSxUQwU1GZhT9DnknXRR2IqA= X-Received: by 2002:a05:690c:4a10:b0:799:198d:8c78 with SMTP id 00721157ae682-7e05f4f5035mr81162727b3.46.1780274701061; Sun, 31 May 2026 17:45:01 -0700 (PDT) Received: from localhost ([2804:30c:1f02:6000:8b59:7c96:762e:9faa]) by smtp.gmail.com with ESMTPSA id 00721157ae682-7e17ae7c667sm30748037b3.27.2026.05.31.17.44.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 31 May 2026 17:45:00 -0700 (PDT) Date: Sun, 31 May 2026 21:45:23 -0300 From: Marcelo Schmitt To: Wadim Mueller Cc: Jonathan Cameron , Krzysztof Kozlowski , Rob Herring , Conor Dooley , David Lechner , Nuno =?iso-8859-1?Q?S=E1?= , Andy Shevchenko , Maxwell Doose , linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, devicetree@vger.kernel.org Subject: Re: [PATCH v3 3/3] iio: flow: add Sensirion SLF3S liquid flow sensor driver Message-ID: References: <20260530205435.37326-1-wafgo01@gmail.com> <20260530205435.37326-4-wafgo01@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=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20260530205435.37326-4-wafgo01@gmail.com> Hello Wadim, Some additional comments. Feel free to disregard any of them if they conflict with previous reviews. On 05/30, Wadim Mueller wrote: > Add a driver for the Sensirion SLF3S family of digital > liquid-flow sensors on I2C. Currently supported variants are > SLF3S-0600F, SLF3S-1300F and SLF3S-4000B; they share the same > register map and differ only in flow-scale factor and calibrated > measurement range. The variant (and therefore the scale) is > auto-detected from the product-information register at probe time. > > Each measurement frame returns a 16-bit signed flow value, a > 16-bit signed temperature reading and a status word, each > protected by a CRC-8 byte. The driver exposes the flow rate as > IIO_VOLUMEFLOW and the temperature as IIO_TEMP via the standard > IIO read_raw / read_scale interface. > > The active calibration medium can be switched at runtime between > the factory-calibrated water and isopropyl-alcohol modes via the > in_volumeflow_medium sysfs attribute; the sensor starts in water > mode after probe. > > This driver also creates the drivers/iio/flow/ subdirectory and > the corresponding Kconfig/Makefile glue. > > Signed-off-by: Wadim Mueller > --- ... > +config SENSIRION_SLF3S > + tristate "Sensirion SLF3S liquid flow sensor" > + depends on I2C > + select CRC8 > + help > + Say yes here to build support for the Sensirion SLF3S family > + of digital liquid-flow sensors: > + > + - SLF3S-0600F > + - SLF3S-1300F > + - SLF3S-4000B > + > + The driver reports the volumetric flow rate and the embedded > + temperature reading via the standard IIO interface. This level of detail is probably not needed in the Kconfig entry. Though, it's probably okay to have it anyways. > + > + To compile this driver as a module, choose M here: the module > + will be called slf3s. > + > +endmenu > diff --git a/drivers/iio/flow/Makefile b/drivers/iio/flow/Makefile > new file mode 100644 > index 000000000..3cf4ab95c > --- /dev/null > +++ b/drivers/iio/flow/Makefile > @@ -0,0 +1,7 @@ > +# SPDX-License-Identifier: GPL-2.0 > +# > +# Makefile for industrial I/O flow sensor drivers > +# > + > +# When adding new entries keep the list in alphabetical order > +obj-$(CONFIG_SENSIRION_SLF3S) += slf3s.o > diff --git a/drivers/iio/flow/slf3s.c b/drivers/iio/flow/slf3s.c > new file mode 100644 > index 000000000..497a56f59 > --- /dev/null > +++ b/drivers/iio/flow/slf3s.c > @@ -0,0 +1,406 @@ ... > +static const struct slf3s_variant slf3s_variants[] = { > + [0] = { > + .sub_type = 0x03, > + .name = "slf3s-0600f", > + .scale_num = 1, > + .scale_den = 600 * MICRO, > + }, > + [1] = { > + .sub_type = 0x02, > + .name = "slf3s-1300f", > + .scale_num = 1, > + .scale_den = 30 * MICRO, This one seems to almost zero out with 9 decimal digit precision. And it doesn't get better if _raw * _scale is to result in m³/s. I haven't followed it closely but, maybe this driver could use some of the new IIO_VAL types from ADF41513 series [1]. Ignore my comment if l/s was accepted. [1]: https://lore.kernel.org/linux-iio/20260531-adf41513-iio-driver-v15-6-da09adf1c0dd@analog.com/ > + }, ... > + > +static int slf3s_read_sample(struct slf3s_data *sf, int *flow, int *temp) > +{ > + u8 buf[9]; Can buf be 6 bytes long? 2 bytes of flow data + 1 CRC + 2 bytes of temp + 1 CRC. > + int ret; > + > + ret = i2c_master_recv(sf->client, buf, ARRAY_SIZE(buf)); > + if (ret < 0) > + return ret; > + if (ret != ARRAY_SIZE(buf)) > + return -EIO; > + > + for (unsigned int i = 0; i < ARRAY_SIZE(buf); i += 3) { > + if (!slf3s_crc_valid(sf, &buf[i])) > + return -EIO; > + } > + > + *flow = sign_extend32(get_unaligned_be16(&buf[0]), 15); > + *temp = sign_extend32(get_unaligned_be16(&buf[3]), 15); > + > + return 0; > +} > + ... > +static const struct iio_chan_spec_ext_info slf3s_ext_info[] = { > + IIO_ENUM("medium", IIO_SHARED_BY_TYPE, &slf3s_medium_enum), > + IIO_ENUM_AVAILABLE("medium", IIO_SHARED_BY_TYPE, &slf3s_medium_enum), We should probably document the new 'medium' ABI. For consolidated ABI, we document it in Documentation/ABI/testing/sysfs-bus-iio. Since this is new stuf, maybe start with a separate ABI doc (e.g. Documentation/ABI/testing/sysfs-bus-iio-slf3s) ? > + { } > +}; With best regards, Marcelo