Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp3360589pxp; Tue, 22 Mar 2022 18:29:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyzV1fa0fmUgtnEr37fUkgDcpk1G2TxO3+6f+c92lgdZCPP+pIp+ujTlTa7PM6moLzgEpgC X-Received: by 2002:a17:906:c107:b0:6df:c114:e286 with SMTP id do7-20020a170906c10700b006dfc114e286mr21452682ejc.216.1647998983791; Tue, 22 Mar 2022 18:29:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647998983; cv=none; d=google.com; s=arc-20160816; b=lOBSvoparEoRChB4Uo50u84wrf++XwYQQ7ayMpMRHSUI1r7Z00O2aeBgeSQVVv6kzg VF3z2+rkXuLzkpIPvess67Gj1Y1saUDHAzrnFIzjk67EQEZlZvWXjDt9aNGVe53hY68r sFqpV9DE55SHNSrub1Wmnytc90aAhEdlG90zCvCKKe/176fGR4FE6ToKiJxjfZ1CTVle /CXkDgk6zvnx1b5heRK63TUZ+JU2FA8IUS+1XcDw7d6hntCpt9tTsR5lBSHLWKfSzXT/ 8If2a7/+hSdyG5t+8YjkJ+K0236v9/ZGr+35wvRE6qNIjnXb+pgowMl8TUq/ThR0hB31 zB0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date; bh=3+QrWTyHbFmaS3a1OgMoY361mvsA500WWKPyaoeRPkI=; b=DVoSSV88iSBRMwb1vyofNcm+lrO4EK9kkW1k8VhNuxv0gEDUhydQfP6rYRAF3D5UL1 mrKl6yGKgk1Lb91fcLMx93gs1f9MSoYQnTtzE23+DYKnI4YgdOWKSrZxbFnPMjcu9AQW e0GdLIqg3VsZp0PPUMFiY6CgEsBGgJc+W8voh/L9KoS5A0rm0uwwNRBT+SAA83bdvwbT Pm1hRjYV+bI/CnOY0CHqAvwlhFdXrqMgGemX51ZpSfpFp4lPubEBrKuxXhAGGarGrbDb vK3nCX9A/CNVC6Gv1j4K2Qud4NyUkWxUWqs+U62tQ2/XIMfUaITEr2mxBg/AQpMiT0jr +5ZA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x15-20020a50f18f000000b00418c2b5be1csi15381195edl.254.2022.03.22.18.29.18; Tue, 22 Mar 2022 18:29:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234105AbiCVUkS (ORCPT + 99 others); Tue, 22 Mar 2022 16:40:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57532 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234154AbiCVUkR (ORCPT ); Tue, 22 Mar 2022 16:40:17 -0400 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2A6DA69293; Tue, 22 Mar 2022 13:38:49 -0700 (PDT) Received: from fraeml705-chm.china.huawei.com (unknown [172.18.147.207]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4KNNYv3qvVz687Yd; Wed, 23 Mar 2022 04:36:35 +0800 (CST) Received: from lhreml710-chm.china.huawei.com (10.201.108.61) by fraeml705-chm.china.huawei.com (10.206.15.54) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2375.24; Tue, 22 Mar 2022 21:38:47 +0100 Received: from localhost (10.47.75.191) by lhreml710-chm.china.huawei.com (10.201.108.61) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21; Tue, 22 Mar 2022 20:38:46 +0000 Date: Tue, 22 Mar 2022 20:38:44 +0000 From: Jonathan Cameron To: Stephen Boyd CC: Jonathan Cameron , Lars-Peter Clausen , , , Gwendal Grignou Subject: Re: [PATCH] iio:proximity:sx9324: Fix hardware gain read/write Message-ID: <20220322203844.0000466f@Huawei.com> In-Reply-To: References: <20220318204808.3404542-1-swboyd@chromium.org> <20220319152641.49d8b3e1@jic23-huawei> Organization: Huawei Technologies Research and Development (UK) Ltd. X-Mailer: Claws Mail 4.0.0 (GTK+ 3.24.29; i686-w64-mingw32) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.47.75.191] X-ClientProxiedBy: lhreml742-chm.china.huawei.com (10.201.108.192) To lhreml710-chm.china.huawei.com (10.201.108.61) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 21 Mar 2022 19:36:33 +0100 Stephen Boyd wrote: > Quoting Jonathan Cameron (2022-03-19 08:26:41) > > On Fri, 18 Mar 2022 13:48:08 -0700 > > Stephen Boyd wrote: > > > > Hi Stephen, > > > > > > > There are four possible gain values according to sx9324_gain_vals[]: 1, > > > 2, 4, and 8. When writing and reading the register the values are off by > > > one. > > > The bits should be set according to this equation: > > > > > > ilog2() + 1 > > > > > > so that a gain of 8 is 0x3 in the register field and a gain of 4 is 0x2 > > > in the register field, etc. Fix up the functions. > > > > So is the 0 value reserved? I can't find an sx9324 datasheet but he > > 9320 is online and that seems to be the case there. If so please state > > that in this description as well. > > Yes 0 is reserved. The top of this driver's C file has the datasheet > link[1] Ah. Thanks ;) > > > > > > > > > Fixes: 4c18a890dff8 ("iio:proximity:sx9324: Add SX9324 support") > > > Cc: Gwendal Grignou > > > Signed-off-by: Stephen Boyd > > > --- > > > drivers/iio/proximity/sx9324.c | 7 +++++-- > > > 1 file changed, 5 insertions(+), 2 deletions(-) > > > > > > diff --git a/drivers/iio/proximity/sx9324.c b/drivers/iio/proximity/sx9324.c > > > index 0d9bbbb50cb4..a3c8e02f5a56 100644 > > > --- a/drivers/iio/proximity/sx9324.c > > > +++ b/drivers/iio/proximity/sx9324.c > > > @@ -379,7 +379,10 @@ static int sx9324_read_gain(struct sx_common_data *data, > > > if (ret) > > > return ret; > > > > > > - *val = 1 << FIELD_GET(SX9324_REG_PROX_CTRL0_GAIN_MASK, regval); > > > + regval = FIELD_GET(SX9324_REG_PROX_CTRL0_GAIN_MASK, regval); > > > + if (regval) > > > > If 0 is reserved then I'd return and error code here to indicate > > we don't know what the gain is rather than carrying on regardless. > > Or is this going to cause problems as it will be an ABI change (error > > return possible when it wasn't really before)? > > > > That sounds OK to me. The driver is only being introduced now so we can > still fix it to reject a gain of 0. Unless 0 should mean "off", i.e. > hardware gain of 1? No. I don't think we want to add that sort of fiddly definition. So error is the way to go - I'd forgotten we only just introduced this so no ABI breakage risk. Jonathan > > [1] https://edit.wpgdadawant.com/uploads/news_file/program/2019/30184/tech_files/program_30184_suggest_other_file.pdf