linux-kbuild.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Yassine Oudjana via B4 Relay <devnull+y.oudjana.protonmail.com@kernel.org>
To: "Manivannan Sadhasivam" <mani@kernel.org>,
	"David S. Miller" <davem@davemloft.net>,
	"Eric Dumazet" <edumazet@google.com>,
	"Jakub Kicinski" <kuba@kernel.org>,
	"Paolo Abeni" <pabeni@redhat.com>,
	"Simon Horman" <horms@kernel.org>,
	"Bjorn Andersson" <andersson@kernel.org>,
	"Konrad Dybcio" <konradybcio@kernel.org>,
	"Masahiro Yamada" <masahiroy@kernel.org>,
	"Nathan Chancellor" <nathan@kernel.org>,
	"Nicolas Schier" <nicolas.schier@linux.dev>,
	"Jonathan Cameron" <jic23@kernel.org>,
	"David Lechner" <dlechner@baylibre.com>,
	"Nuno Sá" <nuno.sa@analog.com>,
	"Andy Shevchenko" <andy@kernel.org>,
	"Luca Weiss" <luca@lucaweiss.eu>
Cc: linux-arm-msm@vger.kernel.org, netdev@vger.kernel.org,
	 linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org,
	 linux-iio@vger.kernel.org,
	Yassine Oudjana <y.oudjana@protonmail.com>
Subject: [PATCH v2 3/4] net: qrtr: Define macro to convert QMI version and instance to QRTR instance
Date: Thu, 10 Jul 2025 09:06:29 +0100	[thread overview]
Message-ID: <20250710-qcom-smgr-v2-3-f6e198b7aa8e@protonmail.com> (raw)
In-Reply-To: <20250710-qcom-smgr-v2-0-f6e198b7aa8e@protonmail.com>

From: Yassine Oudjana <y.oudjana@protonmail.com>

Move QRTR instance conversion from qmi_interface into a new macro in order
to reuse it in QRTR device ID tables.

Signed-off-by: Yassine Oudjana <y.oudjana@protonmail.com>
---
 drivers/soc/qcom/qmi_interface.c |  5 +++--
 include/linux/soc/qcom/qrtr.h    | 10 ++++++++++
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/drivers/soc/qcom/qmi_interface.c b/drivers/soc/qcom/qmi_interface.c
index 6500f863aae5ca218892d13233d4c9bf4b63a0f4..bd97b006757fc20778e4bb512945d85f4cd31b24 100644
--- a/drivers/soc/qcom/qmi_interface.c
+++ b/drivers/soc/qcom/qmi_interface.c
@@ -14,6 +14,7 @@
 #include <linux/workqueue.h>
 #include <trace/events/sock.h>
 #include <linux/soc/qcom/qmi.h>
+#include <linux/soc/qcom/qrtr.h>
 
 static struct socket *qmi_sock_create(struct qmi_handle *qmi,
 				      struct sockaddr_qrtr *sq);
@@ -173,7 +174,7 @@ static void qmi_send_new_lookup(struct qmi_handle *qmi, struct qmi_service *svc)
 	memset(&pkt, 0, sizeof(pkt));
 	pkt.cmd = cpu_to_le32(QRTR_TYPE_NEW_LOOKUP);
 	pkt.server.service = cpu_to_le32(svc->service);
-	pkt.server.instance = cpu_to_le32(svc->version | svc->instance << 8);
+	pkt.server.instance = cpu_to_le32(QRTR_INSTANCE(svc->version, svc->instance));
 
 	sq.sq_family = qmi->sq.sq_family;
 	sq.sq_node = qmi->sq.sq_node;
@@ -236,7 +237,7 @@ static void qmi_send_new_server(struct qmi_handle *qmi, struct qmi_service *svc)
 	memset(&pkt, 0, sizeof(pkt));
 	pkt.cmd = cpu_to_le32(QRTR_TYPE_NEW_SERVER);
 	pkt.server.service = cpu_to_le32(svc->service);
-	pkt.server.instance = cpu_to_le32(svc->version | svc->instance << 8);
+	pkt.server.instance = cpu_to_le32(QRTR_INSTANCE(svc->version, svc->instance));
 	pkt.server.node = cpu_to_le32(qmi->sq.sq_node);
 	pkt.server.port = cpu_to_le32(qmi->sq.sq_port);
 
diff --git a/include/linux/soc/qcom/qrtr.h b/include/linux/soc/qcom/qrtr.h
index e9249d9422b8ca96baa43073cf07c4a75c163219..e2aca520fdbe22bc855004143dc8baa7a3f67517 100644
--- a/include/linux/soc/qcom/qrtr.h
+++ b/include/linux/soc/qcom/qrtr.h
@@ -3,6 +3,8 @@
 #ifndef __QCOM_QRTR_H__
 #define __QCOM_QRTR_H__
 
+#include <linux/bitfield.h>
+#include <linux/bits.h>
 #include <linux/mod_devicetable.h>
 
 struct qrtr_device {
@@ -15,6 +17,14 @@ struct qrtr_device {
 
 #define to_qrtr_device(d) container_of(d, struct qrtr_device, dev)
 
+#define QRTR_INSTANCE(qmi_version, qmi_instance) \
+	(FIELD_PREP(GENMASK(7, 0), qmi_version) | \
+	 FIELD_PREP(GENMASK(15, 8), qmi_instance))
+
+#define QRTR_INSTANCE_CONST(qmi_version, qmi_instance) \
+	(FIELD_PREP_CONST(GENMASK(7, 0), qmi_version) | \
+	 FIELD_PREP_CONST(GENMASK(15, 8), qmi_instance))
+
 struct qrtr_driver {
 	int (*probe)(struct qrtr_device *qdev);
 	void (*remove)(struct qrtr_device *qdev);

-- 
2.50.0



  parent reply	other threads:[~2025-07-10  8:06 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-10  8:06 [PATCH v2 0/4] QRTR bus and Qualcomm Sensor Manager IIO drivers Yassine Oudjana via B4 Relay
2025-07-10  8:06 ` [PATCH v2 1/4] net: qrtr: smd: Rename qdev to qsdev Yassine Oudjana via B4 Relay
2025-07-10  8:06 ` [PATCH v2 2/4] net: qrtr: Turn QRTR into a bus Yassine Oudjana via B4 Relay
2025-07-10  8:53   ` Andy Shevchenko
2025-07-17 13:21     ` Yassine Oudjana
2025-07-10  8:06 ` Yassine Oudjana via B4 Relay [this message]
2025-07-10  8:06 ` [PATCH v2 4/4] iio: Add Qualcomm Sensor Manager driver Yassine Oudjana via B4 Relay
2025-07-10  8:57   ` Andy Shevchenko
2025-07-17 13:31     ` Yassine Oudjana
2025-07-13 15:40   ` Jonathan Cameron
2025-07-17 14:31     ` Yassine Oudjana
2025-07-19 17:19       ` Jonathan Cameron
2025-07-21 11:13   ` Casey Connolly
2025-07-10 11:22 ` [PATCH v2 0/4] QRTR bus and Qualcomm Sensor Manager IIO drivers Simon Horman
2025-07-17 13:27   ` Yassine Oudjana
2025-07-21 11:08 ` Casey Connolly

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=20250710-qcom-smgr-v2-3-f6e198b7aa8e@protonmail.com \
    --to=devnull+y.oudjana.protonmail.com@kernel.org \
    --cc=andersson@kernel.org \
    --cc=andy@kernel.org \
    --cc=davem@davemloft.net \
    --cc=dlechner@baylibre.com \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=jic23@kernel.org \
    --cc=konradybcio@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luca@lucaweiss.eu \
    --cc=mani@kernel.org \
    --cc=masahiroy@kernel.org \
    --cc=nathan@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=nicolas.schier@linux.dev \
    --cc=nuno.sa@analog.com \
    --cc=pabeni@redhat.com \
    --cc=y.oudjana@protonmail.com \
    /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;
as well as URLs for NNTP newsgroup(s).