From patchwork Wed Mar 21 10:29:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Masney X-Patchwork-Id: 10299075 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id CED9560385 for ; Wed, 21 Mar 2018 10:29:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BF0C1296F4 for ; Wed, 21 Mar 2018 10:29:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B33AC2975C; Wed, 21 Mar 2018 10:29:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6232D296F4 for ; Wed, 21 Mar 2018 10:29:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751902AbeCUK3j (ORCPT ); Wed, 21 Mar 2018 06:29:39 -0400 Received: from onstation.org ([52.200.56.107]:47362 "EHLO onstation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751744AbeCUK32 (ORCPT ); Wed, 21 Mar 2018 06:29:28 -0400 Received: from xilitla.hsd1.wv.comcast.net (c-98-236-77-125.hsd1.wv.comcast.net [98.236.77.125]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: masneyb) by onstation.org (Postfix) with ESMTPSA id BA5F61E7F; Wed, 21 Mar 2018 10:29:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=onstation.org; s=default; t=1521628167; bh=I0Jb3CRF4YZDoPr+ltyRu1zRo+hjKKRdQqtEoZYgHAE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NreJGdK5LJ1e0PRrHZUa8Wtq0r8snO4G/Muv3C9aUtjaJ6KOpnA13QSjpY8/20xt9 wKfkZPv6eBQONknE5wzf5gDB6HnVPonfzcwU7GnPqUfEfrDjd99if5ykJyYVlpFrs5 CnMLjPYOY98boeafMtd/JrRmjk6NubTh/Afk3lQ0= From: Brian Masney To: jic23@kernel.org, linux-iio@vger.kernel.org Cc: gregkh@linuxfoundation.org, devel@driverdev.osuosl.org, knaack.h@gmx.de, lars@metafoo.de, pmeerw@pmeerw.net, linux-kernel@vger.kernel.org, Jon.Brenner@ams.com Subject: [PATCH 09/11] staging: iio: tsl2x7x: remove ch0 and ch1 variables from tsl2x7x_get_lux() Date: Wed, 21 Mar 2018 06:29:10 -0400 Message-Id: <20180321102912.5130-10-masneyb@onstation.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180321102912.5130-1-masneyb@onstation.org> References: <20180321102912.5130-1-masneyb@onstation.org> Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Remove the ch0 and ch1 variables from tsl2x7x_get_lux() and write those values directly into the chip->als_cur_info.als_ch0 and chip->als_cur_info.als_ch01 variables. Signed-off-by: Brian Masney --- drivers/staging/iio/light/tsl2x7x.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/drivers/staging/iio/light/tsl2x7x.c b/drivers/staging/iio/light/tsl2x7x.c index 1e38e8449f9e..65b7fbca8c5d 100644 --- a/drivers/staging/iio/light/tsl2x7x.c +++ b/drivers/staging/iio/light/tsl2x7x.c @@ -336,7 +336,6 @@ static int tsl2x7x_write_control_reg(struct tsl2X7X_chip *chip, u8 data) */ static int tsl2x7x_get_lux(struct iio_dev *indio_dev) { - u16 ch0, ch1; /* separated ch0/ch1 data from device */ u32 lux; /* raw lux calculated from device data */ u64 lux64; u32 ratio; @@ -382,24 +381,24 @@ static int tsl2x7x_get_lux(struct iio_dev *indio_dev) } /* extract ALS/lux data */ - ch0 = le16_to_cpup((const __le16 *)&buf[0]); - ch1 = le16_to_cpup((const __le16 *)&buf[2]); + chip->als_cur_info.als_ch0 = le16_to_cpup((const __le16 *)&buf[0]); + chip->als_cur_info.als_ch1 = le16_to_cpup((const __le16 *)&buf[2]); - chip->als_cur_info.als_ch0 = ch0; - chip->als_cur_info.als_ch1 = ch1; - - if (ch0 >= chip->als_saturation || ch1 >= chip->als_saturation) { + if (chip->als_cur_info.als_ch0 >= chip->als_saturation || + chip->als_cur_info.als_ch1 >= chip->als_saturation) { lux = TSL2X7X_LUX_CALC_OVER_FLOW; goto return_max; } - if (!ch0) { + if (!chip->als_cur_info.als_ch0) { /* have no data, so return LAST VALUE */ ret = chip->als_cur_info.lux; goto out_unlock; } + /* calculate ratio */ - ratio = (ch1 << 15) / ch0; + ratio = (chip->als_cur_info.als_ch1 << 15) / chip->als_cur_info.als_ch0; + /* convert to unscaled lux using the pointer to the table */ p = (struct tsl2x7x_lux *)chip->tsl2x7x_device_lux; while (p->ratio != 0 && p->ratio < ratio) @@ -408,9 +407,9 @@ static int tsl2x7x_get_lux(struct iio_dev *indio_dev) if (p->ratio == 0) { lux = 0; } else { - lux = DIV_ROUND_UP(ch0 * p->ch0, + lux = DIV_ROUND_UP(chip->als_cur_info.als_ch0 * p->ch0, tsl2x7x_als_gain[chip->settings.als_gain]) - - DIV_ROUND_UP(ch1 * p->ch1, + DIV_ROUND_UP(chip->als_cur_info.als_ch1 * p->ch1, tsl2x7x_als_gain[chip->settings.als_gain]); }