Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp2558461rwb; Mon, 15 Aug 2022 07:23:56 -0700 (PDT) X-Google-Smtp-Source: AA6agR6mMQ/3IbyGnxDo0PZjEuKL1W+02xLCv7YfBXoTAvvLg9mWVE4MKso8V+2coihtnizjpKsG X-Received: by 2002:a05:6402:26c5:b0:43e:2f1b:31c2 with SMTP id x5-20020a05640226c500b0043e2f1b31c2mr14624133edd.424.1660573436047; Mon, 15 Aug 2022 07:23:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660573436; cv=none; d=google.com; s=arc-20160816; b=wXnJv3W8NNq2gAnmwmzKmvhNlBeGJryyL3osdgxne+BkwD60X0RypbsZDqwId77Ifx A4+Txqq+hpqjWWakYiiSfbNQN5M7jJBr4BdW6icMNysSkhR2FMyKRkKFNpRATHd+jX+1 jbtun0IolnFNSYGSi4/BhzT7gLvijGrDsXchSAZ1VRnOLV0eQEkx7ViCoByTbHChF+6H uOeXOyAJnECywcUoOCB+5dLMgnGPNTkGwlkCx0zzd70lk1EEEe4w4Ek8ieCQvtNYwPFC ripmeJqKBQcsL/tzq0kguc4Id4ac+7+NNo4puf5TiaLVvNcPPq+10OZRKfWbbonKjGHM eZow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :content-id:content-language:accept-language:in-reply-to:references :message-id:date:thread-index:thread-topic:subject:cc:to:from :dkim-signature; bh=+gk1zIe/2wlOR10+rhMR8vZyUOoo8PbfRZUFI4FuEik=; b=u5v88vo4cxtPpV5wqe0CxizLiAxxLzKDtD90uXB9bcsIvCQul5XHx/gRiyBMHYf4og 9x2by8jCqINhmSc6TPwMdvof1hiu5h0KYZVbuOKqREnkLCLz2xC+bMP8HU4NM/JtzjoL tVZD7jhHN+bHY893bljGC+oIkg8//X4QDXP+mp0j1YWWv71LVVrozovk9ANtV3xuCAka r2sww3tcSHShXyKUbvSSnF7DYEXyxzVrKgKXrULYt0MZwr3FGej18rn0QyUfRNG7ji1s oHCn/NoRTAsAqG5Wl/hgykLddJieD0lWbF5ginJYcpdJd7vkHWoiwBZmhU4NTJSCY9jr aoFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sberdevices.ru header.s=mail header.b=beWTLuaE; 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=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=sberdevices.ru Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hc10-20020a170907168a00b0073063cbab03si8096268ejc.655.2022.08.15.07.23.29; Mon, 15 Aug 2022 07:23:56 -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; dkim=pass header.i=@sberdevices.ru header.s=mail header.b=beWTLuaE; 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=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=sberdevices.ru Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242651AbiHOOCZ (ORCPT + 99 others); Mon, 15 Aug 2022 10:02:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46156 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242584AbiHOOCU (ORCPT ); Mon, 15 Aug 2022 10:02:20 -0400 Received: from mail.sberdevices.ru (mail.sberdevices.ru [45.89.227.171]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 133E822B33; Mon, 15 Aug 2022 07:02:15 -0700 (PDT) Received: from s-lin-edge02.sberdevices.ru (localhost [127.0.0.1]) by mail.sberdevices.ru (Postfix) with ESMTP id AA39A5FD05; Mon, 15 Aug 2022 17:02:12 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sberdevices.ru; s=mail; t=1660572132; bh=+gk1zIe/2wlOR10+rhMR8vZyUOoo8PbfRZUFI4FuEik=; h=From:To:Subject:Date:Message-ID:Content-Type:MIME-Version; b=beWTLuaEQ+aONnlAW/G59TyPHF26QbQtq1PHhhYI4FDliH3UGPKs9yOyRIlhpwctO DAUDcHOkAVEpjl4EUhBkWB6Gk8eFSBgYBlb2LJx7to8ff6ykVWbJ6SVcPkeUVbwXax 9RmU1axM5Jsq47aO/saV2qGRpu3BKLaxtv669qH5vA9praMXrISn0nSnM1t3awGlG0 kHrk/1zwedj0t8217KHVqD+cWi7zGOY4xWr8o0mrSUunwVTkQjA5aBBC2gDqM+w4Id abdo8J8T+++caor/mkVjn+DrWWGMIO+cYRpNfsKiwwWBHTxxwk6tmv7IWR4/400fsB dCVC3/bRNK47w== Received: from S-MS-EXCH02.sberdevices.ru (S-MS-EXCH02.sberdevices.ru [172.16.1.5]) by mail.sberdevices.ru (Postfix) with ESMTP; Mon, 15 Aug 2022 17:02:05 +0300 (MSK) From: Dmitry Rokosov To: Andy Shevchenko CC: "akpm@linux-foundation.org" , "jic23@kernel.org" , "robh+dt@kernel.org" , "andriy.shevchenko@linux.intel.com" , "christophe.jaillet@wanadoo.fr" , "stano.jakubek@gmail.com" , "shawnguo@kernel.org" , "stephan@gerhold.net" , "daniel.lezcano@linaro.org" , "wsa@kernel.org" , "lars@metafoo.de" , "Michael.Hennerich@analog.com" , "jbhayana@google.com" , "lucas.demarchi@intel.com" , "jani.nikula@intel.com" , "linus.walleij@linaro.org" , "linux-iio@vger.kernel.org" , kernel , "devicetree@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH v5 6/7] iio: add MEMSensing MSA311 3-axis accelerometer driver Thread-Topic: [PATCH v5 6/7] iio: add MEMSensing MSA311 3-axis accelerometer driver Thread-Index: AQHYrmvoIVWL45TwmUSMsw+zEhPYFa2rqEkAgAQnwoA= Date: Mon, 15 Aug 2022 14:01:13 +0000 Message-ID: <20220815140201.5dpjpk35tdewcpvu@CAB-WSD-L081021.sigma.sbrf.ru> References: <20220812165243.22177-1-ddrokosov@sberdevices.ru> <20220812165243.22177-7-ddrokosov@sberdevices.ru> In-Reply-To: Accept-Language: ru-RU, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [172.16.1.12] Content-Type: text/plain; charset="us-ascii" Content-ID: <987B2D9B23A0EB4184D532ADE9321F15@sberdevices.ru> Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-KSMG-Rule-ID: 4 X-KSMG-Message-Action: clean X-KSMG-AntiSpam-Status: not scanned, disabled by settings X-KSMG-AntiSpam-Interceptor-Info: not scanned X-KSMG-AntiPhishing: not scanned, disabled by settings X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 1.1.2.30, bases: 2022/08/15 12:17:00 #20121227 X-KSMG-AntiVirus-Status: Clean, skipped X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no 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 Sat, Aug 13, 2022 at 01:34:40AM +0300, Andy Shevchenko wrote: [...] > > Spec: https://cdn-shop.adafruit.com/product-files/5309/MSA311-V1.1-ENG.= pdf >=20 > Can you use Datasheet: tag below (just before your SoB tag)? Sure, I can move it on the previous line beforce SoB tag. But with Datasheet: tag this line will be over the commit msg line limit. If you don't mind I will stay with Spec: tag instead of Datasheet: [...] > > +static const struct { > > + int val; > > + int val2; > > +} msa311_fs_table[] =3D { > > + {0, 9580}, {0, 19160}, {0, 38320}, {0, 76641} > > +}; >=20 > At least you may deduplicate the type definition for these data structure= s, like >=20 > struct iio_float { > int integer; > int fract; > }; Agreed. I will make deduplication of this type inside msa311 driver only. [...] > > + dev_err(dev, > > + "cannot set odr %u.%luHz, not available in %s m= ode\n", > > + msa311_odr_table[odr].val, > > + msa311_odr_table[odr].val2 / MILLIHZ_PER_HZ, >=20 > Logically it's MICROHZ_PER_MILLIHZ. >=20 You are right. But I think it would be better to print the original val2 value with zero-padding. [...] > > + freq_uhz =3D msa311_odr_table[odr].val * MICROHZ_PER_HZ + > > + msa311_odr_table[odr].val2; > > + wait_ms =3D (MICROHZ_PER_HZ / freq_uhz) * MSEC_PER_SEC; >=20 > On the contrary this seems correct. Good > > + err =3D iio_device_claim_direct_mode(indio_dev); > > + if (err) > > + return err; > > + > > + mutex_lock(&msa311->lock); > > + err =3D msa311_get_axis(msa311, chan, &axis); > > + mutex_unlock(&msa311->lock); > > + > > + iio_device_release_direct_mode(indio_dev); > > + > > + if (err) { > > + dev_err(dev, "cannot get axis %s (%pe)\n", > > + chan->datasheet_name, ERR_PTR(err)); > > + return err; > > + } > > + > > + pm_runtime_mark_last_busy(dev); > > + pm_runtime_put_autosuspend(dev); >=20 > All error cases above miss the PM restoration. Is it on purpose? > Otherwise fix it here and check everywhere else. Nice catch! This is a bug. I'll fix it in v6 > > + used =3D scnprintf(msa311->chip_name, sizeof(msa311->chip_name)= , > > + "msa311-%hhx", partid); >=20 > > + msa311->chip_name[used] =3D '\0'; >=20 > What is this for exactly? >=20 Ah, you are right, scnprintf() makes null terminating inside. > > + /* Disable all interrupts by default */ > > + err =3D regmap_write(msa311->regs, MSA311_INT_SET_0_REG, 0); > > + if (err) > > + return dev_err_probe(dev, err, > > + "cannot disable set0 interrupts\n"= ); > > + > > + err =3D regmap_write(msa311->regs, MSA311_INT_SET_1_REG, 0); > > + if (err) > > + return dev_err_probe(dev, err, > > + "cannot disable set1 interrupts\n"= ); >=20 > Wondering if the above can be combined to bulk write. >=20 I will try and rework this place if it's workable. > > + /* Unmap all INT1 interrupts by default */ > > + err =3D regmap_write(msa311->regs, MSA311_INT_MAP_0_REG, 0); > > + if (err) > > + return dev_err_probe(dev, err, > > + "failed to unmap map0 interrupts\n= "); > > + > > + err =3D regmap_write(msa311->regs, MSA311_INT_MAP_1_REG, 0); > > + if (err) > > + return dev_err_probe(dev, err, > > + "failed to unmap map1 interrupts\n= "); >=20 > Ditto. The same as above. [...] --=20 Thank you, Dmitry=