From patchwork Wed Jan 9 01:18:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hongye Yuan X-Patchwork-Id: 10753273 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 36AE213BF for ; Wed, 9 Jan 2019 01:18:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1CBF628DDC for ; Wed, 9 Jan 2019 01:18:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0ECB728DE5; Wed, 9 Jan 2019 01:18:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A4A1528DDC for ; Wed, 9 Jan 2019 01:18:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728403AbfAIBSS (ORCPT ); Tue, 8 Jan 2019 20:18:18 -0500 Received: from mail-pl1-f194.google.com ([209.85.214.194]:46875 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729169AbfAIBSS (ORCPT ); Tue, 8 Jan 2019 20:18:18 -0500 Received: by mail-pl1-f194.google.com with SMTP id t13so2728230ply.13 for ; Tue, 08 Jan 2019 17:18:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=/VMaWcpNs96TS4K541xul8R5N5Kv3JoYlBOq9FF+Uoo=; b=lbksRybC5VwwZwNwVNEXSnEaG7XwwwtAPLzkwShm3Hp8W4yrmp4J6WKk0WovMILtY/ qPkFl7tERA7rKEg+35j9xKJNoxz3ldoFnl0XFuxvBAC6xS08OVIg+niWL1M+myJX8/L8 Hw9ZcYlMFtoCXdkYKjgBHOcPopY9z0yvRz8VBJi3wyz37En7F9eK0jUOGhmr1EMJc3WQ JS6Vmp7K3n+5oXhRmKJB3zPXSapABKZs1eWpsbq2FZk1pv967oH0JpP6d0fuYKKQBoc1 JSfjkJAZGNfQCU7urH2UJ4RY/TzOOkZPEpamjo2niELplf+9cM4cp/7ASWxWbRinEQLR JBAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=/VMaWcpNs96TS4K541xul8R5N5Kv3JoYlBOq9FF+Uoo=; b=P1taiKBgVjllZmTB9eGyaOMi/Jx9pT0/+SQLlkQHjFiVbYOxoZ7BF3w5FkWF9id1wz 5jeXAbNNfN5AyFPgg/11SdWbUnxb/S5kKR1Y+1LU5/rC5xiJJa73eML1YElnmQaemYIF WU3/OS9xwXlgyNlKgiD/oOgMxrmC2ioZlzg2M5KZpgQmZGvtAe7nrQ0jc6SisBa0S1Zd C+zuYU4dHm7IXbdsx93Sm0pAURfC2zVRuzsj4QBco5lpH8U6xylpYeAXScnYCl46/8hz lP/cXT2TaS5kN0TsjbTh4ZxZs6jdMFzhMg5iUJVw8bES2IWlAbOFbkdiwsRGy2p3CpIY towQ== X-Gm-Message-State: AJcUukdjPlKHgfZ8qKwZTk6f0dPir50Go+A6vHfggMGbfpmaWRthAraz Qxn6D83YC7ho/QCs+h+cObmQ4BNK X-Google-Smtp-Source: ALg8bN7GIi9g2VsWi8196nGJKw+8Rg7cfNZf1JUw5cvtvDw3YLYYlLxRwAAup3KlMqnlSRSsG3fS3Q== X-Received: by 2002:a17:902:2e01:: with SMTP id q1mr3904915plb.97.1546996697453; Tue, 08 Jan 2019 17:18:17 -0800 (PST) Received: from localhost ([45.77.70.206]) by smtp.gmail.com with ESMTPSA id l3sm114244735pga.92.2019.01.08.17.18.15 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 08 Jan 2019 17:18:16 -0800 (PST) From: Hongye Yuan To: linux-input@vger.kernel.org Cc: jikos@kernel.org, hadess@hadess.net, benjamin.tissoires@redhat.com, rydberg@bitmath.org, roderick.colenbrander@sony.com, ao2@ao2.it, Hongye Yuan Subject: [PATCH v4 1/2] HID: sony: Transform one-time SHANWAN check into quirk Date: Wed, 9 Jan 2019 09:18:08 +0800 Message-Id: <20190109011809.16542-1-outmatch@gmail.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Transform the one-time check for a SHANWAN PS3 clone gamepad into a quirk, to avoid doing the same string comparison in multiple places. Signed-off-by: Hongye Yuan Reviewed-by: Bastien Nocera --- Changes in v4: - Rewrite commit message to make it clearer. --- drivers/hid/hid-sony.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/drivers/hid/hid-sony.c b/drivers/hid/hid-sony.c index 9671a4bad643..fc82f02bae75 100644 --- a/drivers/hid/hid-sony.c +++ b/drivers/hid/hid-sony.c @@ -58,6 +58,7 @@ #define FUTUREMAX_DANCE_MAT BIT(13) #define NSG_MR5U_REMOTE_BT BIT(14) #define NSG_MR7U_REMOTE_BT BIT(15) +#define SHANWAN_GAMEPAD BIT(16) #define SIXAXIS_CONTROLLER (SIXAXIS_CONTROLLER_USB | SIXAXIS_CONTROLLER_BT) #define MOTION_CONTROLLER (MOTION_CONTROLLER_USB | MOTION_CONTROLLER_BT) @@ -1490,6 +1491,7 @@ static int sony_register_sensors(struct sony_sc *sc) */ static int sixaxis_set_operational_usb(struct hid_device *hdev) { + struct sony_sc *sc = hid_get_drvdata(hdev); const int buf_size = max(SIXAXIS_REPORT_0xF2_SIZE, SIXAXIS_REPORT_0xF5_SIZE); u8 *buf; @@ -1519,14 +1521,15 @@ static int sixaxis_set_operational_usb(struct hid_device *hdev) /* * But the USB interrupt would cause SHANWAN controllers to - * start rumbling non-stop. + * start rumbling non-stop, so skip step 3 for these controllers. */ - if (strcmp(hdev->name, "SHANWAN PS3 GamePad")) { - ret = hid_hw_output_report(hdev, buf, 1); - if (ret < 0) { - hid_info(hdev, "can't set operational mode: step 3, ignoring\n"); - ret = 0; - } + if (sc->quirks & SHANWAN_GAMEPAD) + goto out; + + ret = hid_hw_output_report(hdev, buf, 1); + if (ret < 0) { + hid_info(hdev, "can't set operational mode: step 3, ignoring\n"); + ret = 0; } out: @@ -2811,6 +2814,9 @@ static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id) if (!strcmp(hdev->name, "FutureMax Dance Mat")) quirks |= FUTUREMAX_DANCE_MAT; + if (!strcmp(hdev->name, "SHANWAN PS3 GamePad")) + quirks |= SHANWAN_GAMEPAD; + sc = devm_kzalloc(&hdev->dev, sizeof(*sc), GFP_KERNEL); if (sc == NULL) { hid_err(hdev, "can't alloc sony descriptor\n");