Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1455462pxk; Sun, 13 Sep 2020 03:25:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyOnzIVS7M9WboVxl55rkhpxUF+c7ET7mG1jbvHgdVNEIZEcoJnpsmcKgbpL5ilOjqWrwTn X-Received: by 2002:a50:9fa1:: with SMTP id c30mr11840239edf.207.1599992741609; Sun, 13 Sep 2020 03:25:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599992741; cv=none; d=google.com; s=arc-20160816; b=BTxB3B6Eq86m2Wd4St6J/osXyqxwHkLCVF7LjamdQ6R4q7XJuKeeG+Zl5Frd6mF8WB 2nFhUBuQ1bbp0ePdNmeL94twocsCI6C9FLFnOEaDPF8UuUcfFT0OywlbNW5J4mysPpx3 PBl/Q3awkqvfSTHr6iqem0IO9hj8+BjN8bV9w609+AJ8FKmdiBBnrHYJ+6nYGeaRVvc/ rRxtchifvIwF5WNbY3QOxzWU2e/C/ZYbD4ICMpkqb4rtldXti0Yi8pew/rGWEXnaU5Yr 2WCUjz+cz5ub01/ZyqbZAMWc/b7y3FOs+MV6iKzNdkEac+agg0LvvUHJvjOaOh/vy8hz kEUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=VjtbrwFeUIaNBlmRVt0IUVaHfpAQ7vtVrZrm9A23mcY=; b=tJ659PP2Q+61wJSGenGQKJOeBE64upbvn86G638XoOrLjsnFGCgcN+UIhbS7D7ceOD FFtqKacEysVk2T3Ifp/PZiaMC1rAgK78ZsTBxkRUaPbIKougpj0ntHB+xjXlPwkxKxuw V2wPx1wn7QpygM7juwBF2L1ffmnoY5bLFOByejU4b7a5Xk1NaWiNbZjyvwWG3uPdUs1u xRHhLowPEKUrG6LiZR63JWQ8LJongBmQ5zLPIB88ljqA9Sug46PN9QUaL8+XZ6IXjSZ4 gHSZpSfRP8ZvXTpp/glJ5ysk6rZYGuibhNmTzFshw3Xk1dgTRxk1ktFT2sQUcj98cx6h sIAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=RRzfYYSF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v2si2993463ejk.578.2020.09.13.03.25.16; Sun, 13 Sep 2020 03:25:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=RRzfYYSF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725946AbgIMKWh (ORCPT + 99 others); Sun, 13 Sep 2020 06:22:37 -0400 Received: from mail.kernel.org ([198.145.29.99]:58276 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725921AbgIMKWf (ORCPT ); Sun, 13 Sep 2020 06:22:35 -0400 Received: from archlinux (cpc149474-cmbg20-2-0-cust94.5-4.cable.virginm.net [82.4.196.95]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 20AA820709; Sun, 13 Sep 2020 10:22:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599992554; bh=VjtbrwFeUIaNBlmRVt0IUVaHfpAQ7vtVrZrm9A23mcY=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=RRzfYYSFADPgfh68uCeXXMNFRCJEs9eKGw92ImOz5696tiYATv/roGQjfhRQCznrv 99YeeYsO+CwRDjFNSaWC/y5Mm5wLYUi2kOIrfMDmHyJcXfNtGUVtVtTqb1TDiK/NpS ZaGRW8F1MGQHS+Rnb/frJ5LeO0iqMI6N9dlqLUK8= Date: Sun, 16 Aug 2020 09:58:30 +0100 From: Jonathan Cameron To: Jean-Baptiste Maneyrol Cc: Andy Shevchenko , "trix@redhat.com" , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald , =?UTF-8?B?TWljaGE=?= =?UTF-8?B?xYIgTWlyb3PFgmF3?= , Lee Jones , linux-iio , Linux Kernel Mailing List Subject: Re: [PATCH] iio: imu: inv_mpu6050: check for temp_fifo_enable Message-ID: <20200816095830.64650d0a@archlinux> In-Reply-To: References: <20200809155936.16898-1-trix@redhat.com> X-Mailer: Claws Mail 3.17.6 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 13 Aug 2020 08:04:06 +0000 Jean-Baptiste Maneyrol wrote: > Hello, >=20 > this is a case that should never be happening since available scan mask o= nly advertise Accel + Temp, Gyro + Temp, or Accel + Gyro + Temp. > More than that, temperature sensor is not working when MEMS engine is off= . (it's only purpose it to measure temperature of the MEMS to do data tempe= rature compensation). >=20 > So I think we can let this check as it is currently, since this is not a = supported configuration. >=20 Perhaps a good option would be to add a suitably positioned comment to make this clear so we don't get further patches 'fixing' this in the future? Thanks, Jonathan > Best regards, > JB >=20 >=20 > From: Andy Shevchenko > Sent: Monday, August 10, 2020 10:02 > To: trix@redhat.com > Cc: Jonathan Cameron ; Hartmut Knaack = ; Lars-Peter Clausen ; Peter Meerwald ;= Jean-Baptiste Maneyrol ; Micha=C5=82 Miros=C5=82= aw ; Lee Jones ; linux-iio <= linux-iio@vger.kernel.org>; Linux Kernel Mailing List > Subject: Re: [PATCH] iio: imu: inv_mpu6050: check for temp_fifo_enable=20 > =C2=A0 > =C2=A0CAUTION: This email originated from outside of the organization. Pl= ease make sure the sender is who they say they are and do not click links o= r open attachments unless you recognize the sender and know the content is = safe. >=20 > On Sun, Aug 9, 2020 at 7:00 PM wrote: > > > > From: Tom Rix > > > > clang static analysis reports this problem > > > > inv_mpu_ring.c:181:18: warning: Division by zero > >=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 nb =3D fifo_count / byt= es_per_datum; > >=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 ~~~~~~~~~~~^~~~~~~~~~~~~~~~~ > > > > This is a false positive. > > Dividing by 0 is protected by this check > > > >=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (!(st->chip_config.a= ccl_fifo_enable | > >=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 st->chip_config.gyro_fifo_enable | > >=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 st->chip_config.magn_fifo_enable)) > >=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 goto end_session; > >=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 bytes_per_datum =3D 0; > > > > But there is another fifo, temp_fifo > > > >=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (st->chip_config.tem= p_fifo_enable) > >=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 bytes_per_datum +=3D INV_MPU6050_BYTES_PER_TEMP_SE= NSOR; > > > > Which would be skipped if it was the only enabled fifo. > > So add to the check. > > =20 >=20 > > Fixes: 2e4c0a5e2576 ("iio: imu: inv_mpu6050: add fifo temperature data = support") > > > > Signed-off-by: Tom Rix =20 >=20 > There shouldn't be a blank line in between. >=20 > Other than that, > Reviewed-by: Andy Shevchenko >=20 >=20 >=20 > > --- > >=C2=A0 drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c | 1 + > >=C2=A0 1 file changed, 1 insertion(+) > > > > diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c b/drivers/iio/i= mu/inv_mpu6050/inv_mpu_ring.c > > index b533fa2dad0a..5240a400dcb4 100644 > > --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c > > +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c > > @@ -141,6 +141,7 @@ irqreturn_t inv_mpu6050_read_fifo(int irq, void *p) > > > >=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (!(st->chip_config.a= ccl_fifo_enable | > >=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 st->chip_config.gyro_fifo_enable | > > +=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 st->chip_config.temp_fifo_enable | > >=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 st->chip_config.magn_fifo_enable)) > >=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 goto end_session; > >=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 bytes_per_datum =3D 0; > > -- > > 2.18.1 > > =20 >=20 >=20 > -- > With Best Regards, > Andy Shevchenko