From: Jonathan Cameron <jic23@kernel.org>
To: Brian Masney <masneyb@onstation.org>
Cc: devel@driverdev.osuosl.org, lars@metafoo.de,
linux-iio@vger.kernel.org, gregkh@linuxfoundation.org,
linux-kernel@vger.kernel.org, Jon.Brenner@ams.com,
pmeerw@pmeerw.net, knaack.h@gmx.de
Subject: Re: [PATCH 09/11] staging: iio: tsl2x7x: remove ch0 and ch1 variables from tsl2x7x_get_lux()
Date: Sat, 24 Mar 2018 13:42:48 +0000 [thread overview]
Message-ID: <20180324134248.1faeb2ff@archlinux> (raw)
In-Reply-To: <20180321102912.5130-10-masneyb@onstation.org>
On Wed, 21 Mar 2018 06:29:10 -0400
Brian Masney <masneyb@onstation.org> wrote:
> 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 <masneyb@onstation.org>
Hmm. A marginal improvement in readability I suppose, but not a big one.
This I wouldn't have bothered changing but fair enough.
Applied to the togreg branch of iio.git and pushed out as testing.
Thanks,
Jonathan
> ---
> 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]);
> }
>
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
next prev parent reply other threads:[~2018-03-24 13:42 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-21 10:29 [PATCH 00/11] staging: iio: tsl2x7x: staging cleanups Brian Masney
2018-03-21 10:29 ` [PATCH 01/11] staging: iio: tsl2x7x: remove unnecessary code Brian Masney
2018-03-24 13:32 ` Jonathan Cameron
2018-03-21 10:29 ` [PATCH 02/11] staging: iio: tsl2x7x: correct interrupt handler trigger Brian Masney
2018-03-24 13:33 ` Jonathan Cameron
2018-03-21 10:29 ` [PATCH 03/11] staging: iio: tsl2x7x: no need to clear interrupt flag when getting lux Brian Masney
2018-03-24 13:34 ` Jonathan Cameron
2018-03-21 10:29 ` [PATCH 04/11] staging: iio: tsl2x7x: simplify tsl2x7x_prox_cal() Brian Masney
2018-03-24 13:35 ` Jonathan Cameron
2018-03-21 10:29 ` [PATCH 05/11] staging: iio: tsl2x7x: split out als and prox interrupt settings Brian Masney
2018-03-24 13:36 ` Jonathan Cameron
2018-03-21 10:29 ` [PATCH 06/11] staging: iio: tsl2x7x: make logging consistent and correct newlines Brian Masney
2018-03-24 13:39 ` Jonathan Cameron
2018-03-21 10:29 ` [PATCH 07/11] staging: iio: tsl2x7x: split out als and prox persistence settings Brian Masney
2018-03-24 13:40 ` Jonathan Cameron
2018-03-21 10:29 ` [PATCH 08/11] staging: iio: tsl2x7x: remove unused variables from tsl2x7x_get_lux() Brian Masney
2018-03-24 13:41 ` Jonathan Cameron
2018-03-21 10:29 ` [PATCH 09/11] staging: iio: tsl2x7x: remove ch0 and ch1 " Brian Masney
2018-03-24 13:42 ` Jonathan Cameron [this message]
2018-03-21 10:29 ` [PATCH 10/11] staging: iio: tsl2x7x: put local variables in reverse Christmas tree order Brian Masney
2018-03-24 13:44 ` Jonathan Cameron
2018-03-21 10:29 ` [PATCH 11/11] staging: iio: tsl2x7x: add copyright Brian Masney
2018-03-24 13:46 ` Jonathan Cameron
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=20180324134248.1faeb2ff@archlinux \
--to=jic23@kernel.org \
--cc=Jon.Brenner@ams.com \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--cc=knaack.h@gmx.de \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=masneyb@onstation.org \
--cc=pmeerw@pmeerw.net \
/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;
as well as URLs for NNTP newsgroup(s).