From patchwork Thu Oct 19 20:06:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Masney X-Patchwork-Id: 10018235 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 D6B5860224 for ; Thu, 19 Oct 2017 20:07:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CAB0928D63 for ; Thu, 19 Oct 2017 20:07:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BEEF228E42; Thu, 19 Oct 2017 20:07:22 +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=ham 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 2D47328D63 for ; Thu, 19 Oct 2017 20:07:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753183AbdJSUHL (ORCPT ); Thu, 19 Oct 2017 16:07:11 -0400 Received: from onstation.org ([52.200.56.107]:54094 "EHLO onstation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751626AbdJSUGl (ORCPT ); Thu, 19 Oct 2017 16:06:41 -0400 Received: from localhost.localdomain (c-98-236-77-125.hsd1.wv.comcast.net [98.236.77.125]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: masneyb) by onstation.org (Postfix) with ESMTPSA id C166F243C7; Thu, 19 Oct 2017 20:06:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=onstation.org; s=default; t=1508443601; bh=O0ELiLVeA8eK1jMLSFle+ic4DHiu7KQKtI9/kSk8f4I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GdwsSu7vYUvZ6DWStuYk0T4KSbys2blaH16oe4R9mPpU/MlU7F/tZZnO5VdZzSSUw aamh6+DO+mwfkSqIL5F/453foc3Y16xse/9GfC7u2S/XKRGLSGhgfXh7zTBtekdQU7 uBSQe3C+pkGpfHif1Ynr2qCnwjM1oVaGKzYAc7bs= 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 13/13] staging: iio: tsl2x7x: add goto for TSL2X7X_LUX_CALC_OVER_FLOW Date: Thu, 19 Oct 2017 16:06:32 -0400 Message-Id: <20171019200632.25820-14-masneyb@onstation.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171019200632.25820-1-masneyb@onstation.org> References: <20171019200632.25820-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 This patch adds a return_max label for the two cases that need to set the lux to TSL2X7X_LUX_CALC_OVER_FLOW and return. Signed-off-by: Brian Masney --- drivers/staging/iio/light/tsl2x7x.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/staging/iio/light/tsl2x7x.c b/drivers/staging/iio/light/tsl2x7x.c index 42ed9c015aaf..898304d65f64 100644 --- a/drivers/staging/iio/light/tsl2x7x.c +++ b/drivers/staging/iio/light/tsl2x7x.c @@ -364,10 +364,8 @@ static int tsl2x7x_get_lux(struct iio_dev *indio_dev) chip->als_cur_info.als_ch0 = ch0; chip->als_cur_info.als_ch1 = ch1; - if (ch0 >= chip->als_saturation || ch1 >= chip->als_saturation) { - lux = TSL2X7X_LUX_CALC_OVER_FLOW; + if (ch0 >= chip->als_saturation || ch1 >= chip->als_saturation) goto return_max; - } if (!ch0) { /* have no data, so return LAST VALUE */ @@ -418,11 +416,12 @@ static int tsl2x7x_get_lux(struct iio_dev *indio_dev) lux = lux64; lux = (lux + 500) / 1000; - if (lux > TSL2X7X_LUX_CALC_OVER_FLOW) /* check for overflow */ + if (lux > TSL2X7X_LUX_CALC_OVER_FLOW) { /* check for overflow */ +return_max: lux = TSL2X7X_LUX_CALC_OVER_FLOW; + } /* Update the structure with the latest lux. */ -return_max: chip->als_cur_info.lux = lux; ret = lux;