From patchwork Sat Sep 5 20:58:03 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Rojtberg X-Patchwork-Id: 7129781 Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id A16EA9F506 for ; Sat, 5 Sep 2015 20:58:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B980B2088B for ; Sat, 5 Sep 2015 20:58:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A7FFF208AF for ; Sat, 5 Sep 2015 20:58:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752591AbbIEU6Y (ORCPT ); Sat, 5 Sep 2015 16:58:24 -0400 Received: from mail-wi0-f182.google.com ([209.85.212.182]:38504 "EHLO mail-wi0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751755AbbIEU6Y (ORCPT ); Sat, 5 Sep 2015 16:58:24 -0400 Received: by wiclk2 with SMTP id lk2so48032806wic.1 for ; Sat, 05 Sep 2015 13:58:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=UEXzoN4bQy1b9ocOF13IfbT5QRyYHufwQIo87Fbjd2s=; b=0Oa2VAArOyb49dwrGURRrVbtyfpSbjoi4MAegKsnJWgg12oF5WbeFWZq3TboZBXp/6 De2RmtY/8EroOcK48BnaDVe7ciV1b8MYgQqfnSGvij8+M8saRFrGsQEbNZxnHTDcvH5p gUIiON4jAKRjHI31/Bs4CxdoC7drqf5poSkRZW1gBRF54iWOMCxF0y+k6h14SAU8KH4c 0XEuLbJTtSq4E6QpZuYZ0y0mddD0TIpDy3M7fg6AUVbUhDwXtY2OZQQy5hHpwvNJ12Kp 0ZWLXR2Nb1XNWLpaDvm8Yww5ND1H9+b0G0m6U6MeNRKOcWvxI0X7g3EpuFwRUF4ghRmy yFdg== X-Received: by 10.194.192.166 with SMTP id hh6mr19785138wjc.127.1441486702456; Sat, 05 Sep 2015 13:58:22 -0700 (PDT) Received: from deepwhite.fritz.box (p5DE44788.dip0.t-ipconnect.de. [93.228.71.136]) by smtp.gmail.com with ESMTPSA id en5sm11739657wib.18.2015.09.05.13.58.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 05 Sep 2015 13:58:22 -0700 (PDT) From: Pavel Rojtberg X-Google-Original-From: Pavel Rojtberg < rojtberg@gmail.com > To: linux-input@vger.kernel.org, pgriffais@valvesoftware.com, dmitry.torokhov@gmail.com, gregkh@linuxfoundation.org Cc: Pavel Rojtberg Subject: [PATCH 2/6] Input: xpad: clarify LED enumeration Date: Sat, 5 Sep 2015 22:58:03 +0200 Message-Id: <1441486687-4836-3-git-send-email-rojtberg@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1441486687-4836-1-git-send-email-rojtberg@gmail.com> References: <1441486687-4836-1-git-send-email-rojtberg@gmail.com> 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.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, 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 From: Pavel Rojtberg this changes helps understanding the code 1. rename led_no -> pad_nr: the number stored there is not the LED Nr - it gets translated later on to a LED Nr in xpad_identify_controller 2. move all comments regarding xpad_identify_controller to the function definition to prevent inconsistent documentation. Signed-off-by: Pavel Rojtberg --- drivers/input/joystick/xpad.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c index c3ba5be..4cb450c 100644 --- a/drivers/input/joystick/xpad.c +++ b/drivers/input/joystick/xpad.c @@ -345,7 +345,7 @@ struct usb_xpad { int mapping; /* map d-pad to buttons or to axes */ int xtype; /* type of xbox device */ - unsigned long led_no; /* led to lit on xbox360 controllers */ + unsigned long pad_nr; /* the order x360 pads were attached */ }; /* @@ -357,7 +357,6 @@ struct usb_xpad { * The used report descriptor was taken from ITO Takayukis website: * http://euc.jp/periphs/xbox-controller.ja.html */ - static void xpad_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char *data) { struct input_dev *dev = xpad->dev; @@ -506,7 +505,6 @@ static void xpad_identify_controller(struct usb_xpad *xpad); * 01.1 - Pad state (Bytes 4+) valid * */ - static void xpad360w_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char *data) { /* Presence change */ @@ -514,10 +512,6 @@ static void xpad360w_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned cha if (data[1] & 0x80) { xpad->pad_present = 1; usb_submit_urb(xpad->bulk_out, GFP_ATOMIC); - /* - * Light up the segment corresponding to - * controller number. - */ xpad_identify_controller(xpad); } else xpad->pad_present = 0; @@ -891,6 +885,7 @@ struct xpad_led { }; /** + * set the LEDs on Xbox360 / Wireless Controllers * @param command * 0: off * 1: all blink, then previous setting @@ -943,10 +938,12 @@ static void xpad_send_led_command(struct usb_xpad *xpad, int command) mutex_unlock(&xpad->odata_mutex); } +/* + * Light up the segment corresponding to the pad number on Xbox 360 Controllers + */ static void xpad_identify_controller(struct usb_xpad *xpad) { - /* Light up the segment corresponding to controller number */ - xpad_send_led_command(xpad, (xpad->led_no % 4) + 2); + xpad_send_led_command(xpad, (xpad->pad_nr % 4) + 2); } static void xpad_led_set(struct led_classdev *led_cdev, @@ -972,9 +969,9 @@ static int xpad_led_probe(struct usb_xpad *xpad) if (!led) return -ENOMEM; - xpad->led_no = atomic_inc_return(&led_seq); + xpad->pad_nr = atomic_inc_return(&led_seq); - snprintf(led->name, sizeof(led->name), "xpad%lu", xpad->led_no); + snprintf(led->name, sizeof(led->name), "xpad%lu", xpad->pad_nr); led->xpad = xpad; led_cdev = &led->led_cdev; @@ -988,7 +985,6 @@ static int xpad_led_probe(struct usb_xpad *xpad) return error; } - /* Light up the segment corresponding to controller number */ xpad_identify_controller(xpad); return 0;