summaryrefslogtreecommitdiff
path: root/drivers/misc
diff options
context:
space:
mode:
authorColin Ian King <colin.king@canonical.com>2020-01-07 17:52:34 +0000
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-01-14 15:16:51 +0100
commitf896ee51b93e192fa38a62d8cef8c5e9bd4adf68 (patch)
tree5b1609e2f2cbd4afb3fe906af1f9cb8c562d900d /drivers/misc
parentb5a0d4bf2ee80e47629df0d7d8f4a7952ca39941 (diff)
misc: tsl2550: remove redundant initialization to variable r
The variable r is being initialized with a value that is never read and it is being updated later with a new value. Remove the redundant initialization and move the declaration into a deeper code block. Addresses-Coverity: ("Unused value") Signed-off-by: Colin Ian King <colin.king@canonical.com> Link: https://lore.kernel.org/r/20200107175234.121298-1-colin.king@canonical.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/misc')
-rw-r--r--drivers/misc/tsl2550.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/drivers/misc/tsl2550.c b/drivers/misc/tsl2550.c
index 09db397df287..6d71865c8042 100644
--- a/drivers/misc/tsl2550.c
+++ b/drivers/misc/tsl2550.c
@@ -148,16 +148,14 @@ static int tsl2550_calculate_lux(u8 ch0, u8 ch1)
u16 c0 = count_lut[ch0];
u16 c1 = count_lut[ch1];
- /*
- * Calculate ratio.
- * Note: the "128" is a scaling factor
- */
- u8 r = 128;
-
/* Avoid division by 0 and count 1 cannot be greater than count 0 */
if (c1 <= c0)
if (c0) {
- r = c1 * 128 / c0;
+ /*
+ * Calculate ratio.
+ * Note: the "128" is a scaling factor
+ */
+ u8 r = c1 * 128 / c0;
/* Calculate LUX */
lux = ((c0 - c1) * ratio_lut[r]) / 256;