From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966589AbcKLQ7k (ORCPT ); Sat, 12 Nov 2016 11:59:40 -0500 Received: from onstation.org ([52.200.56.107]:55684 "EHLO onstation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966413AbcKLQ7i (ORCPT ); Sat, 12 Nov 2016 11:59:38 -0500 Date: Sat, 12 Nov 2016 11:59:35 -0500 From: Brian Masney To: Jonathan Cameron Cc: linux-iio@vger.kernel.org, devel@driverdev.osuosl.org, gregkh@linuxfoundation.org, lars@metafoo.de, pmeerw@pmeerw.net, knaack.h@gmx.de, linux-kernel@vger.kernel.org, Jon.Brenner@ams.com Subject: Re: [PATCH v3 16/28] staging: iio: tsl2583: updated code comment to match what the code does Message-ID: <20161112165935.GB31082@basecamp.onstation.org> References: <1478769964-7065-1-git-send-email-masneyb@onstation.org> <1478769964-7065-17-git-send-email-masneyb@onstation.org> <67166adf-5a89-3283-8a16-9a0a9a57e770@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <67166adf-5a89-3283-8a16-9a0a9a57e770@kernel.org> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Nov 12, 2016 at 04:36:37PM +0000, Jonathan Cameron wrote: > On 10/11/16 09:25, Brian Masney wrote: > > If channel 0 does not have any data, then the code sets the lux to zero. > > The corresponding comment says that the last value is returned. This > > updates the comment to correctly reflect what the code does. > > > > Signed-off-by: Brian Masney > Better perhaps to just return an error, -EAGAIN perhaps? > I'm not sure why it would not give a value. This check is to avoid a division by zero. Here is the relevant code that wasn't shown in the diff: if (!ch0) { /* have no data, so return 0 */ ret = 0; chip->als_cur_info.lux = 0; goto done; } /* calculate ratio */ ratio = (ch1 << 15) / ch0; Channel 0 is sensitive to both infrared and visible light. In total darkness, the sensor should return 0. Correct me if I am wrong, but I believe that returning 0 here is more correct than -EAGAIN. Brian