From patchwork Wed Feb 5 19:34:18 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: simon@mungewell.org X-Patchwork-Id: 3588621 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 4C3D1C02DC for ; Wed, 5 Feb 2014 19:34:36 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A184820149 for ; Wed, 5 Feb 2014 19:34:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B2E3220127 for ; Wed, 5 Feb 2014 19:34:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751951AbaBETea (ORCPT ); Wed, 5 Feb 2014 14:34:30 -0500 Received: from host171.canaca.com ([67.55.55.225]:42567 "EHLO host171.canaca.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751950AbaBETe3 (ORCPT ); Wed, 5 Feb 2014 14:34:29 -0500 Received: from [208.118.126.162] (helo=simon-virtual-machine.TOPCON.COM) by host171.canaca.com with esmtpa (Exim 4.69) (envelope-from ) id 1WB8Et-0001td-2A; Wed, 05 Feb 2014 14:34:27 -0500 From: Simon Wood To: linux-input@vger.kernel.org Cc: Jiri Kosina , linux-kernel@vger.kernel.org, simon@mungewell.org Subject: [PATCH] HID: hid-sony Report actual brightness value when reading LED Date: Wed, 5 Feb 2014 12:34:18 -0700 Message-Id: <1391628858-2916-1-git-send-email-simon@mungewell.org> X-Mailer: git-send-email 1.8.1.2 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - host171.canaca.com X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - mungewell.org X-Source: X-Source-Args: X-Source-Dir: Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The Dualshock4 controller contains a RGB LED, which is enabled via the '/sys/class/leds' interface. At present the driver only returns whether each of the RGB LEDs is lit (ie not off), but no indication of it's brightness. This patch fixes the reading of the current brightnes so that it returns the value (rather than just off=0, on=LED_FULL). Tested on the DS4 and SixAxis (for compatibility). Signed-off-by: Simon Wood --- drivers/hid/hid-sony.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/hid/hid-sony.c b/drivers/hid/hid-sony.c index 1235405..f9a7610 100644 --- a/drivers/hid/hid-sony.c +++ b/drivers/hid/hid-sony.c @@ -790,7 +790,6 @@ static enum led_brightness sony_led_get_brightness(struct led_classdev *led) struct sony_sc *drv_data; int n; - int on = 0; drv_data = hid_get_drvdata(hdev); if (!drv_data) { @@ -799,13 +798,11 @@ static enum led_brightness sony_led_get_brightness(struct led_classdev *led) } for (n = 0; n < drv_data->led_count; n++) { - if (led == drv_data->leds[n]) { - on = !!(drv_data->led_state[n]); - break; - } + if (led == drv_data->leds[n]) + return drv_data->led_state[n]; } - return on ? LED_FULL : LED_OFF; + return LED_OFF; } static void sony_leds_remove(struct hid_device *hdev)