Received: by 2002:ac0:da4c:0:0:0:0:0 with SMTP id a12csp681102imi; Thu, 21 Jul 2022 08:55:02 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tT9qPW65QLzyySJnMAm5i0wIlbkty5KW8XB1hCCjVMRXI5Tv+TxkIZIPNouvgYpWSuAsPP X-Received: by 2002:a17:907:2bc5:b0:72b:2e3f:3581 with SMTP id gv5-20020a1709072bc500b0072b2e3f3581mr40900175ejc.211.1658418901883; Thu, 21 Jul 2022 08:55:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658418901; cv=none; d=google.com; s=arc-20160816; b=hw3PNTOfzB5X6pOZQMlI7aIkgPbIIAgB6PZsue4/UQfdunpe2BDvuF4+E2xCFMXRRr UwHKZ4vdghwqvn3pyR/T55WJ78eNrN6/qr4xBcYf6zv4ud4pF4tDkkIeTZA01+CSpMGU yEzs9ueo0DRsowQt9eI19kFtBIdh0+a+ZMbrVDjKhn+Q7AjBf3FgOhCQiBp1zIntAFcz Rgt8MgO07eH+6v+dAJ2TOCYBPVfprLzqZ/2NynffJa+E2dj8tHeerEbdWf0FJVqZwbQB ZwNbX2PByb5dLO6LpRco3mqiaoukWxpcbCpNLkxtpCmmLH1ZbU2xP4uxdJc27WdibH3E 2Q3g== 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=Kmo7Mx7f8ta1oYVd70MON4db/P4ycD4f88q03sBW1Gs=; b=Y11v5kjvD1AMONS7gTFgaKkYC3fNOp/ko8wSAiFk968mL6BHd+n1pOjzgPdELNxw4p Bd+IbyBBUUH40dmVamoX3sTdk2o7zGzKIOGINYWcrDvT/S1inPkmGEGfKQymlAsCrm3z 1q2LgpV5tBuMN/asRr7o2TydeFDkgv3fQEG6MDI1X1WKRvBfJ1U1b/kYpM+Kc1rgcx03 mH9YyjUEoPlG3SmSVFzfjSgARMWimj+zp5aTfSU86esU3syqziyILdw12UqARt90rvBK P2lRNQN5C3kB6HMgY1Y/RSqob7VM4Do/EEbfXeTdTfWZERyMetoXnT5NHiobDKWXwJsH zjIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="fX/AYPxO"; 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 f10-20020a0564021e8a00b0043a7b67ce58si3243107edf.107.2022.07.21.08.54.36; Thu, 21 Jul 2022 08:55:01 -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="fX/AYPxO"; 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 S232212AbiGUPi1 (ORCPT + 99 others); Thu, 21 Jul 2022 11:38:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52794 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231726AbiGUPhz (ORCPT ); Thu, 21 Jul 2022 11:37:55 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2389F7E839 for ; Thu, 21 Jul 2022 08:37:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1658417828; 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=Kmo7Mx7f8ta1oYVd70MON4db/P4ycD4f88q03sBW1Gs=; b=fX/AYPxO1eKpH/x18LPpenkEQybAFs+h75wG8qUuLWxQV9njO7Jp4U8BNX5FP8f1FG7de8 YWRBnmFvhWA1qR69ZHrn7OjTyQbw7NaErluYncdAbRdHHGXr6iWzMr/+hZCsAsCujnj+2X tlI42N2rgmY4Dq1a4+JVOkndKzMxqHM= 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-473-B0hQuiYdPNCj0Wx8_Prxeg-1; Thu, 21 Jul 2022 11:37:03 -0400 X-MC-Unique: B0hQuiYdPNCj0Wx8_Prxeg-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 B0A303C025C9; Thu, 21 Jul 2022 15:37:02 +0000 (UTC) Received: from plouf.redhat.com (unknown [10.39.194.200]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7A7CB2166B26; Thu, 21 Jul 2022 15:36:59 +0000 (UTC) From: Benjamin Tissoires To: Greg KH , Jiri Kosina , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , Kumar Kartikeya Dwivedi , 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 v7 09/24] HID: core: store the unique system identifier in hid_device Date: Thu, 21 Jul 2022 17:36:10 +0200 Message-Id: <20220721153625.1282007-10-benjamin.tissoires@redhat.com> In-Reply-To: <20220721153625.1282007-1-benjamin.tissoires@redhat.com> References: <20220721153625.1282007-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=-3.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NONE 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. Reviewed-by: Greg Kroah-Hartman Signed-off-by: Benjamin Tissoires --- no changes in v7 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