From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BD48AC30653 for ; Sun, 7 Jul 2024 15:22:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Subject:Cc:To: From:Date:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=vFGncygpczJ1GWHPt9izIq2TeThnIgFkk1e09oErmJo=; b=pIUr7LjAO5epLIuvIr11h7PxrE UQt3cP+H4FYOggLkT+LiJrZoTZVFZNTupv1SzYCpILO8jtcmje/YjDy15OCzX+udPr1RRP+lTwolS eNhuWZCtqjvFjP23bZzvPvT9a3Gzc/eppbqNKzFk73f4oaqiPqWEOF4+LVBLhU4sdeSplmbbivYXa 6zHxEsqi7g9kgLx+yv8eDy9SlOajRurenojGKQpWdOtH/s8kGo7atrBnGlZ8NLkdNRINfWAacL3b0 UXRQrgVEyKlLjmtcR+UrHIevLjpKvom7qddWJ4oumW/cZJfRj0o3TS8Wu+LLDDo+s0mftftUnA3uS OgEMvxHg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sQTiN-00000001vpX-16YY; Sun, 07 Jul 2024 15:22:11 +0000 Received: from sin.source.kernel.org ([145.40.73.55]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sQTi7-00000001vmR-3aVv for linux-arm-kernel@lists.infradead.org; Sun, 07 Jul 2024 15:21:57 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 26700CE09B8; Sun, 7 Jul 2024 15:21:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 85403C3277B; Sun, 7 Jul 2024 15:21:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1720365713; bh=ZTHfu8WHstnTq0iDPJMZVpdzuIPlhUF3qHQYwWj77zU=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=VTCxanOfSSdDkk/8LHOTeJaccNd8RmSEyaD7BHh08G2W/sbdqo7u9Iow51ikJEREv AAHFJzDu1oV4jm63Z7nPyNWOn2xmpPAo0Uehm/+5dtWktLZQ6gnTnHSQ5AKJFzLVZm kj/1Sv4aCeBSBFEXkWPZvbcoof3USbQy1Pkl+0JT8/nivShAngLiJ3kKsiXoBLKSqa P+hW6Ptm7CaPrXmhl2UdLBEkVCRzYgN4nHAheSrTyK++g5jjAW40lrg9q0hgQSyTC4 u5n/T/c6INdcILMbeN5ftx6XCPzS555heAYeFwpzzUtAR+gnlcm7nsKCCb63A6mNqk bt4UA8ZydhLpQ== Date: Sun, 7 Jul 2024 16:21:44 +0100 From: Jonathan Cameron To: Olivier Moysan Cc: , Lars-Peter Clausen , Maxime Coquelin , Alexandre Torgue , Nuno Sa , , , , Subject: Re: [PATCH v4 8/8] iio: adc: stm32-dfsdm: add scaling support to dfsdm Message-ID: <20240707162144.19ffc0eb@jic23-huawei> In-Reply-To: <20240704155338.2387858-9-olivier.moysan@foss.st.com> References: <20240704155338.2387858-1-olivier.moysan@foss.st.com> <20240704155338.2387858-9-olivier.moysan@foss.st.com> X-Mailer: Claws Mail 4.3.0 (GTK 3.24.42; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240707_082156_108304_5684C0B4 X-CRM114-Status: GOOD ( 16.28 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, 4 Jul 2024 17:53:36 +0200 Olivier Moysan wrote: > Add scaling support to STM32 DFSDM. > > When used in an analog context, a DFSDM filter typically converts the data > from a sigma delta modulator. The IIO device associated to the DFSDM > filter provides these data as raw data. > The IIO device can provide scaling information (voltage and offset) to > allow conversion of raw data into physical values. > > With the new binding based on IIO backend framework, the sigma delta > modulators are defined as backends providing scaling information. > > The scaling is not supported with legacy binding. > > Signed-off-by: Olivier Moysan > Acked-by: Nuno Sa One really minor thing inline. Jonathan > @@ -1278,7 +1308,14 @@ static int stm32_dfsdm_read_raw(struct iio_dev *indio_dev, > int *val2, long mask) > { > struct stm32_dfsdm_adc *adc = iio_priv(indio_dev); > - int ret; > + > + struct stm32_dfsdm_filter *fl = &adc->dfsdm->fl_list[adc->fl_id]; > + struct stm32_dfsdm_filter_osr *flo = &fl->flo[fl->fast]; > + u32 max = flo->max << (flo->lshift - chan->scan_type.shift); > + int ret, idx = chan->scan_index; Trivial but I've been grumping at others about this today so you get it too ;) Don't mix declarations that include assignments with ones that don't. It isn't good for general readability. int idx = chan->scan_index; int ret; I'm not interested in patches to 'fix' this in other code, but nice to not introduce more cases in new code. > + > + if (flo->lshift < chan->scan_type.shift) > + max = flo->max >> (chan->scan_type.shift - flo->lshift); > > switch (mask) { > case IIO_CHAN_INFO_RAW: