Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp755439iog; Mon, 13 Jun 2022 12:13:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzvksVFCb79FfeLCWj8YQyyTP7scgAiBaOpidxEocypd8nipz4aaR/WpWb/PE9Nt4tuefmj X-Received: by 2002:aa7:85d1:0:b0:51b:f4b5:db7b with SMTP id z17-20020aa785d1000000b0051bf4b5db7bmr675220pfn.41.1655147601758; Mon, 13 Jun 2022 12:13:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655147601; cv=none; d=google.com; s=arc-20160816; b=DnFX7lK0VXWkF7ecFd5ReYJdw2fCQOerb3yOuo/P7ALiKnD9RnlijGg9ns8Er5GDTx oWN9SkAtLbadeFAtdgs68FD9hNsBtoVRthvdfOD3GAvBRxZagotwVPI+4rGvMUb3Sork H/BsK58d++qVQdA9X25w+KZA1VoyS9Y1J0jASppLOryL6qscydlBE5CMiVYnR7GQg6Eg Uz7/YRAdX1lukSEACx5zW0GFGrgdCqgiOa+6akmei8o+rQAR7dn9Sbfc9DSCn1eCH6y/ 2yMQAl7GghyburfU+tjrQOBY1JW+6Y9nR7rcS0ngqADqIaPTcw6aEkHWw6oOVj6jSTjh I6/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=eGdfXfwfV78gnjcf5UQqAMy9o19LId4Sm/qy2tCjefs=; b=UcIjGZAkv9ZApSiDhPySzKwNZeh0wxa3hZEhhCZIZV2suz4ahJP/JuVLVtaSoaHY48 0HNGKzwibQrGqo2vUNsdIKn8qlcCKJ1nD7EBfvy3iYotSm6NM7Vw/EH0CMGIvEGRxmdt jpRly1y3GxfBC4ARPufRZ2Dj1t0OSc9M5JpybC+gauEG1qLRR7gMgfIOXSt001B5nTXm El94N0RGHBRthi46hj+SJf4i86AFA0X86A9OgNRdHXC2DfwMKjqCKbix5ukDNQ9cISNF qM+qyN1fMWWtsAIaaa1WlbxJq9u3YtMXPEo0tOgKtVNLGa78/yq7C1fATi+sbRcaYoaM yaCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=gsPB1T8U; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ip4-20020a17090b314400b001e056b31018si13893795pjb.166.2022.06.13.12.13.09; Mon, 13 Jun 2022 12:13:21 -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=@gmail.com header.s=20210112 header.b=gsPB1T8U; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346996AbiFMTEV (ORCPT + 99 others); Mon, 13 Jun 2022 15:04:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54634 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346091AbiFMTDK (ORCPT ); Mon, 13 Jun 2022 15:03:10 -0400 Received: from mail-ed1-x530.google.com (mail-ed1-x530.google.com [IPv6:2a00:1450:4864:20::530]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 927A02E9D8; Mon, 13 Jun 2022 09:44:47 -0700 (PDT) Received: by mail-ed1-x530.google.com with SMTP id g7so7987645eda.3; Mon, 13 Jun 2022 09:44:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=eGdfXfwfV78gnjcf5UQqAMy9o19LId4Sm/qy2tCjefs=; b=gsPB1T8UwmLJ1VZ61mRDNQvLBYrwjhjBqt/329BAIA+3SWHdyZWq5P/srAA8mQz2Vg X4SH0kJTHXqlUv4UfZXuA+pPanPwPwqsFxEYsoMy7nsTwoIRHMMrF10tZOmWrS4I8COp T4kJWRqrqX/dZXSg4lRzX8AWr9U7kmdfdEKzUboA62O9M9+GnPu8XWQIPOV8C0rjW9U/ PWbTD1kgEcV5StqWbzVRUbaaDZp3zN1/hdNJrmv6o8JhYAoK8F6Fr+fCvUB+xL9X+gsu B4fgGZ0ru7YLIs/i4HhVtBoMPyGEt43GMTiu2gYKp/IbCJcVuP3zrAjjrGZDgcyOeET9 xuBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=eGdfXfwfV78gnjcf5UQqAMy9o19LId4Sm/qy2tCjefs=; b=txPegyLmNPjX+yJo9QY1Spml6GdMmbSJyawVzUIkad7c99yWGzO9RUUB6z3guM+m3G hrpy6nFcwhrT6J/JAvEtNhxPcn5+LJ6QpjqpwwUZhl6FR9Yk1NJWFC4bsILh5wIlm/6l CrpCvW7TmXAdIJIW94lnlQz5nOAjE33R/1ibWi7U+FJj3pR/Cxm1mZjidTBtHjJAegsm LAQKVPl8xd2P5CaEL3ANsyzQ2hHmNHrTo+XYVJ1jFJxMd77JvbeXyY+nN7EDhBrVQjAk Ym7eiW1ILwj2ivUeOBaZSMfMtfe0nbu6ikrljiJCcOvmKsTEPjkKdj1AZRIVQkynlmVM lCGA== X-Gm-Message-State: AOAM532Nnwp8E2qt/4tjGLxkyD7Xz1G7ae2Vk4N1nDwJwHlwGXpWamHb xCDT6MTjndkrG0piWsJe7PyP7mWljDGlZ9oG/sY= X-Received: by 2002:aa7:d481:0:b0:42d:d5fd:f963 with SMTP id b1-20020aa7d481000000b0042dd5fdf963mr664238edr.209.1655138685998; Mon, 13 Jun 2022 09:44:45 -0700 (PDT) MIME-Version: 1.0 References: <20220613120534.36991-1-andrea.merello@iit.it> <20220613120534.36991-9-andrea.merello@iit.it> In-Reply-To: <20220613120534.36991-9-andrea.merello@iit.it> From: Andy Shevchenko Date: Mon, 13 Jun 2022 18:44:09 +0200 Message-ID: Subject: Re: [v6 08/14] iio: imu: add Bosch Sensortec BNO055 core driver To: Andrea Merello Cc: Jonathan Cameron , Mauro Carvalho Chehab , linux-iio , Linux Kernel Mailing List , devicetree , Lars-Peter Clausen , Rob Herring , Matt Ranostay , Alexandru Ardelean , jmondi Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,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, Jun 13, 2022 at 2:05 PM wrote: > > From: Andrea Merello > > Add the core driver for the BNO055 IMU from Bosch. This IMU can be > connected via both serial and I2C busses; separate patches will add support > for them. > > The driver supports "AMG" (Accelerometer, Magnetometer, Gyroscope) mode, > that provides raw data from the said internal sensors, and a couple of > "fusion" modes (i.e. the IMU also does calculations in order to provide > euler angles, quaternions, linear acceleration and gravity measurements). > > In fusion modes the AMG data is still available (with some calibration > refinements done by the IMU), but certain settings such as low pass filters > cut-off frequency and sensors' ranges are fixed, while in AMG mode they can > be customized; this is why AMG mode can still be interesting. ... > +config BOSCH_BNO055_IIO Does it need _IIO suffix? Any name collision? ... > +static int bno055_acc_lpf_vals[] = { > + 7, 810000, 15, 630000, 31, 250000, 62, 500000, > + 125, 0, 250, 0, 500, 0, 1000, 0 + Comma? > +}; ... > + /* G: 2, 4, 8, 16 */ Indentation of this comment is a bit off. > +static int bno055_acc_range_vals[] = {1962, 3924, 7848, 15696}; Perhaps split this to 4 lines and put the comment on top of the third line? ... > +static int bno055_gyr_scale_vals[] = { > + 125, 1877467, 250, 1877467, 500, 1877467, > + 1000, 1877467, 2000, 1877467 + Comma? > +}; ... > +#ifdef CONFIG_DEBUG_FS > + struct dentry *debugfs; > +#endif ... > + /* > + * IMU reports sensor offests; IIO wants correction offsets > + * offsets, thus we need the 'minus' here. > + */ ... > + if (kstrtobool(buf, &en)) > + return -EINVAL; Why shadow an actual error code(s)? ... > + ret = kstrtoul(buf, 10, &val); > + if (ret) > + return ret; Here it's done properly (see just above). ... > +static void bno055_debugfs_init(struct iio_dev *iio_dev) > +{ > + struct bno055_priv *priv = iio_priv(iio_dev); > + > + priv->debugfs = debugfs_create_file("firmware_version", 0400, > + iio_get_debugfs_dentry(iio_dev), > + priv, &bno055_fw_version_ops); > + devm_add_action_or_reset(priv->dev, bno055_debugfs_remove, priv->debugfs); Shouldn't we report the potential error here? It's not directly related to debugfs, but something which is not directly related. > +} ... > +static IIO_DEVICE_ATTR(fusion_enable, 0644, > + bno055_fusion_enable_show, > + bno055_fusion_enable_store, 0); IIO_DEVICE_ATTR_RW() > +static IIO_DEVICE_ATTR(in_magn_calibration_fast_enable, 0644, > + bno055_fmc_enable_show, > + bno055_fmc_enable_store, 0); > + > +static IIO_DEVICE_ATTR(in_accel_range_raw, 0644, > + bno055_in_accel_range_show, > + bno055_in_accel_range_store, 0); Ditto for above. ... > + /* > + * All chans are made up 1 16-bit sample, except for quaternion that is channels > + * made up 4 16-bit values. > + * For us the quaternion CH is just like 4 regular CHs. > + * If our read starts past the quaternion make sure to adjust the > + * starting offset; if the quaternion is contained in our scan then make > + * sure to adjust the read len. > + */ -- With Best Regards, Andy Shevchenko