Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp630583rwe; Wed, 24 Aug 2022 06:46:03 -0700 (PDT) X-Google-Smtp-Source: AA6agR4cy9wqcz2dRUHvfmvNAgRmLa8BLTewd9PS7RSOgDUc9WCANIf7Tn80jDPfCIveySMAoGxR X-Received: by 2002:a05:6402:84d:b0:435:a764:9aad with SMTP id b13-20020a056402084d00b00435a7649aadmr8140996edz.332.1661348763663; Wed, 24 Aug 2022 06:46:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661348763; cv=none; d=google.com; s=arc-20160816; b=QGsIjzY07Nuw0GHziWvWtxMluHwfMzAEQdMGlpYgumb3469zTwYWoVuQ823uFtgC22 A8afDPlu9Lyz72AJvakGgGv6ms3YDK6jrNldrLah5O4xTzQMhmCUBZpyF9pOBUdOw9Zt WoJabWHjaqMNUig+p2goskhMZTwkRS2z6IWHxPwA7lPikRgbhsD/Zssi2Bhs7aAPerrS t65O6ZHrJIo3/kgVZz92jUR1MdctJzoVVjL7yvdMaiXGTtaRrzj19qDyulmqt4tO8clP XpTkumSwSlpXl5EbfpZ6YCvyhoZQlKEzNGnxar9kowXnUxBMTbl7Kplpm8aeH9byqbvc 7ngw== 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=giDrealXcGVu/OQH1jwOkr1d3NWH6SrHBA/Re8UetHI=; b=owkx7SaznYa0yGV+GNG7nhDGryMjfu1J9kRYjLscKh/pXMMtcxa2J+8tsDz16ik27r RWSn7Y62+8JHXr/KKkEQssIPIwmcqzhW7+t2oQ/iR4gQvR1kgOSU0o9B9TTUAsd/w78w IorAznC09+gqqn5jxYlOMl06fm1Ild94gydfNT0cOlqe77fQoTLfMja1As+47XjxePok eZCzHrKIqrQsXhMnO6fkZSX/UC6rFJDAuI0z3CHEw21OKuszMLtnYQtHeioL4LXGhay6 MykCBC2qkutb68i6KKqy2mxrDG4umqdiBJm/GACtwPAl1/HH7j/SaKG60QNdTH8gY5vU WL2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Rpum226Z; 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 e8-20020a170906c00800b0073d6c94fc3dsi1732601ejz.162.2022.08.24.06.45.35; Wed, 24 Aug 2022 06:46: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=@redhat.com header.s=mimecast20190719 header.b=Rpum226Z; 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 S238414AbiHXNm2 (ORCPT + 99 others); Wed, 24 Aug 2022 09:42:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60844 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237766AbiHXNmA (ORCPT ); Wed, 24 Aug 2022 09:42:00 -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 ESMTPS id C755A80372 for ; Wed, 24 Aug 2022 06:41:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661348494; 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=giDrealXcGVu/OQH1jwOkr1d3NWH6SrHBA/Re8UetHI=; b=Rpum226Z8sgGMsvBhM1P4NPcRuKMJiimY0HgLqJf/SOk09v2vEdom6xwXKn1r92dYgzfHp 7ytpJimrf92v/L7RIuEtlD8/g/mOBKZIgv6wb5ZwmbZBQIRcMwKvnrvWyUZXWy41Hazb9v It358jNim20DC9RWFrQcPsDRYF56JxQ= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-442-Ygt4zPG0MhiBZ-KnwIGCQA-1; Wed, 24 Aug 2022 09:41:31 -0400 X-MC-Unique: Ygt4zPG0MhiBZ-KnwIGCQA-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id ECC3510395C0; Wed, 24 Aug 2022 13:41:29 +0000 (UTC) Received: from plouf.redhat.com (unknown [10.39.192.211]) by smtp.corp.redhat.com (Postfix) with ESMTP id AE12C945D7; Wed, 24 Aug 2022 13:41:26 +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 v9 08/23] HID: core: store the unique system identifier in hid_device Date: Wed, 24 Aug 2022 15:40:38 +0200 Message-Id: <20220824134055.1328882-9-benjamin.tissoires@redhat.com> In-Reply-To: <20220824134055.1328882-1-benjamin.tissoires@redhat.com> References: <20220824134055.1328882-1-benjamin.tissoires@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Spam-Status: No, score=-2.1 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. Reviewed-by: Greg Kroah-Hartman Signed-off-by: Benjamin Tissoires --- no changes in v9 no changes in v8 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 b7f5566e338d..a00dd43db8bf 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