From: Alan Borzeszkowski <alan.borzeszkowski@linux.intel.com>
To: ericvh@kernel.org, lucho@ionkov.net, asmadeus@codewreck.org,
mika.westerberg@linux.intel.com, andreas.noever@gmail.com,
YehezkelShB@gmail.com, corbet@lwn.net
Cc: linux-usb@vger.kernel.org, v9fs@lists.linux.dev,
linux-doc@vger.kernel.org, linux_oss@crudebyte.com,
alan.borzeszkowski@linux.intel.com
Subject: [PATCH 1/3] thunderbolt: stream: Add tbstream_dev_from_file()
Date: Thu, 24 Sep 2026 18:23:31 +0200 [thread overview]
Message-ID: <20260924162333.147033-2-alan.borzeszkowski@linux.intel.com> (raw)
In-Reply-To: <20260924162333.147033-1-alan.borzeszkowski@linux.intel.com>
Add tbstream_dev_from_file() which returns USB4STREAM device behind a
file. Expose it to in-kernel users via separate header.
Required by the 9P Thunderbolt transport driver to validate mount
source.
Signed-off-by: Alan Borzeszkowski <alan.borzeszkowski@linux.intel.com>
---
MAINTAINERS | 1 +
drivers/thunderbolt/stream.c | 16 ++++++++++++++++
include/linux/thunderbolt_stream.h | 14 ++++++++++++++
3 files changed, 31 insertions(+)
create mode 100644 include/linux/thunderbolt_stream.h
diff --git a/MAINTAINERS b/MAINTAINERS
index cc3cae2e378b..a626e81d1724 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -27211,6 +27211,7 @@ T: git git://git.kernel.org/pub/scm/linux/kernel/git/westeri/thunderbolt.git
F: Documentation/admin-guide/thunderbolt.rst
F: drivers/thunderbolt/
F: include/linux/thunderbolt.h
+F: include/linux/thunderbolt_stream.h
THUNDERBOLT NETWORK DRIVER
M: Mika Westerberg <westeri@kernel.org>
diff --git a/drivers/thunderbolt/stream.c b/drivers/thunderbolt/stream.c
index 25c259dd0760..d6d0aafd5984 100644
--- a/drivers/thunderbolt/stream.c
+++ b/drivers/thunderbolt/stream.c
@@ -21,6 +21,7 @@
#include <linux/poll.h>
#include <linux/sizes.h>
#include <linux/thunderbolt.h>
+#include <linux/thunderbolt_stream.h>
#include <linux/uaccess.h>
#include <linux/uio.h>
#include <linux/uuid.h>
@@ -1024,6 +1025,21 @@ tbstream_dev_from_group(struct config_group *group)
return container_of(group, struct tbstream_dev, group);
}
+/**
+ * tbstream_dev_from_file() - Return USB4STREAM device behind a file
+ * @file: File to check
+ *
+ * Return: Pointer to &struct tbstream_dev, %NULL if file is not
+ * USB4STREAM device.
+ */
+struct tbstream_dev *tbstream_dev_from_file(struct file *file)
+{
+ if (file->f_op != &tbstream_dev_fops)
+ return NULL;
+ return to_tbstream_dev(file->private_data);
+}
+EXPORT_SYMBOL_GPL(tbstream_dev_from_file);
+
static ssize_t tbstream_dev_busy_poll_show(struct config_item *item, char *buf)
{
struct config_group *group = to_config_group(item);
diff --git a/include/linux/thunderbolt_stream.h b/include/linux/thunderbolt_stream.h
new file mode 100644
index 000000000000..ed4fdba7c7e9
--- /dev/null
+++ b/include/linux/thunderbolt_stream.h
@@ -0,0 +1,14 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Thunderbolt Stream API
+ *
+ * Copyright (C) 2026, Intel Corporation
+ * Author: Alan Borzeszkowski <alan.borzeszkowski@linux.intel.com>
+ */
+
+#ifndef THUNDERBOLT_STREAM_H_
+#define THUNDERBOLT_STREAM_H_
+
+struct tbstream_dev *tbstream_dev_from_file(struct file *file);
+
+#endif /* THUNDERBOLT_STREAM_H_ */
--
2.53.0
next prev parent reply other threads:[~2026-09-24 16:24 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-24 16:23 [PATCH 0/3] net/9p: Add 9P transport over USB4STREAM Alan Borzeszkowski
2026-09-24 16:23 ` Alan Borzeszkowski [this message]
2026-09-29 6:42 ` [PATCH 1/3] thunderbolt: stream: Add tbstream_dev_from_file() Mika Westerberg
2026-09-24 16:23 ` [PATCH 2/3] net/9p/thunderbolt: Add native 9P Thunderbolt transport support Alan Borzeszkowski
2026-09-24 16:23 ` [PATCH 3/3] Documentation/fs/9p: Add Thunderbolt transport documentation Alan Borzeszkowski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260924162333.147033-2-alan.borzeszkowski@linux.intel.com \
--to=alan.borzeszkowski@linux.intel.com \
--cc=YehezkelShB@gmail.com \
--cc=andreas.noever@gmail.com \
--cc=asmadeus@codewreck.org \
--cc=corbet@lwn.net \
--cc=ericvh@kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=linux_oss@crudebyte.com \
--cc=lucho@ionkov.net \
--cc=mika.westerberg@linux.intel.com \
--cc=v9fs@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox