Patch from LKML post by Matt Ranostay
From c23e541ef11dc848ca60218aa74690dbb0158114 Mon Sep 17 00:00:00 2001
From: Matt Ranostay <mranostay@gmail.com>
Date: Mon, 3 Jun 2013 22:38:49 +0000
Subject: [PATCH] tsl2550: fix lux1_input error in low light
ADC channel 0 photodiode detects both infrared + visible light,
but ADC channel 1 just detects infrared. However, the latter is a bit
more sensitive in that range so complete darkness or low light causes
a error condition in which the chan0 - chan1 is negative that
results in a -EAGAIN.
This patch changes the resulting lux1_input sysfs attribute message from
"Resource temporarily unavailable" to a user-grokable lux value of 0.
Signed-off-by: Matt Ranostay <mranostay@gmail.com>
---
drivers/misc/tsl2550.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/misc/tsl2550.c b/drivers/misc/tsl2550.c
index 87a1337..eb57610 100644
--- a/drivers/misc/tsl2550.c
+++ b/drivers/misc/tsl2550.c
@@ -177,7 +177,7 @@ static int tsl2550_calculate_lux(u8 ch0, u8 ch1)
} else
lux = 0;
else
- return -EAGAIN;
+ return 0;
/* LUX range check */
return lux > TSL2550_MAX_LUX ? TSL2550_MAX_LUX : lux;
--
2.9.3
[pdp7@skylake ti-linux-kernel-dev]$ git log -1 --oneline
9c848e7 4.4.35-ti-r70 release
[pdp7@skylake ti-linux-kernel-dev]$ git status
On branch ti-linux-4.4.y
Your branch is up-to-date with 'origin/ti-linux-4.4.y'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: patches/defconfig
no changes added to commit (use "git add" and/or "git commit -a")
[pdp7@skylake KERNEL]$ git status
On branch v4.4.35-ti-r70
[pdp7@skylake KERNEL]$ git log --oneline -2 ./drivers/misc/tsl2550.c
c23e541 tsl2550: fix lux1_input error in low light
14e51e5 misc: Drop owner assignment from i2c_driver
root@beaglebone:~# cat /etc/dogtag
BeagleBoard.org Debian Image 2016-08-14
root@beaglebone:~# cat /etc/debian_version
8.6
root@beaglebone:~# uname -a
Linux beaglebone 4.4.35-ti-r70 #1 SMP Fri Dec 2 05:22:17 CST 2016 armv7l GNU/Linux
root@beaglebone:~# cat /sys/devices/platform/ocp/4819c000.i2c/i2c-2/2-0039/lux1_input
cat: /sys/devices/platform/ocp/4819c000.i2c/i2c-2/2-0039/lux1_input: Resource temporarily unavailable
root@beaglebone:~# cat /sys/devices/platform/ocp/4819c000.i2c/i2c-2/2-0039/lux1_input
0
root@beaglebone:~# cat /sys/devices/platform/ocp/4819c000.i2c/i2c-2/2-0039/lux1_input
364
Mainline is the same