Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp832356iob; Wed, 18 May 2022 14:08:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz3Y04asn4bcLElw3CFM0lKPxKN+QJqlQr8gr2YXodzOGDUqUunEnMJ5vispPfNEAoLLD7x X-Received: by 2002:a63:190f:0:b0:3db:972b:46bb with SMTP id z15-20020a63190f000000b003db972b46bbmr1104563pgl.554.1652908095399; Wed, 18 May 2022 14:08:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652908095; cv=none; d=google.com; s=arc-20160816; b=tlyj8m+mPDb5hso+tM9mT6dcJtzD/UCtSXEllHHfyOu6o9yrGAAUXMXt6Vkl6/FrVX nSqo6wqiji/K43zM6/xQHqxMj/2ySE7BL43OuSqnzj1jj1vazHtiJReWHidG7EsfLjJQ FWOvI0sJF5asgqd6NOGCg3/NPqiu2/u1O9fB1mJr8/zGePn/cPkq8KFWstPnvZelRR6P xiVt2i8HOsKc3KeMO4tHCtUTRza9d/EMCcU+gUgCYnAbe98gGJB2j1nwSxCe9fkJ2KGt 6x6hi69Jm4cs7j9GONjEM+qaOhXcmseDWyLt41gyb/1XgRxx+7D6exlbxMyWfHDnFo9G 9mAQ== 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=AlA+M9AznC3l4SAV4drMKMtvnKO+BZZzFpZxWrqpDx0=; b=PZxrxc8vZFQuYg7IkTdY87jKoW95j8AjYL7FZqIbsTSAAjJw0SWGFw4dKx1YvHqz14 rxtrJ1Kr9BbL/xknVJWJc2R8yAvshbAgZ6bwreNHZChpoawxUkRvMNPssIdV+w0ftrXu R0YqNioxBct010b2kWRsoJyj7TnhpTZG1cJmXaLKxtlqIbSES3jjOmpsK3WS62qqB0VX 7IU7gvJS7q7ovtYOnFCwx/U5uE60IgTar4y9TcFCfeG0EzAHVRIhL3YYl1vSz458663L CdOqveqfDKhDZNS3YDNmuQB4QjLodJd0KFVTKuiQWjyMtipNmtnjM3M/D93H9J3A4wdv 3Yng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=SQF60QgK; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id d16-20020a170903231000b001582fa35afasi4292806plh.190.2022.05.18.14.08.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 May 2022 14:08:15 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=SQF60QgK; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8316D140C8; Wed, 18 May 2022 14:01:24 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242928AbiERVAT (ORCPT + 99 others); Wed, 18 May 2022 17:00:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58886 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242900AbiERVAQ (ORCPT ); Wed, 18 May 2022 17:00:16 -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 49C702550AC for ; Wed, 18 May 2022 13:59:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652907598; 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=AlA+M9AznC3l4SAV4drMKMtvnKO+BZZzFpZxWrqpDx0=; b=SQF60QgKRFhRaAQ7MAoOALp+1QbvCYTWzftIYYCCa5MkPAd2M1bqMYVzeQpi8mdC3Uh5vO rJG3feyjkh27qdJBPrmM1SfIsNb+r8xYU0YEkMjIGMCCkSlIshSNOepqsZ1LZtPUVzAUwK SH7GDg3gLhYwj6XVgV631vZgTkFmBls= 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-191-7HM3s6NEMJ-KR3c7GhaLdA-1; Wed, 18 May 2022 16:59:54 -0400 X-MC-Unique: 7HM3s6NEMJ-KR3c7GhaLdA-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 7DA2880B90A; Wed, 18 May 2022 20:59:52 +0000 (UTC) Received: from plouf.redhat.com (unknown [10.39.192.58]) by smtp.corp.redhat.com (Postfix) with ESMTP id A21652166B25; Wed, 18 May 2022 20:59:48 +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 v5 05/17] HID: core: store the unique system identifier in hid_device Date: Wed, 18 May 2022 22:59:12 +0200 Message-Id: <20220518205924.399291-6-benjamin.tissoires@redhat.com> In-Reply-To: <20220518205924.399291-1-benjamin.tissoires@redhat.com> References: <20220518205924.399291-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.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_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 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 --- 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 db925794fbe6..e78f35cfd2d1 100644 --- a/drivers/hid/hid-core.c +++ b/drivers/hid/hid-core.c @@ -2735,10 +2735,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