From patchwork Mon May 29 22:20:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rahul Rameshbabu X-Patchwork-Id: 100445 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp1805968vqr; Mon, 29 May 2023 15:48:03 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ68xU3LzlbbGTnr4wvJ2l+QZWFpNzys7OAbviMi4BgKqwDK5x4NvgGJZYSnvj07PCiMEpOT X-Received: by 2002:a05:6a00:b42:b0:63b:62d1:d868 with SMTP id p2-20020a056a000b4200b0063b62d1d868mr194757pfo.8.1685400483132; Mon, 29 May 2023 15:48:03 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1685400483; cv=pass; d=google.com; s=arc-20160816; b=Fg+A63gCmTrO1PQZjk392orebICaVrCS7nouWgzJQrL2ddkgtGzcdoiqZOvkyf7BZL WrbtmT1xzGfRSJpsIgoFYfmcHWwj7+yP/TPbOFHqCJgRo1OOT2xnpHqYeUv7IyhVt5Ee FsVRUJQfPNE2naqHQFG7LtMN/jQDq4Nn7Ms5yjYHMnElbxvyWflfD9VIXdvzq9NV39P0 IelBIj6BvV3ZbqWryo5WVUVT+Hc9kVK/VDofqgc5ts/624TchpitU++6NSnAiqG0uqh3 7bPhwhIAYzXClLHX8eS9S7AJi9/+sEKbxK9/Sgmt+X0HsCPvkHzrPg2Km8Pds4VVLud5 nhwA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=vUe8hSLSkY6kC/+7P2GtOEmkhIVmW9KSZfXa6hRn4Ck=; b=U19eOAZcIUfzeQJsTYpprO7AwL+8W1aLRFyhb8PUtOBPkRZcakCvQi4j8FE1frugm4 6/nONHdDNdtxIGSzfmnDhXb2Drz5q0SULNTacjwcXSCf//c4rPaSMgxaJuPDxxFqfeg1 2Fw5BcFVm49gkHo0pllg5yqQxIIW7IgCduIfh8DFJAB38wY5U9MLId+Oofj16x7BebV0 pUSHayVeX+ObTgzrU2Jq7xTAQoa7JsoK8AxpbSSJJzeXQWptwlTVm811y6Po/nPzAL67 2RVr59m05Hse1XSR1Z63EIchdp94dbyL7XNsBYLLxVVhFISIsXdS7uFOXaAiKgyBBaLW YwgQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=qKgDYRAS; arc=pass (i=1 spf=pass spfdomain=nvidia.com dkim=pass dkdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i184-20020a6387c1000000b00513af1fa0b5si9577169pge.797.2023.05.29.15.47.51; Mon, 29 May 2023 15:48:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=qKgDYRAS; arc=pass (i=1 spf=pass spfdomain=nvidia.com dkim=pass dkdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229916AbjE2WVN (ORCPT + 99 others); Mon, 29 May 2023 18:21:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47642 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229712AbjE2WVI (ORCPT ); Mon, 29 May 2023 18:21:08 -0400 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2075.outbound.protection.outlook.com [40.107.223.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 42897D9; Mon, 29 May 2023 15:21:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eMzfX0XvPoFwNsXJngJaSecoGvjI0J84HZylrDzxrad+sl89wcD5aJiYCqsn1ENhZlTfcZYw05em/a0ECdus+NzIAm6xBlqn+xKh9+4SMccdDzn31U/6ZVEFb2e9kSKC8fvamqBC4YRQB/yZZPt3du63IN4GHFFj7Zmbh58dQtku+rAgSbQTG18i8jSAFgn8UhGIt5aHMdyveFBAEaPxLeZnmULOPfpnwmtkSWXIhHe9YFvA3oJko9k4WcdvpJZD99SA5cOoVPai8qUHJmIm+YaJNWiQglNynYYh2DKc+4tV6FjhzLbk2WEsvXNDXF0+y20ijup1WKZu+vobPGxV8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=vUe8hSLSkY6kC/+7P2GtOEmkhIVmW9KSZfXa6hRn4Ck=; b=Lf7jDt5WKG0acHlxdJG/GBhLqMsWsJByDQPx5J2dfgVzbBbeLiGUL/09Za2rFWvjx4/0z1Znc0bjmm8zT4erWW+h90WkxAEQlKWKWIpYMt/AYS50Uo6saq25N8K+/kN4iLDWmc5PiXUEBLd7qqTtFUVjQ4Z6FvhG/HXaE+ycg0/r4XolU6RCSWq/c8OqQHZyIBZPSr+E4VnIFDhAaJ2vkKULcmgLaYea4E2KV5NWexqqqy4clGzq5TxDrDu9QRL6p4xGBd1pNlUClrerO2h+SppTD6pssAvtsSDaSoqFNBSFhmjyOy0Z22O9y4+53ma3ILrgEbz+Vh3yN8vWmYZuzQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=vUe8hSLSkY6kC/+7P2GtOEmkhIVmW9KSZfXa6hRn4Ck=; b=qKgDYRASL9hWUjcH+xuwchrI35zTUUAuw3hVCRc+p8sZ65V7H6RLNKxtHzXgxduCMuUcShkAY+JdV+P9u8S2RFkShLBvzQqbNFwG1eyfacpOvPDUgfk9vDpoSic477IrmxZcNyADG25Yj2D/eg3q//FZWZcWsAEWaOQrA0gbOPkQIrZ3NzVWi7NzrkGepRy/qTtWuA7q+eNAGrJDOOS7RP3t27fr3Tgb4FbpOsPq91IkkvEZEEhdUG/mRcaQHtvhnfgytPbNVY7ytHZ55rsU1ZS2n1st3XaOMBdpQI4cYVdXppDMiuFBRVl34qwdAZR8lxMf5BPLNJfaFM8vFAiAgA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from BYAPR12MB2743.namprd12.prod.outlook.com (2603:10b6:a03:61::28) by BN9PR12MB5355.namprd12.prod.outlook.com (2603:10b6:408:104::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.23; Mon, 29 May 2023 22:21:04 +0000 Received: from BYAPR12MB2743.namprd12.prod.outlook.com ([fe80::f3d4:f48a:1bfc:dbf1]) by BYAPR12MB2743.namprd12.prod.outlook.com ([fe80::f3d4:f48a:1bfc:dbf1%5]) with mapi id 15.20.6433.018; Mon, 29 May 2023 22:21:04 +0000 From: Rahul Rameshbabu To: Benjamin Tissoires , Jiri Kosina Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Rahul Rameshbabu Subject: [PATCH RFC v1 1/3] HID: nvidia-shield: Add mappings for consumer HID USAGE buttons Date: Mon, 29 May 2023 15:20:50 -0700 Message-Id: <20230529222052.68913-2-rrameshbabu@nvidia.com> X-Mailer: git-send-email 2.38.4 In-Reply-To: <20230529222052.68913-1-rrameshbabu@nvidia.com> References: <20230529222052.68913-1-rrameshbabu@nvidia.com> X-ClientProxiedBy: SJ0PR03CA0373.namprd03.prod.outlook.com (2603:10b6:a03:3a1::18) To BYAPR12MB2743.namprd12.prod.outlook.com (2603:10b6:a03:61::28) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BYAPR12MB2743:EE_|BN9PR12MB5355:EE_ X-MS-Office365-Filtering-Correlation-Id: 423125f8-d8a8-4efd-882c-08db6092fda9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rTBbCaONemfe9ZJH8f/4mfoc29VDjpI7qhUBCLIywA723t0H6Ik/QXvxBcL+fKDSxLD3rpas0J11Hh905v9eYOrSZ1G3CPzp6thB3SsRO3urd5IHmP0D8oXS0pY3s4XGxWJ9C5Lm2P+NRuXoVmjdTPaVpKgmwA0kBRKV5EMH1JYLBSuuqnl3qw8spzpPVMF32wU8+o2Dt5j01a+JOL++hRkFUoiIx9qRCF1UrtwTS5wPGgMKqYdm8ik5rWag4qTBcdvlh6qvOx2DQoC10svZvfwLye5Lpl7sVVSPu5JdxL2RN3dM25DUnfgkAZCDNHH/1SXFSI3f5a0U15OrGdtttj0YXYjkrlAWTx5qg0b6DcjbO9BFuzz6ltjEDMYAbzb7Uk3jKa3qy8gh5leN08XLlAH/dq3DllyQ2QtWw6Vxqa0cX3mLwTxFFq3u9yDd2l8/Re+NczAXPz+ISPffgORl+L62V7VljledTZOpibgxJ/vkHJ3XLavsX1GqyfwARwp8cKDi+V7UNxj/55D2Pn92FbWgJY3EZwG5Hvcf3EOPHfisJ5p0EUf1sVbt2ijtvLMt X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR12MB2743.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(366004)(39860400002)(396003)(346002)(376002)(136003)(451199021)(6506007)(6512007)(186003)(2906002)(2616005)(110136005)(478600001)(26005)(1076003)(83380400001)(8676002)(41300700001)(38100700002)(8936002)(6486002)(86362001)(6666004)(316002)(66946007)(5660300002)(66476007)(66556008)(36756003)(107886003)(4326008);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 34JsuWz3l1zXILzMP7H5ynEiU7ELQzTaJwmIFpdx+R0rQ09DgaVLpDh2HHkwXwsQcxN461IEbOHNOuy0bGOjMurFxN3/1wXXpoRVsXo8PQ/8WrjRhKt6x0pV5zO/n00Zqo2Z0ppHgvzAyS7P0i9VFbDAgGLstOSnH6OLYhdL3Xlz5b2a4OR7d2+3XA8ZPxqWyxXafVfe6RG6NOUQ/d8XdnnT6oL9LjD7H72XEdBbJr1VgRpWfIRgqzSwebglZPrq1zz0aWHZ9ksuBb9j5jN1iG+W8A2h9vpocUTTXIQs4ooNNHiS230/8kXZqAWCk0rpT2pBkpn+af3tahk2/WHpyu9uEtE8laQV/4+1/dO36mHlXSccwF5mo7cBfyBvSIfvJhjCre278cCgU5+EbUTG6G8sADmNW8K7dlSJ2dEUu6NQpM3FCGDKltX9XjuPeGdNlVtuSd30ceU7S9fiChB5VWxEqHoT8snzSm5Zi0qkdHzXSq7eCwyKFuCXEPmqNq5zc3T+/6esuX8X+prQbi/iYcZ3gmcNKh9BRqudPFvfC8AK59J+g+JW3mz+qNEZW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-Message-Id: 423125f8-d8a8-4efd-882c-08db6092fda9 X-MS-Exchange-CrossTenant-AuthSource: BYAPR12MB2743.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 May 2023 22:21:04.1392 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: mdfj+Xmbq9sbfbWGoUB/ACpI3JZ3EZM15tiuQgzGIlxx9aAQg/m1q/YnPkZJ9bqM/qnkkH6pMsHYBJxpT4kNRA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN9PR12MB5355 X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1767270496928998398?= X-GMAIL-MSGID: =?utf-8?q?1767270496928998398?= Map Android Home, Back, Search, VolumeUp, VolumeDown, and PlayPause buttons to the appropriate input event codes. Signed-off-by: Rahul Rameshbabu --- drivers/hid/hid-nvidia-shield.c | 55 ++++++++++++++++++++++++++++++--- 1 file changed, 50 insertions(+), 5 deletions(-) diff --git a/drivers/hid/hid-nvidia-shield.c b/drivers/hid/hid-nvidia-shield.c index bcf345e365c0..1a9d32b2c80c 100644 --- a/drivers/hid/hid-nvidia-shield.c +++ b/drivers/hid/hid-nvidia-shield.c @@ -15,6 +15,16 @@ #include "hid-ids.h" #define NOT_INIT_STR "NOT INITIALIZED" +#define android_map_key(c) hid_map_usage(hi, usage, bit, max, EV_KEY, (c)) + +enum { + HID_USAGE_ANDROID_PLAYPAUSE_BTN = 0xcd, /* Double-tap volume slider */ + HID_USAGE_ANDROID_VOLUMEUP_BTN = 0xe9, + HID_USAGE_ANDROID_VOLUMEDOWN_BTN = 0xea, + HID_USAGE_ANDROID_SEARCH_BTN = 0x221, /* NVIDIA btn on Thunderstrike */ + HID_USAGE_ANDROID_HOME_BTN = 0x223, + HID_USAGE_ANDROID_BACK_BTN = 0x224, +}; enum { SHIELD_FW_VERSION_INITIALIZED = 0, @@ -416,6 +426,40 @@ static struct shield_device *thunderstrike_create(struct hid_device *hdev) return shield_dev; } +static int android_input_mapping(struct hid_device *hdev, struct hid_input *hi, + struct hid_field *field, + struct hid_usage *usage, unsigned long **bit, + int *max) +{ + if ((usage->hid & HID_USAGE_PAGE) != HID_UP_CONSUMER) + return 0; + + switch (usage->hid & HID_USAGE) { + case HID_USAGE_ANDROID_PLAYPAUSE_BTN: + android_map_key(KEY_PLAYPAUSE); + break; + case HID_USAGE_ANDROID_VOLUMEUP_BTN: + android_map_key(KEY_VOLUMEUP); + break; + case HID_USAGE_ANDROID_VOLUMEDOWN_BTN: + android_map_key(KEY_VOLUMEDOWN); + break; + case HID_USAGE_ANDROID_SEARCH_BTN: + android_map_key(BTN_Z); + break; + case HID_USAGE_ANDROID_HOME_BTN: + android_map_key(BTN_MODE); + break; + case HID_USAGE_ANDROID_BACK_BTN: + android_map_key(BTN_SELECT); + break; + default: + return 0; + } + + return 1; +} + static ssize_t firmware_version_show(struct device *dev, struct device_attribute *attr, char *buf) { @@ -571,11 +615,12 @@ static const struct hid_device_id shield_devices[] = { MODULE_DEVICE_TABLE(hid, shield_devices); static struct hid_driver shield_driver = { - .name = "shield", - .id_table = shield_devices, - .probe = shield_probe, - .remove = shield_remove, - .raw_event = shield_raw_event, + .name = "shield", + .id_table = shield_devices, + .input_mapping = android_input_mapping, + .probe = shield_probe, + .remove = shield_remove, + .raw_event = shield_raw_event, .driver = { .dev_groups = shield_device_groups, }, From patchwork Mon May 29 22:20:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rahul Rameshbabu X-Patchwork-Id: 100441 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp1801888vqr; Mon, 29 May 2023 15:35:44 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ72d9VfXQrKqcjE5J2n9qLW6161kf5q8dJDnYJsQtuA77P7dnf63GCMZx0O3GhroIA6acV+ X-Received: by 2002:a05:6a21:9812:b0:104:1f67:1157 with SMTP id ue18-20020a056a21981200b001041f671157mr323697pzb.26.1685399744412; Mon, 29 May 2023 15:35:44 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1685399744; cv=pass; d=google.com; s=arc-20160816; b=ev1tkx/JXQ9T0Cgmnu/i2g4OKyjcqsGNmH2ThqRe8dGOR4QPy0St9yaVcjXVWEFGbi U3Qy9sppbhijfC+W5rebuRgqSV9A5bGPQmfq5KANI9P59fT0uGVhSzDfeDwsk1qqHRUM dDtl/rjwqT0cSsA7l92kq3Z8dM/XqHOyQ/zrfAqrhaM250g1qaTuL+TMjgwUzTnByveS OhAwN67H9cMoLgfPWnRm5dtxM8HTqKKqWKkW8IIUbl8B1hAxHjoElmyfX2a0aqNlF+om weTpJMcdn8uKhPD3pOVH1uH7kzNuEBHv6UZCQNcXmNHKJt+n7p3q5c/oxI6yE93mO1U1 SIrg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=uWOnow795rwzC8JB5KMVFQH77R3JokfcEzuT6m9WsKA=; b=xXrcAo44pVnPv2G9m3XWg/qFYb4azJhspWk4SUKfBbAWCOjiucu4nH7umbyswAAx6D YHe+Z4AKqal1SU3W4x8EdvEdy3jxx+DxoTnwbsmgNwLf/Pi2uxsN3Hxo+QqpgXw1iF0N 6x2E4zx5lI5KSaX4ChGjduTSRNx3Wwx+qZXKk7XwXJy6Pm8QJCjZux92MPf0RDMIj804 KUwEQOkGtLc+6YS092zYr8JQ/sdobU4W2ahLVg9jDApmkxTYvxSIWa0X0dO+fIBrgI+K 1M8Xd296JU1yiyJDi8BWMfrT7wzYl7lMD4J2Gh79jJSfAU+FIDUESkQzOeVBiSR+qfaZ c8FQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=iSgJuBx8; arc=pass (i=1 spf=pass spfdomain=nvidia.com dkim=pass dkdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a7-20020aa794a7000000b0064d5aab3ec5si575148pfl.156.2023.05.29.15.35.31; Mon, 29 May 2023 15:35:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=iSgJuBx8; arc=pass (i=1 spf=pass spfdomain=nvidia.com dkim=pass dkdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229938AbjE2WVR (ORCPT + 99 others); Mon, 29 May 2023 18:21:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47656 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229899AbjE2WVK (ORCPT ); Mon, 29 May 2023 18:21:10 -0400 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2075.outbound.protection.outlook.com [40.107.223.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C4D32A0; Mon, 29 May 2023 15:21:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OJ13FpPITO08ytDhYLYGZ+ZA6nDnKocjpVOvF3NUE+vA4iLqz2imyA2kQ+WYw4z+rbikLm3NQijB88zUflnaIv0Cfs1j55WZaP17h7BZ1+gmUChmXSXw34syeUoiqhAK4gP7m/VqWZa2GETJgKsb3b9sCu71yDaKtvOfjVDHz7pLZQ5S1ajuS/029eSH6d+CSeNaYyWOKiF6rEcq2a6HNbb4hCcgHNIUrzAjeMYaiiA3okXpkaGD5I8KMo8kjVnRKiF1BBE8z3cBHod2zGC4r6xs2bd0gng4JOEFSexB6WJLtLoFJAdahJ2/nHv0GbKuJpEgnqW8UF5ootF5Chnznw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=uWOnow795rwzC8JB5KMVFQH77R3JokfcEzuT6m9WsKA=; b=g5EUphxDOx/hoFMMz79+u6K5kEc1ZWWY+nnvHOyz2UwmmZz31FfK+jNmuvaaQ/MYXcJgH5ngnveDxqSCRUQc/ewsSfuwn5mE0DefMmaJl+o9TJe+vgedyC+JU5Evxwvmtt/ofPoShAgUTHIsPTcl1ElnGCP+4rVi9GhCVcAMqa8z4XWjN9pcdgECKsFhlo1PQDScYeqlr0EFUCIsHXZ3UIOI7n+WUh3BE+9sXgtAqq/sxQSqL5R16QLl31ILgdcwPvPpywC9lcCKElrmodB5frBox6BZK7vvU70k57XISYdDQ0akjhp9NgI6Ur7sGwcFKgmVXXyKT1KnRDap5vHPBA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=uWOnow795rwzC8JB5KMVFQH77R3JokfcEzuT6m9WsKA=; b=iSgJuBx8/MVuLr8ESOoXPbUEcQNrCVOgGMz0yv+RutEoASTIu+wvEURrVuQcGXh+g57jhCPR/T1l7mJsPBvjzDXYsefdRMtXalaIN3fTZJuEA6Jt3MRk3qrP9K213K1n4JEEjjGAdvFqg15qv/PeKaeCEjhUb5L7/KxOX2DKeggtf29htp5nDBxX/2IjEi1UBDrGz3GxC80/K9AlAcRtFKaZZVehSSc+PmV/bAar8xivYNj2DC4rFxAOFVL5rJ5zRBiptAHkGUYZc4VqAAUV4PdCsR6ZvFDl2yU3yXQ6DchZ4zNypXlO9G7ES82JSZxtBlpKOntc2QYRsKn6Hdv2Eg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from BYAPR12MB2743.namprd12.prod.outlook.com (2603:10b6:a03:61::28) by BN9PR12MB5355.namprd12.prod.outlook.com (2603:10b6:408:104::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.23; Mon, 29 May 2023 22:21:05 +0000 Received: from BYAPR12MB2743.namprd12.prod.outlook.com ([fe80::f3d4:f48a:1bfc:dbf1]) by BYAPR12MB2743.namprd12.prod.outlook.com ([fe80::f3d4:f48a:1bfc:dbf1%5]) with mapi id 15.20.6433.018; Mon, 29 May 2023 22:21:05 +0000 From: Rahul Rameshbabu To: Benjamin Tissoires , Jiri Kosina Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Rahul Rameshbabu Subject: [PATCH RFC v1 2/3] HID: nvidia-shield: Support LED functionality for Thunderstrike Date: Mon, 29 May 2023 15:20:51 -0700 Message-Id: <20230529222052.68913-3-rrameshbabu@nvidia.com> X-Mailer: git-send-email 2.38.4 In-Reply-To: <20230529222052.68913-1-rrameshbabu@nvidia.com> References: <20230529222052.68913-1-rrameshbabu@nvidia.com> X-ClientProxiedBy: SJ0PR03CA0369.namprd03.prod.outlook.com (2603:10b6:a03:3a1::14) To BYAPR12MB2743.namprd12.prod.outlook.com (2603:10b6:a03:61::28) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BYAPR12MB2743:EE_|BN9PR12MB5355:EE_ X-MS-Office365-Filtering-Correlation-Id: da55a48e-613d-4ec8-3cbe-08db6092fea6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: B7gFUwvY/NhrhenEN8NSe6e+BzcqV4EvSZDah96ssdLKulRjmHtBfES/OwpIFLUwMC8Ju23N3JDwhq0hFcJOD+VCCmybWK5OhqLUx7xugVHK/2HgfnnjoX3ErdkA2l0rmGc+KIICtdgtWyOCLI/9n/6Iwl3kQEyf6O5af9Yf44jZD1bhme5JSiw6FhgHBYktLP7Ekb+QIQYMYdHzl26V0KAOg8/bpWw2h16qEGgnTADg3HjyhOrd1bJzXYJIErauALDKo53dPYHY3sBrUjSwpHAYhw/EZv+JcfpHn/glVtg59e7vwSscm5aOcXouzt35yMF10MRRJFH02Nawc26EaASFPaI1IXxZ45910rY4pgTBeOciqzef1xCBQx7lo5EMneFpdV3OYLJV9GAfcsGa8Pc0jjLIckdFKOre7MGYkQc4nnO58u1uvP06rdgXsCMugRMwiBY3AikiueoKJIuC+yLOzO4vh3d1Ogo7qz7ecxs7czmZvQlGBEdOGh4T4OBdWFe7cDQI1WRCWSR8tE/uuqYsU4TEVD2n/fpEbOBor5DdTK+2gSHmuBOCMztJrFYE X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR12MB2743.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(366004)(39860400002)(396003)(346002)(376002)(136003)(451199021)(6506007)(6512007)(186003)(2906002)(2616005)(110136005)(478600001)(26005)(1076003)(83380400001)(8676002)(41300700001)(38100700002)(8936002)(6486002)(86362001)(6666004)(316002)(66946007)(5660300002)(66476007)(66556008)(36756003)(107886003)(4326008);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: rG+GrhGA4NmfZi4zXKPRw+1pIq6UXAwzcY/ptzuD9juglDKY/HzqX7PPUgwVdo8EoP6OUElOkvC2PdLGfaMCB6W0KD8DMi46qf22b0/2UDnCTlDWVq4PDvQzTNqC8ZVN1PgGlsghDnL9p6jM1wb0hZowV1knuRi/xzZ5/JgshVyCH8mZWaIUr+hVxi71VhF4Q1Kzl0AQGI/Fveoi3rCEgz109eVrn06s7bW6xjSq8otqaRjq91kqfD11T2Te6rQaRz7/1AHWz+4xaV3sBPGYMNumnVwv/k1sIZYcpT8hfA5kP6zngqB1vdNAyJ35ngE/r8NFXBYX1Uq0vdBSco+dFr3FaMaNJhgAlSFJwuW/AmaQiR//SJ+eW7h/F5D5JbCtYeXsgbKb6ZtzYtykDazp9Sz3N8KCbW9DFwES52T1fl5FMdTYnTOhHVWkmoFQro002TCEZs+HwkMzhsRfpoNdlW0G2e1Nxa+BUcK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IuWFei89OLH8D4NzX8T7ReR6GzVn3C/qZhnnn2v8Rj3I6x6u2c9YxEMF0G8QAdCw== X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: da55a48e-613d-4ec8-3cbe-08db6092fea6 X-MS-Exchange-CrossTenant-AuthSource: BYAPR12MB2743.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 May 2023 22:21:05.8251 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: erAvVC2bxM2ttg3vGniPbdPOKmLIZGK+GR+Cmpt0gzc1RVZUtBlO3x6OXS/Hiv/E1AG2DmImHFcCCpR+PkNfUg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN9PR12MB5355 X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1767269722109225928?= X-GMAIL-MSGID: =?utf-8?q?1767269722109225928?= Expose the 2017 SHIELD controller (Thunderstrike) LED through the kernel LED API. Signed-off-by: Rahul Rameshbabu --- drivers/hid/hid-nvidia-shield.c | 116 ++++++++++++++++++++++++++++++-- 1 file changed, 111 insertions(+), 5 deletions(-) diff --git a/drivers/hid/hid-nvidia-shield.c b/drivers/hid/hid-nvidia-shield.c index 1a9d32b2c80c..7dfaec1c07e2 100644 --- a/drivers/hid/hid-nvidia-shield.c +++ b/drivers/hid/hid-nvidia-shield.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -35,6 +36,7 @@ enum { THUNDERSTRIKE_FW_VERSION_UPDATE = 0, THUNDERSTRIKE_BOARD_INFO_UPDATE, THUNDERSTRIKE_HAPTICS_UPDATE, + THUNDERSTRIKE_LED_UPDATE, }; enum { @@ -45,12 +47,19 @@ enum { enum { THUNDERSTRIKE_HOSTCMD_ID_FW_VERSION = 1, + THUNDERSTRIKE_HOSTCMD_ID_LED = 6, THUNDERSTRIKE_HOSTCMD_ID_BOARD_INFO = 16, THUNDERSTRIKE_HOSTCMD_ID_USB_INIT = 53, THUNDERSTRIKE_HOSTCMD_ID_HAPTICS = 57, THUNDERSTRIKE_HOSTCMD_ID_BLUETOOTH_INIT = 58, }; +enum thunderstrike_led_state { + THUNDERSTRIKE_LED_OFF = 1, + THUNDERSTRIKE_LED_ON = 8, +} __packed; +static_assert(sizeof(enum thunderstrike_led_state) == 1); + struct thunderstrike_hostcmd_board_info { __le16 revision; __le16 serial[7]; @@ -70,6 +79,7 @@ struct thunderstrike_hostcmd_resp_report { struct thunderstrike_hostcmd_board_info board_info; struct thunderstrike_hostcmd_haptics motors; __le16 fw_version; + enum thunderstrike_led_state led_state; u8 payload[30]; }; } __packed; @@ -81,10 +91,16 @@ struct thunderstrike_hostcmd_req_report { u8 cmd_id; u8 reserved_at_10; - struct { - u8 update; - struct thunderstrike_hostcmd_haptics motors; - } haptics; + union { + struct { + u8 update; + enum thunderstrike_led_state state; + } led; + struct { + u8 update; + struct thunderstrike_hostcmd_haptics motors; + } haptics; + }; u8 reserved_at_30[27]; } __packed; static_assert(sizeof(struct thunderstrike_hostcmd_req_report) == @@ -108,12 +124,15 @@ struct thunderstrike { /* Sub-devices */ struct input_dev *haptics_dev; + struct led_classdev led_dev; /* Resources */ void *req_report_dmabuf; unsigned long update_flags; struct thunderstrike_hostcmd_haptics haptics_val; spinlock_t haptics_update_lock; + u8 led_state : 1; + enum thunderstrike_led_state led_value; struct work_struct hostcmd_req_work; }; @@ -221,6 +240,13 @@ static void thunderstrike_hostcmd_req_work_handler(struct work_struct *work) thunderstrike_send_hostcmd_request(ts); } + if (test_and_clear_bit(THUNDERSTRIKE_LED_UPDATE, &ts->update_flags)) { + thunderstrike_hostcmd_req_report_init(report, THUNDERSTRIKE_HOSTCMD_ID_LED); + report->led.update = 1; + report->led.state = ts->led_value; + thunderstrike_send_hostcmd_request(ts); + } + if (test_and_clear_bit(THUNDERSTRIKE_BOARD_INFO_UPDATE, &ts->update_flags)) { thunderstrike_hostcmd_req_report_init( report, THUNDERSTRIKE_HOSTCMD_ID_BOARD_INFO); @@ -292,6 +318,40 @@ static int thunderstrike_play_effect(struct input_dev *idev, void *data, return thunderstrike_update_haptics(ts, &motors); } +static enum led_brightness +thunderstrike_led_get_brightness(struct led_classdev *led) +{ + struct hid_device *hdev = to_hid_device(led->dev->parent); + struct shield_device *shield_dev = hid_get_drvdata(hdev); + struct thunderstrike *ts; + + ts = container_of(shield_dev, struct thunderstrike, base); + + return ts->led_state; +} + +static void thunderstrike_led_set_brightness(struct led_classdev *led, + enum led_brightness value) +{ + struct hid_device *hdev = to_hid_device(led->dev->parent); + struct shield_device *shield_dev = hid_get_drvdata(hdev); + struct thunderstrike *ts; + + ts = container_of(shield_dev, struct thunderstrike, base); + + switch (value) { + case LED_OFF: + ts->led_value = THUNDERSTRIKE_LED_OFF; + break; + default: + ts->led_value = THUNDERSTRIKE_LED_ON; + break; + } + + set_bit(THUNDERSTRIKE_LED_UPDATE, &ts->update_flags); + schedule_work(&ts->hostcmd_req_work); +} + static void thunderstrike_parse_fw_version_payload(struct shield_device *shield_dev, __le16 fw_version) @@ -338,6 +398,24 @@ thunderstrike_parse_haptics_payload(struct shield_device *shield_dev, haptics->motor_left, haptics->motor_right); } +static void +thunderstrike_parse_led_payload(struct shield_device *shield_dev, + enum thunderstrike_led_state led_state) +{ + struct thunderstrike *ts = container_of(shield_dev, struct thunderstrike, base); + + switch (led_state) { + case THUNDERSTRIKE_LED_OFF: + ts->led_state = 0; + break; + case THUNDERSTRIKE_LED_ON: + ts->led_state = 1; + break; + } + + hid_dbg(shield_dev->hdev, "Thunderstrike led HOSTCMD response, 0x%02X\n", led_state); +} + static int thunderstrike_parse_report(struct shield_device *shield_dev, struct hid_report *report, u8 *data, int size) @@ -364,6 +442,9 @@ static int thunderstrike_parse_report(struct shield_device *shield_dev, thunderstrike_parse_fw_version_payload( shield_dev, hostcmd_resp_report->fw_version); break; + case THUNDERSTRIKE_HOSTCMD_ID_LED: + thunderstrike_parse_led_payload(shield_dev, hostcmd_resp_report->led_state); + break; case THUNDERSTRIKE_HOSTCMD_ID_BOARD_INFO: thunderstrike_parse_board_info_payload( shield_dev, &hostcmd_resp_report->board_info); @@ -395,10 +476,24 @@ static int thunderstrike_parse_report(struct shield_device *shield_dev, return 0; } +static inline int thunderstrike_led_create(struct thunderstrike *ts) +{ + struct led_classdev *led = &ts->led_dev; + + led->name = "thunderstrike:blue:led"; + led->max_brightness = 1; + led->flags = LED_CORE_SUSPENDRESUME; + led->brightness_get = &thunderstrike_led_get_brightness; + led->brightness_set = &thunderstrike_led_set_brightness; + + return led_classdev_register(&ts->base.hdev->dev, led); +} + static struct shield_device *thunderstrike_create(struct hid_device *hdev) { struct shield_device *shield_dev; struct thunderstrike *ts; + int ret; ts = devm_kzalloc(&hdev->dev, sizeof(*ts), GFP_KERNEL); if (!ts) @@ -418,12 +513,22 @@ static struct shield_device *thunderstrike_create(struct hid_device *hdev) hid_set_drvdata(hdev, shield_dev); + ret = thunderstrike_led_create(ts); + if (ret) { + hid_err(hdev, "Failed to create Thunderstrike LED instance\n"); + return ERR_PTR(ret); + } + ts->haptics_dev = shield_haptics_create(shield_dev, thunderstrike_play_effect); if (IS_ERR(ts->haptics_dev)) - return ERR_CAST(ts->haptics_dev); + goto err; hid_info(hdev, "Registered Thunderstrike controller\n"); return shield_dev; + +err: + led_classdev_unregister(&ts->led_dev); + return ERR_CAST(ts->haptics_dev); } static int android_input_mapping(struct hid_device *hdev, struct hid_input *hi, @@ -599,6 +704,7 @@ static void shield_remove(struct hid_device *hdev) ts = container_of(dev, struct thunderstrike, base); hid_hw_close(hdev); + led_classdev_unregister(&ts->led_dev); if (ts->haptics_dev) input_unregister_device(ts->haptics_dev); cancel_work_sync(&ts->hostcmd_req_work); From patchwork Mon May 29 22:20:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rahul Rameshbabu X-Patchwork-Id: 100438 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp1800292vqr; Mon, 29 May 2023 15:31:52 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ69qSOXl+j4sHoif/COyTTXoRmuIBhZnpX0yfnLFhgfUjVfQ2QexWe6DzttQqhwC60n4l+K X-Received: by 2002:a17:902:f68e:b0:1ac:6b92:70c8 with SMTP id l14-20020a170902f68e00b001ac6b9270c8mr431369plg.48.1685399511695; Mon, 29 May 2023 15:31:51 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1685399511; cv=pass; d=google.com; s=arc-20160816; b=rXRowpImozrGmAvFjjUU1BlSFBbhvMhLbKBp6cl/IjqAuc7dk3LXhD8QcEi3MDwWY5 pfk/TfR3CcOPQj4nWqKmFpB99xtaExpmy7XaDhr67kC/gNze/nd32wQyGxiNKLPj9QBB hZUxOWj5bJNn7XhxlgbchWmmyLhtEetoHhw3Ob/MokrbVS1Rj84Ymnxf0qQ/Gu/qoedn StWaOm/nTmAd9YUvbEpr48XgyIMzP5t1WJCWe5joJfVdb48uCN2gTMH4YanYg6PbnZjh SzDxZO95kGXn/xoGbzBzDVeifb0ZhH4pfTYc/feJYbKV19x7whk1raVQJnKnhTDVtuf0 HrBg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=1Y/99eWkTe7Ip9O/z1iHWLHlVTk4HlnJtTJku0CXsck=; b=by62ZX5fZo9wMV3YySkYKF4MNqU3zo4qnjFJCsAlqfWuA73EQuWA/Ac4KYmRiv4SBW Dn7PTbE3UC8+22ITk5XJaOw6HJziEMLB04tEHquPGW/S5xEgsXt7jmN2FaKdyoSXc3P0 2LxKJTNlntlbBruxDKiTNzJ4ZLix02h4i6oIoZt+J3MgAe8dAkpDS+8kKREJIwXtZTgp jdfjdFCxTer1JcB0LP4YandGZUul2+fmqI0Ud60yz9Optk/MvDeBuSXd2NtHW3axegvY tbyOaojp3hQbCLE4NQLuv6l6o7tLN1tqzgCTLVGVbp3qLU59yTpxJK85dpbzvoiR0N3w mAsg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=FIDrBLOL; arc=pass (i=1 spf=pass spfdomain=nvidia.com dkim=pass dkdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a5-20020a170902ecc500b001adf56751ccsi10980802plh.520.2023.05.29.15.31.37; Mon, 29 May 2023 15:31:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=FIDrBLOL; arc=pass (i=1 spf=pass spfdomain=nvidia.com dkim=pass dkdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229587AbjE2WVV (ORCPT + 99 others); Mon, 29 May 2023 18:21:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229903AbjE2WVL (ORCPT ); Mon, 29 May 2023 18:21:11 -0400 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2075.outbound.protection.outlook.com [40.107.223.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 84F4292; Mon, 29 May 2023 15:21:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Z2w4P3ilLQ8KagGuGhsO+NBUqq/ctLYmxl+71TN3jo3bn+6qemWumZDDXRg5Tqalu8BiSXz1DpnG1ox7r2PYn9g3X/YqRchUAubXp2LfwBm9D3+lgH3LnZ+c/GArTq4SjqvD+JSkaUV6ElBzMkguN3Jn12TNRVHiVWVOovJFbn+x0FHO3O/b7FJZi9rM746kupuJk+MOElDcmZrR2v7g3hvp8+1AMmPHSW/chrT+3DMi//yu5UjwGrdz41CECMZOWMN7Ykn3OnYeS8uJJ8N9x6xVq4gecLEWi+9nkH5KTlFo9oJCobd4aeTQFiPxAqh2N9D+IJIXBbJQxYRGQzK1tA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=1Y/99eWkTe7Ip9O/z1iHWLHlVTk4HlnJtTJku0CXsck=; b=VYjSIv+Tdpnb74QuUlE7m76mx8yxP9QG+bPY9FsCFTLwuOhB9gawph9agVKjMZcjwDZL/jSZXVE2qSF0CtwezGFdHzfD6PodUnqHnFqqweLGawggUZ72rxzn4+CRU7j17GG0BnYxtd12I0k4iM9PHZ28yMHlQWm+Tat4UqULf545IuA/Fwi7CfhpfyteWuyw2mzxrWL9x7Xd9oAutI6s4U8bjSuU+AZ3lo7acJHVsUFMcwoI5pQ7JKlr6kdwZzzYTjhVjYBiczAoP/9TtIGH2o5hdSVI/o01t9B+K0XjWsyBAy4f6HV56PpR8I/LlP82rXRpfNPFwtHuIKd+N00S+w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=1Y/99eWkTe7Ip9O/z1iHWLHlVTk4HlnJtTJku0CXsck=; b=FIDrBLOLVXdyG+9fXqD8s1HeaBjhyG1J2+4NjXIO9MVnvxX+9kC28UxgIcHCuLyuYkDDZooE7aeICg9V57rt6TJc4tqPxpsgZ4m3tQL83FEV4miiKUKsg3As9byyMpZqYJqxq/zVDQ9u5uNKHLgkEIi9ANghoBpai1IoKPfbr4llG2CElUg3JP9sESUJao6h5c+BBz8acDA4bpGyk+TbWKuBm8AZvm3kmeuZlbagPT1hPSfaCpb4tarjpzH55WsnnglToOxniwMBvmYq5b4Zb2RgaameP8DHuFFVvTMdI0n7fkFiKCcUs7u+r98iikmvQNyMwTTD+8x8uVcUAqA9Lw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from BYAPR12MB2743.namprd12.prod.outlook.com (2603:10b6:a03:61::28) by BN9PR12MB5355.namprd12.prod.outlook.com (2603:10b6:408:104::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.23; Mon, 29 May 2023 22:21:07 +0000 Received: from BYAPR12MB2743.namprd12.prod.outlook.com ([fe80::f3d4:f48a:1bfc:dbf1]) by BYAPR12MB2743.namprd12.prod.outlook.com ([fe80::f3d4:f48a:1bfc:dbf1%5]) with mapi id 15.20.6433.018; Mon, 29 May 2023 22:21:07 +0000 From: Rahul Rameshbabu To: Benjamin Tissoires , Jiri Kosina Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Rahul Rameshbabu Subject: [PATCH RFC v1 3/3] HID: nvidia-shield: Remove space prefix from label in shield_haptics_create Date: Mon, 29 May 2023 15:20:52 -0700 Message-Id: <20230529222052.68913-4-rrameshbabu@nvidia.com> X-Mailer: git-send-email 2.38.4 In-Reply-To: <20230529222052.68913-1-rrameshbabu@nvidia.com> References: <20230529222052.68913-1-rrameshbabu@nvidia.com> X-ClientProxiedBy: BYAPR21CA0012.namprd21.prod.outlook.com (2603:10b6:a03:114::22) To BYAPR12MB2743.namprd12.prod.outlook.com (2603:10b6:a03:61::28) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BYAPR12MB2743:EE_|BN9PR12MB5355:EE_ X-MS-Office365-Filtering-Correlation-Id: ae99d667-12bc-40a3-03e0-08db6092ffb6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +zUgx2bJuchgLVcJwdh4eNHqLovY/2jXz6QdD23lChNopCTRZ/6nR1H2O0TINyK7drykjG7g2TzYJN2Gcwomq3/CQsXBEuXiWtlpIwQ7UkmbzEYbIoz9dYIWMFiXfsoGvkdaQu6ZkYw9eS+0aNoQqrZsTIPUeyLAq/BUTb5vku4mO3wG3uBFX9lPpJCiuO2T3MZHu8CWrxD8KfwXq9LhXkObpFM0qA6ZPFqWvO3ljpXzgf1lvGjPEROIgbEPSI432XBDb3sIFUx5f+JlUzrgaRuL5bi6AVsQxmaeioJRtCvKeRFT3Z+B5fjPSX5U6WcYhzecx0DPOKeD/jPBspvXLwxmJQ+vYJscDotnDveXuoF+rZWKRuHWMdnlMHqH8XnmrXervr5w1dC7xCWfWGK6wIwNRonUGIjXgubljDxAft+gXJV5yt0n7n7jCJ/Y+oF/Aun7dwIRVlx/nyLPXrfvCN26rRa0ZMB49TxWZvl4yWQV0UNETHNfw8teJefSbLl9y9bO1+A+BOeJwQhTgu/VbV3tfnysznXf8uLbIfT+kNOA5RXkNCmugR0cG46vE2Vg/I5lYpVN8aY6gaCFXF/JbTDEUd5VX02OXu9PxnMexlA= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR12MB2743.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(366004)(39860400002)(396003)(346002)(376002)(136003)(451199021)(6506007)(6512007)(4744005)(186003)(2906002)(2616005)(110136005)(478600001)(26005)(1076003)(83380400001)(8676002)(41300700001)(38100700002)(8936002)(6486002)(966005)(86362001)(6666004)(316002)(66946007)(5660300002)(66476007)(66556008)(36756003)(107886003)(4326008);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: c3KvJq7um15qH5n/xSyD5ejc5jK3vppxImCBAKMwu8YvoEY7WqXE+aggxBGpP8LOQS6bJ3Q84dXCqzoV7NM7NJjykhKQTXdxCis8aOUV9Xr7K8EpPxWY+gCemyUNJmfXtH0loY8uqtAScsZwiSRgbCKfSxQJ5L+8hqEptf7lA+cvr659EtJPhWhtYLOdQsvoYVHvdH5RaIfsc2/2YXQg1LzQ5Sb5n+J3vvbqUm0t8bgGvUvAvHOLcvRl59YNs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rIUBTuaVKXesbk1Km9jcLvMNpSgAdOJ/sbdkq86hBTfIF2I5tLphTw0Hn+bbetoYizo1fctVJiAnPbzDFtx9TTxY94tGWLEV9qHxWiG6E8VeqT/0XzEvlj4nzK2ii2a9OCPJLfuAJXXsNoFt12HhmsU57R2BNLP0PQNLfLiJaPBEz+Tt2fNjEgD78yYcSyHcbRTghqQniNNHskmSx5ZpwSYbi2l2a3UbgS1kYevQH5WEZtAYridvTKYjo6E37k5Uml6jnDFtWohbyytRCjnPe1p0QNzZ11FPg3Bxkigsw== X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: ae99d667-12bc-40a3-03e0-08db6092ffb6 X-MS-Exchange-CrossTenant-AuthSource: BYAPR12MB2743.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 May 2023 22:21:07.5890 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: JiVT7HvSjmzdNkJE9ZW6XeQPF2ddzybbd3SgdZQWbxUhNb8fBJgd1D8dAlBzdrdjxAh9fVRQ+7Vzbx9QSpiUuQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN9PR12MB5355 X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1767269478500541560?= X-GMAIL-MSGID: =?utf-8?q?1767269478500541560?= Accidentally had a whitespace character in front of a label used for error handling in the shield_haptics_create function. Signed-off-by: Rahul Rameshbabu --- Notes: This patch really should be updated in the initial patch that introduces the nvidia-shield HID driver. Using a separate patch to just illustrate this is a cosmetic change if needing to resubmit the original patch for nvidia-shield. Link: https://lore.kernel.org/linux-input/20230418203747.24000-1-rrameshbabu@nvidia.com/ drivers/hid/hid-nvidia-shield.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hid/hid-nvidia-shield.c b/drivers/hid/hid-nvidia-shield.c index 7dfaec1c07e2..85700cec5eac 100644 --- a/drivers/hid/hid-nvidia-shield.c +++ b/drivers/hid/hid-nvidia-shield.c @@ -202,7 +202,7 @@ static struct input_dev *shield_haptics_create( return haptics; - err: +err: input_free_device(haptics); return ERR_PTR(ret); }