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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2B1F5C433EF for ; Sat, 16 Jul 2022 15:55:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232273AbiGPPzu (ORCPT ); Sat, 16 Jul 2022 11:55:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56294 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229865AbiGPPzt (ORCPT ); Sat, 16 Jul 2022 11:55:49 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1505E120A2; Sat, 16 Jul 2022 08:55:49 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id A4B0261137; Sat, 16 Jul 2022 15:55:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5A1DEC34114; Sat, 16 Jul 2022 15:55:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1657986948; bh=iKJk2iY7/xXpJdIBMRXKwzFi0/z2BbDmJmuPi7R5wOE=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=YGUrcHpUg+X9jNbTj2Cqjg8a7ngo4h9R9LvQzzkrCRQH5orMpx2YXEfHYOnLrGJ0O eTCmhxYqUa4wV1twut1+m7STcQgCtxC5pQ5zTJU0KsTaNf2JbpdAYRJNmP550s1TVW 8cpfyMxKULB0awb2a0z9uf8t9UKhQsgDpuz/kjfKn6jPNHsuL2Fn2e0Y5n1fY6mc4d C6C3qUkzLZSDFmxim/LZQGJJjP2z2B916Cr/4Zq/vm+93uDFM7D1yds8+mxgzjep3Q wVY6McsOugd4EOavAqUQIXYDBKBxTPb5WpWUBI4UqWhFVvHtftIcvSmIQPU5RBn6uU oMNX5KSlc6ABQ== Date: Sat, 16 Jul 2022 17:05:40 +0100 From: Jonathan Cameron To: Angel Iglesias Cc: Lars-Peter Clausen , "Rafael J. Wysocki" , Ulf Hansson , Paul Cercueil , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 3/3] iio: pressure: bmp280: Adds more tunable config parameters for BMP380 Message-ID: <20220716170540.0d767e2f@jic23-huawei> In-Reply-To: <5f47527553a3e191e8e458401c1ad9abddd598dc.camel@gmail.com> References: <20220625151039.48148-1-ang.iglesiasg@gmail.com> <20220626153908.5b71d2ac@jic23-huawei> <5f47527553a3e191e8e458401c1ad9abddd598dc.camel@gmail.com> X-Mailer: Claws Mail 4.1.0 (GTK 3.24.34; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org On Mon, 27 Jun 2022 18:10:48 +0200 Angel Iglesias wrote: > On dom, 2022-06-26 at 15:39 +0100, Jonathan Cameron wrote: > > On Sat, 25 Jun 2022 17:10:36 +0200 > > Angel Iglesias wrote: > > =20 > > > Allows to configure the IIR filter coefficient and the sampling > > > frequency > > > The IIR filter coefficient is exposed using the sysfs attribute > > > "filter_low_pass_3db_frequency" > > >=20 > > > Signed-off-by: Angel Iglesias =20 > > Hi Angel > >=20 > > A few comments inline, =20 > > > --- >=20 > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0*val2 =3D data->chip_info->sampling_freq_avail[data= - =20 > > > >sampling_freq][1]; =20 > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0ret =3D IIO_VAL_INT_PLUS_MICRO; > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0break; > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0case IIO_CHAN_INFO_LOW_PAS= S_FILTER_3DB_FREQUENCY: > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0*val =3D data->chip_info- =20 > > > >iir_filter_coeffs_avail[data->iir_filter_coeff]; =20 > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0ret =3D IIO_VAL_INT; > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0break; > > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0default: > > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0ret =3D -EINVAL; > > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0break; > > > @@ -577,6 +647,39 @@ static int > > > bmp280_write_oversampling_ratio_press(struct bmp280_data *data, > > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0return -EINVAL; > > > =C2=A0} > > > =C2=A0 > > > +static int bmp280_write_sampling_frequency(struct bmp280_data > > > *data, > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 int val, int val2) > > > +{ > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0int i; > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0const int (*avail)[2] =3D = data->chip_info- =20 > > > >sampling_freq_avail; =20 > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0const int n =3D data->chip= _info->num_sampling_freq_avail; > > > + > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0for (i =3D 0; i < n; i++) { > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0if (avail[i][0] =3D=3D val && avail[i][1] =3D=3D va= l2) { > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0dat= a->sampling_freq =3D i; =20 > > better to only set the cached value if the write succeeds. > >=20 > > e.g. > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= ret =3D data->chip_info->chip_config(data); > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= if (ret) > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0return ret; > >=20 > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= data->sampling_freq =3D i; > >=20 > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= return 0; =20 >=20 > Ok! Should I restore the previous value in case of failure? The condition is pretty much unknowable, so normally we just assume failure means it didn't write.