From patchwork Wed Feb 18 03:14:50 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: simon@mungewell.org X-Patchwork-Id: 5842581 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.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id EC751BF440 for ; Wed, 18 Feb 2015 03:24:37 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E81572010B for ; Wed, 18 Feb 2015 03:24:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C752C20108 for ; Wed, 18 Feb 2015 03:24:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752186AbbBRDYe (ORCPT ); Tue, 17 Feb 2015 22:24:34 -0500 Received: from smtp-out-04.shaw.ca ([64.59.134.12]:4365 "EHLO smtp-out-04.shaw.ca" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751609AbbBRDYe (ORCPT ); Tue, 17 Feb 2015 22:24:34 -0500 X-Greylist: delayed 578 seconds by postgrey-1.27 at vger.kernel.org; Tue, 17 Feb 2015 22:24:34 EST X-Cloudmark-SP-Filtered: true X-Cloudmark-SP-Result: v=1.1 cv=/24PZDiXryEUsaYH72AX4ulVzqSXihAXfE7Ql5lDP0I= c=1 sm=1 a=BLceEmwcHowA:10 a=x/GiHf5VU5uXFAeKKVSXKg==:17 a=47LbCVvxAAAA:8 a=FeqH8COzjikYNS0dp90A:9 a=HpAAvcLHHh0Zw7uRqdWCyQ==:117 Received: from unknown (HELO localhost.localdomain) ([70.72.56.65]) by smtp-out-04.shaw.ca with ESMTP; 17 Feb 2015 20:14:54 -0700 From: Simon Wood To: linux-input@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Jiri Kosina , Simon Wood Subject: [PATCH] HID: hid-sony: Prevent LED overrun Date: Tue, 17 Feb 2015 20:14:50 -0700 Message-Id: <1424229290-32089-1-git-send-email-simon@mungewell.org> X-Mailer: git-send-email 1.9.1 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_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 If the value written to led1 is larger than 1 (for SixAxis or Intec controllers), it can effect other leds on the device. For example: # echo 3 > /sys/class/leds/0003\:054C\:0268.0013\:\:sony1/brightness turns on both led1 and led2, led2 does not then behave as expected through it's own interface. Patch limits the LEDs 'value' to the 'max brightness', thus preventing bug. Tested with SixAxis DS3, DS4 and Intec (3rd party) controllers, via USB connection. Signed-off-by: Simon Wood --- drivers/hid/hid-sony.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/hid/hid-sony.c b/drivers/hid/hid-sony.c index 31e9d25..385fa1f 100644 --- a/drivers/hid/hid-sony.c +++ b/drivers/hid/hid-sony.c @@ -1296,6 +1296,9 @@ static void sony_led_set_brightness(struct led_classdev *led, drv_data->led_delay_on[n] || drv_data->led_delay_off[n]))) { + if (value > led->max_brightness) + value = led->max_brightness; + drv_data->led_state[n] = value; /* Setting the brightness stops the blinking */