From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752872AbcLBUhH (ORCPT ); Fri, 2 Dec 2016 15:37:07 -0500 Received: from mail-pg0-f50.google.com ([74.125.83.50]:35182 "EHLO mail-pg0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751284AbcLBUhD (ORCPT ); Fri, 2 Dec 2016 15:37:03 -0500 From: Matt Ranostay To: linux-kernel@vger.kernel.org Cc: Matt Ranostay , Arnd Bergmann , Drew Fustini Subject: [PATCH RESEND] tsl2550: fix lux1_input error in low light Date: Fri, 2 Dec 2016 12:36:41 -0800 Message-Id: <1480711001-31832-1-git-send-email-matt@ranostay.consulting> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Cc: Drew Fustini Signed-off-by: Matt Ranostay --- 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 87a13374fdc0..eb5761067310 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.7.4