Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp4494885imw; Tue, 12 Jul 2022 08:56:12 -0700 (PDT) X-Google-Smtp-Source: AGRyM1ul1P1HqhoQ6KQLwT4ZRiccPVvTN4woPa2MMcevyJjXMjNbQfnpPG7LaF4R3yO6t+YLNOLH X-Received: by 2002:a63:ba18:0:b0:412:afd5:1260 with SMTP id k24-20020a63ba18000000b00412afd51260mr21901887pgf.617.1657641372494; Tue, 12 Jul 2022 08:56:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657641372; cv=none; d=google.com; s=arc-20160816; b=QK2nD0T8fZyZcJBi+kgOU1YVTgpdB9/06y+dSBg9uBHeHToSRZCTqrz1wperPQJSOG KJSFz0GP3v94KulRzWzXskuXX5ieyoJfNZjpbD8TnY8nG/RsMRFWvoc2kNyeb2GBpYXb fO0ZwMHREzlb2z7iV23SNnoRGpptv3uR94ea0fMHP6CYbigJmnuydoo53ZRkJJZKzT9v yBrFh6gcszYFFbYHP17mNwFuDgqvtj5RuoQZFpY2oHiL7XzHJVPVN0APIuIimunSKdUs kLqBImdEBNxM1JxVAdrx/PtdtUjpE8U3U5zdst3h886Og84S8fEFS3DZOrDIXmsSCU1A BwcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ADxek73ShDBJ+eTKrRQlmTsuIvUuVWEOpUtdVj+yOnQ=; b=Qfkfjn7imNuCGxAoS//Oh69iBqA3t1XkX+Ezla1Lyh+/incH1XvS8FsZSHpGZy3oOG sCOBxmD7vFN2u658c5VAXLf2P8+zpy/1+Heh7SrSgfuy2ouAMrTBa4gwKBQL4FuMx6Cw kqze2OIV84MePjXlOoWOzme1f4vzXrZAbtJGF7xIpnI6xX6UwT15m2aPGM6AZEOF6mGx ehySF1lZmJ5AtZExOJ7DlJGXUinjNiJNOQmXj+JdmVYpXakXYxRHmT/6vvGGpg8cQ+pe JNGg9P0RAo2bJynf4vJRZoW9xYMYDtSik2NPmwH5FUiRcXJ+crDxsQLzSQpIwhmDbX3A PeDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ihu1bGP2; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y18-20020a63fa12000000b0040c799657f4si14312886pgh.577.2022.07.12.08.55.58; Tue, 12 Jul 2022 08:56:12 -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=@redhat.com header.s=mimecast20190719 header.b=ihu1bGP2; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233835AbiGLPDh (ORCPT + 99 others); Tue, 12 Jul 2022 11:03:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55440 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233877AbiGLPCn (ORCPT ); Tue, 12 Jul 2022 11:02:43 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3C201C08EF for ; Tue, 12 Jul 2022 07:59:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1657637982; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ADxek73ShDBJ+eTKrRQlmTsuIvUuVWEOpUtdVj+yOnQ=; b=ihu1bGP2MQDzPNpwpYXzxamMVvv0xFp4TYpLRqxcT+bvf3MaZGqVFrR850oznt6F5IWbiB HKhAukATzM6pR87efNZvgzJjyFbpXhiPwDpx9+xs7RGco2SKcjLIPNkTwBbZrQ0dNWQhpj OOU4yAHXv3icNVVXl/koX61wm3rxdJw= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-502-xN97oc9BPeaRnOOKq0WxpQ-1; Tue, 12 Jul 2022 10:59:38 -0400 X-MC-Unique: xN97oc9BPeaRnOOKq0WxpQ-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0E622382C965; Tue, 12 Jul 2022 14:59:37 +0000 (UTC) Received: from plouf.redhat.com (unknown [10.39.195.8]) by smtp.corp.redhat.com (Postfix) with ESMTP id B6BD72166B26; Tue, 12 Jul 2022 14:59:33 +0000 (UTC) From: Benjamin Tissoires To: Greg KH , Jiri Kosina , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Shuah Khan , Dave Marchevsky , Joe Stringer , Jonathan Corbet Cc: Tero Kristo , linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-doc@vger.kernel.org, Benjamin Tissoires Subject: [PATCH bpf-next v6 09/23] HID: core: store the unique system identifier in hid_device Date: Tue, 12 Jul 2022 16:58:36 +0200 Message-Id: <20220712145850.599666-10-benjamin.tissoires@redhat.com> In-Reply-To: <20220712145850.599666-1-benjamin.tissoires@redhat.com> References: <20220712145850.599666-1-benjamin.tissoires@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 This unique identifier is currently used only for ensuring uniqueness in sysfs. However, this could be handful for userspace to refer to a specific hid_device by this id. 2 use cases are in my mind: LEDs (and their naming convention), and HID-BPF. Signed-off-by: Benjamin Tissoires --- no changes in v6 new in v5 --- drivers/hid/hid-core.c | 4 +++- include/linux/hid.h | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c index 00154a1cd2d8..11874d264728 100644 --- a/drivers/hid/hid-core.c +++ b/drivers/hid/hid-core.c @@ -2739,10 +2739,12 @@ int hid_add_device(struct hid_device *hdev) hid_warn(hdev, "bad device descriptor (%d)\n", ret); } + hdev->id = atomic_inc_return(&id); + /* XXX hack, any other cleaner solution after the driver core * is converted to allow more than 20 bytes as the device name? */ dev_set_name(&hdev->dev, "%04X:%04X:%04X.%04X", hdev->bus, - hdev->vendor, hdev->product, atomic_inc_return(&id)); + hdev->vendor, hdev->product, hdev->id); hid_debug_register(hdev, dev_name(&hdev->dev)); ret = device_add(&hdev->dev); diff --git a/include/linux/hid.h b/include/linux/hid.h index 4363a63b9775..a43dd17bc78f 100644 --- a/include/linux/hid.h +++ b/include/linux/hid.h @@ -658,6 +658,8 @@ struct hid_device { /* device report descriptor */ struct list_head debug_list; spinlock_t debug_list_lock; wait_queue_head_t debug_wait; + + unsigned int id; /* system unique id */ }; #define to_hid_device(pdev) \ -- 2.36.1