Received: by 2002:a05:6358:53a8:b0:117:f937:c515 with SMTP id z40csp3530892rwe; Sun, 16 Apr 2023 22:35:57 -0700 (PDT) X-Google-Smtp-Source: AKy350Y5ckkrtnvZfdiJuTkxIpQVPx5+qqMehhHYscOcRatsP6UYFVIu+nXhJPe1xXVFbNH3WVf+ X-Received: by 2002:a17:90b:3115:b0:23f:b609:e707 with SMTP id gc21-20020a17090b311500b0023fb609e707mr14135895pjb.2.1681709757629; Sun, 16 Apr 2023 22:35:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681709757; cv=none; d=google.com; s=arc-20160816; b=cmYnsJpCHUgwROSrwFZF1Ciq30+Klmh+b2L2GEGOvlM/f/AAuTiWUX5Fu/iyc2wkky qqAbvB0eCbRWrEQNuUrwirWbMNrYDdzEjA7yOZyEaCMktJBfRfMtJigL3G7lQRZNuSu6 zu0KXh3H0Qs+UBMFIcgz5mcE8YTJTsmyhi60vOpBghic4PO3q0gcDCAdLx7W+QeSKlRw Ocw/1WxgZSuW5vm+ew/GIP9Z6fdsJBKDjtueclQTzviF+eyaHNdMkRimRMET94HRlcrI 2kJyaMbbJYeOTaU/57RPt2emyiPbEQMHxjvSdlg1QrXa3m3qxP9Dj+BHhJIwpZqfgNCQ g4yQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=XqhitnjRrt2Lkm/J3mA2gm0kpUqsLtEyVl0+f/7q8Zc=; b=q7dqr0nG7Su0jMmLcx5q+3oM0LuWzlHvuBZRGczlp1X/I4NnsWmrWCnNp9NJhQNhs1 cOwpTaiw/SRalv7Q2Phvg8fkuF103l1b83NcRuGNHdGP48fezgDvpWJOzBebB52nAREe zBHcdvuSlxfPnEBKpZ75Fyn34gi7a9h28ByrxyGSxliy0YGS/ykSiwPlR2YQGBWP27xp UEMnPsPRymJfBIdMqdvBirkcKYZeAxSOXXIZAuKGrpIYzMG/MxiTVCIJJa6mWwPJeGIa pbsOQDz0bwhXnA4z70hW5KL0ulrwopcFDfCcjQc2mSrkzaavilsI5ubs+tauL28wJII7 POdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=M+6TLzFY; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lk11-20020a17090b33cb00b0024750453f25si7052450pjb.185.2023.04.16.22.35.44; Sun, 16 Apr 2023 22:35:57 -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 (test mode) header.i=@ideasonboard.com header.s=mail header.b=M+6TLzFY; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229574AbjDQFaz (ORCPT + 99 others); Mon, 17 Apr 2023 01:30:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53432 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229458AbjDQFax (ORCPT ); Mon, 17 Apr 2023 01:30:53 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B33126B8; Sun, 16 Apr 2023 22:30:49 -0700 (PDT) Received: from pendragon.ideasonboard.com (133-32-181-51.west.xps.vectant.ne.jp [133.32.181.51]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id AF1DB75B; Mon, 17 Apr 2023 07:30:41 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1681709442; bh=eovj2G78JXYDRcIrgt0oiYQ6nuD4yXkGQthiJoaUxDg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=M+6TLzFYs7Qu8jtTZSt3cj4EjETYc6y6Vld85joRJSvPhQP3neSnGZrve8zfxONvR OgALy57ujP5SxzozDU3/ZCKyA1N3NBLPa8EAfzuvJTWtdDOHZht118RYSiZfseQwHO z8q+dGnM+gzmrIbYqsJOqJK4xGkSRct8IA+InNDg= Date: Mon, 17 Apr 2023 08:30:59 +0300 From: Laurent Pinchart To: Christophe JAILLET Cc: Manivannan Sadhasivam , Mauro Carvalho Chehab , Sakari Ailus , linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, linux-media@vger.kernel.org Subject: Re: [PATCH] media: i2c: imx296: Fix error handling while reading temperature Message-ID: <20230417053059.GC28551@pendragon.ideasonboard.com> References: <827f94730c85b742f9ae66209b383a50ca79ec43.1681683246.git.christophe.jaillet@wanadoo.fr> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <827f94730c85b742f9ae66209b383a50ca79ec43.1681683246.git.christophe.jaillet@wanadoo.fr> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,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 Hi Christophe, Thank you for the patch. On Mon, Apr 17, 2023 at 12:14:42AM +0200, Christophe JAILLET wrote: > If imx296_read() returns an error, its returned value is a negative value. > But because of the "& IMX296_TMDOUT_MASK" (i.e. 0x3ff), 'tmdout' can't be > negative. > > So the error handling does not work as expected and a wrong value is used > to compute the temperature. > > Apply the IMX296_TMDOUT_MASK mask after checking for errors to fix it. > > Fixes: cb33db2b6ccf ("media: i2c: IMX296 camera sensor driver") > Signed-off-by: Christophe JAILLET Dan Carpenter has submitted the same fix in https://lore.kernel.org/linux-media/Y%2FYf19AE78jn5YW7@kili/. Sakari, could you please pick it up ? > --- > drivers/media/i2c/imx296.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/drivers/media/i2c/imx296.c b/drivers/media/i2c/imx296.c > index 4f22c0515ef8..c3d6d52fc772 100644 > --- a/drivers/media/i2c/imx296.c > +++ b/drivers/media/i2c/imx296.c > @@ -922,10 +922,12 @@ static int imx296_read_temperature(struct imx296 *sensor, int *temp) > if (ret < 0) > return ret; > > - tmdout = imx296_read(sensor, IMX296_TMDOUT) & IMX296_TMDOUT_MASK; > + tmdout = imx296_read(sensor, IMX296_TMDOUT); > if (tmdout < 0) > return tmdout; > > + tmdout &= IMX296_TMDOUT_MASK; > + > /* T(°C) = 246.312 - 0.304 * TMDOUT */; > *temp = 246312 - 304 * tmdout; > -- Regards, Laurent Pinchart