tsl2550: fix lux1_input error in low light
authorMatt Ranostay <matt.ranostay@konsulko.com>
Sat, 9 Jun 2018 06:58:15 +0000 (23:58 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 4 Oct 2018 00:00:45 +0000 (17:00 -0700)
commit4804f372b53f65a9e04348ccfa494f169bbeadd9
tree0bc11959d3d62812be198334cd506cc053d1b30b
parentdb12e7d3e9bc593f784ee8602c38a2b5d8d45408
tsl2550: fix lux1_input error in low light

[ Upstream commit ce054546cc2c26891cefa2f284d90d93b52205de ]

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.

Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Matt Ranostay <matt.ranostay@konsulko.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/misc/tsl2550.c