[PATCH v4 11/11] net: qrtr: mhi: Report endpoint id in sysfs

From: Mihai Moldovan
Date: Mon Jul 28 2025 - 12:49:41 EST


From: Denis Kenzior <denkenz@xxxxxxxxx>

Add a read-only 'endpoint' sysfs entry that contains the qrtr endpoint
identifier assigned to this mhi device. Can be used to direct / receive
qrtr traffic only from a particular MHI device.

Signed-off-by: Denis Kenzior <denkenz@xxxxxxxxx>
Reviewed-by: Marcel Holtmann <marcel@xxxxxxxxxxxx>
Reviewed-by: Andy Gross <agross@xxxxxxxxxx>
Signed-off-by: Mihai Moldovan <ionic@xxxxxxxx>

---

v4:
- no changes
- Link to v3: https://msgid.link/e1f5b82cd25b2ac433b1bd7e83e22604e6b24f03.1753313000.git.ionic@xxxxxxxx

v3:
- rebase against current master
- Link to v2: https://msgid.link/1a49dec96d5c2c5258c9df935d8c9381793d4ddd.1752947108.git.ionic@xxxxxxxx

v2:
- rebase against current master
- use %u formatter instead of %d when printing endpoint id (u32) as
per review comment
- Link to v1: https://msgid.link/20241018181842.1368394-11-denkenz@xxxxxxxxx
---
net/qrtr/mhi.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)

diff --git a/net/qrtr/mhi.c b/net/qrtr/mhi.c
index 69f53625a049..9a23c888e234 100644
--- a/net/qrtr/mhi.c
+++ b/net/qrtr/mhi.c
@@ -72,6 +72,16 @@ static int qcom_mhi_qrtr_send(struct qrtr_endpoint *ep, struct sk_buff *skb)
return rc;
}

+static ssize_t endpoint_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct qrtr_mhi_dev *qdev = dev_get_drvdata(dev);
+
+ return sprintf(buf, "%u\n", qdev->ep.id);
+}
+
+static DEVICE_ATTR_RO(endpoint);
+
static int qcom_mhi_qrtr_probe(struct mhi_device *mhi_dev,
const struct mhi_device_id *id)
{
@@ -91,6 +101,9 @@ static int qcom_mhi_qrtr_probe(struct mhi_device *mhi_dev,
if (rc)
return rc;

+ if (device_create_file(&mhi_dev->dev, &dev_attr_endpoint) < 0)
+ dev_err(qdev->dev, "Failed to create endpoint attribute\n");
+
/* start channels */
rc = mhi_prepare_for_transfer_autoqueue(mhi_dev);
if (rc) {
@@ -107,6 +120,7 @@ static void qcom_mhi_qrtr_remove(struct mhi_device *mhi_dev)
{
struct qrtr_mhi_dev *qdev = dev_get_drvdata(&mhi_dev->dev);

+ device_remove_file(&mhi_dev->dev, &dev_attr_endpoint);
qrtr_endpoint_unregister(&qdev->ep);
mhi_unprepare_from_transfer(mhi_dev);
dev_set_drvdata(&mhi_dev->dev, NULL);
--
2.50.0