Received: by 2002:ab2:2994:0:b0:1ef:ca3e:3cd5 with SMTP id n20csp151648lqb; Thu, 14 Mar 2024 07:49:02 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXCbxI2O7i0aF84Od7lRXnFynFK4HN2WVoE7hLIURr8lKYWl0B4z91aj2JldDB5orH7IPk20V2Mrx407ApOi1bqrdlVSqlgxAucxdhf2g== X-Google-Smtp-Source: AGHT+IEqle+U2LeS9kkmU7zXLWhw0NxcSBQOkfwxvBn+oZNHAsVoy55O9N17bhMLQfPwZYQzMq5h X-Received: by 2002:a05:6402:3908:b0:566:ac89:b7d5 with SMTP id fe8-20020a056402390800b00566ac89b7d5mr1376914edb.28.1710427742274; Thu, 14 Mar 2024 07:49:02 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710427742; cv=pass; d=google.com; s=arc-20160816; b=lQ5qEQ0SLN5M3WFgjUWiZrVWgpwbdLfyCVaDvSNuqu/zWNXZsICJ0HnCGAMSAOiq2h IfXaH53awjZGR78ekdh6UgY8BS2QEpRCT5Qztp3zRwPk9BroUCyjmT0Tbk/huRZoMHgn PU3JCc4GCvcnSAFLZqO+L9yUmmHSAwxr72sVmdDNC+yiGNr9ZOEi8DIr2P46BlhuSR7/ 9aqfP8hfJf5v4lxmCymJtVJ2Ii5OTrZAMVDC5RxSravU7TYLdJ5y8ZYGwtZwCUpX8l2R /ZEZEN+7yvRrMKMw5vU9bmZ3FV+Aidk0Xq7oddv/QNP5+jTkchWru71qL3f06SXyNkAE eUVg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=JK+Zxk4zlvrVyRIa8X+Ww3AzHZ98EObe1A4CE16R6VQ=; fh=firv7tdl2abVmITZx2i/WuE3U2C4mzCPGpcG2RKH4AE=; b=F5zQSHRdqUa+7eSMXbJtqluhshR9CxuBbEVbhYkzFDCtzjVxPQ+npEonuGZRzYcKN4 3nhjPL4vFlkGAMQCitLCj9QnzZOA1+T2y1mhSBWGfEwvZ4WxJjlHi3r1N7LZb0Rq2DaT 3r8LxLlMqr5RFKCariS4B29tmKlij7+z4P+HIV7e0ymaVNGNyAX1D19tuRhHJXbuMwQy eAYoS7NwNgc9htiLQB9W3xkVnExNT+9n4qcoUOLtz+rUw9QZwz58bCUV/al7P/Lbt5yR 3TADtUoO5BGXBQIqZ17eL31br0RCaBNH2LBR5YRlovEWuP4b9InYPH5a2nnSB7T2Nt6L ATdA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=IPlBmEXX; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-103434-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-103434-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id f1-20020a056402194100b0056724e587b8si824614edz.252.2024.03.14.07.49.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Mar 2024 07:49:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-103434-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=IPlBmEXX; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-103434-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-103434-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 04DF31F214F6 for ; Thu, 14 Mar 2024 14:49:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E539B6FE10; Thu, 14 Mar 2024 14:48:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="IPlBmEXX" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 07BD56FE11; Thu, 14 Mar 2024 14:48:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710427734; cv=none; b=nx+2KnB8e3bxbeYinxjzIr9aGyn4r5VFOEAYOeRuIkwbgX0PUd1Be4o3SLY5LyQwaPrO6Lqf0I/ILe6TJtUn690of4pwV5HXdcDTEmsjr35nD7bLpyrXDgbV3I1wXJWxeNXV4IIGswUoIBxTPuLkCb/1xpArLeosNrvSCFQnvOw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710427734; c=relaxed/simple; bh=rofZKpUBcRam3OvfUbeuxLCuZr4AEd3TlpTaoB/abvE=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=WFThUm9YbvU/gcDf47UmX06waDIBAZPl2np1reKG23EulTCLs+OpzDU4HXGhqRqHkONiHLlOrBx+fGMPotntcJHa6TyuU/Vi0QBXTltxreFPpSKeDyc5c6Pijr2jt8RhIgEtIm2AlsiN9cmiN44GOBzKwaykh7FmHvH+UE7e2gY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=IPlBmEXX; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 63F5CC433C7; Thu, 14 Mar 2024 14:48:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710427733; bh=rofZKpUBcRam3OvfUbeuxLCuZr4AEd3TlpTaoB/abvE=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=IPlBmEXXyfnENQWhqQBTBTmMMPtorDKGEfbTwS+9N/oaEeaqHn++kLrhpjbwnrUvC SfYRpB+XeLXpk6r8sD/pDcHn1758drWWnPgYrtxrhF8ji17n7JFIpW5jotRtJMau22 aU5JuLYuM8J8l3ExlxbUvA6gozoasCuXcKlMz1xd0dNqhgBbdYEYl+6d/BsrtOob2r U6UW2VOKPRueq/CA1TaSYPaWDjs/O5vBiJV8qvGm/RlJ/ptY/gmZu2Ylbon0/L6mfR vQw5Bnd5o8KiYiQUx+C/op2PL5tLv7M4lWrxkLizoFoyJbOnK6z9gFRkifaGJoS9y/ AMVblH5TcCY6Q== Date: Thu, 14 Mar 2024 14:48:38 +0000 From: Jonathan Cameron To: Vasileios Amoiridis Cc: lars@metafoo.de, andriy.shevchenko@linux.intel.com, ang.iglesiasg@gmail.com, mazziesaccount@gmail.com, ak@it-klinger.de, petre.rodan@subdimension.ro, linus.walleij@linaro.org, phil@raspberrypi.com, 579lpy@gmail.com, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 3/6] iio: pressure: add SCALE and RAW values for channels Message-ID: <20240314144838.49b62a72@jic23-huawei> In-Reply-To: <20240313174007.1934983-4-vassilisamir@gmail.com> References: <20240313174007.1934983-1-vassilisamir@gmail.com> <20240313174007.1934983-4-vassilisamir@gmail.com> X-Mailer: Claws Mail 4.2.0 (GTK 3.24.41; x86_64-pc-linux-gnu) 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=US-ASCII Content-Transfer-Encoding: 7bit On Wed, 13 Mar 2024 18:40:04 +0100 Vasileios Amoiridis wrote: > Add extra IIO_CHAN_INFO_SCALE and IIO_CHAN_INFO_RAW in order to be > able to calculate the processed value with standard userspace IIO > tools. Can be used for triggered buffers as well. > > Signed-off-by: Vasileios Amoiridis > --- > drivers/iio/pressure/bmp280-core.c | 58 ++++++++++++++++++++++++++++++ > 1 file changed, 58 insertions(+) > > diff --git a/drivers/iio/pressure/bmp280-core.c b/drivers/iio/pressure/bmp280-core.c > index dfd845acfa22..6d7734f867bc 100644 > --- a/drivers/iio/pressure/bmp280-core.c > +++ b/drivers/iio/pressure/bmp280-core.c > @@ -138,16 +138,22 @@ static const struct iio_chan_spec bmp280_channels[] = { > { > .type = IIO_PRESSURE, > .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED) | Next to each (or at least the first) existing entry for PROCESSED add a comment that says it is maintained for ABI backwards compatibility reasons. I really don't want people copying the result of this patch into new drivers - we've ended up here because of a less than ideal decision in the past, that history doesn't apply to other drivers. > + BIT(IIO_CHAN_INFO_RAW) | > + BIT(IIO_CHAN_INFO_SCALE) | > BIT(IIO_CHAN_INFO_OVERSAMPLING_RATIO), > }, > { > .type = IIO_TEMP, > .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED) | > + BIT(IIO_CHAN_INFO_RAW) | > + BIT(IIO_CHAN_INFO_SCALE) | > BIT(IIO_CHAN_INFO_OVERSAMPLING_RATIO), > }, > { > .type = IIO_HUMIDITYRELATIVE, > .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED) | > + BIT(IIO_CHAN_INFO_RAW) | > + BIT(IIO_CHAN_INFO_SCALE) | > BIT(IIO_CHAN_INFO_OVERSAMPLING_RATIO), > }, > }; > @@ -156,6 +162,8 @@ static const struct iio_chan_spec bmp380_channels[] = { > { > .type = IIO_PRESSURE, > .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED) | > + BIT(IIO_CHAN_INFO_RAW) | > + BIT(IIO_CHAN_INFO_SCALE) | > BIT(IIO_CHAN_INFO_OVERSAMPLING_RATIO), > .info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ) | > BIT(IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY), > @@ -163,6 +171,8 @@ static const struct iio_chan_spec bmp380_channels[] = { > { > .type = IIO_TEMP, > .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED) | > + BIT(IIO_CHAN_INFO_RAW) | > + BIT(IIO_CHAN_INFO_SCALE) | > BIT(IIO_CHAN_INFO_OVERSAMPLING_RATIO), > .info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ) | > BIT(IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY), > @@ -170,6 +180,8 @@ static const struct iio_chan_spec bmp380_channels[] = { > { > .type = IIO_HUMIDITYRELATIVE, > .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED) | > + BIT(IIO_CHAN_INFO_RAW) | > + BIT(IIO_CHAN_INFO_SCALE) | > BIT(IIO_CHAN_INFO_OVERSAMPLING_RATIO), > .info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ) | > BIT(IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY), > @@ -485,6 +497,52 @@ static int bmp280_read_raw(struct iio_dev *indio_dev, > break; > } > break; > + case IIO_CHAN_INFO_RAW: > + switch (chan->type) { > + case IIO_HUMIDITYRELATIVE: > + *val = data->chip_info->read_humid(data); > + ret = IIO_VAL_INT; > + break; > + case IIO_PRESSURE: > + *val = data->chip_info->read_press(data); > + ret = IIO_VAL_INT; > + break; > + case IIO_TEMP: > + *val = data->chip_info->read_temp(data); > + ret = IIO_VAL_INT; > + break; > + default: > + ret = -EINVAL; > + break; > + } > + break; > + case IIO_CHAN_INFO_SCALE: > + switch (chan->type) { > + case IIO_HUMIDITYRELATIVE: > + *val = data->chip_info->humid_coeffs[0]; > + *val2 = data->chip_info->humid_coeffs[1]; > + ret = IIO_VAL_FRACTIONAL; > + break; > + case IIO_PRESSURE: > + *val = data->chip_info->press_coeffs[0]; > + *val2 = data->chip_info->press_coeffs[1]; > + ret = IIO_VAL_FRACTIONAL; > + break; > + case IIO_TEMP: > + *val = data->chip_info->temp_coeffs[0]; > + *val2 = data->chip_info->temp_coeffs[1]; > + > + if (!strcmp(indio_dev->name, "bmp580")) > + ret = IIO_VAL_FRACTIONAL_LOG2; > + else > + ret = IIO_VAL_FRACTIONAL; > + > + break; > + default: > + ret = -EINVAL; > + break; > + } > + break; > case IIO_CHAN_INFO_OVERSAMPLING_RATIO: > switch (chan->type) { > case IIO_HUMIDITYRELATIVE: