From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Cc: Manivannan Sadhasivam <mani@kernel.org>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Sakari Ailus <sakari.ailus@linux.intel.com>,
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
Date: Mon, 17 Apr 2023 08:30:59 +0300 [thread overview]
Message-ID: <20230417053059.GC28551@pendragon.ideasonboard.com> (raw)
In-Reply-To: <827f94730c85b742f9ae66209b383a50ca79ec43.1681683246.git.christophe.jaillet@wanadoo.fr>
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 <christophe.jaillet@wanadoo.fr>
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
next prev parent reply other threads:[~2023-04-17 5:31 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-16 22:14 Christophe JAILLET
2023-04-17 5:30 ` Laurent Pinchart [this message]
2023-04-17 10:00 ` Sakari Ailus
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230417053059.GC28551@pendragon.ideasonboard.com \
--to=laurent.pinchart@ideasonboard.com \
--cc=christophe.jaillet@wanadoo.fr \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mani@kernel.org \
--cc=mchehab@kernel.org \
--cc=sakari.ailus@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®